mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-31 20:01:12 +00:00
Add serialisation & replay of Acceleration structure build calls
* Add patching of BLAS address in TLAS * Add a compute shader to patch the BLAS address * Adds a pipeline, and root signature for patching the BLAS
This commit is contained in:
@@ -190,6 +190,34 @@ cbuffer DebugMathOperation REG(b0)
|
||||
int mathOp;
|
||||
};
|
||||
|
||||
cbuffer AccStructPatchInfo REG(b0)
|
||||
{
|
||||
uint addressCount;
|
||||
};
|
||||
|
||||
#if defined(SHADER_MODEL_MIN_6_0_REQUIRED) || defined(__cplusplus)
|
||||
typedef uint64_t GPUAddress;
|
||||
|
||||
struct BlasAddressRange
|
||||
{
|
||||
GPUAddress start;
|
||||
GPUAddress end;
|
||||
};
|
||||
|
||||
struct BlasAddressPair
|
||||
{
|
||||
BlasAddressRange oldAddress;
|
||||
BlasAddressRange newAddress;
|
||||
};
|
||||
|
||||
// This corresponds to D3D12_RAYTRACING_INSTANCE_DESC structure
|
||||
struct InstanceDesc
|
||||
{
|
||||
uint64_t padding[7];
|
||||
GPUAddress blasAddress;
|
||||
};
|
||||
#endif
|
||||
|
||||
cbuffer DebugSampleOperation REG(b0)
|
||||
{
|
||||
float4 debugSampleUV;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2022 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SHADER_MODEL_MIN_6_0_REQUIRED
|
||||
#define SHADER_MODEL_MIN_6_0_REQUIRED
|
||||
#endif
|
||||
#include "hlsl_cbuffers.h"
|
||||
|
||||
RWStructuredBuffer<InstanceDesc> instanceDescs : register(u0, space0);
|
||||
StructuredBuffer<BlasAddressPair> oldNewAddressesPair : register(t0, space0);
|
||||
|
||||
bool InRange(BlasAddressRange addressRange, GPUAddress address)
|
||||
{
|
||||
if(addressRange.start <= address && address <= addressRange.end)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
for(uint i = 0; i < addressCount; i++)
|
||||
{
|
||||
if(InRange(oldNewAddressesPair[i].oldAddress, instanceBlasAddress))
|
||||
{
|
||||
uint64_t offset = instanceBlasAddress - oldNewAddressesPair[i].oldAddress.start;
|
||||
instanceDescs[dispatchGroup.x].blasAddress = oldNewAddressesPair[i].newAddress.start + offset;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This might cause device hang but at least we won't access incorrect addresses
|
||||
instanceDescs[dispatchGroup.x].blasAddress = 0;
|
||||
}
|
||||
@@ -117,6 +117,7 @@ RESOURCE_fixedcol_hlsl TYPE_EMBED "hlsl/fixedcol.hlsl"
|
||||
RESOURCE_shaderdebug_hlsl TYPE_EMBED "hlsl/shaderdebug.hlsl"
|
||||
RESOURCE_d3d12_pixelhistory_hlsl TYPE_EMBED "hlsl/d3d12_pixelhistory.hlsl"
|
||||
RESOURCE_depth_copy_hlsl TYPE_EMBED "hlsl/depth_copy.hlsl"
|
||||
RESOURCE_raytracing_hlsl TYPE_EMBED "hlsl/raytracing.hlsl"
|
||||
|
||||
#ifdef RENDERDOC_BAKED_DXC_SHADERS
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define RESOURCE_shaderdebug_hlsl 118
|
||||
#define RESOURCE_d3d12_pixelhistory_hlsl 119
|
||||
#define RESOURCE_depth_copy_hlsl 120
|
||||
#define RESOURCE_raytracing_hlsl 121
|
||||
|
||||
#define RESOURCE_fixedcol_0_dxbc 113
|
||||
#define RESOURCE_fixedcol_1_dxbc 114
|
||||
|
||||
Reference in New Issue
Block a user