This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
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 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: