mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 13:00:32 +00:00
Fix problems with residency management during capture. Closes #2496
* We don't want to allow threaded evictions of resources while we're preparing initial states, and we need to manage residency of heaps as well as individual resources.
This commit is contained in:
@@ -2276,6 +2276,8 @@ void WrappedID3D12Device::StartFrameCapture(void *dev, void *wnd)
|
||||
initStateCurBatch = 0;
|
||||
initStateCurList = NULL;
|
||||
|
||||
GPUSyncAllQueues();
|
||||
|
||||
GetResourceManager()->PrepareInitialContents();
|
||||
|
||||
if(initStateCurList)
|
||||
|
||||
@@ -3165,6 +3165,8 @@ HRESULT WrappedID3D12Device::OpenSharedHandleByName(LPCWSTR Name, DWORD Access,
|
||||
|
||||
HRESULT WrappedID3D12Device::MakeResident(UINT NumObjects, ID3D12Pageable *const *ppObjects)
|
||||
{
|
||||
SCOPED_READLOCK(m_CapTransitionLock);
|
||||
|
||||
ID3D12Pageable **unwrapped = GetTempArray<ID3D12Pageable *>(NumObjects);
|
||||
|
||||
for(UINT i = 0; i < NumObjects; i++)
|
||||
@@ -3181,6 +3183,12 @@ HRESULT WrappedID3D12Device::MakeResident(UINT NumObjects, ID3D12Pageable *const
|
||||
res->MakeResident();
|
||||
unwrapped[i] = res->GetReal();
|
||||
}
|
||||
else if(WrappedID3D12Heap::IsAlloc(ppObjects[i]))
|
||||
{
|
||||
WrappedID3D12Heap *heap = (WrappedID3D12Heap *)ppObjects[i];
|
||||
heap->MakeResident();
|
||||
unwrapped[i] = heap->GetReal();
|
||||
}
|
||||
else
|
||||
{
|
||||
unwrapped[i] = (ID3D12Pageable *)Unwrap((ID3D12DeviceChild *)ppObjects[i]);
|
||||
@@ -3192,6 +3200,8 @@ HRESULT WrappedID3D12Device::MakeResident(UINT NumObjects, ID3D12Pageable *const
|
||||
|
||||
HRESULT WrappedID3D12Device::Evict(UINT NumObjects, ID3D12Pageable *const *ppObjects)
|
||||
{
|
||||
SCOPED_READLOCK(m_CapTransitionLock);
|
||||
|
||||
ID3D12Pageable **unwrapped = GetTempArray<ID3D12Pageable *>(NumObjects);
|
||||
|
||||
for(UINT i = 0; i < NumObjects; i++)
|
||||
@@ -3208,6 +3218,12 @@ HRESULT WrappedID3D12Device::Evict(UINT NumObjects, ID3D12Pageable *const *ppObj
|
||||
res->Evict();
|
||||
unwrapped[i] = res->GetReal();
|
||||
}
|
||||
else if(WrappedID3D12Heap::IsAlloc(ppObjects[i]))
|
||||
{
|
||||
WrappedID3D12Heap *heap = (WrappedID3D12Heap *)ppObjects[i];
|
||||
heap->Evict();
|
||||
unwrapped[i] = heap->GetReal();
|
||||
}
|
||||
else
|
||||
{
|
||||
unwrapped[i] = (ID3D12Pageable *)Unwrap((ID3D12DeviceChild *)ppObjects[i]);
|
||||
|
||||
@@ -170,6 +170,8 @@ HRESULT WrappedID3D12Device::EnqueueMakeResident(D3D12_RESIDENCY_FLAGS Flags, UI
|
||||
ID3D12Fence *pFenceToSignal,
|
||||
UINT64 FenceValueToSignal)
|
||||
{
|
||||
SCOPED_READLOCK(m_CapTransitionLock);
|
||||
|
||||
ID3D12Pageable **unwrapped = GetTempArray<ID3D12Pageable *>(NumObjects);
|
||||
|
||||
// assume objects are immediately resident for the purposes of our tracking
|
||||
@@ -187,24 +189,18 @@ HRESULT WrappedID3D12Device::EnqueueMakeResident(D3D12_RESIDENCY_FLAGS Flags, UI
|
||||
res->MakeResident();
|
||||
unwrapped[i] = res->GetReal();
|
||||
}
|
||||
else if(WrappedID3D12Heap::IsAlloc(ppObjects[i]))
|
||||
{
|
||||
WrappedID3D12Heap *heap = (WrappedID3D12Heap *)ppObjects[i];
|
||||
heap->MakeResident();
|
||||
unwrapped[i] = heap->GetReal();
|
||||
}
|
||||
else
|
||||
{
|
||||
unwrapped[i] = (ID3D12Pageable *)Unwrap((ID3D12DeviceChild *)ppObjects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool capframe = false;
|
||||
|
||||
{
|
||||
SCOPED_READLOCK(m_CapTransitionLock);
|
||||
capframe = IsActiveCapturing(m_State);
|
||||
}
|
||||
|
||||
if(capframe)
|
||||
{
|
||||
// serialise
|
||||
}
|
||||
|
||||
return m_pDevice3->EnqueueMakeResident(Flags, NumObjects, unwrapped, Unwrap(pFenceToSignal),
|
||||
FenceValueToSignal);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
|
||||
else if(type == Resource_Resource)
|
||||
{
|
||||
WrappedID3D12Resource *r = (WrappedID3D12Resource *)res;
|
||||
ID3D12Pageable *pageable = r->ResidencyPageable();
|
||||
ID3D12Pageable *unwrappedPageable = r->UnwrappedResidencyPageable();
|
||||
|
||||
bool nonresident = false;
|
||||
if(!r->IsResident())
|
||||
@@ -112,7 +112,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
|
||||
__uuidof(ID3D12Resource), (void **)©Dst);
|
||||
|
||||
if(nonresident)
|
||||
m_Device->MakeResident(1, &pageable);
|
||||
m_Device->GetReal()->MakeResident(1, &unwrappedPageable);
|
||||
|
||||
const rdcarray<D3D12_RESOURCE_STATES> &states = m_Device->GetSubresourceStates(GetResID(res));
|
||||
RDCASSERT(states.size() == 1);
|
||||
@@ -160,7 +160,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
|
||||
m_Device->ExecuteLists(NULL, true);
|
||||
m_Device->FlushLists();
|
||||
|
||||
m_Device->Evict(1, &pageable);
|
||||
m_Device->GetReal()->Evict(1, &unwrappedPageable);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -176,7 +176,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
|
||||
else
|
||||
{
|
||||
if(nonresident)
|
||||
m_Device->MakeResident(1, &pageable);
|
||||
m_Device->GetReal()->MakeResident(1, &unwrappedPageable);
|
||||
|
||||
ID3D12Resource *arrayTexture = NULL;
|
||||
D3D12_RESOURCE_STATES destState = D3D12_RESOURCE_STATE_COPY_SOURCE;
|
||||
@@ -353,7 +353,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
|
||||
m_Device->FlushLists();
|
||||
|
||||
if(nonresident)
|
||||
m_Device->Evict(1, &pageable);
|
||||
m_Device->GetReal()->Evict(1, &unwrappedPageable);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -931,11 +931,11 @@ public:
|
||||
return WrappedDeviceChild12::IsResident();
|
||||
}
|
||||
|
||||
ID3D12Pageable *ResidencyPageable()
|
||||
ID3D12Pageable *UnwrappedResidencyPageable()
|
||||
{
|
||||
if(m_Heap)
|
||||
return m_Heap;
|
||||
return this;
|
||||
return m_Heap->GetReal();
|
||||
return this->GetReal();
|
||||
}
|
||||
|
||||
void SetHeap(ID3D12Heap *heap)
|
||||
|
||||
Reference in New Issue
Block a user