Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow write-only storage buffers #4370

Open
soltanmm opened this issue Mar 15, 2022 · 1 comment
Open

Disallow write-only storage buffers #4370

soltanmm opened this issue Mar 15, 2022 · 1 comment
Labels
area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator

Comments

@soltanmm
Copy link

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.

@soltanmm soltanmm changed the title Naga validates invalid (?) WGSL Naga validates invalid (?) write-only storage resource-interface WGSL Mar 15, 2022
@kvark kvark added the area: validation Issues related to validation, diagnostics, and error handling label Mar 15, 2022
@kvark
Copy link
Member

kvark commented Mar 15, 2022

This is a bit of a gray issue. From the point of shader translation - it doesn't care. The lack of readable texture storages can be seen as a limitation from the pipeline interface side, and all those validations happen on wgpu side.
However, from the practical point of view, it would be better to get an error at shader module creation instead of the pipeline creation. So we should add this check to Naga.

@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@teoxoy teoxoy changed the title Naga validates invalid (?) write-only storage resource-interface WGSL Disallow write-only storage buffers Nov 3, 2023
@teoxoy teoxoy added this to the WebGPU Specification V1 milestone Nov 3, 2023
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Jan 30, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Jan 30, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Jan 30, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 2, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 8, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 9, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 21, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 26, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Feb 26, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Mar 7, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Mar 28, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Apr 2, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue Apr 18, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue May 8, 2024
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this issue May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator
Projects
Status: No status
Development

No branches or pull requests

4 participants