fix(gum): lazily init VFPU context + font/sprite fixes#5
Merged
AndrewAltimit merged 5 commits intomainfrom Feb 10, 2026
Merged
Conversation
sceGumMatrixMode() and other GUM functions call get_context_unchecked() which panics with unreachable!() if the VFPU_CONTEXT hasn't been initialized yet. This happens when sceGumMatrixMode() is the first GUM call (before sceGumLoadIdentity), which is the normal usage pattern in PSP programs. Replace the match/unreachable with get_or_insert_with(Context::new) so the context is lazily initialized on first access from any GUM function. This matches the original Sony PSP SDK behavior. Fixes panic in PPSSPP: "internal error: entered unreachable code" at gum.rs:91, which caused sceKernelExitGame(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FontRenderer::draw_text previously treated the y parameter as the baseline, causing glyphs to render ~ascender pixels too high and get clipped by container bounds. Store max_glyph_ascender_f at init and add it internally so callers can use simple top-left coordinates. Also fix SpriteBatch::flush to copy vertices into display-list memory via sceGuGetMemory instead of flushing dcache on heap pointers, which ensures vertex data survives past SpriteBatch drop. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reference oasis-os PSP backend as a comprehensive example of the SDK in production, listing 25+ SDK modules used across audio, rendering, threading, networking, input, file I/O, and kernel-mode features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Code ReviewIssues(none) Previous Issues(none) Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Fix rustfmt issues in SpriteBatch::flush and use the get_context_unchecked() helper in sceGumLoadIdentity and sceGumLoadMatrix instead of inlining VFPU_CONTEXT.get_or_insert_with. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
The function performs safe lazy initialization via get_or_insert_with, so the "unchecked" suffix was misleading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
Review Response Agent (Iteration 1)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Codex AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues (if any)
Previous Issues (for incremental reviews)
Suggestions (if any)
Notes
Generated by Codex AI (gpt-5.2-codex). Supplementary to human reviews. |
Owner
Author
Review Response Agent (Iteration 2)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
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
unreachable!()panic inget_context_unchecked()withget_or_insert_with(Context::new)so the VFPU context is lazily initialized on first GUM call. Fixes crash whensceGumMatrixMode()is called beforesceGumLoadIdentity(), which is the normal PSP SDK usage pattern.draw_texty parameter as top-of-line instead of baseline. Storesmax_glyph_ascender_fat init and adds it internally, so callers can use simple top-left coordinates without glyphs being clipped.SpriteBatch::flush()now copies vertices into display-list memory viasceGuGetMemoryinstead of flushing dcache on heap pointers, ensuring vertex data remains valid after the batch is dropped.Test plan
sceGumLoadIdentitycall (no panic)cargo +nightly psp --releaseGenerated with Claude Code