Add reflection of acceleration structures in DXIL & new descriptor type

This commit is contained in:
baldurk
2024-04-19 10:04:26 +01:00
parent c3b66e7984
commit bdc06af0de
10 changed files with 106 additions and 12 deletions
+20 -1
View File
@@ -481,6 +481,12 @@ public:
ret += 3;
break;
}
case DescriptorType::AccelerationStructure:
{
// type, resource, size
ret = 3;
break;
}
case DescriptorType::Image:
case DescriptorType::ImageSampler:
case DescriptorType::ReadWriteImage:
@@ -529,6 +535,7 @@ public:
case DescriptorType::ReadWriteBuffer: return lit("Storage Buffer");
case DescriptorType::TypedBuffer: return lit("Texel Buffer");
case DescriptorType::ReadWriteTypedBuffer: return lit("Storage Texel Buffer");
case DescriptorType::AccelerationStructure: return lit("Acceleration Structure");
case DescriptorType::Image: return lit("Sampled Image");
case DescriptorType::ImageSampler: return lit("Combined Image/Sampler");
case DescriptorType::ReadWriteImage: return lit("Storage Image");
@@ -544,7 +551,8 @@ public:
case DescriptorType::ImageSampler: // no such type on D3D12
case DescriptorType::Buffer:
case DescriptorType::Image:
case DescriptorType::TypedBuffer: return lit("Shader Resource View");
case DescriptorType::TypedBuffer:
case DescriptorType::AccelerationStructure: return lit("Shader Resource View");
case DescriptorType::ReadWriteBuffer:
case DescriptorType::ReadWriteTypedBuffer:
case DescriptorType::ReadWriteImage: return lit("Unordered Resource View");
@@ -621,6 +629,17 @@ public:
break;
}
case DescriptorType::AccelerationStructure:
{
if(row == 1)
return col == 0 ? lit("Acceleration Structure") : QVariant::fromValue(desc.resource);
if(row == 2)
return col == 0 ? lit("Byte Size")
: Formatter::HumanFormat(desc.byteSize, Formatter::OffsetSize);
break;
}
case DescriptorType::Image:
case DescriptorType::ImageSampler:
case DescriptorType::ReadWriteImage:
@@ -875,6 +875,16 @@ void D3D12PipelineStateViewer::addResourceRow(const D3D12ViewTag &view,
}
}
if(descriptor.type == DescriptorType::AccelerationStructure)
{
typeName = tr("Acceleration Structure");
w = descriptor.byteSize;
h = 0;
d = 0;
a = 0;
format = QString();
}
RDTreeWidgetItem *node = NULL;
if(view.type == D3D12ViewTag::OMTarget)
@@ -1362,6 +1362,22 @@ void VulkanPipelineStateViewer::addResourceRow(const ShaderResource *shaderRes,
if(!filledSlot)
setEmptyRow(node);
}
else if(used.access.type == DescriptorType::AccelerationStructure)
{
node = new RDTreeWidgetItem({
slotname,
bindType,
descriptor.resource,
QString(),
QFormatStr("%1 bytes").arg(Formatter::HumanFormat(descriptor.byteSize, Formatter::OffsetSize)),
QString(),
});
node->setTag(tag);
if(!filledSlot)
setEmptyRow(node);
}
else if(used.access.type == DescriptorType::Sampler)
{
if(samplerDescriptor.object == ResourceId())
+7 -1
View File
@@ -890,6 +890,10 @@ DOCUMENT(R"(The type of a descriptor.
.. data:: ReadWriteBuffer
A buffer that can be read from and written to arbitrarily.
.. data:: AccelerationStructure
A ray-tracing acceleration structure, read-only in the shader.
)");
enum class DescriptorType : uint8_t
{
@@ -903,6 +907,7 @@ enum class DescriptorType : uint8_t
ReadWriteImage,
ReadWriteTypedBuffer,
ReadWriteBuffer,
AccelerationStructure,
};
DECLARE_REFLECTION_ENUM(DescriptorType);
@@ -953,7 +958,8 @@ constexpr DescriptorCategory CategoryForDescriptorType(DescriptorType type)
: type == DescriptorType::Sampler ? DescriptorCategory::Sampler
: (type == DescriptorType::ImageSampler || type == DescriptorType::Image ||
type == DescriptorType::TypedBuffer || type == DescriptorType::Buffer)
type == DescriptorType::TypedBuffer || type == DescriptorType::Buffer ||
type == DescriptorType::AccelerationStructure)
? DescriptorCategory::ReadOnlyResource
: (type == DescriptorType::ReadWriteBuffer || type == DescriptorType::ReadWriteImage ||
+18 -2
View File
@@ -786,12 +786,28 @@ void D3D12Replay::FillDescriptor(Descriptor &dst, const D3D12Descriptor *src)
}
else if(srv.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE)
{
dst.type = DescriptorType::Buffer;
dst.type = DescriptorType::AccelerationStructure;
ResourceId asID;
WrappedID3D12Resource::GetResIDFromAddr(srv.RaytracingAccelerationStructure.Location, asID,
dst.byteOffset);
dst.resource = rm->GetOriginalID(asID);
WrappedID3D12Resource *asRes = rm->GetCurrentAs<WrappedID3D12Resource>(asID);
// we *should* get an AS here
D3D12AccelerationStructure *as = NULL;
asRes->GetAccStructIfExist(dst.byteOffset, &as);
if(as)
{
dst.resource = rm->GetOriginalID(as->GetResourceID());
dst.byteOffset = 0;
dst.byteSize = as->Size();
}
else
{
dst.resource = rm->GetOriginalID(asID);
}
}
else if(srv.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE1D)
{
@@ -816,6 +816,12 @@ static bool AnnotateDXILShader(const DXBC::DXBCContainer *dxbc, uint32_t space,
RDCASSERT(!isSampler);
RDCASSERT(!isUav);
}
else if(resKind == ResourceKind::RTAccelerationStructure)
{
descriptorType = DescriptorType::AccelerationStructure;
RDCASSERT(!isSampler);
RDCASSERT(!isUav);
}
else if(isUav)
{
descriptorType = DescriptorType::ReadWriteImage;
+7 -1
View File
@@ -249,6 +249,9 @@ struct ShaderInputBind
TYPE_UAV_APPEND_STRUCTURED,
TYPE_UAV_CONSUME_STRUCTURED,
TYPE_UAV_RWSTRUCTURED_WITH_COUNTER,
// these entries below do not exist in dxbc and so are only set by RenderDoc manually
TYPE_RTAS,
} type;
constexpr bool IsCBuffer() const { return type == TYPE_CBUFFER; }
@@ -256,7 +259,7 @@ struct ShaderInputBind
constexpr bool IsSRV() const
{
return type == TYPE_TBUFFER || type == TYPE_TEXTURE || type == TYPE_STRUCTURED ||
type == TYPE_BYTEADDRESS;
type == TYPE_BYTEADDRESS || type == TYPE_RTAS;
}
constexpr bool IsUAV() const
{
@@ -285,6 +288,9 @@ struct ShaderInputBind
DIM_TEXTURECUBE,
DIM_TEXTURECUBEARRAY,
DIM_BUFFEREX,
// these entries below do not exist in dxbc and so are only set by RenderDoc manually
DIM_RTAS,
} dimension;
uint32_t numComps;
+18 -5
View File
@@ -155,7 +155,8 @@ static void MakeResourceList(bool srv, DXBC::DXBCContainer *dxbc,
r.type == DXBC::ShaderInputBind::TYPE_UAV_RWTYPED) &&
r.dimension != DXBC::ShaderInputBind::DIM_UNKNOWN &&
r.dimension != DXBC::ShaderInputBind::DIM_BUFFER &&
r.dimension != DXBC::ShaderInputBind::DIM_BUFFEREX);
r.dimension != DXBC::ShaderInputBind::DIM_BUFFEREX &&
r.dimension != DXBC::ShaderInputBind::DIM_RTAS);
res.isReadOnly = srv;
switch(r.dimension)
@@ -163,7 +164,8 @@ static void MakeResourceList(bool srv, DXBC::DXBCContainer *dxbc,
default:
case DXBC::ShaderInputBind::DIM_UNKNOWN: res.textureType = TextureType::Unknown; break;
case DXBC::ShaderInputBind::DIM_BUFFER:
case DXBC::ShaderInputBind::DIM_BUFFEREX: res.textureType = TextureType::Buffer; break;
case DXBC::ShaderInputBind::DIM_BUFFEREX:
case DXBC::ShaderInputBind::DIM_RTAS: res.textureType = TextureType::Buffer; break;
case DXBC::ShaderInputBind::DIM_TEXTURE1D: res.textureType = TextureType::Texture1D; break;
case DXBC::ShaderInputBind::DIM_TEXTURE1DARRAY:
res.textureType = TextureType::Texture1DArray;
@@ -187,8 +189,15 @@ static void MakeResourceList(bool srv, DXBC::DXBCContainer *dxbc,
break;
}
if(r.type == DXBC::ShaderInputBind::TYPE_BYTEADDRESS ||
r.type == DXBC::ShaderInputBind::TYPE_UAV_RWBYTEADDRESS)
if(r.type == DXBC::ShaderInputBind::TYPE_RTAS)
{
res.variableType.rows = res.variableType.columns = 1;
res.variableType.elements = 1;
res.variableType.baseType = VarType::Unknown;
res.variableType.name = "RaytracingAccelerationStructure";
}
else if(r.type == DXBC::ShaderInputBind::TYPE_BYTEADDRESS ||
r.type == DXBC::ShaderInputBind::TYPE_UAV_RWBYTEADDRESS)
{
res.variableType.rows = res.variableType.columns = 1;
res.variableType.elements = 1;
@@ -258,7 +267,11 @@ static void MakeResourceList(bool srv, DXBC::DXBCContainer *dxbc,
res.fixedBindSetOrSpace = r.space;
res.bindArraySize = r.bindCount == 0 ? ~0U : r.bindCount;
if(res.isReadOnly)
if(r.type == DXBC::ShaderInputBind::TYPE_RTAS)
{
res.descriptorType = DescriptorType::AccelerationStructure;
}
else if(res.isReadOnly)
{
res.descriptorType = DescriptorType::Image;
if(!res.isTexture)
@@ -996,7 +996,9 @@ static void AddResourceBind(DXBC::Reflection *refl, const TypeInfo &typeInfo, co
defName = srv ? "SRV" : "UAV";
break;
case ResourceKind::RTAccelerationStructure:
RDCWARN("CS or PS with RT use, not reflected");
bind.type = ShaderInputBind::TYPE_RTAS;
defName = "RaytracingAccelerationStructure";
bind.dimension = ShaderInputBind::DIM_RTAS;
break;
case ResourceKind::Texture1D:
bind.type = srv ? ShaderInputBind::TYPE_TEXTURE : ShaderInputBind::TYPE_UAV_RWTYPED;
+1 -1
View File
@@ -2269,7 +2269,7 @@ void VulkanReplay::FillDescriptor(Descriptor &dstel, const DescriptorSetSlot &sr
dstel.type = DescriptorType::ReadWriteBuffer;
break;
case DescriptorSlotType::AccelerationStructure:
dstel.type = DescriptorType::ReadWriteBuffer;
dstel.type = DescriptorType::AccelerationStructure;
break;
case DescriptorSlotType::InputAttachment: dstel.type = DescriptorType::Image; break;
case DescriptorSlotType::InlineBlock: dstel.type = DescriptorType::ConstantBuffer; break;