Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[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 subscribe to this conversation on GitHub. Already have an account? Sign in.
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