Uniform buffer not big enough, how to handle?

Let’s say the max size of my uniform buffer range is 65536, but I want to access more data than that on a per-instance basis. The device capabilities don’t list any size limit for uniform buffers, so I am guessing they can be unlimited in size, but you can only access a range of them at once.

Assuming this is accurate, how do I create an offset for the shader to use to access a different part of the uniform buffer?

Yes, it does. That’s where you got that 65536 number from: maxUniformBufferRange.

Remember, just like OpenGL, there is no such thing as a “uniform buffer”. There is merely a buffer, which can be accessed via a uniform block. In Vulkan, that means creating a VkBuffer whose usage includes UNIFORM_BUFFER_BIT, and binding a range of that buffer to a descriptor of type DESCRIPTOR_TYPE_UNIFORM_BUFFER (or equivalent).

The buffer itself is not special, outside of the fact that you stated that it can be used for that purpose. You are accessing a specific range of a piece of memory through a uniform buffer descriptor. The buffer object itself is simply part of how you define what range of memory you’re talking about.

1 Like