struct array_f32 { f: array<f32>; };
[[group(0), binding(0)]] var<storage, read> dataIn : array_f32;
[[group(0), binding(1)]] var<storage, write> dataOut : array_f32;
[[stage(compute), workgroup_size(4, 1)]]
fn main([[builtin(global_invocation_id)]] global_id : vec3<u32>) {
dataOut.f[global_id.x] = dataIn.f[global_id.x] + 1.0;
}
Instructions: Check out JavaScript console.
Note: We can't Read/Write to the same buffer and
have to use one more buffer to read result.