diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index efd86ebb3..e2f0c9883 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -834,7 +834,12 @@ void WrappedID3D11DeviceContext::VSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->VSSetSamplers(StartSlot, NumSamplers, samps)); @@ -1204,7 +1209,12 @@ void WrappedID3D11DeviceContext::HSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->HSSetSamplers(StartSlot, NumSamplers, samps)); @@ -1573,7 +1583,12 @@ void WrappedID3D11DeviceContext::DSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->DSSetSamplers(StartSlot, NumSamplers, samps)); @@ -1944,7 +1959,12 @@ void WrappedID3D11DeviceContext::GSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->GSSetSamplers(StartSlot, NumSamplers, samps)); @@ -2417,6 +2437,8 @@ void WrappedID3D11DeviceContext::RSSetState(ID3D11RasterizerState *pRasterizerSt SERIALISE_ELEMENT(m_ResourceID).Named("Context ID"); Serialise_RSSetState(GET_SERIALISER, pRasterizerState); + MarkResourceReferenced(GetIDForResource(pRasterizerState), eFrameRef_Read); + m_ContextRecord->AddChunk(scope.Get()); } @@ -2705,7 +2727,12 @@ void WrappedID3D11DeviceContext::PSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->PSSetSamplers(StartSlot, NumSamplers, samps)); @@ -3420,6 +3447,8 @@ void WrappedID3D11DeviceContext::OMSetBlendState(ID3D11BlendState *pBlendState, SERIALISE_ELEMENT(m_ResourceID).Named("Context ID"); Serialise_OMSetBlendState(GET_SERIALISER, pBlendState, BlendFactor, SampleMask); + MarkResourceReferenced(GetIDForResource(pBlendState), eFrameRef_Read); + m_ContextRecord->AddChunk(scope.Get()); } @@ -3477,6 +3506,8 @@ void WrappedID3D11DeviceContext::OMSetDepthStencilState(ID3D11DepthStencilState SERIALISE_ELEMENT(m_ResourceID).Named("Context ID"); Serialise_OMSetDepthStencilState(GET_SERIALISER, pDepthStencilState, StencilRef); + MarkResourceReferenced(GetIDForResource(pDepthStencilState), eFrameRef_Read); + m_ContextRecord->AddChunk(scope.Get()); } @@ -4529,7 +4560,12 @@ void WrappedID3D11DeviceContext::CSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState *samps[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; for(UINT i = 0; i < NumSamplers; i++) + { + if(ppSamplers[i] && IsActiveCapturing(m_State)) + MarkResourceReferenced(GetIDForResource(ppSamplers[i]), eFrameRef_Read); + samps[i] = UNWRAP(WrappedID3D11SamplerState, ppSamplers[i]); + } SERIALISE_TIME_CALL(m_pRealContext->CSSetSamplers(StartSlot, NumSamplers, samps)); diff --git a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp index 0f8a259eb..c32957a83 100644 --- a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp @@ -157,7 +157,15 @@ HRESULT WrappedID3D11Device::CreateBlendState1(const D3D11_BLEND_DESC1 *pBlendSt SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateBlendState1); Serialise_CreateBlendState1(GET_SERIALISER, pBlendStateDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11BlendState1 *st = (WrappedID3D11BlendState1 *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppBlendState = wrapped; @@ -256,7 +264,15 @@ HRESULT WrappedID3D11Device::CreateRasterizerState1(const D3D11_RASTERIZER_DESC1 SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateRasterizerState1); Serialise_CreateRasterizerState1(GET_SERIALISER, pRasterizerDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11RasterizerState2 *st = (WrappedID3D11RasterizerState2 *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppRasterizerState = wrapped; diff --git a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp index 6cb223e3d..4a5eab494 100644 --- a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp @@ -802,7 +802,15 @@ HRESULT WrappedID3D11Device::CreateRasterizerState2(const D3D11_RASTERIZER_DESC2 SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateRasterizerState2); Serialise_CreateRasterizerState2(GET_SERIALISER, pRasterizerDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11RasterizerState2 *st = (WrappedID3D11RasterizerState2 *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppRasterizerState = wrapped; @@ -875,7 +883,15 @@ HRESULT WrappedID3D11Device::CreateQuery1(const D3D11_QUERY_DESC1 *pQueryDesc, I SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateQuery1); Serialise_CreateQuery1(GET_SERIALISER, pQueryDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11Query1 *q = (WrappedID3D11Query1 *)wrapped; + ResourceId id = q->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppQuery = wrapped; diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index 97f513433..22ae98171 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -2273,7 +2273,15 @@ HRESULT WrappedID3D11Device::CreateBlendState(const D3D11_BLEND_DESC *pBlendStat SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateBlendState); Serialise_CreateBlendState(GET_SERIALISER, pBlendStateDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11BlendState1 *st = (WrappedID3D11BlendState1 *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppBlendState = wrapped; @@ -2367,7 +2375,15 @@ HRESULT WrappedID3D11Device::CreateDepthStencilState(const D3D11_DEPTH_STENCIL_D SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateDepthStencilState); Serialise_CreateDepthStencilState(GET_SERIALISER, pDepthStencilDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11DepthStencilState *st = (WrappedID3D11DepthStencilState *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppDepthStencilState = wrapped; @@ -2461,7 +2477,15 @@ HRESULT WrappedID3D11Device::CreateRasterizerState(const D3D11_RASTERIZER_DESC * SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateRasterizerState); Serialise_CreateRasterizerState(GET_SERIALISER, pRasterizerDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11RasterizerState2 *st = (WrappedID3D11RasterizerState2 *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppRasterizerState = wrapped; @@ -2555,7 +2579,15 @@ HRESULT WrappedID3D11Device::CreateSamplerState(const D3D11_SAMPLER_DESC *pSampl SCOPED_SERIALISE_CHUNK(D3D11Chunk::CreateSamplerState); Serialise_CreateSamplerState(GET_SERIALISER, pSamplerDesc, &wrapped); - m_DeviceRecord->AddChunk(scope.Get()); + WrappedID3D11SamplerState *st = (WrappedID3D11SamplerState *)wrapped; + ResourceId id = st->GetResourceID(); + + RDCASSERT(GetResourceManager()->GetResourceRecord(id) == NULL); + + D3D11ResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + record->Length = 0; + + record->AddChunk(scope.Get()); } *ppSamplerState = wrapped;