Add and release live resources properly during replay

This commit is contained in:
baldurk
2016-07-10 18:10:03 +02:00
parent f39b3e727e
commit 0f6f06c5ec
2 changed files with 49 additions and 0 deletions
+14
View File
@@ -1126,6 +1126,15 @@ void WrappedID3D12Device::ReleaseResource(ID3D12DeviceChild *res)
SCOPED_LOCK(m_ResourceStatesLock);
m_ResourceStates.erase(id);
}
// wrapped resources get released all the time, we don't want to
// try and slerp in a resource release. Just the explicit ones
if(m_State < WRITING)
{
if(GetResourceManager()->HasLiveResource(id))
GetResourceManager()->EraseLiveResource(id);
return;
}
}
bool WrappedID3D12Device::Serialise_SetShaderDebugPath(ID3D12DeviceChild *res, const char *p)
@@ -1275,6 +1284,11 @@ ID3D12GraphicsCommandList *WrappedID3D12Device::GetNewList()
HRESULT hr = CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_Alloc, NULL,
__uuidof(ID3D12GraphicsCommandList), (void **)&ret);
if(m_State < WRITING)
{
GetResourceManager()->AddLiveResource(GetResID(ret), ret);
}
RDCASSERTEQUAL(hr, S_OK);
}
@@ -91,6 +91,10 @@ HRESULT WrappedID3D12Device::CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC *
m_DeviceRecord->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
if(pDesc->Type == D3D12_COMMAND_LIST_TYPE_DIRECT)
{
@@ -166,6 +170,10 @@ HRESULT WrappedID3D12Device::CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type
record->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppCommandAllocator = (ID3D12CommandAllocator *)wrapped;
}
@@ -240,6 +248,9 @@ HRESULT WrappedID3D12Device::CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST
wrapped->Reset(pCommandAllocator, pInitialState);
}
// during replay, the caller is responsible for calling AddLiveResource as this function
// can be called from ID3D12GraphicsCommandList::Reset serialising
*ppCommandList = (ID3D12GraphicsCommandList *)wrapped;
}
@@ -309,6 +320,10 @@ HRESULT WrappedID3D12Device::CreateGraphicsPipelineState(const D3D12_GRAPHICS_PI
record->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppPipelineState = (ID3D12PipelineState *)wrapped;
}
@@ -376,6 +391,10 @@ HRESULT WrappedID3D12Device::CreateComputePipelineState(const D3D12_COMPUTE_PIPE
record->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppPipelineState = (ID3D12PipelineState *)wrapped;
}
@@ -449,6 +468,10 @@ HRESULT WrappedID3D12Device::CreateDescriptorHeap(const D3D12_DESCRIPTOR_HEAP_DE
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppvHeap = (ID3D12DescriptorHeap *)wrapped;
}
@@ -523,6 +546,10 @@ HRESULT WrappedID3D12Device::CreateRootSignature(UINT nodeMask, const void *pBlo
record->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppvRootSignature = (ID3D12RootSignature *)wrapped;
}
@@ -668,6 +695,10 @@ HRESULT WrappedID3D12Device::CreateCommittedResource(const D3D12_HEAP_PROPERTIES
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
{
SCOPED_LOCK(m_ResourceStatesLock);
@@ -764,6 +795,10 @@ HRESULT WrappedID3D12Device::CreateFence(UINT64 InitialValue, D3D12_FENCE_FLAGS
record->AddChunk(scope.Get());
}
else
{
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
*ppFence = (ID3D12Fence *)wrapped;
}