feat: Add 32-bit floating-point atomics (SHADER_FLT32_ATOMIC
)
#6234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connections
#1020
Description
It enables 32-bit floating point atomic operations on backends including Metal v3.0 (Apple 7 ). Currently, it does not support Vulkan, which has a feature flag
VK_EXT_shader_atomic_float
though.However, Metal doesn't support all atomic operations and all address spaces. The Metal specification (2024-06-06) said:
This indicates we can't have workgroup-level floating-point atomic value.
It means that there are some read-modify-write functions we can't use.
The supported atomic operations by Metal are checked below:
atomicStore
✅atomicLoad
✅atomicAdd
✅atomicSub
atomicMax
atomicMin
atomicAnd
atomicOr
atomicXor
atomicExchange
✅atomicCompareExchangeWeak
✅ (Though it is unimplemented on MSL backend)In
wgpu-types
, I have added the feature flagSHADER_FLT32_ATOMIC
.Testing
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.cargo xtask validate msl
to validate shaders.cargo xtask validate spv
to validate shaders.