From fbed56ac55401160482374ce8da44b4365f46992 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 27 Mar 2024 12:29:58 +0000 Subject: [PATCH] Don't report descriptor access for non-stage-visible descriptors * If these are actually used it's an application error. --- renderdoc/driver/vulkan/vk_info.cpp | 28 +++++++++++++++++++ .../driver/vulkan/vk_shader_feedback.cpp | 9 ++++++ 2 files changed, 37 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 485a92d75c..2b818687c8 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/renderdoc/driver/vulkan/vk_shader_feedback.cpp b/renderdoc/driver/vulkan/vk_shader_feedback.cpp index 39c128a81b..c1bece315c 100644 --- a/renderdoc/driver/vulkan/vk_shader_feedback.cpp +++ b/renderdoc/driver/vulkan/vk_shader_feedback.cpp @@ -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);