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

[wgsl-out] Correct handling of named pointer expressions. #1384

Merged
merged 3 commits into from
Sep 27, 2021

Conversation

jimblandy
Copy link
Member

Depends on #1381.

Treat expressions in Function::named_expressions like WGSL let declarations,
assuming that the Load Rule was applied to the rhs of the declaration, meaning
that their values are always Indirection::Ordinary.

Split write_expr_plain_form out from write_expr_with_indirection, to clean
up the parenthesis generation: no more opened_paren variable, just function
calls. This makes the early return for named expressions neater.

Fixes #1382.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few notes

tests/in/pointers.wgsl Show resolved Hide resolved
src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
src/back/wgsl/writer.rs Outdated Show resolved Hide resolved
src/proc/mod.rs Show resolved Hide resolved
Treat `TypeInner::ValuePointer` and `TypeInner::Pointer` as equivalent by
converting them to a canonical form before comparison.

Support `ValuePointer` in WGSL type output.

Fixes gfx-rs#1318.
Treat expressions in `Function::named_expressions` like WGSL `let` declarations,
assuming that the Load Rule was applied to the rhs of the declaration, meaning
that their values are always `Indirection::Ordinary`.

Split `write_expr_plain_form` out from `write_expr_with_indirection`, to clean
up the parenthesis generation: no more `opened_paren` variable, just function
calls. This makes the early return for named expressions neater.

Fixes gfx-rs#1382.
@kvark kvark merged commit 53c8672 into gfx-rs:master Sep 27, 2021
@jimblandy jimblandy deleted the let-pointers branch September 28, 2021 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Naga produces incorrect WGSL for let-bound pointers
2 participants