-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[naga wgsl-out] let
declarations are wrongly detected as const
#6207
Comments
I tested diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs
index 23e6204cc..c60f3a7e9 100644
--- a/naga/src/valid/function.rs
+++ b/naga/src/valid/function.rs
@@ -1365,7 +1365,11 @@ impl super::Validator {
) -> Result<FunctionInfo, WithSpan<FunctionError>> {
let mut info = mod_info.process_function(fun, module, self.flags, self.capabilities)?;
- let local_expr_kind = crate::proc::ExpressionKindTracker::from_arena(&fun.expressions);
+ let mut local_expr_kind = crate::proc::ExpressionKindTracker::from_arena(&fun.expressions);
+
+ for (handle, _) in fun.expressions.iter() {
+ local_expr_kind.force_non_const(handle);
+ }
for (var_handle, var) in fun.local_variables.iter() {
self.validate_local_var(var, module.to_ctx(), &info, &local_expr_kind) and it doesn't fix, but we should still need correct constness information for fixing the issue. |
I thought this should be fine for wgsl-out and the validator. The reason it's not ok in the frontend is because treating them as const changes semantics in a non-spec compliant way. What would be an example where this is an issue? |
I do not have concrete example but wgpu/naga/src/back/wgsl/writer.rs Lines 1113 to 1125 in 960555a
|
The problem is that both Line 1397 in b7d1f4c
|
Or alternatively do the reverts and remove const from wgpu/naga/src/front/wgsl/lower/mod.rs Lines 1587 to 1590 in 93f64dc
|
Not having them in |
Will this have negative consequences on our ability to generate debug information? |
What exactly is considered as debug info in naga? |
I don't think this has a strict definition yet, nor is it set in stone. I think currently the spirv backend uses the variable name in the named_expressions to add label the name of certain values to spirv when debug information is enabled. I would be willing to accept this is the wrong place to do it, and I don't know the specifics, but there are spirv-out tests with debug information in the snapshots. |
Leaving local |
Description
In wgsl-in there is
wgpu/naga/src/front/wgsl/lower/mod.rs
Lines 1370 to 1376 in 07becfe
but in wgsl-out when we create expression tracker from arena this information is lost:
wgpu/naga/src/back/wgsl/writer.rs
Line 169 in 07becfe
wgpu/naga/src/back/wgsl/writer.rs
Line 197 in 07becfe
same problem is also in validator
wgpu/naga/src/valid/function.rs
Line 1368 in 07becfe
which causes #4390(such checks should only be done in const but let expr should not be treated as const).The text was updated successfully, but these errors were encountered: