Skip to content

Commit

Permalink
Explicitly use global const ctx in offset
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Jan 20, 2025
1 parent 779261e commit afb5706
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions naga/src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ pub enum ExpressionContextType<'temp, 'out> {
/// [`naga::Function`]: crate::Function
/// [`Constant`]: ExpressionContextType::Constant
/// [`naga::Module`]: crate::Module
/// [`as_const`]: ExpressionContext::as_const
/// [`Expression::Constant`]: crate::Expression::Constant
pub struct ExpressionContext<'source, 'temp, 'out> {
// WGSL AST values.
Expand Down Expand Up @@ -372,18 +371,6 @@ pub struct ExpressionContext<'source, 'temp, 'out> {
}

impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
fn as_const(&mut self) -> ExpressionContext<'source, '_, '_> {
ExpressionContext {
globals: self.globals,
types: self.types,
ast_expressions: self.ast_expressions,
const_typifier: self.const_typifier,
module: self.module,
expr_type: ExpressionContextType::Constant(None),
global_expression_kind_tracker: self.global_expression_kind_tracker,
}
}

fn as_global(&mut self) -> GlobalContext<'source, '_, '_> {
GlobalContext {
ast_expressions: self.ast_expressions,
Expand Down Expand Up @@ -2903,7 +2890,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {

let offset = args
.next()
.map(|arg| self.expression(arg, &mut ctx.as_const()))
.map(|arg| self.expression(arg, &mut ctx.as_global().as_const()))
.ok()
.transpose()?;

Expand Down

0 comments on commit afb5706

Please sign in to comment.