I am trying to declare a descriptor in my pipeline for a shader storage buffer and use them however I keep getting this error
2 VUID-VkGraphicsPipelineCreateInfo-layout-07988 Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-layout-07988 ] Object 0: handle = 0xa21a4e0000000030, type = VK_OBJECT_TYPE_SHADER_MODULE; Object 1: handle = 0xea7170000000031, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x215f02cd | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] SPIR-V (VK_SHADER_STAGE_FRAGMENT_BIT) uses descriptor slot [Set 0 Binding 2] (type
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) but was not declared in the pipeline layout. The Vulkan spec states: If a resource variables is declared in a shader, a descriptor slot in layout must match the shader stage (Vulkan® 1.3.280 - A Specification (with all registered extensions))
I have double checked my layout creation code and it does actually contain the descriptor layouts that it needs, I have double checked whether the right binding is used and right shader stage is used etc… I am not sure what else could be wrong. If i change the order the descriptor layouts are in the array a different descriptor set brings the same error but in a different binding and shader stage.
For example the one above is from this ordering:
Info.DescriptorLayoutHandles = { m_RenderData.InstanceStorageLayout->GetLayout(), m_RenderData.ImageSamplerLayout->GetLayout(),
m_RenderData.DirectionalLightLayout->GetLayout(), m_RenderData.PointLightLayout->GetLayout() };
and this new error
Illumina Error: 2 VUID-VkGraphicsPipelineCreateInfo-layout-07988 Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-layout-07988 ] Object 0: handle = 0x4b7df1000000002f, type = VK_OBJECT_TYPE_SHADER_MODULE; Object 1: handle = 0xea7170000000031, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x215f02cd | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[0] SPIR-V (VK_SHADER_STAGE_VERTEX_BIT) uses descriptor slot [Set 0 Binding 0] (type
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) but was not declared in the pipeline layout. The Vulkan spec states: If a resource variables is declared in a shader, a descriptor slot in layout must match the shader stage (Vulkan® 1.3.280 - A Specification (with all registered extensions))
is from this ordering
Info.DescriptorLayoutHandles = { m_RenderData.PointLightLayout->GetLayout(), m_RenderData.InstanceStorageLayout->GetLayout(),
m_RenderData.ImageSamplerLayout->GetLayout(), m_RenderData.DirectionalLightLayout->GetLayout(), };
Descriptors and buffers have been working for a while now however only recently adding more has caused this issue. Here is how I create the pipeline layout:
VkPipelineLayoutCreateInfo PipelineLayoutInfo{};
PipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
PipelineLayoutInfo.setLayoutCount = (uint32_t)Info.DescriptorLayoutHandles.size();
PipelineLayoutInfo.pSetLayouts = Info.DescriptorLayoutHandles.data();
PipelineLayoutInfo.pushConstantRangeCount = 0;
PipelineLayoutInfo.pPushConstantRanges = nullptr;
VkPushConstantRange Range{};
if (Info.UsePushConstant)
{
Range.offset = 0;
Range.stageFlags = GetVulkanShaderStage(Info.PushConstantShaderStage);
uint32_t MaxPushConstantSize = VulkanBackend::GetPhysicalDevice()->GetProperties().DeviceProperties.limits.maxPushConstantsSize;
ILLUMINA_DEBUG_LOG_INFO("max push constant size ", MaxPushConstantSize);
ILLUMINA_ASSERT(Info.PushConstantSize < MaxPushConstantSize, "that is over the limit of push constant sizes for this device");
Range.size = Info.PushConstantSize;
PipelineLayoutInfo.pushConstantRangeCount = 1;
PipelineLayoutInfo.pPushConstantRanges = &Range;
}
VkResult Result = vkCreatePipelineLayout(m_LogicalDevice->GetHandle(), &PipelineLayoutInfo, nullptr, &m_PipelineLayoutHandle);
and this is how i create descriptor layouts:
std::vector<VkDescriptorSetLayoutBinding> LayoutBindings;
for (auto& Descriptor : Descriptors)
{
VkDescriptorSetLayoutBinding LayoutBinding{};
LayoutBinding.binding = Descriptor.Binding;
LayoutBinding.descriptorCount = Descriptor.Count;
LayoutBinding.descriptorType = GetDescriptorType(Descriptor.Type);
LayoutBinding.stageFlags = GetVulkanShaderStage(Descriptor.ShaderStage);
LayoutBinding.pImmutableSamplers = nullptr;
LayoutBindings.push_back(LayoutBinding);
}
VkDescriptorSetLayoutCreateInfo LayoutInfo{};
LayoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
LayoutInfo.bindingCount = (uint32_t)LayoutBindings.size();
LayoutInfo.pBindings = LayoutBindings.data();
VkResult Result = vkCreateDescriptorSetLayout(VulkanAPI::VulkanBackend::GetLogicalDevice()->GetHandle(), &LayoutInfo, nullptr, &m_Layout);
If anyone could direct me to another possible source of error I could check that would be appreciated. Thank you.