0
$\begingroup$

I know that vertex attributes sourced from vertex buffers in OpenGL need to adhere to the basic alignment requirements of their base types, so e.g. 4 bytes for floats or uints. However, I am unable to find much clear information about the general alignment requirements of vertex attributes beyond (or rather below) that. Or put more concretely, are byte-sized attributes allowed to be aligned only to byte offsets (as well as being tightly packed as the only attributes in their buffer)?

There are some claims that each individual attribute should be 4-byte aligned, as in this article from the GL wiki. However, that article looks a little outdated in general and also doesn't really back these claims in any way (or clarify if that is a "should" or a "shall"). I wasn't really able to find something about it in the GL specification, but admittedly haven't read it end-to-end. So is there any clear statement if individual attributes are allowed to be byte-aligned/packed? While specific hardware experience would certainly be interesting, a clear yes/no from the spec would be optimal.


Now I know such sub-word alignment, even if allowed, might not exhibit the best performance characteristics when compared to bigger chunks. However, performance isn't of the most critical concern here, rather than making the most of the available memory. I also could basically implement such tightly packed attributes myself by just putting them as uints into an SSBO instead and pulling them myself in the vertex shader with some bit-twiddling on the vertex ID. But it would still be nice for the project workflow if it was reliably doable within the normal GL vertex attribute pipeline.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.