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

WGSL doesn't type check values for vectors #43

Closed
Timo-DK opened this issue Apr 8, 2020 · 1 comment
Closed

WGSL doesn't type check values for vectors #43

Timo-DK opened this issue Apr 8, 2020 · 1 comment
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@Timo-DK
Copy link
Collaborator

Timo-DK commented Apr 8, 2020

Having the following WGSL:

[[location 0]] var<in> a_uv : vec2<f32>;
[[location 0]] var<out> o_color : vec4<f32>;

fn main_frag() -> void {
  o_color = vec4<f32>(1, 0, 0, 1);
  return;
}
entry_point fragment as "main" = main_frag;

The values provided into the vector float 4 with the 4 integer values will be correctly parsed to the IR model:

Constant {
    name: None,
    specialization: None,
    inner: Sint(
        1,
    ),
    ty: Handle(4),
},
Constant {
    name: None,
    specialization: None,
    inner: Sint(
        0,
    ),
    ty: Handle(4),
},

The back-ends would now have to check if the vector where these constants are provided for is able to use them. I think it would be better to let the WGSL front-end check if the values in a vector are of the same Type as the composite they are in.

This is not something only applicable to vectors, and should have a general type check to ensure a correct IR model is delivered to the back-end.

@Timo-DK Timo-DK added lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Apr 8, 2020
@Timo-DK Timo-DK changed the title WGSL does not type check values for vectors WGSL doesn't type check values for vectors Apr 8, 2020
@kvark kvark added the kind: bug Something isn't working label Apr 8, 2020
paulkernfeld pushed a commit to paulkernfeld/naga that referenced this issue May 20, 2020
A baby step towards gfx-rs#43
kvark pushed a commit that referenced this issue May 22, 2020
* Check constant types

A baby step towards #43

* Move tp src/proc/typifier, remove unneeded return

* Don't do pub(crate)

* Don't use crate::proc::UnexpectedConstantTypeError

Co-authored-by: Paul Kernfeld <paulkernfeld@gmail.com>
@kvark
Copy link
Member

kvark commented Apr 16, 2021

Closed as a part of #59

@kvark kvark closed this as completed Apr 16, 2021
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

No branches or pull requests

2 participants