Skip to content

Clamp out-of-range unorm inputs#651

Merged
solidpixel merged 5 commits into
mainfrom
input_clamp
Jun 22, 2026
Merged

Clamp out-of-range unorm inputs#651
solidpixel merged 5 commits into
mainfrom
input_clamp

Conversation

@solidpixel

@solidpixel solidpixel commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Unorm inputs are expected to be between 0 and 1, scaled to 0-65535 internally. When input image data is a UNORM8 data source this is guaranteed, as data is passed in using the matching encoding. However, when images are passed in as fp16 or fp32 inputs the data is not constrained. We can end up with out-of-range values and NaNs, which trigger UB when later stored into an integer.

This PR clamps unorm inputs to guarantee they stay in a valid range.

Original issue reported by @sahvx655-wq.

@solidpixel solidpixel self-assigned this Jun 22, 2026
@solidpixel solidpixel merged commit f863361 into main Jun 22, 2026
9 checks passed
@solidpixel solidpixel deleted the input_clamp branch June 22, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant