From e4812a1177551a105fe29abdfc34a2fd1a24407c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 5 Mar 2025 11:34:47 +0100 Subject: [PATCH] [dxvk] Always use SAMPLE_ZERO for implicit resolves --- src/dxvk/dxvk_context.cpp | 17 +++++++++++++++-- src/dxvk/dxvk_implicit_resolve.cpp | 5 ----- src/dxvk/dxvk_implicit_resolve.h | 1 - 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 210526438..e574015cf 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -7750,8 +7750,21 @@ namespace dxvk { prepareImage(op.inputImage, vk::makeSubresourceRange(op.resolveRegion.srcSubresource)); prepareImage(op.resolveImage, vk::makeSubresourceRange(op.resolveRegion.dstSubresource)); - resolveImageRp(op.resolveImage, op.inputImage, op.resolveRegion, - op.resolveFormat, op.resolveMode, op.resolveMode); + // 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) { + 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); + } } } diff --git a/src/dxvk/dxvk_implicit_resolve.cpp b/src/dxvk/dxvk_implicit_resolve.cpp index abaa92d12..e1c284a99 100644 --- a/src/dxvk/dxvk_implicit_resolve.cpp +++ b/src/dxvk/dxvk_implicit_resolve.cpp @@ -129,11 +129,6 @@ namespace dxvk { op.resolveRegion.dstSubresource.baseArrayLayer = 0u; op.resolveRegion.extent = view.resolveView->mipLevelExtent(0u); op.resolveFormat = view.inputView->info().format; - op.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; - - if ((format->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt) - || (format->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))) - op.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; view.resolveDone = true; } diff --git a/src/dxvk/dxvk_implicit_resolve.h b/src/dxvk/dxvk_implicit_resolve.h index 1f9f695b2..d75681976 100644 --- a/src/dxvk/dxvk_implicit_resolve.h +++ b/src/dxvk/dxvk_implicit_resolve.h @@ -20,7 +20,6 @@ namespace dxvk { Rc resolveImage = nullptr; VkImageResolve resolveRegion = { }; VkFormat resolveFormat = VK_FORMAT_UNDEFINED; - VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE; };