Don't generate resource usage for descriptor buffers

* This will need to be handled separately by post-patching usage in at submit
  time using versioned copies of the descriptor buffer (hopefully only one)
This commit is contained in:
baldurk
2025-06-12 11:34:51 +01:00
parent 30cfee6f2b
commit 3d23227dd4
3 changed files with 84 additions and 55 deletions
+66 -53
View File
@@ -7102,21 +7102,23 @@ void WrappedVulkan::AddUsage(VulkanActionTreeNode &actionNode, rdcarray<DebugMes
if(!constantBlock.bufferBacked)
continue;
AddUsageForBind(actionNode, debugMessages, constantBlock.fixedBindSetOrSpace,
constantBlock.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_Constants) + shad));
AddUsageForDescriptorSetBind(actionNode, debugMessages, constantBlock.fixedBindSetOrSpace,
constantBlock.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_Constants) + shad));
}
for(const ShaderResource &res : sh.refl->readOnlyResources)
{
AddUsageForBind(actionNode, debugMessages, res.fixedBindSetOrSpace, res.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_Resource) + shad));
AddUsageForDescriptorSetBind(actionNode, debugMessages, res.fixedBindSetOrSpace,
res.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_Resource) + shad));
}
for(const ShaderResource &res : sh.refl->readWriteResources)
{
AddUsageForBind(actionNode, debugMessages, res.fixedBindSetOrSpace, res.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_RWResource) + shad));
AddUsageForDescriptorSetBind(actionNode, debugMessages, res.fixedBindSetOrSpace,
res.fixedBindNumber,
ResourceUsage(uint32_t(ResourceUsage::VS_RWResource) + shad));
}
}
@@ -7127,9 +7129,9 @@ void WrappedVulkan::AddUsage(VulkanActionTreeNode &actionNode, rdcarray<DebugMes
AddFramebufferUsage(actionNode, state);
}
void WrappedVulkan::AddUsageForBind(VulkanActionTreeNode &actionNode,
rdcarray<DebugMessage> &debugMessages, uint32_t bindset,
uint32_t bind, ResourceUsage usage)
void WrappedVulkan::AddUsageForDescriptorSetBind(VulkanActionTreeNode &actionNode,
rdcarray<DebugMessage> &debugMessages,
uint32_t bindset, uint32_t bind, ResourceUsage usage)
{
static bool hugeRangeWarned = false;
uint32_t eid = actionNode.action.eventId;
@@ -7148,8 +7150,12 @@ void WrappedVulkan::AddUsageForBind(VulkanActionTreeNode &actionNode,
msg.source = MessageSource::IncorrectAPIUse;
msg.severity = MessageSeverity::High;
if(bindset >= descSets.size() || descSets[bindset].descSet == ResourceId())
if(bindset >= descSets.size() || !descSets[bindset].IsBound())
{
// can't generate usage for descriptor buffers
if(!state.descBufs.empty())
return;
msg.description =
StringFormat::Fmt("Shader referenced a descriptor set %i that was not bound", bindset);
debugMessages.push_back(msg);
@@ -7210,51 +7216,58 @@ void WrappedVulkan::AddUsageForBind(VulkanActionTreeNode &actionNode,
if(!descset.data.binds[bind])
return;
DescriptorSetSlot &slot = descset.data.binds[bind][a];
// handled as part of the framebuffer attachments
if(slot.type == DescriptorSlotType::InputAttachment)
return;
// ignore unwritten descriptors
if(slot.type == DescriptorSlotType::Unwritten)
return;
// we don't mark samplers with usage
if(slot.type == DescriptorSlotType::Sampler)
return;
ResourceId id;
switch(slot.type)
{
case DescriptorSlotType::CombinedImageSampler:
case DescriptorSlotType::SampledImage:
case DescriptorSlotType::StorageImage:
if(slot.resource != ResourceId())
id = c.m_ImageView[slot.resource].image;
break;
case DescriptorSlotType::UniformTexelBuffer:
case DescriptorSlotType::StorageTexelBuffer:
if(slot.resource != ResourceId())
id = c.m_BufferView[slot.resource].buffer;
break;
case DescriptorSlotType::UniformBuffer:
case DescriptorSlotType::UniformBufferDynamic:
case DescriptorSlotType::StorageBuffer:
case DescriptorSlotType::StorageBufferDynamic:
case DescriptorSlotType::AccelerationStructure:
if(slot.resource != ResourceId())
id = slot.resource;
break;
default: RDCERR("Unexpected type %d", slot.type); break;
}
if(id != ResourceId())
actionNode.resourceUsage.push_back(make_rdcpair(id, EventUsage(eid, usage)));
AddUsageForDescriptor(actionNode, descset.data.binds[bind][a], usage);
}
}
void WrappedVulkan::AddUsageForDescriptor(VulkanActionTreeNode &actionNode,
const DescriptorSetSlot &slot, ResourceUsage usage)
{
VulkanCreationInfo &c = m_CreationInfo;
uint32_t eid = actionNode.action.eventId;
// handled as part of the framebuffer attachments
if(slot.type == DescriptorSlotType::InputAttachment)
return;
// ignore unwritten descriptors
if(slot.type == DescriptorSlotType::Unwritten)
return;
// we don't mark samplers with usage
if(slot.type == DescriptorSlotType::Sampler)
return;
ResourceId id;
switch(slot.type)
{
case DescriptorSlotType::CombinedImageSampler:
case DescriptorSlotType::SampledImage:
case DescriptorSlotType::StorageImage:
if(slot.resource != ResourceId())
id = c.m_ImageView[slot.resource].image;
break;
case DescriptorSlotType::UniformTexelBuffer:
case DescriptorSlotType::StorageTexelBuffer:
if(slot.resource != ResourceId())
id = c.m_BufferView[slot.resource].buffer;
break;
case DescriptorSlotType::UniformBuffer:
case DescriptorSlotType::UniformBufferDynamic:
case DescriptorSlotType::StorageBuffer:
case DescriptorSlotType::StorageBufferDynamic:
case DescriptorSlotType::AccelerationStructure:
if(slot.resource != ResourceId())
id = slot.resource;
break;
default: RDCERR("Unexpected type %d", slot.type); break;
}
if(id != ResourceId())
actionNode.resourceUsage.push_back(make_rdcpair(id, EventUsage(eid, usage)));
}
void WrappedVulkan::AddFramebufferUsage(VulkanActionTreeNode &actionNode,
const VulkanRenderState &renderState)
{
+5 -2
View File
@@ -1231,8 +1231,11 @@ private:
void AddEvent();
void AddUsage(VulkanActionTreeNode &actionNode, rdcarray<DebugMessage> &debugMessages);
void AddUsageForBind(VulkanActionTreeNode &actionNode, rdcarray<DebugMessage> &debugMessages,
uint32_t bindset, uint32_t bind, ResourceUsage usage);
void AddUsageForDescriptorSetBind(VulkanActionTreeNode &actionNode,
rdcarray<DebugMessage> &debugMessages, uint32_t bindset,
uint32_t bind, ResourceUsage usage);
void AddUsageForDescriptor(VulkanActionTreeNode &actionNode, const DescriptorSetSlot &slot,
ResourceUsage usage);
void AddFramebufferUsage(VulkanActionTreeNode &actionNode, const VulkanRenderState &renderState);
void AddFramebufferUsageAllChildren(VulkanActionTreeNode &actionNode,
@@ -8756,6 +8756,10 @@ bool WrappedVulkan::Serialise_vkCmdBindDescriptorBuffersEXT(
}
else
{
// track while reading, as while we can't track resource usage for descriptor buffers we want
// to know we're using them
m_BakedCmdBufferInfo[m_LastCmdBufferID].state.descBufs.resize(bufferCount);
ObjDisp(commandBuffer)
->CmdBindDescriptorBuffersEXT(Unwrap(commandBuffer), bufferCount, unwrappedInfos.data());
}
@@ -8860,6 +8864,15 @@ bool WrappedVulkan::Serialise_vkCmdSetDescriptorBufferOffsetsEXT(
}
else
{
// track while reading, as while we can't track resource usage for descriptor buffers we want
// to know we're using them
for(VkPipelineBindPoint bindPoint :
{VK_PIPELINE_BIND_POINT_GRAPHICS, VK_PIPELINE_BIND_POINT_COMPUTE,
VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR})
{
m_BakedCmdBufferInfo[m_LastCmdBufferID].state.GetPipeline(bindPoint).descSets.clear();
}
ObjDisp(commandBuffer)
->CmdSetDescriptorBufferOffsetsEXT(Unwrap(commandBuffer), pipelineBindPoint, Unwrap(layout),
firstSet, setCount, pBufferIndices, pOffsets);