mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-07 15:20:58 +00:00
Implement auditing of indirect RT dispatches
This commit is contained in:
@@ -338,7 +338,8 @@ struct LocalRootSigData
|
||||
|
||||
cbuffer RayIndirectDispatchCB REG(b0)
|
||||
{
|
||||
GPUAddress scratchBuffer;
|
||||
GPUAddress destBuffer;
|
||||
GPUAddress destBufferEnd;
|
||||
|
||||
uint commandSigDispatchOffset;
|
||||
uint commandSigStride;
|
||||
|
||||
@@ -265,11 +265,24 @@ void PatchTable(uint byteOffset)
|
||||
}
|
||||
|
||||
// Each SV_GroupId corresponds to one shader record to patch
|
||||
[numthreads(RECORD_PATCH_THREADS, 1, 1)] void RENDERDOC_PatchRayDispatchCS(uint3 dispatchThread
|
||||
[numthreads(RECORD_PATCH_THREADS, 1, 1)] void RENDERDOC_PatchShaderTableCS(uint3 dispatchThread
|
||||
: SV_DispatchThreadID) {
|
||||
if(dispatchThread.x < shaderrecord_count)
|
||||
PatchTable(shaderrecord_stride * dispatchThread.x);
|
||||
}
|
||||
};
|
||||
|
||||
// Each SV_GroupId corresponds to one shader record to patch
|
||||
[numthreads(RECORD_PATCH_THREADS, 1, 1)] void RENDERDOC_CopyShaderTableCS(uint3 dispatchThread
|
||||
: SV_DispatchThreadID) {
|
||||
if(dispatchThread.x < shaderrecord_count)
|
||||
{
|
||||
for(uint b = 0; b < shaderrecord_stride;)
|
||||
{
|
||||
b = CopyData(patchSource, patchDest, shaderrecord_stride * dispatchThread.x, b,
|
||||
shaderrecord_stride);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// define these structs in hlsl for simplicity
|
||||
|
||||
@@ -327,7 +340,7 @@ GPUAddress AlignRecordAddress(GPUAddress x)
|
||||
numCommands = min(numCommands, applicationCountBuffer.Load(0));
|
||||
}
|
||||
|
||||
GPUAddress outputBufferLocation = scratchBuffer;
|
||||
GPUAddress outputBufferLocation = destBuffer;
|
||||
uint dispatchIndex = 0;
|
||||
|
||||
PatchingExecute execute = (PatchingExecute)0xccddeeff;
|
||||
@@ -443,6 +456,13 @@ GPUAddress AlignRecordAddress(GPUAddress x)
|
||||
patchedExecuteArguments.Store(commandSigDispatchOffset + commandOffset + 6 * 16, raw.b);
|
||||
}
|
||||
|
||||
// check for buffer overrun
|
||||
if(!lessEqual(outputBufferLocation, destBufferEnd))
|
||||
{
|
||||
// error! don't patch, this will fail. Needs to be caught by auditing
|
||||
dispatchIndex = 0;
|
||||
}
|
||||
|
||||
// store the number of patching indirect dispatches we'll do, up to 4 per the application's number
|
||||
internalExecuteCount.Store(0, dispatchIndex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user