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 component mapping to fix stencil copies failing to output
anything, which manifested as the fragment only showing one primitive
without correct output data.
  • Loading branch information
jristic committed Dec 30, 2023
1 parent 4815ada commit b3a9f00
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion renderdoc/driver/d3d12/d3d12_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ void D3D12DebugManager::PixelHistoryCopyPixel(ID3D12GraphicsCommandListX *cmd,
p.multisampled ? D3D12_SRV_DIMENSION_TEXTURE2DMS : D3D12_SRV_DIMENSION_TEXTURE2D;
srvDesc.Format = p.srcImageFormat;
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
// multisample SRVs don't have a specifier for plane slice, use the component mapping instead.
if(p.multisampled && p.planeSlice == 1)
srvDesc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(1, 1, 1, 1);
if(!p.multisampled)
{
srvDesc.Texture2D.MipLevels = 1;
Expand Down Expand Up @@ -596,8 +599,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 b3a9f00

Please sign in to comment.