From f5ca3cf5df85186b516b91923e9a69df944eb059 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 25 Sep 2024 00:23:57 +0200 Subject: [PATCH] [d3d9] ResolveZ: Only copy aspects that both images support --- src/d3d9/d3d9_device.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 0d0ef4c1..d25cb388 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -7640,14 +7640,26 @@ namespace dxvk { const D3D9_VK_FORMAT_MAPPING srcFormatInfo = LookupFormat(srcDesc->Format); const D3D9_VK_FORMAT_MAPPING dstFormatInfo = LookupFormat(dstDesc->Format); - const VkImageSubresource dstSubresource = + VkImageSubresource dstSubresource = dstTextureInfo->GetSubresourceFromIndex( dstFormatInfo.Aspect, 0); - const VkImageSubresource srcSubresource = + VkImageSubresource srcSubresource = srcTextureInfo->GetSubresourceFromIndex( srcFormatInfo.Aspect, src->GetSubresource()); + if ((dstSubresource.aspectMask & srcSubresource.aspectMask) != 0) { + // for depthStencil -> depth or depthStencil -> stencil copies, only copy the aspect that both images support + dstSubresource.aspectMask = dstSubresource.aspectMask & srcSubresource.aspectMask; + srcSubresource.aspectMask = dstSubresource.aspectMask & srcSubresource.aspectMask; + } else if (unlikely(dstSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT && srcSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)) { + Logger::err(str::format("D3D9DeviceEx::ResolveZ: Trying to blit from ", + srcFormatInfo.FormatColor, " (aspect ", srcSubresource.aspectMask, ")", " to ", + dstFormatInfo.FormatColor, " (aspect ", dstSubresource.aspectMask, ")" + )); + return; + } + const VkImageSubresourceLayers dstSubresourceLayers = { dstSubresource.aspectMask, dstSubresource.mipLevel,