```rust [[]] var<storage, read_write> indices : array<u32>; [[]] var<storage, read> buffer : array<u32, 3>; [[stage(compute)]] fn main() { if (iAmNaughtyInvocation) { indices[0] = 1000; } else { indices[0] = 0; } // workgroupBarrier(); buffer[indices[0]]; } [[stage(compute)]] fn main() { if (iAmNaughtyInvocation) { indices[0] = 1000; buffer[indices[0]]; } else { indices[0] = 0; // clamp let i : u32 = indices[0]; let c = clamp(i, 0, N); buffer[c]; } } [[stage(compute)]] fn main() { if (iAmNaughtyInvocation) { indices[0] = 1000; buffer[indices[0]]; } else if (someVar < 3u) { indices[0] = someVar; // no clamp buffer[indices[0]]; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up