From a7e8422237efcbfc284f198b6a81ab0451772a3e Mon Sep 17 00:00:00 2001 From: Jovan Ristic Date: Wed, 20 Dec 2023 18:06:44 -0800 Subject: [PATCH] Fix D3D12 pixel history lacking primIDs for draws without a PS. * No rendertarget was bound to the primitive ID generating draw because rts is empty in draws without a rendertarget bound in the base draw. Setting rts[0] was presumably stomping memory instead in this case. * Included is a fix for validation layer error thrown when reproducing the problem, in D3D12ColorAndStencilCallback during a Pre/PostDispatch CopyPixel uses the value of m_SavedState but was not set. In the case of rpFlags, the value was uninitialized because D3D12RenderState does not include it in its constructor. That caused an invalid resource transition to be issued and was fortunately caught by the debug layer, otherwise it was thus far invisible when running without debug on. --- renderdoc/driver/d3d12/d3d12_pixelhistory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp index 4880ae197..ebdb522c6 100644 --- a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp +++ b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp @@ -989,6 +989,7 @@ struct D3D12ColorAndStencilCallback : public D3D12PixelHistoryCallback size_t storeOffset = m_EventIndices.size() * sizeof(D3D12EventInfo) + offsetof(struct D3D12EventInfo, premod); + m_SavedState = m_pDevice->GetQueue()->GetCommandData()->GetCurRenderState(); CopyPixel(eid, cmd, storeOffset); } bool PostDispatch(uint32_t eid, ID3D12GraphicsCommandListX *cmd) @@ -1959,6 +1960,7 @@ struct D3D12PixelHistoryPerFragmentCallback : D3D12PixelHistoryCallback D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 0.0f, 0, 1, &state.scissors[0]); + state.rts.resize(1); state.rts[0] = *m_CallbackInfo.colorDescriptor; state.dsv = *m_CallbackInfo.dsDescriptor; state.pipe = GetResID(psosIter[i]);