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

feature: [spv-front] Support for OpAtomicCompareExchange, fixes #6296 #6590

Merged

Conversation

schell
Copy link
Contributor

@schell schell commented Nov 22, 2024

Connections

Description
Adds support for parsing and executing OpAtomicCompareExchange in the SPIR-V frontend.
This concludes the work to support atomics in the SPIR-V frontend, excluding test clean-up.

Testing

RUST_LOG=trace cargo watch -x 'test -p naga --features spv-in,wgsl-in,wgsl-out -- --nocapture atomic_compare_exchange'

Checklist

  • First, merge [naga spv-in] Let BlockContext hold a &mut Module. #6682.
  • Run cargo fmt.
  • Run taplo format.
  • 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 marked this pull request as ready for review November 23, 2024 23:28
@schell schell requested a review from a team as a code owner November 23, 2024 23:28
@schell schell mentioned this pull request Nov 23, 2024
@schell schell changed the title feature: [spv-front] WIP Support for OpAtomicCompareExchange feature: [spv-front] Support for OpAtomicCompareExchange, fixes #6296 Nov 23, 2024
@schell schell force-pushed the feature/spirv-front-atomics-compare-exchange branch from bc2c9ab to 5d88eda Compare November 24, 2024 03: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.

Okay, I got into reviewing this, but ended up filing other stuff I noticed in the process (#6670 and #6671). I'll pick it up again tomorrow.

naga/src/front/spv/mod.rs Outdated Show resolved Hide resolved
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 changes to type_gen.rs are not the way we should handle this. That file should remain unchanged by this PR.

Instead, BlockContext should borrow a shared reference to Module::special_types in addition to all the other bits and pieces it borrows, and then it should simply look up the appropriate crate::PredeclaredType::AtomicCompareExchangeWeakResult key in SpecialTypes::predeclared_types. It knows it will find the entry, because parse put them both there.

@jimblandy
Copy link
Member

@schell Just a heads up, I pushed a tiny cleanup commit to this branch.

naga/src/front/spv/mod.rs Outdated Show resolved Hide resolved
@jimblandy
Copy link
Member

The way this PR causes the atomic result types to be included in all modules built from SPIR-V source is not great. But it's not straightforward to address unless we fix #6679.

@jimblandy jimblandy force-pushed the feature/spirv-front-atomics-compare-exchange branch from fe3c399 to 704540b Compare December 7, 2024 19:47
@jimblandy
Copy link
Member

jimblandy commented Dec 7, 2024

Okay, I've put up #6682 to fix #6679, rebased this PR on top of that, and then made the atomic struct creation work the way it should. This PR now makes no changes to the snapshot output files.

@jimblandy
Copy link
Member

jimblandy commented Dec 7, 2024

This PR cannot be merged, in its current form, until #6682 is merged.

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.

If I understand correctly, this is the final phase of your work on SPIR-V atomic input. If that's the case, then it's time to remove the tests in front/spv/mod.rs, and turn atomic_compare_exchange.spv into an ordinary snapshot test.

@schell
Copy link
Contributor Author

schell commented Dec 7, 2024

Cleaning up the tests is still a part of my intended work. My grant project goes to the end of the year (and I've re-applied for 2025 as well).

@jimblandy jimblandy dismissed their stale review December 8, 2024 01:10

Since I pushed a fix for some of my comments, for clarity I want to re-post the remaining items as a new review.

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.

It's okay to address the tests in a subsequent PR. For now, here are the only remaining items to be addressed. Pretty minor, this looks good otherwise.

naga/src/front/spv/mod.rs Outdated Show resolved Hide resolved
naga/src/front/spv/mod.rs Outdated Show resolved Hide resolved
@schell schell requested a review from jimblandy December 8, 2024 23:00
@schell
Copy link
Contributor Author

schell commented Dec 8, 2024

Your last two comments have been addressed @jimblandy, I think we're g2g 👍 .

@schell schell force-pushed the feature/spirv-front-atomics-compare-exchange branch from 589ab65 to 51af04a Compare December 8, 2024 23:26
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.

Looks great!

@jimblandy
Copy link
Member

Note, this is still blocked on #6682.

jimblandy pushed a commit to schell/wgpu that referenced this pull request Dec 9, 2024
Add support for parsing and executing OpAtomicCompareExchange in the SPIR-V frontend.
This concludes the work to support atomics in the SPIR-V frontend,
excluding test clean-up.

Fixes gfx-rs#6296.
Fixes gfx-rs#6590.

Connections:

- [naga spv-in] Support for OpAtomicCompareExchange gfx-rs#6296
- [spv-in] Atomics support gfx-rs#4489
@jimblandy jimblandy force-pushed the feature/spirv-front-atomics-compare-exchange branch from 51af04a to d63c660 Compare December 9, 2024 14:39
Add support for parsing and executing OpAtomicCompareExchange in the SPIR-V frontend.
This concludes the work to support atomics in the SPIR-V frontend,
excluding test clean-up.

Fixes gfx-rs#6296.
Fixes gfx-rs#6590.

Connections:

- [naga spv-in] Support for OpAtomicCompareExchange gfx-rs#6296
- [spv-in] Atomics support gfx-rs#4489

Co-authored-by: Jim Blandy <[email protected]>
@jimblandy jimblandy force-pushed the feature/spirv-front-atomics-compare-exchange branch from d63c660 to ec61a8d Compare December 9, 2024 14:44
@jimblandy jimblandy enabled auto-merge (squash) December 9, 2024 14:44
@jimblandy jimblandy merged commit 234b6dd into gfx-rs:trunk Dec 9, 2024
27 checks passed
@schell
Copy link
Contributor Author

schell commented Dec 9, 2024

Thank you @jimblandy ! 🙇

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.

2 participants