-
Notifications
You must be signed in to change notification settings - Fork 195
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
is "- 1" can be considered as const Expressions? #2020
Comments
The current implementation uses the core::num::i32::from_str_radix to parse an int in the tokenization stage, which doesn't allow any space between the preceding '-' and number literals. I think for const int literals, this limitation is ok. The real question is wgsl seems not to support the const operator (like this minus unary case) as a const expression at all. |
Note this is expected, we haven't implemented any of the const stuff yet |
so this could be somthing which will implement later? |
Yeah, we'll need to eventually to be conformant. |
closing as duplicate of #1829 |
so i was testing the textureSample function, https://www.w3.org/TR/WGSL/#texturesample
I notice that the
fn textureSample(t: texture_2d,
s: sampler,
coords: vec2,
offset: vec2) -> vec4 usage,
the last offset: vec2 is consider to be the const expression, according to here https://www.w3.org/TR/WGSL/#const-expr
so if i want to use like textureSample(_, _, _, off) is gonna be wrong (off is a vec2 parameter), make sense.
but if i use like textureSample(_, _, _, vec2(- 1, - 1)) (there is a space between '-' and '1') it's still wrong, I am not sure why the space can cause an issue.
The reason why this "space" is a problem to me is: using Rust, most of the time you need to use macro.
the token stream will automatically separate "-1" to "- 1", same as “()” to “( )”, “!a” to "! a"
so I am wondering if anyone wants to combine the wgls with rust macro, this textureSample's offset will be a problem?
any ideas?
thanks!!!!
The text was updated successfully, but these errors were encountered: