How hrydgard/ppsspp works
Project Type and Purpose
• PPSSPP is a cross-platform PSP emulator written in C++. It consists of:
• A Core emulation engine (CPU, HLE modules, file systems, audio, input).
• A GPU rendering subsystem with multiple backends (OpenGL, Vulkan, D3D9/11, software).
• UI layers for multiple platforms (SDL, Qt, UWP, Windows native, Android, iOS).
• External libraries (‘ext/’), assets, and tools.
File Structure
• Top-level directories:
• Common/ – low-level utilities, threading, math, file I/O, crypto, data structures.
• Core/ – CPU emulation (MIPS interpreter, JITs), HLE PSP modules, file systems, audio/video decoders, debugger, replay.
• GPU/ – abstracted GPU commands + per-API backends (Common, D3D9, D3D11, OpenGL, Vulkan, Software, VR).
• UI/ – common UI components and screens.
• Qt/, SDL/, UWP/, Windows/, macOS/, Android/, iOS/ – platform-specific host wrappers (windowing, input, audio).
• libretro/, headless/ – alternative front-ends.
• ext/ – bundled third-party libraries (zlib, libpng, SPIRV-Cross, ImGui, etc).
• build scripts and CMake toolchains for cross-platform builds.
Read README for Context
• Confirms PPSSPP’s purpose: “a fast and portable PSP emulator” using high-level emulation (HLE) without a BIOS.
• Emulation features: CPU JIT, IR interpreter, HLE modules, GPU abstraction, multi-backend rendering, multi-platform UI.
Main Components & Their Relationships
A. Emulation Core (blue)
• CPU pipeline – MIPS interpreter & JITs (ARM, ARM64, x86, RISC-V).
• IR subsystem – IR frontend, analysis, passes, interpreter & JIT.
• HLE modules – PSP kernel, audio/video syscalls, networking (sceNet), file I/O.
• File systems – VFS, ISO, Zip, directory…
• Memory management – MemMap, MemArena.
• Audio engine – Atrac3 standalone, OpenSL, XAudio, etc.
• Input handling – gesture, key mapping, controller.
B. GPU Subsystem (green)
• GPU Common – command translation, shader generators, state cache.
• Backends – OpenGL, Vulkan, D3D9, D3D11, Software rasterizer, VR/OpenXR.
• Framebuffer & swapchain – platform-specific surface.
C. UI Layer (yellow)
• Common UI screens – menus, settings, developer tools (ImGui).
• Per-platform UI – SDL host, Qt host, Windows Win32 host, UWP host, Android Activity, iOS UIViewController.
D. Platform Abstraction (orange)
• Window & context management – SDL, Qt, Win32, Cocoa, Android JNI.
• Input device abstraction – SDL joystick, XInput, DInput, Android controllers.
• Audio output – OpenSL ES, CoreAudio, WASAPI, XAudio.
• Thread & timing – std::thread, platform timers.
• File dialogs & storage – portable‐file‐dialogs, Scoped Storage on Android.
E. External Libraries & Tools (gray)
• ext/… – zlib, libpng, rapidjson, ImGui, SPIRV-Cross, mini-upnpc, cityhash, etc.
• Tools – SaveTool, langtool, headless host, libretro core.
• Assets – shaders, fonts, language packs, themes, VFP lookup tables.
Architectural Patterns & Principles
• Modular layering:
• Core ←→ GPU ←→ Platform ←→ UI
• Each layer depends only on the layer below + well-defined interfaces.
• Plugin-style GPU backends:
• One API layer (Common) + multiple dynamic backends.
• HLE approach:
• PSP syscalls implemented in Core/HLE modules, no BIOS required.
• Cross-compile toolchain abstraction via CMakePresets / custom toolchain files.
Detail Level & Coverage
• Essential elements without overwhelming:
• Low-level utilities under “Common” rather than listing each file.
• Major sub-systems (CPU, HLE, GPU, UI).
• How assets (shaders, themes, data files) feed into Core/GPU/UI at runtime.