Fix OpenGL stage-clear wallpaper rendering upside-down#127
Merged
Conversation
The capture path was force-flipping rows on OpenGL on the assumption that glReadPixels uses bottom-left origin, but mGameFb is created with opengl_invertY=true (interpreter.cpp:5893) so the engine pre-negates vertex Y at draw time (interpreter.cpp:2761). The OGL framebuffer's bottom row is therefore already the N64 top row, and the wrapper's compensating flip was inverting an already-correct buffer. D3D11 / Metal have no analogous flag and never needed a flip. Confirmed via a short-lived SSB64_FB_FLIP=always|never|auto env-var harness — only "never" produced an upright wallpaper on OpenGL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
port_capture_game_framebufferwas force-flipping rows on OpenGL on the assumption thatglReadPixelsuses bottom-left origin. That's true of raw GL, butmGameFbis created withopengl_invertY=true(libultraship/.../interpreter.cpp:5893), so the engine pre-negates vertex Y at draw time (interpreter.cpp:2761). The OGL framebuffer's bottom row is therefore already the N64 top row, and the wrapper's "compensating" flip was inverting an already-correct buffer.SSB64_FB_FLIP=always\|never\|autoenv-var harness from a single Debug build — onlyneverproduced an upright wallpaper. Locked in as the unconditional default.ReadFramebufferToCPUwalks textures in native top-left order with no analogous flag, so they were correct without any flip and remain unchanged.Test plan
main).Notes
docs/bugs/opengl_fb_capture_y_flip_double_invert_2026-05-03.mdfor full root cause + audit hook.mGameFbMsaaResolvedis the only LUS-managed FB built withinvertY=false. Capture only reaches it on the OGL+MSAA+non-matching-viewport sub-config, which we couldn't trigger in the A/B session — if a future report describes upside-down only with MSAA on, this is the next likely place to look.🤖 Generated with Claude Code