mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[naga] Hoist ConstantEvaluator
construction in process_function
.
There's no need to build a fresh `ConstantEvaluator` for every expression; just build it once and reuse it.
This commit is contained in:
parent
f464598646
commit
aaf3b17623
@ -282,18 +282,18 @@ fn process_function(
|
||||
let mut emitter = Emitter::default();
|
||||
let mut block = Block::new();
|
||||
|
||||
for (old_h, expr, span) in expressions.drain() {
|
||||
let mut expr = match expr {
|
||||
Expression::Override(h) => Expression::Constant(override_map[h.index()]),
|
||||
expr => expr,
|
||||
};
|
||||
let mut evaluator = ConstantEvaluator::for_wgsl_function(
|
||||
module,
|
||||
&mut function.expressions,
|
||||
&mut local_expression_kind_tracker,
|
||||
&mut emitter,
|
||||
&mut block,
|
||||
);
|
||||
let mut evaluator = ConstantEvaluator::for_wgsl_function(
|
||||
module,
|
||||
&mut function.expressions,
|
||||
&mut local_expression_kind_tracker,
|
||||
&mut emitter,
|
||||
&mut block,
|
||||
);
|
||||
|
||||
for (old_h, mut expr, span) in expressions.drain() {
|
||||
if let Expression::Override(h) = expr {
|
||||
expr = Expression::Constant(override_map[h.index()]);
|
||||
}
|
||||
adjust_expr(&adjusted_local_expressions, &mut expr);
|
||||
let h = evaluator.try_eval_and_append(expr, span)?;
|
||||
debug_assert_eq!(old_h.index(), adjusted_local_expressions.len());
|
||||
|
Loading…
Reference in New Issue
Block a user