Skip to content
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] Explicitly use global const ctx in offset #6945

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions naga/src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,29 @@ pub struct ExpressionContext<'source, 'temp, 'out> {
}

impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
#[allow(dead_code)]
fn as_const(&mut self) -> ExpressionContext<'source, '_, '_> {
Comment on lines +375 to 376
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to remove this and add it back later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; the PR would become a one line change then.

I think it would be fine to fold it into #6935. Or would you still like to land this separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to land it as it stands now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe not given how clippy/rustdoc hates me, but I would still like to land this separately. Reverted to initial version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair.

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),
expr_type: ExpressionContextType::Constant(match self.expr_type {
ExpressionContextType::Runtime(ref mut local_expression_context)
| ExpressionContextType::Constant(Some(ref mut local_expression_context)) => {
Some(LocalExpressionContext {
local_table: local_expression_context.local_table,
function: local_expression_context.function,
block: local_expression_context.block,
emitter: local_expression_context.emitter,
typifier: local_expression_context.typifier,
local_expression_kind_tracker: local_expression_context
.local_expression_kind_tracker,
})
}
ExpressionContextType::Constant(None) | ExpressionContextType::Override => None,
}),
global_expression_kind_tracker: self.global_expression_kind_tracker,
}
}
Expand Down Expand Up @@ -2903,7 +2918,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
Loading