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

spv-in parse more atomic ops #5824

Merged
merged 17 commits into from
Sep 18, 2024

Conversation

schell
Copy link
Contributor

@schell schell commented Jun 16, 2024

Connections
Part of

Depends on

Description

This adds parsing for the following atomic operations to naga::spv::Frontend::next_block:

  • OpAtomicLoad
  • OpAtomicStore
  • OpAtomicExchange
  • OpAtomicCompareExchange
  • OpAtomicCompareExchangeWeak (deprecated)
  • OpAtomicIIncrement was included in spv-in parsing Op::AtomicIIncrement #5702
  • OpAtomicIDecrement
  • OpAtomicIAdd
  • OpAtomicISub
  • OpAtomicSMin
  • OpAtomicUMin
  • OpAtomicSMax
  • OpAtomicUMax
  • OpAtomicAnd
  • OpAtomicOr
  • OpAtomicXor
  • OpAtomicFlagTestAndSet
  • OpAtomicFlagClear

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch 3 times, most recently from 9c40733 to 6df6ec9 Compare June 23, 2024 02:35
@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch from df45dc6 to 5007742 Compare August 9, 2024 20:25
@schell schell marked this pull request as ready for review August 9, 2024 20:25
@schell schell requested a review from a team as a code owner August 9, 2024 20:25
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

The tests in src/front/atomic_upgrade.rs really belong in src/front/spv. We can't have SPIR-V specific code outside src/front/spv and src/back/spv.

@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch from 5b24147 to 2c65b11 Compare August 9, 2024 20:38
@schell schell requested a review from jimblandy August 10, 2024 00:30
@schell
Copy link
Contributor Author

schell commented Aug 29, 2024

@teoxoy do you think you would feel comfortable giving this a look over?

naga/src/front/spv/mod.rs Show resolved Hide resolved
naga/src/front/spv/mod.rs Show resolved Hide resolved
naga/src/front/atomic_upgrade.rs Outdated Show resolved Hide resolved
@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch from cd49517 to 2695c3c Compare September 6, 2024 01:26
@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch from 2695c3c to 9e5d4e1 Compare September 6, 2024 19:25
@schell
Copy link
Contributor Author

schell commented Sep 10, 2024

@jimblandy do you have any more comments? I think we're getting pretty close with this 🤞 .

@schell schell force-pushed the feature/spirv-front-atomics-3-more-ops branch from 3d6ef1b to f7001b5 Compare September 15, 2024 18:45
@jimblandy
Copy link
Member

jimblandy commented Sep 16, 2024

@schell Does this commit look okay? 87b0109

@schell
Copy link
Contributor Author

schell commented Sep 16, 2024

@jimblandy that commit seems just fine 👍

@jimblandy
Copy link
Member

jimblandy commented Sep 16, 2024

@schell So, right now this branch has a bunch of merges from trunk. We are generally trying to merge PRs by rebasing, because we don't want the work-in-progress commits in our history forever. Could you change this PR's branch to be merge-free?

Edit: I believe the standard git rebase behavior will just drop merges. Then you can fixup/squash as appropriate. cc our git authority: @ErichDonGubler

@schell
Copy link
Contributor Author

schell commented Sep 16, 2024

@jimblandy I rebased earlier today, so I think we're good to go - though now it's out of date again, so I'll do that again.

@schell
Copy link
Contributor Author

schell commented Sep 16, 2024

Ok - my rebase earlier clobbered your "span" commit, so I cherry-picked it back in. The change of get_contained_global_variable to return a Result I made at the same time you did, and your change got clobbered as well, but my change covers that issue. So now I think we're g2g 👍

@schell
Copy link
Contributor Author

schell commented Sep 17, 2024

Tests still pass and everything :)

@jimblandy jimblandy force-pushed the feature/spirv-front-atomics-3-more-ops branch from 9817ed5 to 69fc037 Compare September 18, 2024 01:34
@jimblandy jimblandy force-pushed the feature/spirv-front-atomics-3-more-ops branch from 69fc037 to 1507ddd Compare September 18, 2024 01:35
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

I think the flag ops are not going to work, because WGSL doesn't support atomic<bool>, so those Literal::Bool values are going to make something unhappy.

@schell
Copy link
Contributor Author

schell commented Sep 18, 2024

Ok, I'll add tests for those and debug it. As an alternative do you think we can make it use u32?

@jimblandy
Copy link
Member

Yes, treating the argument as atomic<u32> or atomic<i32> seems consistent with the SPIR-V ops, too, which say that the pointer should be a pointer "to a 32-bit integer type".

@schell
Copy link
Contributor Author

schell commented Sep 18, 2024

Yeah, you're right. I just missed that. Ok, I'll just stick to that then.

@jimblandy
Copy link
Member

If the tests pass with the code as it is, then if I'm reading correctly (and I'm often not), that would mean that the validator is not properly type-checking Statement::Atomic, because the pointer would be to an atomic<i32 | u32>, but the value would be a bool.

@schell
Copy link
Contributor Author

schell commented Sep 18, 2024

You know what - I don't even have the ability to create code that uses the flag ops (not from rust-gpu, at least). I say we skip these until a later date.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Okay, with the untested ops removed, this is good to go.

@jimblandy jimblandy enabled auto-merge (squash) September 18, 2024 04:42
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Sorry - I just noticed that some of the .spvasm files in naga/tests/in/spv do not match their .spv files. That needs to be squared away before we can merge.

@jimblandy
Copy link
Member

I've filed #6292 as a follow-up for converting the tests to snapshot tests.

@jimblandy jimblandy enabled auto-merge (squash) September 18, 2024 05:33
@jimblandy jimblandy merged commit fc85e4f into gfx-rs:trunk Sep 18, 2024
25 checks passed
@schell schell deleted the feature/spirv-front-atomics-3-more-ops branch September 18, 2024 08:36
ErichDonGubler added a commit to erichdongubler-mozilla/wgpu that referenced this pull request Sep 19, 2024
nical pushed a commit that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants