Add a DescriptorType to GetDescriptors query

* This will be optional in many cases but for some situations might be required
  when type information is not implicitly available in the descriptor store.
  Generally it should always be available unless the descriptor store is being
  viewed 'blank' purely from its contents with no other context.
This commit is contained in:
baldurk
2025-07-30 22:10:23 +01:00
parent f896f8a2e2
commit ceb062b658
16 changed files with 156 additions and 71 deletions
+10 -1
View File
@@ -1475,6 +1475,8 @@ void DescriptorViewer::ViewD3D12State()
ranges[0].count = resourceDesc->descriptorCount;
ranges[0].descriptorSize = resourceDesc->descriptorByteSize;
ranges[0].offset = resourceDesc->firstDescriptorOffset;
// we are interpreting typeless descriptors, assume D3D12 can interpret it
ranges[0].type = DescriptorType::Unknown;
descriptors = r->GetDescriptors(resourceDesc->resourceId, ranges);
}
}
@@ -1487,6 +1489,8 @@ void DescriptorViewer::ViewD3D12State()
ranges[0].count = samplerDesc->descriptorCount;
ranges[0].descriptorSize = samplerDesc->descriptorByteSize;
ranges[0].offset = samplerDesc->firstDescriptorOffset;
// we are interpreting typeless descriptors, assume D3D12 can interpret it
ranges[0].type = DescriptorType::Unknown;
samplerDescriptors = r->GetSamplerDescriptors(samplerDesc->resourceId, ranges);
}
}
@@ -1525,6 +1529,8 @@ void DescriptorViewer::OnEventChanged(uint32_t eventId)
ranges[0].count = m_DescriptorStore.descriptorCount;
ranges[0].descriptorSize = descSize;
ranges[0].offset = m_DescriptorStore.firstDescriptorOffset;
// assume this descriptor store knows its type information and can interpret typeless descriptors
ranges[0].type = DescriptorType::Unknown;
rdcarray<Descriptor> descriptors = r->GetDescriptors(m_DescriptorStore.resourceId, ranges);
rdcarray<DescriptorLogicalLocation> locations =
@@ -1547,7 +1553,9 @@ void DescriptorViewer::OnEventChanged(uint32_t eventId)
idx++;
// combine contiguous ranges
if(!ranges.empty() && ranges.back().offset + ranges.back().count * descSize == i * descSize)
if(!ranges.empty() &&
ranges.back().offset + ranges.back().count * descSize == i * descSize &&
ranges.back().type == descriptors[i].type)
{
ranges.back().count++;
}
@@ -1557,6 +1565,7 @@ void DescriptorViewer::OnEventChanged(uint32_t eventId)
range.offset = m_DescriptorStore.firstDescriptorOffset + uint32_t(i * descSize);
range.descriptorSize = descSize;
range.count = 1;
range.type = descriptors[i].type;
ranges.push_back(range);
}
}
@@ -498,6 +498,8 @@ void D3D11PipelineStateViewer::OnEventChanged(uint32_t eventId)
range.offset = 0;
range.descriptorSize = state->descriptorByteSize;
range.count = state->descriptorCount;
// D3D11 doesn't need the descriptor type, it has internal type information
range.type = DescriptorType::Unknown;
rdcarray<DescriptorRange> ranges = {range};
@@ -528,15 +528,14 @@ void D3D12PipelineStateViewer::OnEventChanged(uint32_t eventId)
// if the last range is contiguous with this access, append this access as a new range to query
if(!ranges.empty() && ranges.back().descriptorSize == acc.byteSize &&
ranges.back().offset + ranges.back().descriptorSize == acc.byteOffset)
ranges.back().offset + ranges.back().descriptorSize == acc.byteOffset &&
ranges.back().type == acc.type)
{
ranges.back().count++;
continue;
}
DescriptorRange range;
range.offset = acc.byteOffset;
range.descriptorSize = acc.byteSize;
DescriptorRange range = acc;
ranges.push_back(range);
}
@@ -485,6 +485,8 @@ void GLPipelineStateViewer::OnEventChanged(uint32_t eventId)
range.offset = 0;
range.descriptorSize = state->descriptorByteSize;
range.count = state->descriptorCount;
// GL doesn't need the descriptor type, it has internal type information
range.type = DescriptorType::Unknown;
rdcarray<DescriptorRange> ranges = {range};
+5 -4
View File
@@ -170,7 +170,7 @@ struct AccessedResourceTag
{
}
AccessedResourceTag(ShaderDirectAccess acc, VarType t)
: resRef(acc), type(t), step(0), category(acc.category)
: resRef(acc), type(t), step(0), category(CategoryForDescriptorType(acc.type))
{
}
AccessedResourceTag(ShaderVariable var) : step(0), type(var.type)
@@ -181,7 +181,7 @@ struct AccessedResourceTag
{
resRef.directAccess = true;
resRef.access = var.GetDirectAccess();
category = resRef.access.category;
category = CategoryForDescriptorType(resRef.access.type);
}
else
{
@@ -2979,6 +2979,7 @@ QString ShaderViewer::stringRep(const ShaderVariable &var, uint32_t row)
ranges[0].count = 1;
ranges[0].descriptorSize = access.byteSize;
ranges[0].offset = access.byteOffset;
ranges[0].type = access.type;
rdcarray<DescriptorLogicalLocation> locations =
r->GetDescriptorLocations(access.descriptorStore, ranges);
@@ -5249,7 +5250,7 @@ RDTreeWidgetItem *ShaderViewer::makeAccessedResourceNode(const ShaderVariable &v
}
else
{
category = acc.category;
category = CategoryForDescriptorType(acc.type);
bindIdx = m_ReadOnlyResources.indexOf(acc);
}
if(category != DescriptorCategory::ReadOnlyResource)
@@ -5269,7 +5270,7 @@ RDTreeWidgetItem *ShaderViewer::makeAccessedResourceNode(const ShaderVariable &v
}
else
{
category = acc.category;
category = CategoryForDescriptorType(acc.type);
bindIdx = m_ReadWriteResources.indexOf(acc);
}
if(category != DescriptorCategory::ReadWriteResource)
+3 -4
View File
@@ -3294,15 +3294,14 @@ void TextureViewer::OnEventChanged(uint32_t eventId)
// if the last range is contiguous with this access, append this access as a new range to query
if(!ranges.empty() && ranges.back().descriptorSize == update.access.byteSize &&
ranges.back().offset + ranges.back().descriptorSize == update.access.byteOffset)
ranges.back().offset + ranges.back().descriptorSize == update.access.byteOffset &&
ranges.back().type == update.access.type)
{
ranges.back().count++;
continue;
}
DescriptorRange range;
range.offset = update.access.byteOffset;
range.descriptorSize = update.access.byteSize;
DescriptorRange range = update.access;
ranges.push_back(range);
}