Track command list state for all replayed command lists

* This allows us to have up-to-the-command correct state even for command lists
  that aren't the partial one.
This commit is contained in:
baldurk
2020-07-10 11:34:19 +01:00
parent bd484d85de
commit 9a2c49210a
5 changed files with 458 additions and 355 deletions
@@ -288,17 +288,19 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetDepthBounds(SerialiserType
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
Unwrap1(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->OMSetDepthBounds(Min, Max);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
m_Cmd->m_RenderState.depthBoundsMin = Min;
m_Cmd->m_RenderState.depthBoundsMax = Max;
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -306,6 +308,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetDepthBounds(SerialiserType
Unwrap1(pCommandList)->OMSetDepthBounds(Min, Max);
GetCrackedList1()->OMSetDepthBounds(Min, Max);
stateUpdate = true;
}
if(stateUpdate)
{
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state.depthBoundsMin = Min;
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state.depthBoundsMax = Max;
}
@@ -351,6 +358,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetSamplePositions(
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
@@ -358,14 +367,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetSamplePositions(
Unwrap1(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
D3D12RenderState &state = m_Cmd->m_RenderState;
state.samplePos.NumSamplesPerPixel = NumSamplesPerPixel;
state.samplePos.NumPixels = NumPixels;
state.samplePos.Positions.assign(pSamplePositions, NumSamplesPerPixel * NumPixels);
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -373,13 +379,16 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetSamplePositions(
Unwrap1(pCommandList)->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
GetCrackedList1()->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
stateUpdate = true;
}
state.samplePos.NumSamplesPerPixel = NumSamplesPerPixel;
state.samplePos.NumPixels = NumPixels;
state.samplePos.Positions.assign(pSamplePositions, NumSamplesPerPixel * NumPixels);
}
if(stateUpdate)
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
state.samplePos.NumSamplesPerPixel = NumSamplesPerPixel;
state.samplePos.NumPixels = NumPixels;
state.samplePos.Positions.assign(pSamplePositions, NumSamplesPerPixel * NumPixels);
}
}
@@ -96,6 +96,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass(
ds->cpuDescriptor = Unwrap(m_pDevice->GetDebugManager()->GetTempDescriptor(DSV));
}
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
@@ -159,22 +161,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass(
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
m_Cmd->m_Partial[D3D12CommandData::Primary].renderPassActive = true;
m_Cmd->m_RenderState.rts = RTVs;
m_Cmd->m_RenderState.dsv = DSV;
m_Cmd->m_RenderState.renderpass = true;
m_Cmd->m_RenderState.rpRTs.resize(NumRenderTargets);
for(UINT r = 0; r < NumRenderTargets; r++)
m_Cmd->m_RenderState.rpRTs[r] = pRenderTargets[r];
m_Cmd->m_RenderState.rpDSV = {};
if(pDepthStencil)
m_Cmd->m_RenderState.rpDSV = *pDepthStencil;
m_Cmd->m_RenderState.rpFlags = Flags;
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -232,6 +225,19 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass(
// Flags);
// GetCrackedList4()->BeginRenderPass(NumRenderTargets, pRenderTargets, pDepthStencil, Flags);
m_Cmd->AddEvent();
DrawcallDescription draw;
draw.name = "BeginRenderPass()";
draw.flags |= DrawFlags::BeginPass | DrawFlags::PassBoundary;
m_Cmd->AddDrawcall(draw, true);
stateUpdate = true;
}
if(stateUpdate)
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
state.rts = RTVs;
@@ -248,14 +254,6 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass(
state.rpDSV = *pDepthStencil;
state.rpFlags = Flags;
m_Cmd->AddEvent();
DrawcallDescription draw;
draw.name = "BeginRenderPass()";
draw.flags |= DrawFlags::BeginPass | DrawFlags::PassBoundary;
m_Cmd->AddDrawcall(draw, true);
}
}
@@ -352,6 +350,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_EndRenderPass(SerialiserType &s
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
@@ -361,14 +361,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_EndRenderPass(SerialiserType &s
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
m_Cmd->m_Partial[D3D12CommandData::Primary].renderPassActive = false;
m_Cmd->m_RenderState.rts.clear();
m_Cmd->m_RenderState.dsv = D3D12Descriptor();
m_Cmd->m_RenderState.renderpass = false;
m_Cmd->m_RenderState.rpRTs.clear();
m_Cmd->m_RenderState.rpDSV = {};
m_Cmd->m_RenderState.rpFlags = D3D12_RENDER_PASS_FLAG_NONE;
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -384,6 +383,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_EndRenderPass(SerialiserType &s
m_Cmd->AddDrawcall(draw, true);
stateUpdate = true;
}
if(stateUpdate)
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
state.rts.clear();
@@ -46,6 +46,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRate(
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
@@ -53,15 +55,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRate(
Unwrap5(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
->RSSetShadingRate(baseShadingRate, combiners);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
m_Cmd->m_RenderState.shadingRate = baseShadingRate;
if(combiners)
{
m_Cmd->m_RenderState.shadingRateCombiners[0] = combiners[0];
m_Cmd->m_RenderState.shadingRateCombiners[1] = combiners[1];
}
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -69,6 +67,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRate(
Unwrap5(pCommandList)->RSSetShadingRate(baseShadingRate, combiners);
GetCrackedList5()->RSSetShadingRate(baseShadingRate, combiners);
stateUpdate = true;
}
if(stateUpdate)
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
state.shadingRate = baseShadingRate;
@@ -118,6 +121,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRateImage(Serialise
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
bool stateUpdate = false;
if(IsActiveReplaying(m_State))
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
@@ -125,10 +130,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRateImage(Serialise
Unwrap5(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
->RSSetShadingRateImage(Unwrap(shadingRateImage));
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
m_Cmd->m_RenderState.shadingRateImage = GetResID(shadingRateImage);
}
stateUpdate = true;
}
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
stateUpdate = true;
}
}
else
@@ -136,6 +142,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_RSSetShadingRateImage(Serialise
Unwrap5(pCommandList)->RSSetShadingRateImage(Unwrap(shadingRateImage));
GetCrackedList5()->RSSetShadingRateImage(Unwrap(shadingRateImage));
stateUpdate = true;
}
if(stateUpdate)
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
state.shadingRateImage = GetResID(shadingRateImage);
File diff suppressed because it is too large Load Diff
+4
View File
@@ -3506,6 +3506,10 @@ void WrappedID3D12Device::ReplayLog(uint32_t startEventID, uint32_t endEventID,
cmd.m_OutsideCmdList = NULL;
}
if(!partial)
cmd.m_RenderState =
cmd.m_BakedCmdListInfo[cmd.m_Partial[D3D12CommandData::Primary].partialParent].state;
#if ENABLED(SINGLE_FLUSH_VALIDATE)
FlushLists(true);
#endif