-
Notifications
You must be signed in to change notification settings - Fork 353
Description
Thinking about struct offsets. Currently we do something like:
[[block]] struct MaterialUniforms {
[[offset(0)]] baseColorFactor : vec4<f32>;
[[offset(16)]] metallicRoughnessFactor : vec2<f32>;
[[offset(32)]] emissiveFactor : vec3<f32>;
[[offset(44)]] occlusionStrength : f32;
};What if we shortened that to something like:
[[block]] struct MaterialUniforms {
baseColorFactor : vec4<f32>;
[[span(16)]] metallicRoughnessFactor : vec2<f32>;
[[span(16)]] emissiveFactor : vec3<f32>;
occlusionStrength : f32;
};Where, basically, the offsets start at zero with the first element. If the next element distance is the same as the size of the type (so 16 bytes for a vec4<f32> or 12 bytes for a vec3<f32>) you don't have to provide anything. In the case where the size is different (the vec3's having vec4 size above) you annotate with a span(<size>). Basically, saying here is the real size of this element. We would still have to validate things are correct, but provides the clarity of offsets, without the verbosity I think.
Would cut down down the number of annotations (looking through Austins examples, none of the structs would be annotated) and it fixes up the issue with shuffling members around as the annotation is on the line it refers too and doesn't effect other lines. Also removes the ability to have random sized holes in your data structure.