1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 04:29:15 +01:00

[dxvk] Add convenience function to query default resolve mode

Removes some code duplication.
This commit is contained in:
Philip Rebohle 2025-03-10 20:05:51 +01:00
parent fd9b561100
commit 292a0b498a
2 changed files with 23 additions and 13 deletions

View File

@ -1961,11 +1961,7 @@ namespace dxvk {
if (useRp) {
// Work out resolve mode based on format properties. For color images,
// we must use AVERAGE unless the resolve uses an integer format.
VkResolveModeFlagBits mode = VK_RESOLVE_MODE_AVERAGE_BIT;
if (formatInfo->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt)
|| (formatInfo->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))
mode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
VkResolveModeFlagBits mode = getDefaultResolveMode(formatInfo);
this->resolveImageRp(dstImage, srcImage, region,
format, mode, mode);
@ -7777,17 +7773,12 @@ namespace dxvk {
// Always do a SAMPLE_ZERO resolve here since that's less expensive and closer to what
// happens on native AMD anyway. Need to use a shader in case we are dealing with a
// non-integer color image since render pass resolves only support AVERAGE.
auto formatInfo = lookupFormatInfo(op.resolveFormat);
bool useRp = (formatInfo->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt))
|| (formatInfo->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
if (useRp) {
if (getDefaultResolveMode(op.resolveFormat) == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT) {
resolveImageRp(op.resolveImage, op.inputImage, op.resolveRegion,
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
} else {
resolveImageFb(op.resolveImage, op.inputImage, op.resolveRegion,
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_NONE);
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
}
}
}

View File

@ -114,4 +114,23 @@ namespace dxvk {
return lookupFormatInfoSlow(format);
}
}
/**
* \brief Queries default resolve mode for format
*
* For depth-stencil formats, this will return SAMPLE_ZERO.
* \param [in] format Format to look up
* \returns Default resolve mode
*/
inline VkResolveModeFlagBits getDefaultResolveMode(const DxvkFormatInfo* format) {
if ((format->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))
|| (format->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt)))
return VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
return VK_RESOLVE_MODE_AVERAGE_BIT;
}
inline VkResolveModeFlagBits getDefaultResolveMode(VkFormat format) {
return getDefaultResolveMode(lookupFormatInfo(format));
}
}