mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-03 18:55:39 +00:00
Performs basic peephole optimizations on the AST. Use in transform::Hlsl. Required to have the DecomposeStorageAccess transform operate correctly with the output of InlinePointerLets transform, specifically when declaring `let` pointer expressions to storage buffers. Fixed: tint:221 Fixed: tint:492 Fixed: tint:829 Change-Id: I536390921a6492378104e9c3c100d9e761294a27 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51921 Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: David Neto <dneto@google.com>
31 lines
451 B
WebGPU Shading Language
31 lines
451 B
WebGPU Shading Language
type Arr = array<u32, 50>;
|
|
|
|
[[block]]
|
|
struct Buf {
|
|
count : u32;
|
|
data : Arr;
|
|
};
|
|
|
|
[[group(0), binding(0)]] var<storage> b : [[access(read)]] Buf;
|
|
|
|
[[stage(compute)]]
|
|
fn main() {
|
|
var i : u32 = 0u;
|
|
loop {
|
|
if ((i >= b.count)) {
|
|
break;
|
|
}
|
|
let p : ptr<storage, u32> = &(b.data[i]);
|
|
if (((i % 2u) == 0u)) {
|
|
continue;
|
|
}
|
|
*(p) = 0u;
|
|
|
|
continuing {
|
|
*(p) = (*(p) * 2u);
|
|
i = (i + 1u);
|
|
}
|
|
}
|
|
return;
|
|
}
|