Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add D3D12 pixel history depth bounds test. #3195

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions renderdoc/driver/d3d12/d3d12_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,19 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback
uint32_t eventFlags = CalculateEventFlags(pipeState);
m_EventFlags[eid] = eventFlags;

WrappedID3D12PipelineState *origPSO =
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12PipelineState>(pipeState.pipe);
if(origPSO == NULL)
RDCERR("Failed to retrieve original PSO for pixel history.");

D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC pipeDesc;
origPSO->Fill(pipeDesc);

if(pipeDesc.DepthStencilState.DepthBoundsTestEnable)
m_EventDepthBounds[eid] = {pipeState.depthBoundsMin, pipeState.depthBoundsMax};
else
m_EventDepthBounds[eid] = {};

// TODO: figure out if the shader has early fragments tests turned on,
// based on the currently bound fragment shader.
bool earlyFragmentTests = false;
Expand Down Expand Up @@ -1291,6 +1304,13 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback
RDCERR("Can't find event flags for event %u", eventId);
return it->second;
}
rdcpair<float, float> GetEventDepthBounds(uint32_t eventId)
{
auto it = m_EventDepthBounds.find(eventId);
if(it == m_EventDepthBounds.end())
RDCERR("Can't find event flags for event %u", eventId);
return it->second;
}

void FetchOcclusionResults()
{
Expand Down Expand Up @@ -1745,6 +1765,7 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback
rdcarray<uint32_t> m_Events;
// Key is event ID, value is the flags for that event.
std::map<uint32_t, uint32_t> m_EventFlags;
std::map<uint32_t, rdcpair<float, float>> m_EventDepthBounds;
// Key is a pair <Base pipeline, pipeline flags>
std::map<rdcpair<ResourceId, uint32_t>, ID3D12PipelineState *> m_PipeCache;
// Key: pair <event ID, test>
Expand Down Expand Up @@ -3036,6 +3057,13 @@ rdcarray<PixelModification> D3D12Replay::PixelHistory(rdcarray<EventUsage> event

if(!passed)
history[h].depthTestFailed = true;

rdcpair<float, float> depthBounds = tfCb->GetEventDepthBounds(history[h].eventId);

if((history[h].preMod.depth < depthBounds.first ||
history[h].preMod.depth > depthBounds.second) &&
depthBounds.second > depthBounds.first)
history[h].depthBoundsFailed = true;
}
}
}
Expand Down