Skip to content

Remove offset. #1349

@dj2

Description

@dj2

After the span, offset and align discussion I wonder if the right idea is to just remove offset.

Proposal

We spec the alignment and span of each type that can be put in a buffer, this is partially done already with the Alignment table in the spec. So, we spec something along the lines of:

| type | align | span |
| vec2 | 8     | 8    |
| vec3 | 16    | 16   |
| vec4 | 16    | 16   |
| f32   | 4    | 4    |
| ... |

We can then, if desired, update the various compilers to dump out the offsets for a given struct to make matching up to the API side easier (would this be useful as a reflection API?)

Future

If, in the future, we want packed types, we add a [[packed]] decoration to structs, at that point, all members of the struct would be tightly packed they'd all have a span of their exact type size (so vec3 spans 12) and there would be no padding injected between them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions