Fix replay refcounting of D3D11 objects

This commit is contained in:
baldurk
2020-09-12 23:15:44 +01:00
parent 50ebd8d379
commit 433a51cf64
5 changed files with 12 additions and 99 deletions
+5 -3
View File
@@ -302,6 +302,8 @@ WrappedID3D11Device::~WrappedID3D11Device()
m_LayoutShaders.clear();
m_LayoutDescs.clear();
FlushPendingDead();
m_ResourceManager->Shutdown();
SAFE_DELETE(m_ResourceManager);
@@ -1630,9 +1632,9 @@ void WrappedID3D11Device::ReportDeath(ID3D11DeviceChild *obj)
m_DeadObjects.push_back(obj);
// if we're shutting down, immediately flush the object as dead. This isn't super efficient but
// it's not the end of the world
if(m_RefCount == 0)
// if we're shutting down or replaying, immediately flush the object as dead. This isn't super
// efficient but it's not the end of the world
if(m_RefCount == 0 || IsReplayMode(m_State))
FlushPendingDead();
}
+2 -3
View File
@@ -246,10 +246,9 @@ struct DummyID3D11InfoQueue : public ID3D11InfoQueue
// so we can keep the refcounting on our own device
struct WrappedID3D11InfoQueue : public ID3D11InfoQueue
{
WrappedID3D11Device *m_pDevice;
ID3D11InfoQueue *m_pReal;
WrappedID3D11Device *m_pDevice = NULL;
ID3D11InfoQueue *m_pReal = NULL;
WrappedID3D11InfoQueue() : m_pDevice(NULL) {}
//////////////////////////////
// implement IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
+2
View File
@@ -56,6 +56,8 @@ void D3D11ResourceManager::FreeCaptureData()
ResourceId D3D11ResourceManager::GetID(ID3D11DeviceChild *res)
{
if(WrappedID3D11DeviceContext::IsAlloc(res))
return ((WrappedID3D11DeviceContext *)res)->GetResourceID();
return GetIDForDeviceChild(res);
}
+1 -92
View File
@@ -332,98 +332,7 @@ D3D11RenderState::D3D11RenderState(WrappedID3D11DeviceContext *context)
{
RDCEraseMem(this, sizeof(D3D11RenderState));
// IA
context->IAGetInputLayout(&IA.Layout);
context->IAGetPrimitiveTopology(&IA.Topo);
context->IAGetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, IA.VBs,
(UINT *)IA.Strides, (UINT *)IA.Offsets);
context->IAGetIndexBuffer(&IA.IndexBuffer, &IA.IndexFormat, &IA.IndexOffset);
// VS
context->VSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, VS.SRVs);
context->VSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, VS.Samplers);
context->VSGetShader((ID3D11VertexShader **)&VS.Object, VS.Instances, &VS.NumInstances);
// DS
context->DSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, DS.SRVs);
context->DSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, DS.Samplers);
context->DSGetShader((ID3D11DomainShader **)&DS.Object, DS.Instances, &DS.NumInstances);
// HS
context->HSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, HS.SRVs);
context->HSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, HS.Samplers);
context->HSGetShader((ID3D11HullShader **)&HS.Object, HS.Instances, &HS.NumInstances);
// GS
context->GSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, GS.SRVs);
context->GSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, GS.Samplers);
context->GSGetShader((ID3D11GeometryShader **)&GS.Object, GS.Instances, &GS.NumInstances);
context->SOGetTargets(D3D11_SO_BUFFER_SLOT_COUNT, SO.Buffers);
// RS
context->RSGetState(&RS.State);
RDCEraseEl(RS.Viewports);
RS.NumViews = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
context->RSGetViewports(&RS.NumViews, RS.Viewports);
RDCEraseEl(RS.Scissors);
RS.NumScissors = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
context->RSGetScissorRects(&RS.NumScissors, RS.Scissors);
// CS
context->CSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, CS.SRVs);
if(context->IsFL11_1())
context->CSGetUnorderedAccessViews(0, D3D11_1_UAV_SLOT_COUNT, CSUAVs);
else
context->CSGetUnorderedAccessViews(0, D3D11_PS_CS_UAV_REGISTER_COUNT, CSUAVs);
context->CSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, CS.Samplers);
context->CSGetShader((ID3D11ComputeShader **)&CS.Object, CS.Instances, &CS.NumInstances);
// PS
context->PSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, PS.SRVs);
context->PSGetSamplers(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, PS.Samplers);
context->PSGetShader((ID3D11PixelShader **)&PS.Object, PS.Instances, &PS.NumInstances);
context->VSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
VS.ConstantBuffers, VS.CBOffsets, VS.CBCounts);
context->DSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
DS.ConstantBuffers, DS.CBOffsets, DS.CBCounts);
context->HSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
HS.ConstantBuffers, HS.CBOffsets, HS.CBCounts);
context->GSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
GS.ConstantBuffers, GS.CBOffsets, GS.CBCounts);
context->CSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
CS.ConstantBuffers, CS.CBOffsets, CS.CBCounts);
context->PSGetConstantBuffers1(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
PS.ConstantBuffers, PS.CBOffsets, PS.CBCounts);
// OM
context->OMGetBlendState(&OM.BlendState, OM.BlendFactor, &OM.SampleMask);
context->OMGetDepthStencilState(&OM.DepthStencilState, &OM.StencRef);
ID3D11RenderTargetView *tmpViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
context->OMGetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, tmpViews, NULL);
OM.UAVStartSlot = 0;
for(int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
{
if(tmpViews[i] != NULL)
{
OM.UAVStartSlot = i + 1;
SAFE_RELEASE(tmpViews[i]);
}
}
if(context->IsFL11_1())
context->OMGetRenderTargetsAndUnorderedAccessViews(
OM.UAVStartSlot, OM.RenderTargets, &OM.DepthView, OM.UAVStartSlot,
D3D11_1_UAV_SLOT_COUNT - OM.UAVStartSlot, OM.UAVs);
else
context->OMGetRenderTargetsAndUnorderedAccessViews(
OM.UAVStartSlot, OM.RenderTargets, &OM.DepthView, OM.UAVStartSlot,
D3D11_PS_CS_UAV_REGISTER_COUNT - OM.UAVStartSlot, OM.UAVs);
context->GetPredication(&Predicate, &PredicateValue);
CopyState(*context->GetCurrentPipelineState());
}
void D3D11RenderState::Clear()
+2 -1
View File
@@ -76,7 +76,8 @@ void D3D11Replay::Shutdown()
m_ProxyResources[i]->Release();
m_ProxyResources.clear();
m_pDevice->Release();
// explicitly delete the device, as all the replay resources created will be keeping refs on it
delete m_pDevice;
}
void D3D11Replay::CreateResources(IDXGIFactory *factory)