mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-17 13:07:14 +00:00
Don't mark renderstate dirty on each draw, mark dirty on bind
* Note this also means we can't mark resources clean when clearing them since you could bind -> clear -> draw and the resource wouldn't be re-marked dirty. This isn't much of a loss in precision though since usually any resource that's cleared is going to be dirty again in short order, so there's no point trying to track it in the hopes that it might stay clean. * For the most part the code was doing this, but there were a couple of inconsistencies along the way.
This commit is contained in:
@@ -2362,14 +2362,15 @@ void WrappedID3D11DeviceContext::SOSetTargets(UINT NumBuffers, ID3D11Buffer *con
|
||||
// technically this isn't dirty until the draw call, but let's be conservative
|
||||
// to avoid having to track "possibly" dirty resources.
|
||||
// Besides, it's unlikely an application will set an output then not draw to it
|
||||
if(m_State >= WRITING_CAPFRAME)
|
||||
if(m_State == WRITING_CAPFRAME)
|
||||
{
|
||||
MarkResourceReferenced(GetIDForResource(ppSOTargets[i]), eFrameRef_Write);
|
||||
|
||||
if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(ppSOTargets[i]));
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(ppSOTargets[i]));
|
||||
m_MissingTracks.insert(GetIDForResource(ppSOTargets[i]));
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
MarkDirtyResource(GetIDForResource(ppSOTargets[i]));
|
||||
}
|
||||
bufs[i] = UNWRAP(WrappedID3D11Buffer, ppSOTargets[i]);
|
||||
}
|
||||
@@ -3249,6 +3250,8 @@ void WrappedID3D11DeviceContext::OMSetRenderTargets(UINT NumViews,
|
||||
// Besides, it's unlikely an application will set an output then not draw to it
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -3263,6 +3266,8 @@ void WrappedID3D11DeviceContext::OMSetRenderTargets(UINT NumViews,
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -3513,6 +3518,8 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
|
||||
// Besides, it's unlikely an application will set an output then not draw to it
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -3527,6 +3534,8 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
|
||||
ppUnorderedAccessViews[i]->GetResource(&res);
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -3540,6 +3549,8 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -3829,10 +3840,6 @@ void WrappedID3D11DeviceContext::DrawIndexedInstanced(UINT IndexCountPerInstance
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_DrawInstanced(UINT VertexCountPerInstance_,
|
||||
@@ -3900,10 +3907,6 @@ void WrappedID3D11DeviceContext::DrawInstanced(UINT VertexCountPerInstance, UINT
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_DrawIndexed(UINT IndexCount_, UINT StartIndexLocation_,
|
||||
@@ -3963,10 +3966,6 @@ void WrappedID3D11DeviceContext::DrawIndexed(UINT IndexCount, UINT StartIndexLoc
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_Draw(UINT VertexCount_, UINT StartVertexLocation_)
|
||||
@@ -4022,10 +4021,6 @@ void WrappedID3D11DeviceContext::Draw(UINT VertexCount, UINT StartVertexLocation
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_DrawAuto()
|
||||
@@ -4130,10 +4125,6 @@ void WrappedID3D11DeviceContext::DrawAuto()
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstancedIndirect(ID3D11Buffer *pBufferForArgs,
|
||||
@@ -4255,10 +4246,6 @@ void WrappedID3D11DeviceContext::DrawIndexedInstancedIndirect(ID3D11Buffer *pBuf
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
|
||||
if(pBufferForArgs && m_State >= WRITING_CAPFRAME)
|
||||
MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read);
|
||||
@@ -4370,10 +4357,6 @@ void WrappedID3D11DeviceContext::DrawInstancedIndirect(ID3D11Buffer *pBufferForA
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
|
||||
if(pBufferForArgs && m_State >= WRITING_CAPFRAME)
|
||||
MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read);
|
||||
@@ -4730,6 +4713,8 @@ void WrappedID3D11DeviceContext::CSSetUnorderedAccessViews(
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
MarkDirtyResource(GetIDForResource(res));
|
||||
else if(m_State == WRITING_CAPFRAME)
|
||||
m_MissingTracks.insert(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -4977,8 +4962,6 @@ void WrappedID3D11DeviceContext::ExecuteCommandList(ID3D11CommandList *pCommandL
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
|
||||
WrappedID3D11CommandList *wrapped = (WrappedID3D11CommandList *)pCommandList;
|
||||
|
||||
wrapped->MarkDirtyResources(m_pDevice->GetResourceManager());
|
||||
@@ -5064,10 +5047,6 @@ void WrappedID3D11DeviceContext::Dispatch(UINT ThreadGroupCountX, UINT ThreadGro
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool WrappedID3D11DeviceContext::Serialise_DispatchIndirect(ID3D11Buffer *pBufferForArgs,
|
||||
@@ -5175,10 +5154,6 @@ void WrappedID3D11DeviceContext::DispatchIndirect(ID3D11Buffer *pBufferForArgs,
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
|
||||
if(pBufferForArgs && m_State >= WRITING_CAPFRAME)
|
||||
MarkResourceReferenced(GetIDForResource(pBufferForArgs), eFrameRef_Read);
|
||||
@@ -5352,10 +5327,6 @@ void WrappedID3D11DeviceContext::Flush()
|
||||
|
||||
m_CurrentPipelineState->MarkReferenced(this, false);
|
||||
}
|
||||
else if(m_State == WRITING_IDLE)
|
||||
{
|
||||
m_CurrentPipelineState->MarkDirty(this);
|
||||
}
|
||||
|
||||
m_pRealContext->Flush();
|
||||
}
|
||||
@@ -6520,8 +6491,6 @@ void WrappedID3D11DeviceContext::ClearRenderTargetView(ID3D11RenderTargetView *p
|
||||
MarkResourceReferenced(GetIDForResource(pRenderTargetView), eFrameRef_Read);
|
||||
}
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
m_pDevice->GetResourceManager()->MarkCleanResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
@@ -6692,8 +6661,6 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewUint(
|
||||
MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read);
|
||||
}
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
m_pDevice->GetResourceManager()->MarkCleanResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -6866,8 +6833,6 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewFloat(
|
||||
MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read);
|
||||
}
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
m_pDevice->GetResourceManager()->MarkCleanResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
|
||||
@@ -7034,8 +6999,6 @@ void WrappedID3D11DeviceContext::ClearDepthStencilView(ID3D11DepthStencilView *p
|
||||
MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read);
|
||||
}
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
m_pDevice->GetResourceManager()->MarkCleanResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,55 +154,6 @@ void D3D11RenderState::ReleaseRefs()
|
||||
RDCEraseEl(CSUAVs);
|
||||
}
|
||||
|
||||
void D3D11RenderState::MarkDirty(WrappedID3D11DeviceContext *ctx) const
|
||||
{
|
||||
for(UINT i = 0; i < D3D11_1_UAV_SLOT_COUNT; i++)
|
||||
{
|
||||
ID3D11Resource *res = NULL;
|
||||
if(CSUAVs[i])
|
||||
{
|
||||
CSUAVs[i]->GetResource(&res);
|
||||
ctx->MarkDirtyResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
|
||||
for(UINT i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++)
|
||||
ctx->MarkDirtyResource(GetIDForResource(SO.Buffers[i]));
|
||||
|
||||
for(UINT i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
||||
{
|
||||
ID3D11Resource *res = NULL;
|
||||
if(OM.RenderTargets[i])
|
||||
{
|
||||
OM.RenderTargets[i]->GetResource(&res);
|
||||
ctx->MarkDirtyResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
|
||||
for(UINT i = 0; i < D3D11_1_UAV_SLOT_COUNT; i++)
|
||||
{
|
||||
ID3D11Resource *res = NULL;
|
||||
if(OM.UAVs[i])
|
||||
{
|
||||
OM.UAVs[i]->GetResource(&res);
|
||||
ctx->MarkDirtyResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
ID3D11Resource *res = NULL;
|
||||
if(OM.DepthView)
|
||||
{
|
||||
OM.DepthView->GetResource(&res);
|
||||
ctx->MarkDirtyResource(GetIDForResource(res));
|
||||
SAFE_RELEASE(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool initial) const
|
||||
{
|
||||
ctx->MarkResourceReferenced(GetIDForResource(IA.Layout),
|
||||
@@ -250,7 +201,6 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init
|
||||
if(CSUAVs[i])
|
||||
{
|
||||
CSUAVs[i]->GetResource(&res);
|
||||
ctx->m_MissingTracks.insert(GetIDForResource(res));
|
||||
// UAVs we always assume to be partial updates
|
||||
ctx->MarkResourceReferenced(GetIDForResource(CSUAVs[i]),
|
||||
initial ? eFrameRef_Unknown : eFrameRef_Read);
|
||||
@@ -361,7 +311,6 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init
|
||||
if(OM.RenderTargets[i])
|
||||
{
|
||||
OM.RenderTargets[i]->GetResource(&res);
|
||||
ctx->m_MissingTracks.insert(GetIDForResource(res));
|
||||
ctx->MarkResourceReferenced(GetIDForResource(OM.RenderTargets[i]),
|
||||
initial ? eFrameRef_Unknown : eFrameRef_Read);
|
||||
if(viewportScissorPartial)
|
||||
@@ -379,7 +328,6 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init
|
||||
if(OM.UAVs[i])
|
||||
{
|
||||
OM.UAVs[i]->GetResource(&res);
|
||||
ctx->m_MissingTracks.insert(GetIDForResource(res));
|
||||
// UAVs we always assume to be partial updates
|
||||
ctx->MarkResourceReferenced(GetIDForResource(OM.UAVs[i]),
|
||||
initial ? eFrameRef_Unknown : eFrameRef_Read);
|
||||
@@ -398,7 +346,6 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init
|
||||
if(OM.DepthView)
|
||||
{
|
||||
OM.DepthView->GetResource(&res);
|
||||
ctx->m_MissingTracks.insert(GetIDForResource(res));
|
||||
ctx->MarkResourceReferenced(GetIDForResource(OM.DepthView),
|
||||
initial ? eFrameRef_Unknown : eFrameRef_Read);
|
||||
if(viewportScissorPartial)
|
||||
|
||||
@@ -274,7 +274,6 @@ struct D3D11RenderState
|
||||
}
|
||||
void SetDevice(WrappedID3D11Device *device) { m_pDevice = device; }
|
||||
void MarkReferenced(WrappedID3D11DeviceContext *ctx, bool initial) const;
|
||||
void MarkDirty(WrappedID3D11DeviceContext *ctx) const;
|
||||
|
||||
private:
|
||||
void AddRefs();
|
||||
|
||||
Reference in New Issue
Block a user