Skip to content

Disallow write-only storage buffers #4370

@soltanmm

Description

@soltanmm

AFAICT, according to Resource Layout Compatibility, WGSL does not consider write-only storage buffers to be part of the resource interface.

Naga 0.8.5 appears to validate the following fragment of module-scope WGSL:

[[group(2), binding(0)]] var<storage, write> my_struct_global_variable: MyStruct;

Behavior on master-as-of-this-post is similar. Inserting the following module-scope WGSL fragment in tests/in/access.wgsl results in a passing cargo test:

struct Baz {
  a: u32,
};
@group(1) @binding(0)
var<storage,write> baz: Baz;

But trying to actually use such a binding through wgpu results in errors like:

thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_compute_pipeline
    error matching shader requirements against the pipeline
    shader global ResourceBinding { group: 2, binding: 0 } is not available in the layout pipeline layout
    storage class Storage { access: LOAD | STORE } doesn't match the shader Storage { access: STORE }

'

Because it's making the reasonable assumption that the shader wanted something readable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: validationIssues related to validation, diagnostics, and error handlingnagaShader Translator

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions