-
Notifications
You must be signed in to change notification settings - Fork 947
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
spv-in upgrading AtomicIIncrement type #5775
Conversation
6dce12d
to
ca9fa56
Compare
f6c97c7
to
c2a7034
Compare
b8982b3
to
d790a8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are bits and pieces of this that seem right - I think the type upgrading is almost right, for example - but I think the overall approach needs to be changed.
First of all, would be it feasible to restrict our focus for the time being to global variables with atomic or array-of-atomic types, leaving struct members and function arguments that are pointers to atomic values for later PRs?
In that case, what the SPIR-V front end needs to produce is a set of global variables whose types need to be upgraded. Atomics can only appear in workgroup
and storage
, so they can only really be held in global variables, we don't need to worry about locals or arguments. So instead of the FastHashMap<..., AtomicOp>
structure you're producing now, you probably just need an IndexSet<Handle<GlobalVariable>>
. The front end can discover the relevant global by looking into the Expression
it just constructed for the atomic instruction's pointer operand.
(If the set will be iterated over, we prefer IndexSet
over HashSet
, to keep the iteration order deterministic.)
Then, the upgrade_atomics
function needs to iterate over all those globals and upgrade their types. I think you shouldn't need to update any Expression
s at all, so you shouldn't need to mess with any functions or expressions.
Ok @jimblandy I'll try what you suggest with regard to tracking |
The reason I think you won't need to update any expressions is that Naga IR Load expressions and Store statements both can operate on Atomics, so everything accessing the globals whose types you're whacking, whether Loads, Stores, or Atomics, should still be okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two drive-by comments:
6de0d29
to
438aa63
Compare
438aa63
to
9ec3a2d
Compare
f3a8298
to
e9af0fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've pushed a few more commits here. Please look them over, and if they seem all right, then we can land this.
Be sure to squash the changes when you land it!
Oh, um, I guess I should actually fix my review comments if I'm going to approve this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimblandy these changes all make sense to me. Thank you!
To support atomic instructions in the SPIR-V front end, observe which global variables the input accesses using atomic instructions, and adjust their types from ordinary scalars to atomic values. See comments in `naga::front::atomic_upgrade`.
f8e7a3b
to
4e50664
Compare
Squashed and rebased. Fixed up some |
Head branch was pushed to by a user without write access
4e50664
to
6d1b715
Compare
6d1b715
to
4e50664
Compare
Connections
Partially addresses #4489.
Follow up to #5702.
This creates a new module
naga/src/front/atomic_upgrade.rs
that begins the upgrade process by recursing through types and expressions previously marked during parsing.This results in aModule
that contains all needed types, but still does not validate, as the upgrades to expressions need to be applied to any expressions that use those expressions until all are resolved.This results in a
Module
that validates, at least for the test case.@jimblandy @cwfitzgerald :)
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.