-
Notifications
You must be signed in to change notification settings - Fork 846
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
Add 64 bit atomics #5383
base: trunk
Are you sure you want to change the base?
Add 64 bit atomics #5383
Conversation
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.
Still reviewing, this is just the stuff I've noticed so far.
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.
Before I review this further I'd like to see the doc comments filled in enough.
@atlv24 Thanks very much for the new comments - these are helpful. |
@atlv24 I just pushed a new commit to this branch; the log message is below. Could you look it over and see what you think?
|
(No offense meant by removing your docs, after asking you to write them - they were helpful in getting started!) |
Rather than introducing an entirely new statement variant `AtomicNoResult`, make `Statement::Atomic::result` an `Option`. This reduces the patch size by about a third, and has no effect on snapshot output other than the direct IR dumps. In HLSL output, don't bother to generated "discard" temporaries for functions where the final `original_value` parameter is not required. This improves snapshot output. Improve documentation for `Expression::AtomicResult`, `Statement::Atomic`, and the new `valid::Capabilities` flags. Rewrite `Atomic` statement validation. Consolidate validation of `AtomicResult` expressions with this; gfx-rs#5771 ensures that there is indeed some `Atomic` statement referring to every `AtomicResult` expression, so we can be sure it will be validated. Fixes gfx-rs#5742.
Merged trunk so CI would pay attention |
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.
If my changes look good, then the rest of this looks good to me.
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.
Took a brief look at the feature detection code.
mem::size_of::<crate::dx12::types::D3D12_FEATURE_DATA_D3D12_OPTIONS9>() as _, | ||
) | ||
}; | ||
hr == 0 && features9.AtomicInt64OnGroupSharedSupported != 0 |
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.
Shouldn't we check for AtomicInt64OnTypedResourceSupported
as well?
if let Some(ref shader_atomic_int64) = self.shader_atomic_int64 { | ||
features.set( | ||
F::SHADER_INT64_ATOMIC_ALL_OPS | F::SHADER_INT64_ATOMIC_MIN_MAX, | ||
shader_atomic_int64.shader_buffer_int64_atomics != 0, |
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.
Shouldn't we check for shaderSharedInt64Atomics
as well?
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.
shaderSharedInt64Atomics
indicates whether shaders can perform 64-bit unsigned and signed integer atomic operations on shared and payload memory.
Does "shared" mean WGSL var<workgroup>
? What is "payload"?
/me searches the spec frantically
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.
Does "shared" mean WGSL
var<workgroup>
?
That was my read, D3D12's AtomicInt64OnGroupSharedSupported
is more explicit.
AtomicInt64OnGroupSharedSupported
is a boolean that specifies whether 64-bit integer atomics are supported ongroupshared
variables.
What is "payload"?
I have no idea 😅
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.
I did not succeed in finding clearly relevant definitions of these terms.
Connections
Part of an incoming series of PRs needed by #5123
Others in this series: #5155 #5154
Addresses #4424
Depends on #5498 and #5497
Ultimately for bevy meshlets pipeline bevyengine/bevy#10164
Description
Shaders currently do not support 64 bit integer atomics. Add support for these gated by a feature flag when the capability is present.
Metal 64bit atomics are quite different from VK/DX style atomics, they do not have a return/output value of any kind and are only available in min/max variants. To accommodate this, a separate feature was added for min/max 64 bit atomics, and AtomicFunctionNoReturn was created in the naga IR to represent these return-less atomics.
DirectX ShaderModel version detection was also implemented, as SM 6.0 was insufficient for this feature.
Testing
A couple snapshot tests have been added to test int64 atomic operations.
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.