Repository navigation
shader: look up an input channel without underflowing - #56
Conversation
find_input matched each input element with `(row and channel in the element).then_some((id, channel - e.col))`. then_some evaluates its argument first, so the subtraction ran for every element, also those whose first channel is past the one asked for. In a build with overflow checks (tests, debug runs) a pixel shader reading a channel below any element that starts at z or w panicked, whichever row that element was in, and packed inputs such as a float2 in .zw are common. Release builds wrapped and threw the value away. then() computes it only when the element holds the channel. Found with a random-input harness over pixel, vertex and mesh programs with matching signatures. The new test panics without the fix.
|
juwwww |
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
|
Verified
AI-assisted. |
|
checked: this was already merged (8fe0b74) while I was running these, so this is a post-merge confirmation of 5fbea47 rather than a pre-merge review. Environment: Linux x86_64 (Debian, kernel 6.12), Rust 1.98.1 from rust-toolchain.toml, cargo -j4, no game files, no GPU. What I ran (in a throwaway worktree of the PR head 5fbea47, base 97c78d1):
Review notes:
Not verified: |
shader: look up an input channel without underflowing
find_input matched each input element with
(row and channel in the element).then_some((id, channel - e.col)). then_some evaluates its argument first, so the subtraction ran for every element, also those whose first channel is past the one asked for. In a build with overflow checks (tests, debug runs) a pixel shader reading a channel below any element that starts at z or w panicked, whichever row that element was in, and packed inputs such as a float2 in .zw are common. Release builds wrapped and threw the value away.then() computes it only when the element holds the channel.
Found with a random-input harness over pixel, vertex and mesh programs with matching signatures. The new test panics without the fix.