Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
980 views
in Technique[技术] by (71.8m points)

graphics - Get offset alignment for a uniform buffer on a given device

Is there any way to receive the alignment, in bytes, of the offset within the allocation required for a buffer with usage VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT on a given VkDevice?

If I already got such a VkBuffer, then this value can be retrieved from the size field of the VkMemoryRequirements structure received from a call to vkGetBufferMemoryRequirements.

But if I want to obtain this value with a given buffer, do I need to create a "dummy" buffer with size 1 (specifying size 0 yields a validation error, when the validation layer is enabled)?

question from:https://stackoverflow.com/questions/65916816/get-offset-alignment-for-a-uniform-buffer-on-a-given-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The alignment requirement for a UBO is a device limitation: VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment. The reason for this is that it applies not just to the requirement for the offset used when binding a buffer to a memory allocation, but also to any offsets used within a buffer to the start of UBO data when using that buffer as a UBO descriptor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...