'Can I bind a descriptor at 2 without binding 0 and 1?
I have the following uniform in a shader pipeline:
layout (set = 1, binding = 0) uniform window_uniform_data_uniform {};
Now I want to bind this set, so I do:
vkCmdBindDescriptorSets(cmd_buffer->vk_buffer_handle, VkPipelineBindPoint::VK_PIPELINE_BIND_POINT_GRAPHICS,
PipelineLayouts::GUI,
1, // THE UNIFORM BUFFER IS SET 1
1,
&DescriptorSets::GUI, 0, nullptr);
When I call that function I get the validation error:
Vulkan validation layer callback: Validation Error: [ VUID-VkPipelineLayoutCreateInfo-pSetLayouts-parameter ] Object 0: handle = 0x1acf6211460, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xb3f957d3 | Invalid VkDescriptorSetLayout Object 0x0. The Vulkan spec states: If setLayoutCount is not 0, pSetLayouts must be a valid pointer to an array of setLayoutCount valid VkDescriptorSetLayout handles
The reason I think this is happening is because in the pipeline layout description I say that there is one set layout count:
pipelineLayoutInfo.setLayoutCount = 1;
pipelineLayoutInfo.pSetLayouts = &DescriptorSetLayouts::GUI;
Which makes sense to me because in the shader I have only set = 1, and no 0. However what I think is happening is in the vkCmdBindDescriptorSets I pass (firstSet (1), descriptorSetCount(1) ) because I only want to update set 1. Vulkan probably looks up element/position 1 of the pipeline layouts and sees that it's empty or has invalid arguments. Is this correct?
If this is the case, does this mean that if I have a description in a shader that's set = 11 that the pipeline needs to be created with 10 dummy layouts, even if I never update them?
Solution 1:[1]
VkPipelineLayoutCreateInfo has the member setLayoutCount, but there's no "set offset" member. A pipeline layout has setLayoutCount descriptor sets, with indices on the range [0, setLayoutCount).
Your pipeline has a set 0 even if the shaders in that pipeline never use it. It's still there.
Note that the validation error you get is not from vkBindDescriptorSets; it's from VkPipelineLayoutCreateInfo, likely in the call to vkCreatePipelineLayout.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nicol Bolas |
