mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Rename list-submission callbacks to not be AS-specific
This commit is contained in:
@@ -201,8 +201,8 @@ private:
|
||||
static rdcstr GetChunkName(uint32_t idx);
|
||||
D3D12ResourceManager *GetResourceManager() { return m_pDevice->GetResourceManager(); }
|
||||
|
||||
rdcarray<std::function<bool()>> m_ImmediateASCallbacks;
|
||||
rdcarray<std::function<bool()>> m_PendingASCallbacks;
|
||||
rdcarray<std::function<bool()>> m_ImmediateCallbacks;
|
||||
rdcarray<std::function<bool()>> m_PendingCallbacks;
|
||||
rdcarray<std::function<void()>> m_UnusedCleanupCallbacks;
|
||||
public:
|
||||
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12GraphicsCommandList);
|
||||
@@ -253,34 +253,39 @@ public:
|
||||
|
||||
bool ValidateRootGPUVA(D3D12_GPU_VIRTUAL_ADDRESS buffer);
|
||||
|
||||
void AddSubmissionASBuildCallback(bool waitForSubmission, const std::function<bool()> &postBldExec,
|
||||
const std::function<void()> &unusedCleanup)
|
||||
void AddSubmissionASBuildCallback(bool waitForSubmission, const std::function<bool()> &callback,
|
||||
const std::function<void()> &cleanupCallback)
|
||||
{
|
||||
if(waitForSubmission)
|
||||
m_PendingASCallbacks.push_back(postBldExec);
|
||||
else
|
||||
m_ImmediateASCallbacks.push_back(postBldExec);
|
||||
m_UnusedCleanupCallbacks.push_back(unusedCleanup);
|
||||
if(callback)
|
||||
{
|
||||
if(waitForSubmission)
|
||||
m_PendingCallbacks.push_back(callback);
|
||||
else
|
||||
m_ImmediateCallbacks.push_back(callback);
|
||||
}
|
||||
|
||||
if(cleanupCallback)
|
||||
m_UnusedCleanupCallbacks.push_back(cleanupCallback);
|
||||
}
|
||||
|
||||
bool ExecuteImmediateASBuildCallbacks()
|
||||
bool ExecuteImmediateCallbacks()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
for(std::function<bool()> &func : m_ImmediateASCallbacks)
|
||||
for(std::function<bool()> &func : m_ImmediateCallbacks)
|
||||
{
|
||||
success &= func();
|
||||
}
|
||||
|
||||
m_ImmediateASCallbacks.clear();
|
||||
m_ImmediateCallbacks.clear();
|
||||
m_UnusedCleanupCallbacks.clear();
|
||||
return success;
|
||||
}
|
||||
|
||||
void TakeWaitingASBuildCallbacks(rdcarray<std::function<bool()>> &callbacks)
|
||||
void TakeWaitingCallbacks(rdcarray<std::function<bool()>> &callbacks)
|
||||
{
|
||||
callbacks.append(std::move(m_PendingASCallbacks));
|
||||
m_PendingASCallbacks.clear();
|
||||
callbacks.append(std::move(m_PendingCallbacks));
|
||||
m_PendingCallbacks.clear();
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
|
||||
@@ -409,8 +409,8 @@ HRESULT WrappedID3D12GraphicsCommandList::ResetInternal(ID3D12CommandAllocator *
|
||||
}
|
||||
m_RayDispatches.clear();
|
||||
|
||||
m_ImmediateASCallbacks.clear();
|
||||
m_PendingASCallbacks.clear();
|
||||
m_ImmediateCallbacks.clear();
|
||||
m_PendingCallbacks.clear();
|
||||
|
||||
for(std::function<void()> &func : m_UnusedCleanupCallbacks)
|
||||
func();
|
||||
|
||||
@@ -173,11 +173,11 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue1,
|
||||
CaptureState &m_State;
|
||||
|
||||
// tracking ray dispatches that are pending during capture, to free them once the execution is finished
|
||||
ID3D12Fence *m_RayFence = NULL;
|
||||
ID3D12Fence *m_CallbackFence = NULL;
|
||||
UINT64 m_RayFenceValue = 1;
|
||||
rdcarray<PatchedRayDispatch::Resources> m_RayDispatchesPending;
|
||||
|
||||
ID3D12Fence *GetRayFence();
|
||||
ID3D12Fence *GetCallbackFence();
|
||||
|
||||
bool m_MarkedActive = false;
|
||||
|
||||
|
||||
@@ -796,18 +796,18 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se
|
||||
return true;
|
||||
}
|
||||
|
||||
ID3D12Fence *WrappedID3D12CommandQueue::GetRayFence()
|
||||
ID3D12Fence *WrappedID3D12CommandQueue::GetCallbackFence()
|
||||
{
|
||||
// if we don't have a fence for this queue tracking, create it now
|
||||
if(!m_RayFence)
|
||||
if(!m_CallbackFence)
|
||||
{
|
||||
// create this unwrapped so that it doesn't get recorded into captures
|
||||
m_pDevice->GetReal()->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence),
|
||||
(void **)&m_RayFence);
|
||||
m_RayFence->SetName(L"Queue Ray Fence");
|
||||
(void **)&m_CallbackFence);
|
||||
m_CallbackFence->SetName(L"Queue Callback Fence");
|
||||
}
|
||||
|
||||
return m_RayFence;
|
||||
return m_CallbackFence;
|
||||
}
|
||||
|
||||
void WrappedID3D12CommandQueue::ExecuteCommandLists(UINT NumCommandLists,
|
||||
@@ -840,7 +840,7 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
|
||||
{
|
||||
SERIALISE_TIME_CALL(m_pReal->ExecuteCommandLists(NumCommandLists, unwrapped));
|
||||
|
||||
rdcarray<std::function<bool()>> pendingASBuildCallbacks;
|
||||
rdcarray<std::function<bool()>> pendingCallbacks;
|
||||
|
||||
for(UINT i = 0; i < NumCommandLists; i++)
|
||||
{
|
||||
@@ -852,24 +852,24 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
|
||||
RDCLOG("Submit-callbacks for %s", ToStr(wrapped->GetResourceID()).c_str());
|
||||
}
|
||||
|
||||
if(!wrapped->ExecuteImmediateASBuildCallbacks())
|
||||
if(!wrapped->ExecuteImmediateCallbacks())
|
||||
{
|
||||
RDCERR("Unable to execute post build for acc struct");
|
||||
RDCERR("Unable to execute list submission callback");
|
||||
}
|
||||
|
||||
wrapped->TakeWaitingASBuildCallbacks(pendingASBuildCallbacks);
|
||||
wrapped->TakeWaitingCallbacks(pendingCallbacks);
|
||||
}
|
||||
|
||||
if(!pendingASBuildCallbacks.empty())
|
||||
if(!pendingCallbacks.empty())
|
||||
{
|
||||
ID3D12Fence *fence = GetRayFence();
|
||||
ID3D12Fence *fence = GetCallbackFence();
|
||||
|
||||
// these callbacks need to be synchronised at every submission to process them as soon as the
|
||||
// results are available, since we could submit a build on one queue and then a dependent
|
||||
// build on another queue later once it's finished without any intermediate submissions on the
|
||||
// first queue. For that reason we pass these to the RT handler to hold onto, and tick it
|
||||
GetResourceManager()->GetRTManager()->AddPendingASBuilds(fence, m_RayFenceValue,
|
||||
pendingASBuildCallbacks);
|
||||
GetResourceManager()->GetRTManager()->AddPendingCallbacks(fence, m_RayFenceValue,
|
||||
pendingCallbacks);
|
||||
|
||||
// add the signal for those callbacks to wait on
|
||||
HRESULT hr = m_pReal->Signal(fence, m_RayFenceValue++);
|
||||
@@ -1030,7 +1030,7 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
|
||||
|
||||
m_RayDispatchesPending.append(rayDispatches);
|
||||
|
||||
HRESULT hr = m_pReal->Signal(GetRayFence(), m_RayFenceValue++);
|
||||
HRESULT hr = m_pReal->Signal(GetCallbackFence(), m_RayFenceValue++);
|
||||
CHECK_HR(m_pDevice, hr);
|
||||
RDCASSERTEQUAL(hr, S_OK);
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ WrappedID3D12CommandQueue::~WrappedID3D12CommandQueue()
|
||||
{
|
||||
SAFE_DELETE(m_FrameReader);
|
||||
|
||||
SAFE_RELEASE(m_RayFence);
|
||||
SAFE_RELEASE(m_CallbackFence);
|
||||
|
||||
for(SDObject *o : m_Cmd.m_EventAnnotations)
|
||||
delete o;
|
||||
@@ -682,8 +682,8 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12CommandQueue::QueryInterface(REFIID riid,
|
||||
void WrappedID3D12CommandQueue::CheckAndFreeRayDispatches()
|
||||
{
|
||||
UINT64 signalled = 0;
|
||||
if(m_RayFence)
|
||||
signalled = m_RayFence->GetCompletedValue();
|
||||
if(m_CallbackFence)
|
||||
signalled = m_CallbackFence->GetCompletedValue();
|
||||
|
||||
for(PatchedRayDispatch::Resources &ray : m_RayDispatchesPending)
|
||||
{
|
||||
|
||||
@@ -1230,20 +1230,20 @@ void D3D12RTManager::AddBuildTimer(uint32_t q, uint64_t size)
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12RTManager::AddPendingASBuilds(ID3D12Fence *fence, UINT64 waitValue,
|
||||
const rdcarray<std::function<bool()>> &callbacks)
|
||||
void D3D12RTManager::AddPendingCallbacks(ID3D12Fence *fence, UINT64 waitValue,
|
||||
const rdcarray<std::function<bool()>> &callbacks)
|
||||
{
|
||||
SCOPED_LOCK(m_PendingASBuildsLock);
|
||||
SCOPED_LOCK(m_PendingCallbacksLock);
|
||||
for(const std::function<bool()> &cb : callbacks)
|
||||
{
|
||||
fence->AddRef();
|
||||
m_PendingASBuilds.push_back({fence, waitValue, cb});
|
||||
m_PendingCallbacks.push_back({fence, waitValue, cb});
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12RTManager::TickASManagement()
|
||||
{
|
||||
CheckPendingASBuilds();
|
||||
CheckPendingCallbacks();
|
||||
CheckASCaching();
|
||||
}
|
||||
|
||||
@@ -1533,17 +1533,17 @@ void D3D12RTManager::CheckASCaching()
|
||||
m_InMemASBuildDatas.erase(first, last - first + 1);
|
||||
}
|
||||
|
||||
void D3D12RTManager::CheckPendingASBuilds()
|
||||
void D3D12RTManager::CheckPendingCallbacks()
|
||||
{
|
||||
std::map<ID3D12Fence *, UINT64> fenceValues;
|
||||
SCOPED_LOCK(m_PendingASBuildsLock);
|
||||
SCOPED_LOCK(m_PendingCallbacksLock);
|
||||
|
||||
if(m_PendingASBuilds.empty())
|
||||
if(m_PendingCallbacks.empty())
|
||||
return;
|
||||
|
||||
for(size_t i = 0; i < m_PendingASBuilds.size(); i++)
|
||||
for(size_t i = 0; i < m_PendingCallbacks.size(); i++)
|
||||
{
|
||||
PendingASBuild &build = m_PendingASBuilds[i];
|
||||
PendingCallbacks &build = m_PendingCallbacks[i];
|
||||
|
||||
// first time we see each fence, get the completed value
|
||||
if(fenceValues[build.fence] == 0)
|
||||
@@ -1556,9 +1556,9 @@ void D3D12RTManager::CheckPendingASBuilds()
|
||||
build.callback();
|
||||
|
||||
// swap with last if this isn't already last - we don't need to keep order
|
||||
if(i < m_PendingASBuilds.size() - 1)
|
||||
std::swap(build, m_PendingASBuilds.back());
|
||||
m_PendingASBuilds.pop_back();
|
||||
if(i < m_PendingCallbacks.size() - 1)
|
||||
std::swap(build, m_PendingCallbacks.back());
|
||||
m_PendingCallbacks.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,8 +1271,8 @@ public:
|
||||
UINT64 ArgumentBufferOffset,
|
||||
ID3D12Resource *pCountBuffer, UINT64 CountBufferOffset);
|
||||
|
||||
void AddPendingASBuilds(ID3D12Fence *fence, UINT64 waitValue,
|
||||
const rdcarray<std::function<bool()>> &callbacks);
|
||||
void AddPendingCallbacks(ID3D12Fence *fence, UINT64 waitValue,
|
||||
const rdcarray<std::function<bool()>> &callbacks);
|
||||
void TickASManagement();
|
||||
|
||||
// this disk cache is primarily single threaded - either the disk cache thread owns
|
||||
@@ -1354,7 +1354,7 @@ private:
|
||||
void InitReplayBlasPatchingResources();
|
||||
|
||||
void CheckASCaching();
|
||||
void CheckPendingASBuilds();
|
||||
void CheckPendingCallbacks();
|
||||
|
||||
void CopyFromVA(ID3D12GraphicsCommandList4 *unwrappedCmd, ID3D12Resource *dstRes,
|
||||
uint64_t dstOffset, D3D12_GPU_VIRTUAL_ADDRESS sourceVA, uint64_t byteSize);
|
||||
@@ -1426,14 +1426,14 @@ private:
|
||||
|
||||
uint32_t GetFreeQuery();
|
||||
|
||||
struct PendingASBuild
|
||||
struct PendingCallbacks
|
||||
{
|
||||
ID3D12Fence *fence;
|
||||
UINT64 fenceValue;
|
||||
std::function<bool()> callback;
|
||||
};
|
||||
Threading::CriticalSection m_PendingASBuildsLock;
|
||||
rdcarray<PendingASBuild> m_PendingASBuilds;
|
||||
Threading::CriticalSection m_PendingCallbacksLock;
|
||||
rdcarray<PendingCallbacks> m_PendingCallbacks;
|
||||
};
|
||||
|
||||
struct D3D12ResourceManagerConfiguration
|
||||
|
||||
Reference in New Issue
Block a user