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

unhelpful diagnostic from naga regarding missing & #6983

Open
crowlKats opened this issue Jan 24, 2025 · 3 comments
Open

unhelpful diagnostic from naga regarding missing & #6983

crowlKats opened this issue Jan 24, 2025 · 3 comments
Labels
area: naga front-end kind: diagnostics Error message should be better lang: WGSL WebGPU Shading Language naga Shader Translator

Comments

@crowlKats
Copy link
Collaborator

wgpu version 24.0.0

While working on the reworked webgpu bindings for Deno, I attempted to run a test, which is a 1-1 copy of hello-compute but written in javascript.

So using this shader, I am getting this diagnostic:

Device::create_shader_module error: 
Shader validation error: 
   ┌─ :20:36
   │
20 │     let array_length = arrayLength(input);
   │                                    ^^^^^ naga::Expression [4]


error: GPUValidationError: 
Shader validation error: 
   ┌─ :20:36
   │
20 │     let array_length = arrayLength(input);
   │                                    ^^^^^ naga::Expression [4]

: Entry point doubleMe at Compute is invalid: Expression [4] is invalid: Loading of [3] can't be done

Apparently, thanks to @teoxoy the solution is to do arrayLength(&input). The diagnostic is not very helpful here.
Also unsure why this is happening, since the wgpu repo itself is using the shader as-is without this change, yet the example works fine.

@crowlKats crowlKats added area: naga front-end kind: diagnostics Error message should be better lang: WGSL WebGPU Shading Language naga Shader Translator labels Jan 24, 2025
@sagudev
Copy link
Contributor

sagudev commented Jan 24, 2025

Also unsure why this is happening, since the wgpu repo itself is using the shader as-is without this change, yet the example works fine.

This example was introduced in 7fccb6b so it is not present in v24, but I tested it on trunk and it does not work (run via naga-cli). Is hello compute even tested in CI? cc @cwfitzgerald

@sagudev
Copy link
Contributor

sagudev commented Jan 24, 2025

chromium reports this error:

Error while parsing WGSL: :20:24 error: no matching call to 'arrayLength(array<f32>)'

2 candidate functions:
 • 'arrayLength(ptr<storage, array<T>, R>  ✗ ) -> u32' where:
      ✗  'R' is 'read'
 • 'arrayLength(ptr<storage, array<T>, W>  ✗ ) -> u32' where:
      ✗  'W' is 'write' or 'read_write'

    let array_length = arrayLength(input);
                       ^^^^^^^^^^^^^^^^^^


 - While validating [ShaderModuleDescriptor]
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor]).

@cwfitzgerald
Copy link
Member

cwfitzgerald commented Jan 24, 2025

Oh my goodness, did I manage to write a whole example and never acutely run it? I think I was so focused on ensuring it built when extracted from the repo I just... never ran it.

Correct that example is only ever built in CI as it's completely separate from our normal testing stack.

Very sorry @crowlKats I'll get on this right away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end kind: diagnostics Error message should be better lang: WGSL WebGPU Shading Language naga Shader Translator
Projects
Status: Todo
Development

No branches or pull requests

3 participants