mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
tint: Add support for atomic ops to spirv reader
The following operations are supported: OpAtomicLoad OpAtomicStore OpAtomicExchange OpAtomicCompareExchange OpAtomicCompareExchangeWeak OpAtomicIIncrement OpAtomicIDecrement OpAtomicIAdd OpAtomicISub OpAtomicSMin OpAtomicUMin OpAtomicSMax OpAtomicUMax OpAtomicAnd OpAtomicOr OpAtomicXor These are not, but may be supported in the future: OpAtomicFlagTestAndSet OpAtomicFlagClear OpAtomicFMinEXT OpAtomicFMaxEXT OpAtomicFAddEXT Bug: tint:1441 Change-Id: Ifd53643b38d43664905a0dddfca609add4914670 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94121 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
57810d81d5
commit
268d7b8357
@@ -0,0 +1,52 @@
|
||||
struct S_atomic {
|
||||
x : i32,
|
||||
a : atomic<u32>,
|
||||
y : u32,
|
||||
}
|
||||
|
||||
struct S {
|
||||
x : i32,
|
||||
a : u32,
|
||||
y : u32,
|
||||
}
|
||||
|
||||
type Arr = array<S, 10u>;
|
||||
|
||||
var<private> local_invocation_index_1 : u32;
|
||||
|
||||
var<workgroup> wg : array<S_atomic, 10u>;
|
||||
|
||||
fn compute_main_inner(local_invocation_index : u32) {
|
||||
var idx : u32 = 0u;
|
||||
idx = local_invocation_index;
|
||||
loop {
|
||||
let x_23 : u32 = idx;
|
||||
if (!((x_23 < 10u))) {
|
||||
break;
|
||||
}
|
||||
let x_28 : u32 = idx;
|
||||
wg[x_28].x = 0i;
|
||||
atomicStore(&(wg[x_28].a), 0u);
|
||||
wg[x_28].y = 0u;
|
||||
|
||||
continuing {
|
||||
let x_41 : u32 = idx;
|
||||
idx = (x_41 + 1u);
|
||||
}
|
||||
}
|
||||
workgroupBarrier();
|
||||
atomicStore(&(wg[4i].a), 1u);
|
||||
return;
|
||||
}
|
||||
|
||||
fn compute_main_1() {
|
||||
let x_53 : u32 = local_invocation_index_1;
|
||||
compute_main_inner(x_53);
|
||||
return;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1i, 1i, 1i)
|
||||
fn compute_main(@builtin(local_invocation_index) local_invocation_index_1_param : u32) {
|
||||
local_invocation_index_1 = local_invocation_index_1_param;
|
||||
compute_main_1();
|
||||
}
|
||||
Reference in New Issue
Block a user