Closed CheapMeow closed 2 months ago
Is anything wrong?
Default buffer block alignment in GLSL is std140, resulting in following compilation: https://shader-playground.timjones.io/758f913c2dba4afb747ba19854ccbef5
OpMemberDecorate %ParamBlock 0 Offset 0 // 'attachmentIndex' has offset=0
OpMemberDecorate %ParamBlock 1 Offset 16 // 'padding' has offset=16
// `16` + sizeof(vec3) = 28
Basically you have double padding: one from GLSL-compiler, one from your code.
Is anything wrong?
Default buffer block alignment in GLSL is std140, resulting in following compilation: https://shader-playground.timjones.io/758f913c2dba4afb747ba19854ccbef5
OpMemberDecorate %ParamBlock 0 Offset 0 // 'attachmentIndex' has offset=0 OpMemberDecorate %ParamBlock 1 Offset 16 // 'padding' has offset=16 // `16` + sizeof(vec3) = 28
Basically you have double padding: one from GLSL-compiler, one from your code.
You are right, i don't fully understand std140. Because vec3 is vector, so its offset is n times of vec4.Thank you!
I use spirv_cross to decompile glsl. But get unexpected buffer size.
It is how I use spirv_cross.
It is the frag shader that is decomiled.
The size of
param
should be16
, but spriv_cross return28
.Is anything wrong? Or the memory alignment has some special rule I don't know? Thank you for your reply.