Repository navigation
Conversation
The source texture already holds the pixels for a duplicate frame. Keep uploading when the debug HUD or fade-in modifies those pixels.
Only the debug HUD, fade-in and ambient LEDs need the RGBA frame on the CPU. When none of them is active, upload the core's RGB565 buffer directly. Draw duplicates from the texture because there is no CPU copy.
Uploading to a texture that the current frame still samples makes the PowerVR driver allocate storage on every frame. Upload to the texture that the previous frame did not use.
A duplicate frame ran every user shader pass again on the same source texture. Reuse the output in the FBO textures and run only the final draw to the screen.
…, and hash shader cache keys Keep packed RGB565 frames across duplicate callbacks and context resets, track dual source texture storage per slot with GL allocation error checks, keep SDL presentation safe across source changes, include source FNV-1a hash in shader cache keys, and allow direct RGB565 upload during fast-forward.
…L swap Cache MVPMatrix, VertexCoord, and TexCoord locations at shader link time, keep one persistent FBO per shader pass instead of re-attaching every frame, and drop per-frame glGetError/glIsTexture/glCheckFramebufferStatus queries (checking completeness on attach). Move SDL_RenderClear() out of PLAT_blitRenderer() into the non-GL PLAT_flip() blit path to avoid per-frame SDL GL context switches, and clear FBO 0 inside PLAT_GL_Swap() before the final pass.
This branch has not been deployed
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.
This PR streamlines the OpenGL ES video pipeline in
minarchby avoiding redundant pixel conversions, texture uploads, shader reruns, and per-frame GL driver overhead. It makes gameplay frames finish faster and lets the CPU stay at lower clock speeds without changing image output.On a Trimui Brick Pro running GBA with a shader, overlay, and rewind enabled, active frame work drops from 8.03 ms to 7.76 ms (p95 down from 10.06 ms to 9.42 ms) and average CPU frequency drops by 39 MHz (1506 → 1467 MHz).
Changes
workspace/all/common/generic_video.c,workspace/all/minarch/ma_video.c): When a core emitted a duplicate frame (common in 30 fps games and static screens),minarchstill re-uploaded the source texture and re-ran every user shader pass. Tracking frame dirtiness and reusing valid FBO outputs skips those redundant uploads and passes whenever neither the source pixels nor frame-counter shaders changed.generic_video.c,ma_video.c,api.h): RGB565 cores (GB/GBC/GBA/SNES/MD/PSX) were converted to 32-bit RGBA on the CPU every frame before uploading. Uploading RGB565 textures directly to GLES (including during fast-forward)—while retaining a packed RGB565 copy for duplicate frames/context resets and keeping the non-GL SDL path safe—eliminates that per-frame CPU conversion completely.generic_video.c,PLAT_GL_Swap): Uploading into a texture the PowerVR GPU was still sampling for the previous frame forced the driver to allocate fresh backing storage every frame. Alternating between two source textures with per-slot dimension/format tracking and allocation error checks avoids that repeated reallocation.generic_video.c,init_shader_program): Cached shader binaries were keyed only by filename and the source string was leaked after parsing. Hashing the shader source into the.shadercachekey and freeing the buffer prevents stale binaries after shader edits and fixes the load-time leak.generic_video.c,runShaderPass,PLAT_blitRenderer,PLAT_flip,PLAT_GL_Swap): Every frame looked up attribute/uniform locations by name, re-attached a shared FBO, ranglGetError/glIsTexture/glCheckFramebufferStatuschecks, and calledSDL_RenderClear()inPLAT_blitRenderer()(triggering an SDL GL context switch on every GL frame). Caching locations at link time, giving each shader pass a persistent FBO, checking completeness only on attach, movingSDL_RenderClear()to the non-GLPLAT_flip()path, and clearing the GL backbuffer once per swap cuts ~0.45 ms/frame of CPU driver overhead while guaranteeing clean letterbox bars on all EGL surfaces.Results
Measured on Trimui Brick Pro (
tg5040, GBAgpspwith shader + overlay + rewind @ 16 ms):upstream/main)Blast Radius
generic_video.c),GFX_Rendererstruct (api.h), andminarchframe callback (ma_video.c).generic_video.c(tg5040,tg5050,h700,my355, desktop).Testing and Verification
minarchcleanly for bothtg5040andh700toolchains with zero warnings.tg5040) across GBA (gpsp) and PAL SNES (snes9x).SDL_RenderClear()out ofPLAT_blitRenderer()could leave undefined letterbox pixels on EGL surfaces that discard backbuffers; added an explicitglClear(GL_COLOR_BUFFER_BIT)on FBO 0 every swap (which also acts as a TBDR fast-clear on PowerVR/Mali) and keptSDL_RenderClear()on the non-GLPLAT_flip()path.ma_video.cand validated per-slotglTexImage2Dallocations so duplicate callbacks, fast-forward drops, or GL resets never display stale or uninitialized textures.SDL_LockTexture/SDL_ConvertPixelsinPLAT_flip()so source format changes remain safe when the SDL path is used.