Additional resources on alignment #296
AlecGoncharow
started this conversation in
Ideas
Replies: 1 comment
-
Hmm interesting. Float arrays really get padded like that? You'd think they'd just have padding on the end. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed you have a page on alignment and just wanted to drop a few links about aligned offset in uniform buffers as I have run into this in my own project.
A great resource for GLSL, which appears to be tackling similar topics is the Uniform block layout section on the Advanced GLSL page on Learn OpenGL.
This includes this example:
Which I found particularly helpful. One additional thing to note is that
mat4
(and likelymat3
but I haven't tested it) is also required to be on a multiple of 16 aligned offset.Another particularly sharp edge is that the
mat3
type in GLSL also assumes each column has the same alignment as avec4
type, not sure if this is true in WGSL as well.FWIW it seems this is such an annoying thing to deal with that some recommend not using
vec3
's at all, I am not sold on this idea, but I believe it is worth acknowledging.Beta Was this translation helpful? Give feedback.
All reactions