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

64 bit Image Atomics #5537

Merged
merged 1 commit into from
Jan 15, 2025
Merged

64 bit Image Atomics #5537

merged 1 commit into from
Jan 15, 2025

Conversation

atlv24
Copy link
Collaborator

@atlv24 atlv24 commented Apr 15, 2024

Connections
Fixes #5009
Depends on #6706
Ultimately for bevy meshlets pipeline bevyengine/bevy#10164

Description
Adds 64 bit image atomics to Vulkan, DirectX, and Metal backends. Emulates using RG32Uint on platforms where R64Uint is not available (directX, metal).

Testing
naga tests and runtime tests are included

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.

naga/src/back/glsl/mod.rs Outdated Show resolved Hide resolved
naga/src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
naga/src/back/msl/writer.rs Outdated Show resolved Hide resolved
naga/src/back/spv/image.rs Outdated Show resolved Hide resolved
wgpu-hal/src/metal/conv.rs Outdated Show resolved Hide resolved
naga/src/back/spv/image.rs Outdated Show resolved Hide resolved
naga/src/valid/function.rs Outdated Show resolved Hide resolved
tests/tests/image_atomics/mod.rs Outdated Show resolved Hide resolved
tests/tests/image_atomics/image_atomics.wgsl Outdated Show resolved Hide resolved
@jimblandy
Copy link
Member

@atlv24 Earlier today you asked me for a suggestion about the texture usages, and a review of the tests. I've posted those now. Is there anything else you need before breaking this up into independent commits for review?

@atlv24
Copy link
Collaborator Author

atlv24 commented Oct 2, 2024

@jimblandy I've broken it into independent commits already, thanks for the feedback. I've implemented the texture usage stuff, now im working on the tests. :D

@atlv24 atlv24 force-pushed the ruint64 branch 3 times, most recently from ace6c83 to ceca097 Compare October 18, 2024 18:16
@atlv24 atlv24 requested a review from jimblandy October 18, 2024 19:02
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Looking at the wgpu side:

What would prevent you from doing atomics on an image without the image atomics flag set?

wgpu-hal/src/dx12/adapter.rs Outdated Show resolved Hide resolved
wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs Outdated Show resolved Hide resolved
@atlv24
Copy link
Collaborator Author

atlv24 commented Oct 21, 2024

What would prevent you from doing atomics on an image without the image atomics flag set?

The naga validator currently only permits image atomic operations on the r64uint texture format, and only when the feature is available. No provisions were made for other texture formats yet

@atlv24 atlv24 mentioned this pull request Nov 22, 2024
7 tasks
@cwfitzgerald cwfitzgerald changed the title 64 bit image atomics Image Atomics and 64bit Images Dec 11, 2024
@cwfitzgerald cwfitzgerald self-assigned this Dec 11, 2024
@atlv24 atlv24 mentioned this pull request Dec 11, 2024
7 tasks
@atlv24 atlv24 changed the title Image Atomics and 64bit Images 64 bit Image Atomics Dec 11, 2024
@atlv24 atlv24 force-pushed the ruint64 branch 2 times, most recently from 3220089 to 52960d9 Compare December 11, 2024 22:48
@atlv24
Copy link
Collaborator Author

atlv24 commented Dec 11, 2024

@cwfitzgerald i have split this into two PRs: #6706 adds image atomics without any of the 64 bit stuff, this one adds the 64 bit stuff. Only the second commit on this PR is relevant to it, as this PR's branch is based off of the other's, so it includes its commits.

@atlv24 atlv24 force-pushed the ruint64 branch 5 times, most recently from 7cf8199 to 17a304c Compare December 18, 2024 05:02
@cwfitzgerald
Copy link
Member

Demoting to draft while dependent

@cwfitzgerald cwfitzgerald marked this pull request as draft December 18, 2024 23:33
@atlv24 atlv24 marked this pull request as ready for review January 13, 2025 17:39
tests/tests/image_atomics/mod.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/conv.rs Outdated Show resolved Hide resolved
wgpu-types/src/lib.rs Outdated Show resolved Hide resolved
tests/tests/image_atomics/mod.rs Show resolved Hide resolved
@cwfitzgerald
Copy link
Member

cwfitzgerald commented Jan 14, 2025

Ran this locally, got this failure on all devices

--- STDERR:              wgpu-test::wgpu-test [Executed] [Dx12/NVIDIA GeForce RTX 4070/2] wgpu_test::image_atomics::image_64_atomics ---
[2025-01-14T03:59:58Z ERROR wgpu::backend::wgpu_core] Handling wgpu errors as fatal by default
thread '<unnamed>' panicked at wgpu\src\backend\wgpu_core.rs:1423:26:
wgpu error: Validation Error

Caused by:
  In Device::create_texture
    Texture usages TextureUsages(STORAGE_ATOMIC) are not allowed on a texture of type R64Uint due to downlevel restrictions


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2025-01-14T03:59:58Z ERROR wgpu_test::expectations] Panic: wgpu error: Validation Error

    Caused by:
      In Device::create_texture
        Texture usages TextureUsages(STORAGE_ATOMIC) are not allowed on a texture of type R64Uint due to downlevel restrictions


thread '<unnamed>' panicked at tests\src\run.rs:120:9:
tests\tests\image_atomics\mod.rs:9:49: test "wgpu_test::image_atomics::image_64_atomics" did not behave as expected

This does not appear in CI as image atomics is not supported on any device, in part because of #6911

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Seems alright to me!

Whatever you did fixed the problem locally

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

LGTM

@cwfitzgerald cwfitzgerald merged commit be95178 into gfx-rs:trunk Jan 15, 2025
30 checks passed
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.

Image (64bit) atomic support
5 participants