Vulkan DescriptorSets and DynamicOffset

Hi there,

I have a question about difference between DynamicOffsets defined in vkCmdBindDescriptorSets and pBufferInfo defined at VkWriteDescriptorSet while updating DescriptorSets. As I have understood that we can use a large block of a buffer and put multiple ubos into that buffer, and specify the each location by setting DynamicOffset parameters. If so that, what is the point of defining range and offset in BufferInfo. Can’t we use range and offset info to specify location of each ubos inside of a large block of buffer.

To let you know the state of my knowledge about Vulkan API: I have no background in any API. You can just suggest that I should not dive into a low level API. I am just trying to get into Computer Graphics. I have followed Overv/VulkanTutorial with the books its referenced, and tried out SaschaWillems/Vulkan examples. Then I decided to write again a triangle renderer in Vulkan to sum up what I have learned.

Thanks!

If so that, what is the point of defining range and offset in BufferInfo.

It is orthogonal thing to do.

Can’t we use range and offset info to specify location of each ubos inside of a large block of buffer.

What if you have two (or more) different Descriptor Sets, and just happen to want to have them in a single VkBuffer.

If I understood your statement correctly, that is another thing bugging me. How does a descriptor set know which set of vertices it will supply the ubo. I could not find anywhere where we bind vertex sets and ubos. Is this happening right at binding descriptor sets to cmd buffer and calling one of the draw cmd. Or it supplies the ubo to whole buffer which is called in a draw function.

And thanks for your reply.

I don’t especially know what you mean by “vertex sets”, but you can use buffers for vertex indices and attribute memory. The expected attributes are defined by the pipeline in VkPipelineVertexInputStateCreateInfo. The buffers to be used for these attributes and indices are provided by vkCmdBindVertexBuffers.

UBOs are just descriptors.

I mean a model’s vertices. Let me make it clear and explain what is in my mind. All models, for example, have a descriptor set, and this descriptor set passed to vertex shader. For instance, if we have two model, each models’ own vertices, which are also defined by an index buffer, are supplied with its own UBO in shader. So the thing I had not understood was how Vulkan knows which UBO is supplied to vertex shader. Then I examined again the examples/descriptorsets of SaschaWillems/Vulkan. I saw that the UBO supplied or binded to vertex shader are determined by these two successive calls.

vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1,
                                        &cube.descriptorSet, 0, nullptr);
    vkCmdDrawIndexed(drawCmdBuffers[i], models.cube.indexCount, 1, 0, 0, 0);

The reason I have created this post was that I was unable to create a single UBO buffer and align all the models’ UBOs in that buffer. I was trying to do the alignment by setting pBufferInfo in VkWriteDescriptorSet. It applied first model’s UBO to other models also, which I did not want. Then I have created separate buffer for each UBO, and the problem solved.

After going over it again, now that makes sense to me. I will try to implement single buffer allocation with DynamicOffset.

Just one more thing, can you elaborate about this statement a little bit? It has confused me.

Thanks for the time.

What I mean is, it is not some choice between supplying offset in VkWriteDescriptorSet or in vkCmdBindDescriptorSets. You are allowed to do both.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.