mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-14 10:33:42 +00:00
When an initializer is present, use type inference instead of explicitly typing `var` and `let` declarations. This reduces the size of the generated WGSL and improves readability. Change-Id: I241ee2108279b550735945940f2b62bbbd493708 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132142 Commit-Queue: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: James Price <jrprice@google.com> Reviewed-by: David Neto <dneto@google.com>
59 lines
1.0 KiB
WebGPU Shading Language
59 lines
1.0 KiB
WebGPU Shading Language
struct S_atomic {
|
|
/* @offset(0) */
|
|
x : i32,
|
|
/* @offset(4) */
|
|
a : atomic<u32>,
|
|
/* @offset(8) */
|
|
y : u32,
|
|
}
|
|
|
|
struct S {
|
|
/* @offset(0) */
|
|
x : i32,
|
|
/* @offset(4) */
|
|
a : u32,
|
|
/* @offset(8) */
|
|
y : u32,
|
|
}
|
|
|
|
alias 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_2 : u32) {
|
|
var idx = 0u;
|
|
idx = local_invocation_index_2;
|
|
loop {
|
|
let x_23 = idx;
|
|
if (!((x_23 < 10u))) {
|
|
break;
|
|
}
|
|
let x_28 = idx;
|
|
wg[x_28].x = 0i;
|
|
atomicStore(&(wg[x_28].a), 0u);
|
|
wg[x_28].y = 0u;
|
|
|
|
continuing {
|
|
let x_41 = idx;
|
|
idx = (x_41 + 1u);
|
|
}
|
|
}
|
|
workgroupBarrier();
|
|
atomicStore(&(wg[4i].a), 1u);
|
|
return;
|
|
}
|
|
|
|
fn compute_main_1() {
|
|
let x_53 = 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();
|
|
}
|