Fix bounds check

Previous behavior: images larger that 2048px would have their bottom
right corners transparent because the info didn't get uploaded to the
GPU
This commit is contained in:
Ian Taylor 2026-04-09 19:33:16 -07:00 committed by Ashley Wulber
parent 7fd263d99e
commit 37f7eab8a3

View file

@ -347,7 +347,15 @@ impl Atlas {
let stride = PIXEL * w;
// bounds check for source pixels to fragment
if pixels.len() < offset + PIXEL * image_width as usize * h {
// The upload loop accesses rows 0..h; the last row starts at
// `offset + (h-1) * PIXEL * image_width` and reads `stride` bytes.
// Using `h` instead of `h-1` over-estimates by one full image_width
// row, causing false positives for bottom-right fragments whose
// x-offset is non-zero and whose bottom edge reaches the image edge.
if h > 0
&& pixels.len()
< offset + (h - 1) * PIXEL * image_width as usize + stride
{
return;
}