Hi.I am experimenting with a single dynamic uniform buffer (VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) shared between different shaders, each of the shaders has a single uniform buffer but the size of those uniform buffers can vary from shader to shader (from 100 to 1500 bytes approximately).Hence the question: in the descriptor write (which I do only once) - what are the consequences of setting an arbitrary/arbitrary large range for VkDescriptorBufferInfo value?E.g. let's say I have two shaders A and B. In scope of a single frame first render happens with shader A, second with B. A uses uniform buffer of 128 bytes. B use uniform buffer of 1024 bytes. Both A and B use same descriptor set with different dynamic offsets (0 and 128). Would VkDescriptorBufferInfo.range value of 1024 (the size of the larger buffer) be a valid one? Does it have a negative performance impact while rendering A, since A uses only 128 bytes uniform buffer?In general what is the recommended strategy of choosing VkDescriptorBufferInfo.range while aiming to have a single dynamic uniform buffer used for different shaders with different uniform buffer sizes?
Regards,Aleksei
This should be fine - rebinding the descriptor to update the offsets is a metadata update, so shouldn't have any performance implications. The only place where specifying an overly large range will hurt is for cache maintenance operations if you have the buffer allocated of a memory allocator that is cached on the host and your system doesn't have hardware cache coherency (few mobile systems do). You don't normally need host cached memory for uniform buffers, as they are write-only, so that problem is trivially avoided by swapping allocator.