Open Hugobros3 opened 3 years ago
It's being pointed out to me GLSL mandates specialization constants to not alter struct layouts:
Arrays inside a block may be sized with a specialization constant, but the block will have a static layout. Changing the specialized size will not re-layout the block. In the absence of explicit offsets, the layout will be based on the default size of the array.
This just reads like careful wording around this limitation, in practice I don't see anyone wanting this behavior as the default, let alone the only option. I hope this is reconsidered for future SPIR-V revisions.
Such code:
Cannot be translated correctly. This "works" in glslang but actually will break as soon as we specialize
N_bins
to be anything different than 42. The issue is theOffset
decoration on struct type members takes a literal, instead of a constant instruction likeOpTypeArray
does for its length parameter, meaning we can't express the relation with the spec constant.Generated code for reference: