Track when GPU work for build inputs has completed

This commit is contained in:
baldurk
2024-11-15 14:59:20 +00:00
parent c43db5a64d
commit 5a9f200f94
2 changed files with 18 additions and 3 deletions
@@ -1211,10 +1211,19 @@ void WrappedID3D12GraphicsCommandList::BuildRaytracingAccelerationStructure(
return ProcessASBuildAfterSubmission(asbWrappedResourceId, asbWrappedResourceBufferOffset,
dstASId, type, byteSize, buildData);
},
[buildData]() { buildData->Release(); });
// add a ref for the lambda below which tracks when it's ready for readback
buildData->AddRef();
AddSubmissionASBuildCallback(
true,
[buildData]() {
if(buildData)
buildData->Release();
});
buildData->MarkWorkComplete();
buildData->Release();
return true;
},
[buildData]() { buildData->Release(); });
// an indirect AS build will pull in buffers we can't know about
if(pDesc->Inputs.Type == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL)
+6
View File
@@ -1125,6 +1125,9 @@ struct ASBuildData
// geometry GPU addresses have been de-based to contain only offsets
rdcarray<RTGeometryDesc> geoms;
void MarkWorkComplete() { complete = true; }
bool IsWorkComplete() const { return complete; }
void AddRef();
void Release();
@@ -1147,6 +1150,9 @@ private:
// timestamp this build data was recorded on
double timestamp = 0;
// has the GPU work for this build data finished and synchronised?
bool complete = false;
// how many bytes of overhead are currently present, due to copying with strided vertex/AABB data
uint64_t bytesOverhead = 0;