Skip to content

Commit dd2b7cd

Browse files
sagudevVecvec
authored andcommitted
Revert [wgsl-out] Write const named expr as const declarations
Signed-off-by: sagudev <[email protected]>
1 parent bef0936 commit dd2b7cd

File tree

5 files changed

+5
-22
lines changed

5 files changed

+5
-22
lines changed

naga/src/back/glsl/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use thiserror::Error;
6464
use crate::{
6565
back::{self, Baked},
6666
common,
67-
proc::{self, ExpressionKindTracker, NameKey},
67+
proc::{self, NameKey},
6868
valid, Handle, ShaderStage, TypeInner,
6969
};
7070
use features::FeaturesManager;
@@ -1678,7 +1678,6 @@ impl<'a, W: Write> Writer<'a, W> {
16781678
info,
16791679
expressions: &func.expressions,
16801680
named_expressions: &func.named_expressions,
1681-
expr_kind_tracker: ExpressionKindTracker::from_arena(&func.expressions),
16821681
};
16831682

16841683
self.named_expressions.clear();

naga/src/back/hlsl/writer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use super::{
1717
use crate::{
1818
back::{self, Baked},
1919
common,
20-
proc::{self, index, ExpressionKindTracker, NameKey},
20+
proc::{self, index, NameKey},
2121
valid, Handle, Module, RayQueryFunction, Scalar, ScalarKind, ShaderStage, TypeInner,
2222
};
2323

@@ -426,7 +426,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
426426
info,
427427
expressions: &function.expressions,
428428
named_expressions: &function.named_expressions,
429-
expr_kind_tracker: ExpressionKindTracker::from_arena(&function.expressions),
430429
};
431430
let name = self.names[&NameKey::Function(handle)].clone();
432431

@@ -467,7 +466,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
467466
info,
468467
expressions: &ep.function.expressions,
469468
named_expressions: &ep.function.named_expressions,
470-
expr_kind_tracker: ExpressionKindTracker::from_arena(&ep.function.expressions),
471469
};
472470

473471
self.write_wrapped_functions(module, &ctx)?;

naga/src/back/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Backend functions that export shader [`Module`](super::Module)s into binary and
1111

1212
use alloc::string::String;
1313

14-
use crate::proc::ExpressionKindTracker;
15-
1614
#[cfg(dot_out)]
1715
pub mod dot;
1816
#[cfg(glsl_out)]
@@ -128,8 +126,6 @@ pub struct FunctionCtx<'a> {
128126
pub expressions: &'a crate::Arena<crate::Expression>,
129127
/// Map of expressions that have associated variable names
130128
pub named_expressions: &'a crate::NamedExpressions,
131-
/// For constness checks
132-
pub expr_kind_tracker: ExpressionKindTracker,
133129
}
134130

135131
impl FunctionCtx<'_> {

naga/src/back/msl/writer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
arena::{Handle, HandleSet},
1818
back::{self, Baked},
1919
common,
20-
proc::{self, index, ExpressionKindTracker, NameKey, TypeResolution},
20+
proc::{self, index, NameKey, TypeResolution},
2121
valid, FastHashMap, FastHashSet,
2222
};
2323

@@ -5572,7 +5572,6 @@ template <typename A>
55725572
info: &mod_info[fun_handle],
55735573
expressions: &fun.expressions,
55745574
named_expressions: &fun.named_expressions,
5575-
expr_kind_tracker: ExpressionKindTracker::from_arena(&fun.expressions),
55765575
};
55775576

55785577
writeln!(self.out)?;
@@ -5729,7 +5728,6 @@ template <typename A>
57295728
info: fun_info,
57305729
expressions: &fun.expressions,
57315730
named_expressions: &fun.named_expressions,
5732-
expr_kind_tracker: ExpressionKindTracker::from_arena(&fun.expressions),
57335731
};
57345732

57355733
self.write_wrapped_functions(module, &ctx)?;

naga/src/back/wgsl/writer.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
self,
1717
wgsl::{address_space_str, ToWgsl, TryToWgsl},
1818
},
19-
proc::{self, ExpressionKindTracker, NameKey},
19+
proc::{self, NameKey},
2020
valid, Handle, Module, ShaderStage, TypeInner,
2121
};
2222

@@ -178,7 +178,6 @@ impl<W: Write> Writer<W> {
178178
info: fun_info,
179179
expressions: &function.expressions,
180180
named_expressions: &function.named_expressions,
181-
expr_kind_tracker: ExpressionKindTracker::from_arena(&function.expressions),
182181
};
183182

184183
// Write the function
@@ -207,7 +206,6 @@ impl<W: Write> Writer<W> {
207206
info: info.get_entry_point(index),
208207
expressions: &ep.function.expressions,
209208
named_expressions: &ep.function.named_expressions,
210-
expr_kind_tracker: ExpressionKindTracker::from_arena(&ep.function.expressions),
211209
};
212210
self.write_function(module, &ep.function, &func_ctx)?;
213211

@@ -1029,14 +1027,8 @@ impl<W: Write> Writer<W> {
10291027
func_ctx: &back::FunctionCtx,
10301028
name: &str,
10311029
) -> BackendResult {
1032-
// Some functions are marked as const, but are not yet implemented as constant expression
1033-
let quantifier = if func_ctx.expr_kind_tracker.is_impl_const(handle) {
1034-
"const"
1035-
} else {
1036-
"let"
1037-
};
10381030
// Write variable name
1039-
write!(self.out, "{quantifier} {name}")?;
1031+
write!(self.out, "let {name}")?;
10401032
if self.flags.contains(WriterFlags::EXPLICIT_TYPES) {
10411033
write!(self.out, ": ")?;
10421034
let ty = &func_ctx.info[handle].ty;

0 commit comments

Comments
 (0)