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] Comparing scalar with vector type incorrectly passes validation #2439

Closed
Wumpf opened this issue Aug 16, 2023 · 0 comments · Fixed by #2440
Closed

[wgsl-in] Comparing scalar with vector type incorrectly passes validation #2439

Wumpf opened this issue Aug 16, 2023 · 0 comments · Fixed by #2440
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@Wumpf
Copy link
Member

Wumpf commented Aug 16, 2023

Spec says both sides of the comparision need to have the same type.
https://www.w3.org/TR/WGSL/#comparison-expr

The following snippet should therefore not pass validation.

const some_vec = vec3<f32>(1.0, 1.0, 1.0);

@fragment
fn main() -> @location(0) vec4<f32> {
    if (all(1.0 < some_vec)) {
        return vec4(0.0);
    }
    return vec4(1.0);
}

Note that Chrome will already correctly reject this, whereas Naga doesn't

@Wumpf Wumpf changed the title [wgsl-in] Comparing scalar with vector type is allowed [wgsl-in] Comparing scalar with vector type incorrectly passes validation Aug 16, 2023
fornwall added a commit to fornwall/naga that referenced this issue Aug 16, 2023
fornwall added a commit to fornwall/naga that referenced this issue Aug 16, 2023
fornwall added a commit to fornwall/naga that referenced this issue Aug 16, 2023
@teoxoy teoxoy added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Aug 17, 2023
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Aug 17, 2023
teoxoy pushed a commit that referenced this issue Aug 18, 2023
* [wgsl-in] Avoid splatting all binary operator expressions

Fixes #2439.

* [wgsl-in] Expand binary_op_splat function comment
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.

2 participants