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

Naga Error Message Is Cryptic on Missing Specifier in Struct #6837

Open
OptimisticPeach opened this issue Dec 30, 2024 · 4 comments
Open

Naga Error Message Is Cryptic on Missing Specifier in Struct #6837

OptimisticPeach opened this issue Dec 30, 2024 · 4 comments
Assignees
Labels
area: naga middle-end Intermediate representation kind: diagnostics Error message should be better naga Shader Translator

Comments

@OptimisticPeach
Copy link
Contributor

Description
I'm trying to extend bevy's shaders, and I need to pass an extra value from vertex to fragment. Bevy has a few functions available which take the original VertexOutput struct as a parameter. Therefore, I decided that introducing this struct would be reasonable:

struct ActualOut {
    inner: VertexOutput, // original bevy struct
    @location(8) view_position: vec3<f32>,
}

And then replaced the input/output types of my vertex/fragment shaders with ActualOut. Unfortunately, Naga complains about the inner field lacking an @location marker -- I'm not sure if this is actually incorrect according to the spec, however in any case if it is indeed the intended behaviour then the error is massively cryptic:

2024-12-30T07:32:15.713303Z ERROR wgpu_core::device::global: Device::create_shader_module error:
Shader validation error: Entry point fragment at Fragment is invalid
  ┌─ :1:1
  │
1 │
  │   naga::Type [56]
  │
  = Argument 0 varying error
  = Struct member 0 is missing a binding

I'm running on naga v23.1.0.

If you need more details (a repro isn't super easy to put together, but if you need me to I'd be happy to do so), please let me know.

@sagudev
Copy link
Contributor

sagudev commented Dec 30, 2024

This is not allowed per spec:

struct B {
  @location(0) x: f32
}

struct C {
  // Invalid, structures with user-defined IO cannot be nested.
  b: B
}

@cwfitzgerald cwfitzgerald changed the title Naga Error Message Is Crytic on Missing Specifier in Struct Naga Error Message Is Cryptic on Missing Specifier in Struct Dec 30, 2024
@teoxoy teoxoy added naga Shader Translator kind: diagnostics Error message should be better labels Jan 6, 2025
@AbdullahElsheshtawy
Copy link
Contributor

Is this error less cryptic?

2024-12-30T07:32:15.713303Z ERROR wgpu_core::device::global: Device::create_shader_module error:
Shader validation error: Entry point fragment at Fragment is invalid
  ┌─ :1:1
  │
1 │
  │   naga::Type [56]
  │
  = Argument 0 varying error
  = Struct member 0 is missing a binding, Structures with user-defined IO cannot be nested

@OptimisticPeach
Copy link
Contributor Author

As an end user, I'd rather see something like:

2024-12-30T07:32:15.713303Z ERROR wgpu_core::device::global: Device::create_shader_module error:
Shader validation error: Entry point fragment at Fragment is invalid
  ┌─ :1:1
  │
1 │
  │   naga::Type [56]
  │
  = Argument 0 varying error
  = Struct `ActualOut` member 0 (`inner`) is missing a binding, structures with user-defined IO cannot be nested

Since now I have actual names that I've written in the error message.

@AbdullahElsheshtawy
Copy link
Contributor

Yeah naga error messages are in need of refactoring. I will see what I can do about it (no guarantees though)

@cwfitzgerald cwfitzgerald added the area: naga middle-end Intermediate representation label Jan 13, 2025
@ErichDonGubler ErichDonGubler self-assigned this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga middle-end Intermediate representation kind: diagnostics Error message should be better naga Shader Translator
Projects
Status: Todo
Development

No branches or pull requests

6 participants