Update descriptor when it is bound to command buffer in executale state

Hello everybody!

I’m searching a way to change descriptor set by vkUpdateDescriptorSets to the new uniform buffer when this descriptor has already been used in the command buffer (vkBeginCommandBuffer/vkCmdBindDescriptorSets/vkEndCommandBuffer are executed on it). I would like to change actual uniform data pointer without rebuild comman buffer. VK_EXT_descriptor_indexing is not applicable because GPU doesn’t support it. I guess that dynamic uniform is also not applicable because all dynamic offsets are set only during command bufffers building.

Which is way to update command buffer dynamic data pointer to shader without command buffer rebuilding?

Thanks!

A command buffer is supposed to be an immutable piece of command state. When executed, it should execute the same things each time. The contents of memory objects used by it might change, but everything else should not.

As such, you cannot modify a descriptor set that is being used by a command buffer. At all. There is no way to change the specific addresses of descriptors used by a command buffer.

You seem to be trying to make all of your command buffers entirely static. Unless your scene itself is static, that’s not going to be an effective way to build your rendering system. There are basically two ways to go when it comes to Vulkan rendering systems:

  1. Rebuild your command buffers each frame.

  2. Make your CBs immutable. This means that all of the decisions you make about what gets rendered and where must happen by modifying memory objects. So all of your rendering commands would be indirect draws, with some hard-coded cap on the number of draw calls. But this also means multi-buffering these memory objects and therefore the command buffers that use them. This is necessary so that, while one frame is rendering, you can be setting the data needed for the next frame. This also means you can’t be rendering to the actual swapchain image, since that is all kinds of problematic.