Skip to content

Commit

Permalink
Fix D3D12 pixel history MSAA test issues.
Browse files Browse the repository at this point in the history
* Add missing resource transitions for the dispatch copy to fix
validation issues encountered while running the test.
* Adjust the MSAA copy path to use the second channel for stencil to
fix copies failing to output anything, which manifested as the fragment
only showing one primitive without correct output data.
  • Loading branch information
jristic committed Dec 31, 2023
1 parent 4815ada commit 3e0473b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions renderdoc/data/hlsl/d3d12_pixelhistory.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Texture2DArray<float> copyin_depth : register(t0);
Texture2DArray<uint> copyin_stencil : register(t1);

Texture2DMSArray<float> copyin_depth_ms : register(t2);
Texture2DMSArray<uint> copyin_stencil_ms : register(t3);
Texture2DMSArray<uint2> copyin_stencil_ms : register(t3);

Texture2DArray<float4> copyin_float : register(t4);
Texture2DMSArray<float4> copyin_float_ms : register(t5);
Expand Down Expand Up @@ -70,7 +70,7 @@ RWBuffer<int> copyout_int : register(u4);
}
else if(copy_stencil)
{
uint val = copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
uint val = copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
copyout_stencil[dst_slot] = val;
}
else
Expand Down
21 changes: 20 additions & 1 deletion renderdoc/driver/d3d12/d3d12_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,27 @@ struct D3D12PixelHistoryCallback : public D3D12ActionCallback
// copy using a compute shader into a staging image first
if(p.multisampled)
{
// TODO: Is a resource transition needed here?
// For pipeline barriers.
D3D12_RESOURCE_BARRIER barriers[2] = {};
barriers[0] = barrier;
barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
// Validation will complain if we don't transition all subresources for an SRV.
barriers[0].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;

barriers[1].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barriers[1].Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barriers[1].Transition.pResource = m_CallbackInfo.dstBuffer;
barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
barriers[1].Transition.Subresource = 0;

cmd->ResourceBarrier(2, barriers);

m_pDevice->GetDebugManager()->PixelHistoryCopyPixel(cmd, m_CallbackInfo.dstBuffer, p, offset);

std::swap(barriers[0].Transition.StateBefore, barriers[0].Transition.StateAfter);
std::swap(barriers[1].Transition.StateBefore, barriers[1].Transition.StateAfter);
cmd->ResourceBarrier(2, barriers);
}
else
{
Expand Down

0 comments on commit 3e0473b

Please sign in to comment.