Skip to content

Fix native AA framebuffer overflow from quantized display copies - #182

Merged
capz merged 1 commit into
mainfrom
codex/native-aa-framebuffer-bounds
Nov 14, 2026
Merged

capz merged 1 commit into
mainfrom
codex/native-aa-framebuffer-bounds

Conversation

@capz

@capz capz commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Native 480i/p antialiasing uses a 242-line EFB. With the pinned libogc2, its quantized display copy writes 483 rows, while the VI-sized framebuffer reserves only 480. At 640 pixels, that overruns each buffer by 3,840 bytes and can corrupt adjacent allocations during display changes.

Allocate boot and replacement XFBs for max(VI rows, GX_GetNumXfbLines(...)) using a temporary storage-mode copy. The real VI mode, 480-line output, stride and AA settings stay intact. Failed replacement allocations still preserve both active buffers and avoid GX/VI publication.

Validation: the complete native suite passes in debug and O3/LTO. Regressions cover 483/479-row quantizers, padded strides, ordinary 240/480/576 modes, metadata and both allocation failures. A PowerPC/Dolphin GPU canary using the production helper observed 3,840 changed guard bytes for each legacy 480i/p AA allocation and zero for every protected copy. All 12 cases passed, including return from 576p to 480p AA, 240p AA and safe 480i. This verifies emulator GX-copy bounds; physical-console behavior remains unqualified.

Measurements, hashes and reproduction. CI coverage/workflow checks pass locally. The glass-cube sample needs a published SDK containing this fix before enabling native AA by default.

@capz
capz marked this pull request as ready for review November 14, 2026 22:09
@capz
capz merged commit 09eac4b into main Nov 14, 2026
33 of 35 checks passed
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