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

[wgsl-in] Rejection of matrix consts #1956

Closed
hanawatson opened this issue May 29, 2022 · 4 comments · Fixed by #2266
Closed

[wgsl-in] Rejection of matrix consts #1956

hanawatson opened this issue May 29, 2022 · 4 comments · Fixed by #2266
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@hanawatson
Copy link

AFAIK, const matrices should be able to be initialized as normal (e.g. mat2x2<f32>(0.0, 0.0, 0.0, 0.0)) but naga seems to reject them.

WGSL example:

let const0: mat2x2<f32> = mat2x2<f32>(0.0, 0.0, 0.0, 0.0);

@stage(compute) @workgroup_size(1)
fn main() {
    var var0 = 0;
}

Error:

error: 
          ┌─ test.wgsl:1:33
          │
        1 │ let const0: mat2x2<f32> = mat2x2<f32>(0.0, 0.0, 0.0, 0.0);
          │                                 ^^^^^^^^^^^^^^^^^^^^^^^^^ naga::Constant [2]
        
        Constant [2] 'const0' is invalid: 
                Composing expects 2 components but 4 were given

The error seems to get worse in terms of clarity if the matrix isn't directly named, i.e.:

WGSL:

let const0: array<mat2x2<f32>, 1> = array<mat2x2<f32>, 1>(mat2x2<f32>(0.0, 0.0, 0.0, 0.0));

@stage(compute) @workgroup_size(1)
fn main() {
    var var0 = 0;
}

Error:

 error: 
        
        Constant [3] '' is invalid: 
                Composing expects 2 components but 4 were given
@hanawatson
Copy link
Author

Edit: this also seems to happen with other types

WGSL:

let const0: vec3<f32> = vec3<f32>(0.0);

@stage(compute) @workgroup_size(1)
fn main() {
    var var0 = 0;
}

Error:

   error: 
          ┌─ test.wgsl:1:29
          │
        1 │ let const0: vec3<f32> = vec3<f32>(0.0);
          │                             ^^^^^^^^^^ naga::Constant [2]
        
        Constant [2] 'const0' is invalid: 
                Composing expects 3 components but 1 were given

The above error also applies for array<f32, 3> etc. that are initialized with one parameter.

@teoxoy teoxoy added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels May 31, 2022
@teoxoy teoxoy added this to the WGSL Specification V1 milestone May 31, 2022
@teoxoy
Copy link
Member

teoxoy commented May 31, 2022

#1957 and this one have the same underlying cause; global constructors currently use a different code-path (to make sure all the expressions are const) and feature wise it's not on par with the non global constructors.

We should figure this out when we get to implement creation-time expressions.

@bzm3r
Copy link

bzm3r commented Sep 13, 2022

Ran into this headfirst today 😩

@cdecompilador
Copy link

also rejects array constants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants