mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
* feat: Add 32-bit floating-point atomics * Current supported platforms: Metal * Platforms to support in the future: Vulkan Related issues or PRs: * gfx-rs/wgpu#1020 * Add changelog * Edit changelog * feat: Add 32-bit float atomics support for Vulkan (SPIR-V shaders) * atomicSub for f32 in the previous commits is removed. * Update test * chore: doc type link * refactor: Revise float atomics on msl and spv * Make branches tidy * Also revise old codes * Ensure the implementations are supported by Metal and Vulkan backends * refactor: Renaming flt32 atomics to float32 atomics * chore: Add link to Vulkan feature * fix: cargo fmt * chore: hack comment * Revert changelog * Fix: Cargo advisory * Update wgpu-hal/src/metal/adapter.rs Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> * Update naga/src/lib.rs Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> * Adjust feature flag position --------- Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
48 lines
1.6 KiB
WebGPU Shading Language
48 lines
1.6 KiB
WebGPU Shading Language
struct Struct {
|
|
atomic_scalar: atomic<f32>,
|
|
atomic_arr: array<atomic<f32>, 2>,
|
|
}
|
|
|
|
@group(0) @binding(0)
|
|
var<storage, read_write> storage_atomic_scalar: atomic<f32>;
|
|
@group(0) @binding(1)
|
|
var<storage, read_write> storage_atomic_arr: array<atomic<f32>, 2>;
|
|
@group(0) @binding(2)
|
|
var<storage, read_write> storage_struct: Struct;
|
|
|
|
@compute
|
|
@workgroup_size(2)
|
|
fn cs_main(@builtin(local_invocation_id) id: vec3<u32>) {
|
|
atomicStore(&storage_atomic_scalar, 1.5);
|
|
atomicStore(&storage_atomic_arr[1], 1.5);
|
|
atomicStore(&storage_struct.atomic_scalar, 1.5);
|
|
atomicStore(&storage_struct.atomic_arr[1], 1.5);
|
|
|
|
workgroupBarrier();
|
|
|
|
let l0 = atomicLoad(&storage_atomic_scalar);
|
|
let l1 = atomicLoad(&storage_atomic_arr[1]);
|
|
let l2 = atomicLoad(&storage_struct.atomic_scalar);
|
|
let l3 = atomicLoad(&storage_struct.atomic_arr[1]);
|
|
|
|
workgroupBarrier();
|
|
|
|
atomicAdd(&storage_atomic_scalar, 1.5);
|
|
atomicAdd(&storage_atomic_arr[1], 1.5);
|
|
atomicAdd(&storage_struct.atomic_scalar, 1.5);
|
|
atomicAdd(&storage_struct.atomic_arr[1], 1.5);
|
|
|
|
workgroupBarrier();
|
|
|
|
atomicExchange(&storage_atomic_scalar, 1.5);
|
|
atomicExchange(&storage_atomic_arr[1], 1.5);
|
|
atomicExchange(&storage_struct.atomic_scalar, 1.5);
|
|
atomicExchange(&storage_struct.atomic_arr[1], 1.5);
|
|
|
|
// // TODO: https://github.com/gpuweb/gpuweb/issues/2021
|
|
// atomicCompareExchangeWeak(&storage_atomic_scalar, 1.5);
|
|
// atomicCompareExchangeWeak(&storage_atomic_arr[1], 1.5);
|
|
// atomicCompareExchangeWeak(&storage_struct.atomic_scalar, 1.5);
|
|
// atomicCompareExchangeWeak(&storage_struct.atomic_arr[1], 1.5);
|
|
}
|