How to align buffer?
tksuoran opened this issue · comments
I want to write to a buffer, which previously has already been written to. In this case, the write offset should be properly aligned, in order to respect buffer offset alignment requirements. I have some questions related to this:
BufferDesc::BufferType type;
is documented as GLES only. This does not seem to be accurate:vulkan::Buffer::create()
inspectstype
, and derivesVkBufferUsageFlags
from it.IBuffer
does not seem to expose buffer type. So how do I know which alignment should I apply to a buffer? At least in GL there is separate alignment values for different buffer target bindings.- How do I figure out different buffer type alignments? Which buffer types
DeviceFeatureLimits::BufferAlignment
applies to? DoesShaderStorageBufferOffsetAlignment
apply to only shader storage buffers? What alignment should I use for uniform buffer offset?
I wonder ifIBuffer
should expose buffer type? Or maybeIBuffer
could have method to apply necessary offset alignment (size_t in, aligned size_t out)?
Thanks!
I will make a fix for (1)
and (2)
by adding IBuffer::getBufferType()
.
As for (3)
, DeviceFeatureLimits::ShaderStorageBufferOffsetAlignment
applies to storage buffers and DeviceFeatureLimits::BufferAlignment
applies to uniform buffers. There's currently no API in IGL to get alignment information for other buffer types.