mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
56465df92bec94379ec2192e5ae42606fcbe9d09
809: Add overflow detection to hello-compute r=kvark a=danwilhelm Description The `hello-compute` example sometimes gives incorrect results if an intermediate Collatz value overflows. Proposed Solution We can detect overflows before they occur, since the `3n+1` step is the only possible overflow. (WGSL only supports u32.) Example `cargo run --example hello-compute 77031 837799 8400511 63728127` > Incorrect Current Output: `[350, 524, 312, 346]` > Correct Output: `[350, 524, 685, 949]` > Proposed Solution: `[350, 524, OVERFLOW, OVERFLOW]` Notes - The `hello-compute` example appears to be [borrowed from naga](https://github.com/gfx-rs/naga/blob/master/tests/in/collatz.wgsl), so this would cause the implementations to differ. - Hexadecimal literals are not yet implemented in naga for WGSL shaders, so the shader literals are not as pretty as they could be. - Revised terminology `times` -> `steps` to be consistent with [Wikipedia](https://en.wikipedia.org/wiki/Collatz_conjecture). Co-authored-by: Dan Wilhelm <dan@danwilhelm.com>
Description
No description provided
Languages
Rust
79.9%
WGSL
16.2%
HLSL
2%
GLSL
1.7%
JavaScript
0.2%