wgpu/naga/tests/out/wgsl/atomicOps-int64-min-max.wgsl
JMS55 17fcb19425
[naga, hal] miscellaneous fixes for Atomic64 support (#5952)
In `naga:🔙hlsl`:

- Generate calls to `Interlocked{op}64` when necessary. not
  `Interlocked{op}`.

- Make atomic operations that do not produce a value emit their
  operands properly.
  
In the Naga snapshot tests:

- Adapt `atomicOps-int64-min-max.wgsl` to include cases that
  cover non-trivial atomic operation operand emitting.

In `wgpu_hal::vulkan::adapter`:

- When retrieving physical device features, be sure to include
  the `PhysicalDeviceShaderAtomicInt64Features` extending struct
  in the chain whenever the `VK_KHR_shader_atomic_int64` extension
  is available.

- Request both `shader_{buffer,shared}_int64_atomics` in the
  `PhysicalDeviceShaderAtomicInt64Features` extending struct when either of
  `wgpu_types::Features::SHADER_INT64_ATOMIC_{ALL_OPS,MIN_MAX}` is requested.

---------

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-07-13 19:17:59 -07:00

32 lines
1.0 KiB
WebGPU Shading Language

struct Struct {
atomic_scalar: atomic<u64>,
atomic_arr: array<atomic<u64>, 2>,
}
@group(0) @binding(0)
var<storage, read_write> storage_atomic_scalar: atomic<u64>;
@group(0) @binding(1)
var<storage, read_write> storage_atomic_arr: array<atomic<u64>, 2>;
@group(0) @binding(2)
var<storage, read_write> storage_struct: Struct;
@group(0) @binding(3)
var<uniform> input: u64;
@compute @workgroup_size(2, 1, 1)
fn cs_main(@builtin(local_invocation_id) id: vec3<u32>) {
let _e3 = input;
atomicMax((&storage_atomic_scalar), _e3);
let _e7 = input;
atomicMax((&storage_atomic_arr[1]), (1lu + _e7));
atomicMax((&storage_struct.atomic_scalar), 1lu);
atomicMax((&storage_struct.atomic_arr[1]), u64(id.x));
workgroupBarrier();
let _e20 = input;
atomicMin((&storage_atomic_scalar), _e20);
let _e24 = input;
atomicMin((&storage_atomic_arr[1]), (1lu + _e24));
atomicMin((&storage_struct.atomic_scalar), 1lu);
atomicMin((&storage_struct.atomic_arr[1]), u64(id.x));
return;
}