diff --git a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp index 448b58677e..0ce159752a 100644 --- a/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp +++ b/renderdoc/driver/d3d12/d3d12_pixelhistory.cpp @@ -1260,6 +1260,19 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback uint32_t eventFlags = CalculateEventFlags(pipeState); m_EventFlags[eid] = eventFlags; + WrappedID3D12PipelineState *origPSO = + m_pDevice->GetResourceManager()->GetCurrentAs(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; @@ -1291,6 +1304,13 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback RDCERR("Can't find event flags for event %u", eventId); return it->second; } + rdcpair 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() { @@ -1745,6 +1765,7 @@ struct D3D12TestsFailedCallback : public D3D12PixelHistoryCallback rdcarray m_Events; // Key is event ID, value is the flags for that event. std::map m_EventFlags; + std::map> m_EventDepthBounds; // Key is a pair std::map, ID3D12PipelineState *> m_PipeCache; // Key: pair @@ -3036,6 +3057,13 @@ rdcarray D3D12Replay::PixelHistory(rdcarray event if(!passed) history[h].depthTestFailed = true; + + rdcpair 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; } } }