Handle unrolling array-of-pointers for replay-time AS builds

This commit is contained in:
baldurk
2024-10-19 01:21:47 +01:00
parent ac1a680b47
commit b4c659eb9a
6 changed files with 173 additions and 107 deletions
+19 -19
View File
@@ -29,32 +29,29 @@ StructuredBuffer<BlasAddressPair> oldNewAddressesPair : register(t0);
bool InRange(BlasAddressRange addressRange, GPUAddress address)
{
if(lessEqual(addressRange.start, address) && lessThan(address, addressRange.end))
{
return true;
}
return false;
return (lessEqual(addressRange.start, address) && lessThan(address, addressRange.end));
}
// Each SV_GroupId corresponds to each of the BLAS (instance) in TLAS
[numthreads(1, 1, 1)] void RENDERDOC_PatchAccStructAddressCS(uint3 dispatchGroup
: SV_GroupId) {
GPUAddress instanceBlasAddress = instanceDescs[dispatchGroup.x].blasAddress;
GPUAddress RemapCaptureToReplayAddress(GPUAddress instanceBlasAddress)
{
for(uint i = 0; i < addressCount; i++)
{
if(InRange(oldNewAddressesPair[i].oldAddress, instanceBlasAddress))
{
GPUAddress offset = sub(instanceBlasAddress, oldNewAddressesPair[i].oldAddress.start);
instanceDescs[dispatchGroup.x].blasAddress =
add(oldNewAddressesPair[i].newAddress.start, offset);
return;
return add(oldNewAddressesPair[i].newAddress.start, offset);
}
}
// This might cause device hang but at least we won't access incorrect addresses
instanceDescs[dispatchGroup.x].blasAddress = 0;
// This might cause device hang but at least we won't access incorrect addresses
return 0;
}
// Each SV_GroupId corresponds to each of the BLAS (instance) in TLAS
[numthreads(1, 1, 1)] void RENDERDOC_PatchAccStructAddressCS(uint3 dispatchGroup
: SV_GroupId) {
instanceDescs[dispatchGroup.x].blasAddress =
RemapCaptureToReplayAddress(instanceDescs[dispatchGroup.x].blasAddress);
}
StructuredBuffer<StateObjectLookup> stateObjects : register(t1);
@@ -450,13 +447,16 @@ GPUAddress AlignRecordAddress(GPUAddress x)
internalExecuteCount.Store(0, dispatchIndex);
}
StructuredBuffer<uint2> applicationBLASPointers : register(t0);
StructuredBuffer<uint2> applicationBLASPointers : register(t1);
RWStructuredBuffer<TLASCopyExecute> internalTLASCopyArguments : register(u0);
[numthreads(1, 1, 1)] void RENDERDOC_PrepareTLASCopyIndirectExecuteCS(uint3 dispatchThread
: SV_DispatchThreadID) {
TLASCopyExecute execute = (TLASCopyExecute)0;
execute.blasPointer = applicationBLASPointers[dispatchThread.x];
if(addressCount > 0)
execute.blasPointer = RemapCaptureToReplayAddress(applicationBLASPointers[dispatchThread.x]);
else
execute.blasPointer = applicationBLASPointers[dispatchThread.x];
execute.index = dispatchThread.x;
execute.dispatchDim = uint3(1, 1, 1);
@@ -464,7 +464,7 @@ RWStructuredBuffer<TLASCopyExecute> internalTLASCopyArguments : register(u0);
}
// this is from the EI argument above, so we always copy from [0] to indirect the pointer
StructuredBuffer<InstanceDesc> copySource : register(t0);
StructuredBuffer<InstanceDesc> copySource : register(t1);
// also from the EI argument above
cbuffer TLASCopyExecuteCB : register(b0)