Skip to content

Commit

Permalink
Fix D3D12 pixel history lacking primIDs for draws without a PS.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
jristic authored and Zorro666 committed Dec 22, 2023
1 parent 977adf5 commit a7e8422
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions renderdoc/driver/d3d12/d3d12_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit a7e8422

Please sign in to comment.