Vulkan newbie's question about layout modifier "set = ..."

Hi,
I’m learning Vulkan and have a question about layout modifier "set = ".
In my vertex shader, I do need to have 3 uniform buffers, like:

layout(std140, set = 0, binding = 0) uniform uniformBufferA
{
	fields go here ...
};
layout(std140, set = 1, binding = 0) uniform uniformBufferB
{
	fields go here ...
};
layout(std140, set = 3, binding = 0) uniform uniformBufferC
{
	fields go here ...
};

I have three uniform buffers (I do have my reason not to use a single buffer with different bindings, this is not my question). I use “set = 0”, “set = 1” and “set = 2” to assign descriptor No to them.

My question is that how can I reflect this sequence in my source code to properly assign buffer data to them by “vkUpdateDescriptorSets()”? What are function arguments exactly reflect the descriptor set’s No. when I create descriptor set layout, descriptor set, or pipeline?

Most of Vulkan samples tend to use a single descriptor set to contain multiple descriptors at different bindings (like model-view-proj mat at binding 0, image sampler at binding 1, …). I can not find answer easily.

Appreciated for any suggestions.

I found answer by myself, should have read Vulkan document more carefully. The descriptor sequence defined in shaders should be reflected at the following two places:

(1) When create the pipeline layout using vkCreatePipelineLayout(), the argument “pDescriptorSets” should contain the descriptor set in the same sequence as in shaders.
(2) When bind descriptor set during the frame rendering using vkCmdBindDescriptorSets(), the argument “pDescriptorSets” should contain the descriptor set in the same sequence as in shaders.

1 Like

Hi,

thanks for sharing the solution :slight_smile:

Marton