Feat: GS, VIF1, VU1 pathways + font rendering stubs + mpeg stubs#80
Merged
ran-j merged 3 commits intoran-j:mainfrom Feb 24, 2026
Merged
Feat: GS, VIF1, VU1 pathways + font rendering stubs + mpeg stubs#80ran-j merged 3 commits intoran-j:mainfrom
ran-j merged 3 commits intoran-j:mainfrom
Conversation
- Replace direct VRAM writes with GIF packet path - sceGsExecLoadImage: build GIF packet, set MADR/QWC/CHCR - sceGsExecStoreImage: GIF packet, processPendingTransfers, consumeLocalToHostBytes - sceGsPutDispEnv/sceGsPutDrawEnv: program GIF DMA Path3 (5/9 QWs) - sceGsResetGraph: GIF packet + writeIORegister for pmode/smode2/dispfb/display/bgcolor - sceGsSetDefDrawEnv: GIF packet layout, sceGszbufaddr for zbuf - sceGsSyncPath: processPendingTransfers, poll DMA channels - sceGsSyncV/sceGsSyncVCallback: return 0 - sceGszbufaddr: zbuf calculation (width/height blocks, gparam) Helpers (ps2_stubs_helpers.inl): - GsDispEnvMem: 5 fields (pmode, smode2, dispfb, display, bgcolor) for GIF layout - writeGsDispEnv: read-modify-write pattern - toDmaPhys: SPR (scratchpad) handling for DMA MADR bit 31 - submitDmaSend: chain mode (chcr=0x185) for sceDmaSend/sceDmaSendI/sceDmaSendM Misc stubs (ps2_stubs_misc.inl): - Add sceeFontInit, sceeFontLoadFont, sceeFontPrintfAt, sceeFontPrintfAt2 - Add sceeFontClose, sceeFontSetColour, sceeFontSetMode, sceeFontSetFont, sceeFontSetScale - Font stubs use GIF packets for CLUT and texture upload Call list (ps2_call_list.h): - Add sceeFont* entries between sceGszbufaddr and sceIoctl
fix: fixed flickering error when rendering in memory.cpp
Owner
|
Since it's tested on a recompiled game I will merge but I see some Edge cases on this code but we can work on it |
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.
PS2 Recomp Playground — Pull Request Description
Overview
Adds three GS pathways.
Adds font loading and rendering stubs.
Adds mpeg stubs.
Architecture Diagram
flowchart TB subgraph EE["Emotion Engine (EE)"] direction TB RDRAM["RDRAM (32MB)"] EE_CPU["EE CPU (R5900)"] Runner["Recompiled Functions"] Stubs["ps2_stubs"] Syscalls["ps2_syscalls"] EE_CPU --> Runner EE_CPU --> Stubs EE_CPU --> Syscalls Runner --> RDRAM Stubs --> RDRAM end subgraph DMA["DMA Controller"] DMA_CH0["DMA Ch0"] DMA_CH1["DMA Ch1 (VIF1)"] DMA_CH2["DMA Ch2 (GIF)"] end subgraph VIF1["VIF1 (Vector Interface)"] VIF1_Regs["VIF1 Registers"] VIF1_Interp["VIF1 Interpreter"] VIF1_Interp --> |"MPG: load VU1 microcode"| VU1_Code VIF1_Interp --> |"UNPACK: load VU1 data"| VU1_Data VIF1_Interp --> |"DIRECT: Path 2"| GIF_Arbiter VIF1_Interp --> |"MSCAL: trigger VU1"| VU1_Exec end subgraph VU1["VU1 (Vector Unit 1)"] VU1_Code["VU1 Micro Memory (16KB)"] VU1_Data["VU1 Data Memory (16KB)"] VU1_Exec["VU1 Interpreter"] VU1_Exec --> |"XGKICK: Path 1"| GIF_Arbiter end subgraph GS["Graphics Synthesizer (GS)"] GIF_Arbiter["GIF Arbiter"] GS_GPU["GS GPU"] GS_VRAM["GS VRAM (4MB)"] GS_Raster["GS Rasterizer"] GIF_Arbiter --> GS_GPU GS_GPU --> GS_Raster GS_Raster --> GS_VRAM end subgraph Host["Host"] Raylib["Raylib Window"] GS_VRAM --> |"Display snapshot"| Raylib end RDRAM --> |"sceDmaSend / sceDmaSendN"| DMA_CH2 RDRAM --> |"sceDmaSend (VIF1)"| DMA_CH1 DMA_CH2 --> |"Path 3"| GIF_Arbiter DMA_CH1 --> VIF1_Interp VIF1_Regs --> VIF1_InterpEE–GS–VIF1–VU1 Pathways
The GIF (Graphics Interface) sends textures and geometry to the GS. It receives data from three different PATHs. Only one PATH may run at a time; when one PATH stops, the highest-priority queued PATH begins transfer.
Path 1: VU1 Memory → GIF (VU1-Assisted Rendering)
Source: VU1 internal VU Memory (XGKICK)
Path: EE → DMA channel 0x10009000 (VIF1) → VIF1 Interpreter → VU1 Data / VU1 Code → VU1 Interpreter → XGKICK → GIF Path 1 → GS
Trigger:
sceDmaSendto VIF1 channel (0x10009000)Flow:
processPendingTransfers()enqueues tom_pendingVif1TransfersprocessVIF1Data()interprets VIF commands:Use case: 3D geometry, transforms, and complex rendering pipelines
Path 2: VIF1 Interface → GIF
Source: VIF1 interface (pass-through)
Path: EE → VIF1 →
VIF_DIRECT/VIF_DIRECTHL→ GIF Path 2 → GSVIF_DIRECT/VIF_DIRECTHLsubmit the following QWs to the GIF Arbiter as Path 2Path 3: GIF DMAC Channel → GIF
Source: GIF DMAC channel (channel 2, 0x1000A000)
Path: EE → DMA channel 2 (0x1000A000) → GIF Arbiter → GS
Trigger:
sceDmaSend,sceDmaSendN,sceDmaSendI,sceDmaSendM(stubs)Flow:
processPendingTransfers()PS2Memory::processPendingTransfers()reads from RDRAM at MADR, submits toGifArbiteras Path 3GifArbitersorts by path priority (Path1 < Path2 < Path3) and drainsGS::processGIFPacket()parses GIF tags (PACKED, REGLIST, IMAGE) and updates GS state / rasterizesUse case: EE builds GIF packets in RDRAM and sends them directly to the GS (e.g. 2D UI, fonts, simple draws)
GIF Path Arbitration
Only one PATH may run at a time. Under normal conditions, when one PATH stops, the highest-priority queued PATH begins transfer. The arbiter drains in priority order: PATH1 (VU1 XGKICK) → PATH2 (VIF1 DIRECT) → PATH3 (GIF DMAC channel 2).
File-by-File Description
GS::processGIFPacket.New Stubs in
ps2_stubs_misc.inlsceeFont (10 stubs)
sceeFontInitsceeFontLoadFontsceeFontPrintfAtsceeFontPrintfAt2sceeFontGenerateStringsceeFontClosesceeFontSetColoursceeFontSetModesceeFontSetFontsceeFontSetScalesceMpeg (6 stubs)
sceMpegAddStrCallbacksceMpegClearRefBuffsceMpegCreatesceMpegGetPicturesceMpegIsEndsceMpegReset