From 4815adaa83b4e561576b895e353ec3864a81dd23 Mon Sep 17 00:00:00 2001 From: Jovan Ristic Date: Thu, 21 Dec 2023 18:37:59 -0800 Subject: [PATCH] Fix D3D12 pixel history missing stencil copy. * When viewing pixel history on a depth stencil, the depth value was copied but the stencil value was not. --- renderdoc/driver/d3d12/d3d12_pixelhistory.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp index ebdb522c6..59025621c 100644 --- a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp +++ b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp @@ -1074,6 +1074,20 @@ private: CopyImagePixel(cmd, targetCopyParams, offset); + if(IsDepthAndStencilFormat(m_CallbackInfo.targetDesc.Format)) + { + D3D12CopyPixelParams stencilCopyParams = targetCopyParams; + stencilCopyParams.srcImageFormat = + GetDepthSRVFormat(m_CallbackInfo.targetImage->GetDesc().Format, 1); + stencilCopyParams.copyFormat = DXGI_FORMAT_R8_TYPELESS; + stencilCopyParams.planeSlice = 1; + stencilCopyParams.srcImageState = + m_SavedState.dsv.GetDSV().Flags & D3D12_DSV_FLAG_READ_ONLY_STENCIL + ? D3D12_RESOURCE_STATE_DEPTH_READ + : D3D12_RESOURCE_STATE_DEPTH_WRITE; + CopyImagePixel(cmd, stencilCopyParams, offset + sizeof(float)); + } + // If the target image is a depth/stencil view, we already copied the value above. if(IsDepthFormat(m_CallbackInfo.targetDesc.Format)) return;