D3D12ShaderDebug support for direct heap access bindings

Added:
D3D12Descriptor FindDescriptor(WrappedID3D12Device *device, const DXDebug::HeapDescriptorType heapType, uint32_t descriptorIndex);
This commit is contained in:
Jake Turner
2024-12-04 09:51:49 +00:00
parent 8e69038ebc
commit 8d24385f15
2 changed files with 55 additions and 0 deletions
@@ -425,6 +425,53 @@ bool D3D12ShaderDebug::CalculateSampleGather(
return true;
}
D3D12Descriptor D3D12ShaderDebug::FindDescriptor(WrappedID3D12Device *device,
const DXDebug::HeapDescriptorType heapType,
uint32_t descriptorIndex)
{
RDCASSERT(heapType != HeapDescriptorType::NoHeap);
const D3D12RenderState &rs = device->GetQueue()->GetCommandData()->m_RenderState;
D3D12ResourceManager *rm = device->GetResourceManager();
// Fetch the correct heap sampler and resource descriptor heaps
WrappedID3D12DescriptorHeap *descHeap = NULL;
rdcarray<ResourceId> descHeaps = rs.heaps;
for(ResourceId heapId : descHeaps)
{
WrappedID3D12DescriptorHeap *pD3D12Heap = rm->GetCurrentAs<WrappedID3D12DescriptorHeap>(heapId);
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = pD3D12Heap->GetDesc();
if(heapDesc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
{
if((heapType == HeapDescriptorType::Sampler) && (descHeap == NULL))
descHeap = pD3D12Heap;
}
else
{
RDCASSERT(heapDesc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
if((heapType == HeapDescriptorType::CBV_SRV_UAV) && (descHeap == NULL))
descHeap = pD3D12Heap;
}
}
if(descHeap == NULL)
{
RDCERR("Couldn't find descriptor heap type %u", heapType);
return D3D12Descriptor();
}
D3D12Descriptor *desc = (D3D12Descriptor *)descHeap->GetCPUDescriptorHandleForHeapStart().ptr;
if(descriptorIndex >= descHeap->GetNumDescriptors())
{
RDCERR("Descriptor index %u out of bounds Max:%u", descriptorIndex,
descHeap->GetNumDescriptors());
return D3D12Descriptor();
}
desc += descriptorIndex;
return *desc;
}
D3D12Descriptor D3D12ShaderDebug::FindDescriptor(WrappedID3D12Device *device,
D3D12_DESCRIPTOR_RANGE_TYPE descType,
const BindingSlot &slot,
@@ -432,6 +479,11 @@ D3D12Descriptor D3D12ShaderDebug::FindDescriptor(WrappedID3D12Device *device,
{
D3D12Descriptor descriptor;
if(slot.heapType != DXDebug::HeapDescriptorType::NoHeap)
{
return FindDescriptor(device, slot.heapType, slot.descriptorIndex);
}
const D3D12RenderState &rs = device->GetQueue()->GetCommandData()->m_RenderState;
D3D12ResourceManager *rm = device->GetResourceManager();
@@ -52,6 +52,9 @@ bool CalculateSampleGather(bool dxil, WrappedID3D12Device *device, int sampleOp,
GatherChannel gatherChannel, const DXBC::ShaderType shaderType,
uint32_t instruction, const char *opString, ShaderVariable &output);
D3D12Descriptor FindDescriptor(WrappedID3D12Device *device,
const DXDebug::HeapDescriptorType heapType, uint32_t descriptorIndex);
D3D12Descriptor FindDescriptor(WrappedID3D12Device *device, D3D12_DESCRIPTOR_RANGE_TYPE descType,
const DXDebug::BindingSlot &slot, const DXBC::ShaderType shaderType);