Skip to content

Storage variables shouldn't be required to be structs #2188

@litherum

Description

@litherum

Trying to compile this:

[[group(0), binding(0)]] var<storage, read> myArray: array<i32, 8>;

is an error. Instead, the author has to say:

[[block]] struct MyData {
    myArray: array<i32, 8>;
};
[[group(0), binding(0)]] var<storage, read> myBuffer: MyData;

This seems like a lot of characters to type just to get something simple. We should relax this constraint, and if the backend API requires a struct, a single-member struct can be generated around the member type.

So, the WebGPU author could instead write:

[[group(0), binding(0), block]] var<storage, read> myArray: array<i32, 8>;

or even better, just

[[group(0), binding(0)]] var<storage, read> myArray: array<i32, 8>;

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