mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
The upscale mapped output pixels to source pixels through a 16.16 ratio rounded down, (fb_width << 16) / out_width. At any factor that is not a power of two the ratio comes out short, so the first source column and row are repeated once too often and the last ones once too few: at 3x, column 0 is three pixels wide plus one and the last column is two, and the drift moves every column boundary between them. It shows as uneven text and uneven borders at Internal Upscale 3x, 5x, 6x and 7x, and at the Auto level whenever it lands on one of those. The source of each output pixel is now floor(dst * fb / out), stepped along each row and column with a remainder, so there is no division and nothing can overflow. At a whole factor each source pixel is repeated exactly that many times. Output at 2x, 4x and 8x is unchanged byte for byte; at other factors it now matches an exact reference (checked over 1500 random sizes, factors and pitches, under ASan and UBSan).