Refactor ray dispatch patching

* This makes the shader more amenable to running indirectly for indirect
  patching
This commit is contained in:
baldurk
2024-06-13 13:33:06 +01:00
parent 62b2e2226d
commit e03c17d079
4 changed files with 211 additions and 223 deletions
+8 -12
View File
@@ -295,18 +295,6 @@ cbuffer RayDispatchPatchCB REG(b0)
GPUAddress unwrapped_sampHeapBase;
GPUAddress unwrapped_srvHeapBase;
uint raydispatch_missoffs;
uint raydispatch_missstride;
uint raydispatch_misscount;
uint raydispatch_hitoffs;
uint raydispatch_hitstride;
uint raydispatch_hitcount;
uint raydispatch_calloffs;
uint raydispatch_callstride;
uint raydispatch_callcount;
uint wrapped_sampHeapSize;
uint wrapped_srvHeapSize;
uint unwrapped_heapStrides; // LSB = sampler, MSB = srv
@@ -314,6 +302,12 @@ cbuffer RayDispatchPatchCB REG(b0)
uint numPatchingAddrs;
};
cbuffer RayDispatchShaderRecordCB REG(b1)
{
uint shaderrecord_stride;
uint shaderrecord_count;
};
struct StateObjectLookup
{
uint2 id; // ResourceId
@@ -328,6 +322,8 @@ struct ShaderRecordData
uint rootSigIndex; // only lower 16-bits are valid
};
#define RECORD_PATCH_THREADS 32
#define MAX_LOCALSIG_PARAMS 31
struct LocalRootSigData
+90 -50
View File
@@ -57,9 +57,9 @@ bool InRange(BlasAddressRange addressRange, GPUAddress address)
instanceDescs[dispatchGroup.x].blasAddress = 0;
}
StructuredBuffer<StateObjectLookup> stateObjects : register(t0);
StructuredBuffer<ShaderRecordData> records : register(t1);
StructuredBuffer<LocalRootSigData> rootsigs : register(t2);
StructuredBuffer<StateObjectLookup> stateObjects : register(t1);
StructuredBuffer<ShaderRecordData> records : register(t2);
StructuredBuffer<LocalRootSigData> rootsigs : register(t3);
struct WrappedRecord
{
@@ -67,9 +67,10 @@ struct WrappedRecord
uint index;
};
StructuredBuffer<BlasAddressPair> patchAddressesPair : register(t3);
StructuredBuffer<BlasAddressPair> patchAddressesPair : register(t4);
RWByteAddressBuffer bufferToPatch : register(u0);
ByteAddressBuffer patchSource : register(t0);
RWByteAddressBuffer patchDest : register(u0);
struct DescriptorHeapData
{
@@ -81,12 +82,51 @@ struct DescriptorHeapData
uint unwrapped_stride;
};
uint CopyData(uint byteOffset, uint dataOffset, uint dataEnd)
{
uint4 data = 0;
uint readBytes = 0;
// copy larger chunks if possible
if(dataOffset + 16 <= dataEnd)
{
data = patchSource.Load4(byteOffset + dataOffset);
patchDest.Store4(byteOffset + dataOffset, data);
readBytes = 16;
}
else if(dataOffset + 12 <= dataEnd)
{
data = patchSource.Load3(byteOffset + dataOffset).xyzx;
patchDest.Store3(byteOffset + dataOffset, data.xyz);
readBytes = 12;
}
else if(dataOffset + 8 <= dataEnd)
{
data = patchSource.Load2(byteOffset + dataOffset).xyxx;
patchDest.Store2(byteOffset + dataOffset, data.xy);
readBytes = 8;
}
else if(dataOffset + 4 <= dataEnd)
{
data = patchSource.Load(byteOffset + dataOffset).xxxx;
patchDest.Store(byteOffset + dataOffset, data.x);
readBytes = 4;
}
else
{
readBytes = dataEnd;
}
// don't copy anything here, everything should be uint32 aligned
return dataOffset + readBytes;
}
void PatchTable(uint byteOffset)
{
// load our wrapped record from the start of the table
WrappedRecord wrappedRecord;
wrappedRecord.id = bufferToPatch.Load2(byteOffset);
wrappedRecord.index = bufferToPatch.Load(byteOffset + 8);
wrappedRecord.id = patchSource.Load2(byteOffset);
wrappedRecord.index = patchSource.Load(byteOffset + 8);
// find the state object it came from
int i = 0;
@@ -109,8 +149,8 @@ void PatchTable(uint byteOffset)
// will in theory not crash.
if(objectLookup.id.x == 0 && objectLookup.id.y == 0)
{
bufferToPatch.Store4(byteOffset, uint4(0, 0, 0, 0));
bufferToPatch.Store4(byteOffset + 16, uint4(0, 0, 0, 0));
patchDest.Store4(byteOffset, uint4(0, 0, 0, 0));
patchDest.Store4(byteOffset + 16, uint4(0, 0, 0, 0));
return;
}
@@ -119,8 +159,11 @@ void PatchTable(uint byteOffset)
ShaderRecordData recordData = records[objectLookup.offset + wrappedRecord.index];
// store the unwrapped shader identifier
bufferToPatch.Store4(byteOffset, recordData.identifier[0]);
bufferToPatch.Store4(byteOffset + 16, recordData.identifier[1]);
patchDest.Store4(byteOffset, recordData.identifier[0]);
patchDest.Store4(byteOffset + 16, recordData.identifier[1]);
// size of a shader record, which we've just copied/patched above
uint firstUncopiedByte = 32;
uint rootSigIndex = (recordData.rootSigIndex & 0xffff);
@@ -147,9 +190,16 @@ void PatchTable(uint byteOffset)
uint paramOffset = sig.paramOffsets[i] & 0xffff;
bool isHandle = (sig.paramOffsets[i] & 0xffff0000) == 0;
// copy any gap from where we last processed
for(uint b = firstUncopiedByte; b < paramOffset;)
{
b = CopyData(byteOffset, b, paramOffset);
}
firstUncopiedByte = paramOffset + 8;
if(isHandle)
{
GPUAddress wrappedHandlePtr = bufferToPatch.Load2(byteOffset + paramOffset);
GPUAddress wrappedHandlePtr = patchSource.Load2(byteOffset + paramOffset);
bool patched = false;
[allow_uav_condition] for(int h = 0; h < 2; h++)
@@ -162,7 +212,7 @@ void PatchTable(uint byteOffset)
GPUAddress handleOffset = GPUAddress(index * heaps[h].unwrapped_stride, 0);
GPUAddress unwrapped = add(heaps[h].unwrapped_base, handleOffset);
bufferToPatch.Store2(byteOffset + paramOffset, unwrapped);
patchDest.Store2(byteOffset + paramOffset, unwrapped);
patched = true;
break;
}
@@ -171,7 +221,7 @@ void PatchTable(uint byteOffset)
if(!patched)
{
// won't work but is our best effort
bufferToPatch.Store2(byteOffset + paramOffset, GPUAddress(0, 0));
patchDest.Store2(byteOffset + paramOffset, GPUAddress(0, 0));
}
}
else
@@ -179,56 +229,46 @@ void PatchTable(uint byteOffset)
// during capture addresses don't have to be patched, only patch them on replay
if(numPatchingAddrs > 0)
{
GPUAddress origAddress = bufferToPatch.Load2(byteOffset + paramOffset);
GPUAddress origAddress = patchSource.Load2(byteOffset + paramOffset);
[allow_uav_condition] for(uint i = 0; i < numPatchingAddrs; i++)
{
if(InRange(patchAddressesPair[i].oldAddress, origAddress))
{
GPUAddress offset = sub(origAddress, patchAddressesPair[i].oldAddress.start);
bufferToPatch.Store2(byteOffset + paramOffset,
add(patchAddressesPair[i].newAddress.start, offset));
patchDest.Store2(byteOffset + paramOffset,
add(patchAddressesPair[i].newAddress.start, offset));
break;
}
}
}
else
{
GPUAddress origAddress = patchSource.Load2(byteOffset + paramOffset);
patchDest.Store2(byteOffset + paramOffset, origAddress);
}
}
}
// copy any remaining trailing bytes
for(uint b = firstUncopiedByte; b < shaderrecord_stride;)
{
b = CopyData(byteOffset, b, shaderrecord_stride);
}
}
else
{
// no root sig data to patch, just copy the whole stride
for(uint b = firstUncopiedByte; b < shaderrecord_stride;)
{
b = CopyData(byteOffset, b, shaderrecord_stride);
}
}
}
// Each SV_GroupId corresponds to one shader record to patch
[numthreads(1, 1, 1)] void RENDERDOC_PatchRayDispatchCS(uint3 dispatchGroup
: SV_GroupId) {
uint group = dispatchGroup.x;
if(group == 0)
{
PatchTable(0);
return;
}
group--;
if(group < raydispatch_misscount)
{
PatchTable(raydispatch_missoffs + raydispatch_missstride * group);
return;
}
group -= raydispatch_misscount;
if(group < raydispatch_hitcount)
{
PatchTable(raydispatch_hitoffs + raydispatch_hitstride * group);
return;
}
group -= raydispatch_hitcount;
if(group < raydispatch_callcount)
{
PatchTable(raydispatch_calloffs + raydispatch_callstride * group);
return;
}
[numthreads(RECORD_PATCH_THREADS, 1, 1)] void RENDERDOC_PatchRayDispatchCS(uint3 dispatchThread
: SV_DispatchThreadID) {
if(dispatchThread.x < shaderrecord_count)
PatchTable(shaderrecord_stride * dispatchThread.x);
}
+110 -145
View File
@@ -856,145 +856,10 @@ PatchedRayDispatch D3D12RaytracingResourceAndUtilHandler::PatchRayDispatch(
const uint32_t callOffs = patchDataSize;
patchDataSize += (uint32_t)desc.CallableShaderTable.SizeInBytes;
cbufferData.raydispatch_missoffs = missOffs;
cbufferData.raydispatch_missstride = (uint32_t)desc.MissShaderTable.StrideInBytes;
if(desc.MissShaderTable.SizeInBytes > 0)
cbufferData.raydispatch_misscount =
desc.MissShaderTable.StrideInBytes == 0
? 1
: uint32_t(desc.MissShaderTable.SizeInBytes / desc.MissShaderTable.StrideInBytes);
cbufferData.raydispatch_hitoffs = hitOffs;
cbufferData.raydispatch_hitstride = (uint32_t)desc.HitGroupTable.StrideInBytes;
if(desc.HitGroupTable.SizeInBytes > 0)
cbufferData.raydispatch_hitcount =
desc.HitGroupTable.StrideInBytes == 0
? 1
: uint32_t(desc.HitGroupTable.SizeInBytes / desc.HitGroupTable.StrideInBytes);
cbufferData.raydispatch_calloffs = callOffs;
cbufferData.raydispatch_callstride = (uint32_t)desc.CallableShaderTable.StrideInBytes;
if(desc.CallableShaderTable.SizeInBytes > 0)
cbufferData.raydispatch_callcount =
desc.CallableShaderTable.StrideInBytes == 0
? 1
: uint32_t(desc.CallableShaderTable.SizeInBytes / desc.CallableShaderTable.StrideInBytes);
m_GPUBufferAllocator.Alloc(D3D12GpuBufferHeapType::DefaultHeapWithUav,
D3D12GpuBufferHeapMemoryFlag::Default, patchDataSize,
D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT, &scratchBuffer);
ResourceId id;
uint64_t offs = 0;
rdcarray<ID3D12Resource *> tableResources;
// we transition all unique table resources into copy source. In theory with new barriers this is
// safe because buffers don't have layouts there so it would be in COMMON for interop?
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
D3D12_HEAP_PROPERTIES heapProps;
{
WrappedID3D12Resource::GetResIDFromAddr(desc.RayGenerationShaderRecord.StartAddress, id, offs);
ID3D12Resource *res =
Unwrap(m_wrappedDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(id));
res->GetHeapProperties(&heapProps, NULL);
if(!tableResources.contains(res) && heapProps.Type != D3D12_HEAP_TYPE_UPLOAD)
{
tableResources.push_back(res);
barrier.Transition.pResource = res;
unwrappedCmd->ResourceBarrier(1, &barrier);
}
unwrappedCmd->CopyBufferRegion(scratchBuffer->Resource(), scratchBuffer->Offset() + raygenOffs,
res, offs, desc.RayGenerationShaderRecord.SizeInBytes);
}
ret.desc.RayGenerationShaderRecord.StartAddress = scratchBuffer->Address() + raygenOffs;
{
WrappedID3D12Resource::GetResIDFromAddr(desc.MissShaderTable.StartAddress, id, offs);
ID3D12Resource *res =
Unwrap(m_wrappedDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(id));
res->GetHeapProperties(&heapProps, NULL);
if(!tableResources.contains(res) && heapProps.Type != D3D12_HEAP_TYPE_UPLOAD)
{
tableResources.push_back(res);
barrier.Transition.pResource = res;
unwrappedCmd->ResourceBarrier(1, &barrier);
}
unwrappedCmd->CopyBufferRegion(scratchBuffer->Resource(), scratchBuffer->Offset() + missOffs,
res, offs, desc.MissShaderTable.SizeInBytes);
}
ret.desc.MissShaderTable.StartAddress = scratchBuffer->Address() + missOffs;
if(desc.HitGroupTable.SizeInBytes > 0)
{
WrappedID3D12Resource::GetResIDFromAddr(desc.HitGroupTable.StartAddress, id, offs);
ID3D12Resource *res =
Unwrap(m_wrappedDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(id));
res->GetHeapProperties(&heapProps, NULL);
if(!tableResources.contains(res) && heapProps.Type != D3D12_HEAP_TYPE_UPLOAD)
{
tableResources.push_back(res);
barrier.Transition.pResource = res;
unwrappedCmd->ResourceBarrier(1, &barrier);
}
unwrappedCmd->CopyBufferRegion(scratchBuffer->Resource(), scratchBuffer->Offset() + hitOffs,
res, offs, desc.HitGroupTable.SizeInBytes);
ret.desc.HitGroupTable.StartAddress = scratchBuffer->Address() + hitOffs;
}
if(desc.CallableShaderTable.SizeInBytes > 0)
{
WrappedID3D12Resource::GetResIDFromAddr(desc.CallableShaderTable.StartAddress, id, offs);
ID3D12Resource *res =
Unwrap(m_wrappedDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(id));
res->GetHeapProperties(&heapProps, NULL);
if(!tableResources.contains(res) && heapProps.Type != D3D12_HEAP_TYPE_UPLOAD)
{
tableResources.push_back(res);
barrier.Transition.pResource = res;
unwrappedCmd->ResourceBarrier(1, &barrier);
}
unwrappedCmd->CopyBufferRegion(scratchBuffer->Resource(), scratchBuffer->Offset() + callOffs,
res, offs, desc.CallableShaderTable.SizeInBytes);
ret.desc.CallableShaderTable.StartAddress = scratchBuffer->Address() + callOffs;
}
barrier.Transition.pResource = scratchBuffer->Resource();
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
unwrappedCmd->ResourceBarrier(1, &barrier);
// put the resources into common. This should be implicitly promotable to
// D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE but also compatible with new barriers if they are used
for(ID3D12Resource *res : tableResources)
{
barrier.Transition.pResource = res;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;
unwrappedCmd->ResourceBarrier(1, &barrier);
}
RDCCOMPILE_ASSERT(WRAPPED_DESCRIPTOR_STRIDE == sizeof(D3D12Descriptor),
"Shader descriptor stride is wrong");
@@ -1022,12 +887,14 @@ PatchedRayDispatch D3D12RaytracingResourceAndUtilHandler::PatchRayDispatch(
cbufferData.numPatchingAddrs = m_NumPatchingAddrs;
RayDispatchShaderRecordCB recordInfo;
// set up general patching data - lookup buffers and so on
unwrappedCmd->SetPipelineState(m_RayPatchingData.pipe);
unwrappedCmd->SetComputeRootSignature(m_RayPatchingData.rootSig);
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::RootConstantBuffer,
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::GeneralCB,
sizeof(cbufferData) / sizeof(uint32_t), &cbufferData, 0);
unwrappedCmd->SetComputeRootUnorderedAccessView((UINT)D3D12PatchRayDispatchParam::DestBuffer,
scratchBuffer->Address());
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::StateObjectData,
m_LookupAddrs[0]);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::RecordData,
@@ -1036,10 +903,83 @@ PatchedRayDispatch D3D12RaytracingResourceAndUtilHandler::PatchRayDispatch(
m_LookupAddrs[2]);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::AddrPatchData,
m_LookupAddrs[3]);
unwrappedCmd->Dispatch(1 + cbufferData.raydispatch_misscount + cbufferData.raydispatch_hitcount +
cbufferData.raydispatch_callcount,
1, 1);
// dispatch per shader table
// raygen - required
{
recordInfo.shaderrecord_count = 1;
recordInfo.shaderrecord_stride = uint32_t(ret.desc.RayGenerationShaderRecord.SizeInBytes);
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::RecordCB,
sizeof(recordInfo) / sizeof(uint32_t), &recordInfo, 0);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::SourceBuffer,
ret.desc.RayGenerationShaderRecord.StartAddress);
ret.desc.RayGenerationShaderRecord.StartAddress = scratchBuffer->Address() + raygenOffs;
unwrappedCmd->SetComputeRootUnorderedAccessView((UINT)D3D12PatchRayDispatchParam::DestBuffer,
ret.desc.RayGenerationShaderRecord.StartAddress);
unwrappedCmd->Dispatch(1, 1, 1);
}
// miss - optional
if(ret.desc.MissShaderTable.SizeInBytes > 0)
{
recordInfo.shaderrecord_count =
uint32_t(ret.desc.MissShaderTable.SizeInBytes / ret.desc.MissShaderTable.StrideInBytes);
recordInfo.shaderrecord_stride = uint32_t(ret.desc.MissShaderTable.StrideInBytes);
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::RecordCB,
sizeof(recordInfo) / sizeof(uint32_t), &recordInfo, 0);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::SourceBuffer,
ret.desc.MissShaderTable.StartAddress);
ret.desc.MissShaderTable.StartAddress = scratchBuffer->Address() + missOffs;
unwrappedCmd->SetComputeRootUnorderedAccessView((UINT)D3D12PatchRayDispatchParam::DestBuffer,
ret.desc.MissShaderTable.StartAddress);
unwrappedCmd->Dispatch(AlignUp(recordInfo.shaderrecord_count, (uint32_t)RECORD_PATCH_THREADS) /
RECORD_PATCH_THREADS,
1, 1);
}
// hitgroups - optional
if(desc.HitGroupTable.SizeInBytes > 0)
{
recordInfo.shaderrecord_count =
uint32_t(ret.desc.HitGroupTable.SizeInBytes / ret.desc.HitGroupTable.StrideInBytes);
recordInfo.shaderrecord_stride = uint32_t(ret.desc.HitGroupTable.StrideInBytes);
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::RecordCB,
sizeof(recordInfo) / sizeof(uint32_t), &recordInfo, 0);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::SourceBuffer,
ret.desc.HitGroupTable.StartAddress);
ret.desc.HitGroupTable.StartAddress = scratchBuffer->Address() + hitOffs;
unwrappedCmd->SetComputeRootUnorderedAccessView((UINT)D3D12PatchRayDispatchParam::DestBuffer,
ret.desc.HitGroupTable.StartAddress);
unwrappedCmd->Dispatch(AlignUp(recordInfo.shaderrecord_count, (uint32_t)RECORD_PATCH_THREADS) /
RECORD_PATCH_THREADS,
1, 1);
}
// callables - optional
if(desc.CallableShaderTable.SizeInBytes > 0)
{
recordInfo.shaderrecord_count = uint32_t(ret.desc.CallableShaderTable.SizeInBytes /
ret.desc.CallableShaderTable.StrideInBytes);
recordInfo.shaderrecord_stride = uint32_t(ret.desc.CallableShaderTable.StrideInBytes);
unwrappedCmd->SetComputeRoot32BitConstants((UINT)D3D12PatchRayDispatchParam::RecordCB,
sizeof(recordInfo) / sizeof(uint32_t), &recordInfo, 0);
unwrappedCmd->SetComputeRootShaderResourceView((UINT)D3D12PatchRayDispatchParam::SourceBuffer,
ret.desc.CallableShaderTable.StartAddress);
ret.desc.CallableShaderTable.StartAddress = scratchBuffer->Address() + callOffs;
unwrappedCmd->SetComputeRootUnorderedAccessView((UINT)D3D12PatchRayDispatchParam::DestBuffer,
ret.desc.CallableShaderTable.StartAddress);
unwrappedCmd->Dispatch(AlignUp(recordInfo.shaderrecord_count, (uint32_t)RECORD_PATCH_THREADS) /
RECORD_PATCH_THREADS,
1, 1);
}
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Transition.pResource = scratchBuffer->Resource();
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
@@ -1165,8 +1105,11 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
{
// need 5x 2-DWORD root buffers, the rest we can have for constants.
// this could be made another buffer to track but it fits in push constants so we'll use them
RDCCOMPILE_ASSERT((sizeof(RayDispatchPatchCB) / sizeof(uint32_t)) + 5 * 2 < 64,
"Root signature constants are too large");
RDCCOMPILE_ASSERT(
((sizeof(RayDispatchPatchCB) + sizeof(RayDispatchShaderRecordCB)) / sizeof(uint32_t)) +
(uint32_t(D3D12PatchRayDispatchParam::Count) - 2) * 2 <
64,
"Root signature constants are too large");
// Root Signature
rdcarray<D3D12_ROOT_PARAMETER1> rootParameters;
@@ -1184,7 +1127,17 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
{
D3D12_ROOT_PARAMETER1 rootParam;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
rootParam.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam.Constants.ShaderRegister = 1;
rootParam.Constants.RegisterSpace = 0;
rootParam.Constants.Num32BitValues = sizeof(RayDispatchShaderRecordCB) / sizeof(uint32_t);
rootParameters.push_back(rootParam);
}
{
D3D12_ROOT_PARAMETER1 rootParam;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
rootParam.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam.Descriptor.ShaderRegister = 0;
rootParam.Descriptor.RegisterSpace = 0;
@@ -1194,7 +1147,7 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
{
D3D12_ROOT_PARAMETER1 rootParam;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV;
rootParam.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam.Descriptor.ShaderRegister = 0;
rootParam.Descriptor.RegisterSpace = 0;
@@ -1232,6 +1185,18 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
rootParameters.push_back(rootParam);
}
{
D3D12_ROOT_PARAMETER1 rootParam;
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
rootParam.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam.Descriptor.ShaderRegister = 4;
rootParam.Descriptor.RegisterSpace = 0;
rootParam.Descriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
rootParameters.push_back(rootParam);
}
RDCASSERT(rootParameters.size() == uint32_t(D3D12PatchRayDispatchParam::Count));
D3D12ShaderCache *shaderCache = m_wrappedDevice->GetShaderCache();
if(shaderCache != NULL)
+3 -16
View File
@@ -601,21 +601,6 @@ struct D3D12GpuBuffer
D3D12GpuBuffer &operator=(const D3D12GpuBuffer &) = delete;
D3D12GpuBufferHeapType HeapType() const { return m_heapType; }
D3D12_HEAP_TYPE GetD3D12HeapType() const
{
switch(m_heapType)
{
case D3D12GpuBufferHeapType::AccStructDefaultHeap:
case D3D12GpuBufferHeapType::DefaultHeap:
case D3D12GpuBufferHeapType::DefaultHeapWithUav: return D3D12_HEAP_TYPE_DEFAULT;
case D3D12GpuBufferHeapType::ReadBackHeap: return D3D12_HEAP_TYPE_READBACK;
case D3D12GpuBufferHeapType::UploadHeap: return D3D12_HEAP_TYPE_UPLOAD;
case D3D12GpuBufferHeapType::CustomHeapWithUavCpuAccess: return D3D12_HEAP_TYPE_CUSTOM;
default: RDCERR("Unhandled/Invalid type");
}
return D3D12_HEAP_TYPE_DEFAULT;
}
bool operator!=(const D3D12GpuBuffer &other) const { return !(*this == other); }
bool operator==(const D3D12GpuBuffer &other) const
{
@@ -1014,7 +999,9 @@ enum class D3D12PatchTLASBuildParam
enum class D3D12PatchRayDispatchParam
{
RootConstantBuffer,
GeneralCB,
RecordCB,
SourceBuffer,
DestBuffer,
StateObjectData,
RecordData,