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:
parent
7fd263d99e
commit
37f7eab8a3
1 changed files with 9 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue