Skip to content

Commit

Permalink
Don't report descriptor access for non-stage-visible descriptors
Browse files Browse the repository at this point in the history
* If these are actually used it's an application error.
  • Loading branch information
baldurk committed Apr 10, 2024
1 parent 12a17b1 commit fbed56a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions renderdoc/driver/vulkan/vk_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ void VulkanCreationInfo::Pipeline::Shader::ProcessStaticDescriptorAccess(
if(bind.bindArraySize > 1)
continue;

// VkShaderStageFlagBits and ShaderStageMask are identical bit-for-bit.
// this might be deliberate if the binding is never actually used dynamically, only
// statically used bindings must be declared
if((setLayoutInfos[bind.fixedBindSetOrSpace]->bindings[bind.fixedBindNumber].stageFlags &
(VkShaderStageFlags)MaskForStage(refl->stage)) == 0)
continue;

access.type = DescriptorType::ConstantBuffer;
access.index = i;

Expand Down Expand Up @@ -877,6 +884,13 @@ void VulkanCreationInfo::Pipeline::Shader::ProcessStaticDescriptorAccess(
if(bind.bindArraySize > 1)
continue;

// VkShaderStageFlagBits and ShaderStageMask are identical bit-for-bit.
// this might be deliberate if the binding is never actually used dynamically, only
// statically used bindings must be declared
if((setLayoutInfos[bind.fixedBindSetOrSpace]->bindings[bind.fixedBindNumber].stageFlags &
(VkShaderStageFlags)MaskForStage(refl->stage)) == 0)
continue;

access.type = DescriptorType::Sampler;
access.index = i;
access.byteSize = bind.fixedBindSetOrSpace;
Expand All @@ -893,6 +907,13 @@ void VulkanCreationInfo::Pipeline::Shader::ProcessStaticDescriptorAccess(
if(bind.bindArraySize > 1)
continue;

// VkShaderStageFlagBits and ShaderStageMask are identical bit-for-bit.
// this might be deliberate if the binding is never actually used dynamically, only
// statically used bindings must be declared
if((setLayoutInfos[bind.fixedBindSetOrSpace]->bindings[bind.fixedBindNumber].stageFlags &
(VkShaderStageFlags)MaskForStage(refl->stage)) == 0)
continue;

access.type = refl->readOnlyResources[i].descriptorType;
access.index = i;
access.byteSize = bind.fixedBindSetOrSpace;
Expand All @@ -909,6 +930,13 @@ void VulkanCreationInfo::Pipeline::Shader::ProcessStaticDescriptorAccess(
if(bind.bindArraySize > 1)
continue;

// VkShaderStageFlagBits and ShaderStageMask are identical bit-for-bit.
// this might be deliberate if the binding is never actually used dynamically, only
// statically used bindings must be declared
if((setLayoutInfos[bind.fixedBindSetOrSpace]->bindings[bind.fixedBindNumber].stageFlags &
(VkShaderStageFlags)MaskForStage(refl->stage)) == 0)
continue;

access.type = refl->readWriteResources[i].descriptorType;
access.index = i;
access.byteSize = bind.fixedBindSetOrSpace;
Expand Down
9 changes: 9 additions & 0 deletions renderdoc/driver/vulkan/vk_shader_feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,15 @@ bool VulkanReplay::FetchShaderFeedback(uint32_t eventId)
return;
}

// VkShaderStageFlagBits and ShaderStageMask are identical bit-for-bit.
if((descLayouts[bindset]->bindings[bind].stageFlags &
(VkShaderStageFlags)MaskForStage(key.stage)) == 0)
{
// this might be deliberate if the binding is never actually used dynamically, only
// statically used bindings must be declared
return;
}

if(descLayouts[bindset]->bindings[bind].variableSize)
{
auto it = m_pDriver->m_DescriptorSetState.find(descSet);
Expand Down

0 comments on commit fbed56a

Please sign in to comment.