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 doesn't type check values for vectors #43

Closed
Napokue opened this issue Apr 8, 2020 · 1 comment
Closed

WGSL doesn't type check values for vectors #43

Napokue 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

@Napokue
Copy link
Collaborator

Napokue 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.

@Napokue Napokue added lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Apr 8, 2020
@Napokue Napokue 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 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

No branches or pull requests

2 participants