# has207/xenia-edge architecture

> Architecture diagram of the GitHub repository has207/xenia-edge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/has207/xenia-edge
- Repository: https://github.com/has207/xenia-edge

## Overview

#### Purpose and entry points
Xenia Edge is a native C++ Xbox 360 emulator fork focused on compatibility, usability, iteration speed, and Windows/Linux/macOS support, with Android packaging present. The desktop launcher is `src/xenia/app/xenia_main.cc`, which hosts the emulator window and game library. Core orchestration is `src/xenia/emulator.cc` / `src/xenia/emulator.h`. Android enters through Java activities and native windowed-app support: `android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java` and `src/xenia/ui/windowed_app_main_android.cc`.

#### Host application, library, and content loading
The application layer scans configured host directories, maintains the game library, resolves titles/compatibility metadata, and launches selected content. Key boundaries are host UI/filesystem versus guest content and runtime:
- `src/xenia/app/game_library.cc`
- `src/xenia/app/directory_scanner.cc`
- `src/xenia/app/game_compat_db.cc`
Guest media, disc images, archives, host directories, and Xbox content containers are abstracted behind the VFS device/entry/file model:
- `src/xenia/vfs/virtual_file_system.cc`
- `src/xenia/vfs/devices/disc_image_device.cc`
- `src/xenia/vfs/devices/xcontent_container_device.cc`

#### Emulator composition and guest OS boundary
`Emulator` assembles memory, CPU, kernel, graphics, audio, HID, VFS, and patching into a game execution session. The kernel emulates Xbox system modules, exported APIs, guest objects, scheduling, threads, I/O, and XAM services; it is the principal boundary between guest calls and host implementations.
- `src/xenia/emulator.cc`
- `src/xenia/kernel/kernel_state.cc`
- `src/xenia/kernel/guest_scheduler.cc`
- `src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc`
- `src/xenia/kernel/xam/xam_module.cc`

#### CPU emulation and dynamic recompilation
Xbox 360 PowerPC code is loaded from XEX/ELF/raw modules, mapped into guest memory, and dispatched through the processor/thread model. The PPC frontend decodes guest instructions into HIR; compiler passes optimize/validate it; host-specific backends emit and cache native x64 or AArch64 code.
- `src/xenia/cpu/processor.cc`
- `src/xenia/cpu/ppc/ppc_frontend.cc`
- `src/xenia/cpu/compiler/compiler.cc`
- `src/xenia/cpu/backend/x64/x64_backend.cc`
- `src/xenia/cpu/backend/a64/a64_backend.cc`
Memory/MMIO plumbing is shared cross-subsystem infrastructure: `src/xenia/memory.cc` and `src/xenia/cpu/mmio_handler.cc`.

#### GPU command, shader, and presentation pipeline
Guest Xenos command streams and registers are interpreted by a command processor, accessing shared guest memory, textures, render targets, and translated shaders. Guest microcode is translated through SPIR-V/DXIL-oriented components, then submitted to a selected host graphics backend. This is the largest hardware-translation boundary.
- `src/xenia/gpu/command_processor.cc`
- `src/xenia/gpu/graphics_system.cc`
- `src/xenia/gpu/shader_translator.cc`
- `src/xenia/gpu/spirv_shader_translator.cc`
- `src/xenia/gpu/shared_memory.cc`
Backend implementations target Direct3D 12, Vulkan, and Metal:
- `src/xenia/gpu/d3d12/d3d12_graphics_system.cc`
- `src/xenia/gpu/vulkan/vulkan_graphics_system.cc`
- `src/xenia/gpu/metal/metal_graphics_system.cc`

#### Host UI, input, and audio
The UI layer owns native windows/surfaces, presenters, settings/dialogs, and overlay drawing; it interfaces with graphics providers rather than guest GPU logic directly. HID maps keyboard/SDL/portal devices into guest input, while APU emulates audio/XMA and outputs through SDL or XAudio2.
- `src/xenia/ui/windowed_app.h`
- `src/xenia/ui/presenter.cc`
- `src/xenia/hid/input_system.cc`
- `src/xenia/apu/audio_system.cc`
- `src/xenia/apu/xma_decoder.cc`

#### Runtime ecosystem and diagnostics
CMake is the main native build system (`CMakeLists.txt`, `src/xenia/CMakeLists.txt`); Android uses Gradle. Platform abstractions cover Windows, POSIX/Linux, macOS, and Android under `src/xenia/base`. Material dependencies include SDL3, FFmpeg, wxWidgets/ImGui, DirectX headers/compiler, Vulkan/MoltenVK, SPIR-V tooling, and Metal conversion libraries in `third_party/`. Optional integration includes Discord presence (`src/xenia/app/discord/discord_presence.cc`) and RenderDoc API access (`src/xenia/ui/renderdoc_api.cc`). GPU trace reader/writer/player/viewer paths support reproducible graphics debugging: `src/xenia/gpu/trace_writer.cc`, `src/xenia/gpu/trace_player.cc`, `src/xenia/gpu/trace_viewer.cc`.

Main entry points: [`src/xenia/emulator.cc`](https://github.com/has207/xenia-edge/blob/edge/src/xenia/emulator.cc) (Emulator session), [`src/xenia/kernel/kernel_state.cc`](https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/kernel_state.cc) (Xbox kernel state), [`src/xenia/gpu/graphics_system.cc`](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/graphics_system.cc) (Graphics system), [`src/xenia/app/game_library.cc`](https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/game_library.cc) (Game library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Application"]
  node_desktop_launcher["Desktop launcher<br/>C++ entry point<br/>[xenia_main.cc]"]
  node_android_launcher["Android launcher<br/>Java activity"]
  node_android_native_app["Android native app<br/>native entry"]
  node_game_library["Game library<br/>library service<br/>[game_library.cc]"]
  node_directory_scanner["Directory scanner<br/>content discovery"]
  node_compatibility_db[("Compatibility DB<br/>metadata service<br/>[game_compat_db.cc]")]
  node_window_ui["Window UI and presenter<br/>host presentation<br/>[presenter.cc]"]
end

subgraph group_runtime["Emulator Runtime"]
  node_emulator{{"Emulator session<br/>runtime orchestrator<br/>[emulator.cc]"}}
  node_kernel["Xbox kernel state<br/>guest OS boundary<br/>[kernel_state.cc]"]
  node_scheduler["Guest scheduler<br/>thread scheduler<br/>[guest_scheduler.cc]"]
  node_xboxkrnl["Xboxkrnl exports<br/>guest system module<br/>[xboxkrnl_module.cc]"]
  node_xam["XAM services<br/>guest system module<br/>[xam_module.cc]"]
end

subgraph group_cpu["CPU Recompilation"]
  node_processor["PPC processor<br/>guest CPU runtime<br/>[processor.cc]"]
  node_ppc_frontend["PPC frontend<br/>instruction decoder<br/>[ppc_frontend.cc]"]
  node_compiler["HIR compiler<br/>optimization pipeline<br/>[compiler.cc]"]
  node_native_backends["x64 / AArch64 backends<br/>native code generators<br/>[x64_backend.cc]"]
end

subgraph group_gpu["Graphics Translation"]
  node_graphics_system["Graphics system<br/>GPU orchestration<br/>[graphics_system.cc]"]
  node_command_processor["Xenos command processor<br/>GPU command interpreter"]
  node_shader_translator["Shader translation<br/>microcode translator"]
  node_graphics_backends["D3D12 / Vulkan / Metal<br/>host GPU backends"]
  node_gpu_trace["GPU trace tooling<br/>graphics diagnostics<br/>[trace_player.cc]"]
end

subgraph group_io["Guest I/O and Devices"]
  node_memory_mmio["Guest memory and MMIO<br/>shared infrastructure<br/>[memory.cc]"]
  node_vfs["Virtual file system<br/>guest storage boundary"]
  node_content_container["XContent containers<br/>VFS device"]
  node_input_system["Input system<br/>HID emulation<br/>[input_system.cc]"]
  node_audio_system["Audio system<br/>APU emulation<br/>[audio_system.cc]"]
end

node_desktop_launcher -->|"browses titles"| node_game_library
node_android_launcher -->|"starts"| node_android_native_app
node_android_native_app -->|"creates session"| node_emulator
node_game_library -->|"scans"| node_directory_scanner
node_game_library -->|"resolves metadata"| node_compatibility_db
node_game_library -->|"launches content"| node_emulator
node_emulator -->|"hosts guest OS"| node_kernel
node_emulator -->|"runs guest code"| node_processor
node_emulator -->|"initializes GPU"| node_graphics_system
node_emulator -->|"mounts content"| node_vfs
node_emulator -->|"initializes HID"| node_input_system
node_emulator -->|"initializes APU"| node_audio_system
node_kernel -->|"schedules threads"| node_scheduler
node_kernel -->|"exports APIs"| node_xboxkrnl
node_kernel -->|"provides services"| node_xam
node_kernel -->|"guest I/O"| node_vfs
node_vfs -->|"mounts"| node_content_container
node_processor -->|"decodes PPC"| node_ppc_frontend
node_ppc_frontend -->|"produces HIR"| node_compiler
node_compiler -->|"emits native code"| node_native_backends
node_processor -->|"accesses"| node_memory_mmio
node_command_processor -->|"translates shaders"| node_shader_translator
node_graphics_system -->|"drives commands"| node_command_processor
node_command_processor -->|"reads guest resources"| node_memory_mmio
node_shader_translator -->|"produces host shaders"| node_graphics_backends
node_graphics_system -->|"submits frames"| node_graphics_backends
node_graphics_system -->|"presents frames"| node_window_ui
node_graphics_system -.->|"records / replays"| node_gpu_trace
node_input_system -->|"guest input events"| node_kernel
node_audio_system -->|"guest audio services"| node_kernel

click node_desktop_launcher "https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/xenia_main.cc"
click node_android_launcher "https://github.com/has207/xenia-edge/blob/edge/android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java"
click node_android_native_app "https://github.com/has207/xenia-edge/blob/edge/src/xenia/ui/windowed_app_main_android.cc"
click node_game_library "https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/game_library.cc"
click node_directory_scanner "https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/directory_scanner.cc"
click node_compatibility_db "https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/game_compat_db.cc"
click node_window_ui "https://github.com/has207/xenia-edge/blob/edge/src/xenia/ui/presenter.cc"
click node_emulator "https://github.com/has207/xenia-edge/blob/edge/src/xenia/emulator.cc"
click node_kernel "https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/kernel_state.cc"
click node_scheduler "https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/guest_scheduler.cc"
click node_xboxkrnl "https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc"
click node_xam "https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/xam/xam_module.cc"
click node_memory_mmio "https://github.com/has207/xenia-edge/blob/edge/src/xenia/memory.cc"
click node_vfs "https://github.com/has207/xenia-edge/blob/edge/src/xenia/vfs/virtual_file_system.cc"
click node_content_container "https://github.com/has207/xenia-edge/blob/edge/src/xenia/vfs/devices/xcontent_container_device.cc"
click node_processor "https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/processor.cc"
click node_ppc_frontend "https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/ppc/ppc_frontend.cc"
click node_compiler "https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/compiler/compiler.cc"
click node_native_backends "https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/backend/x64/x64_backend.cc"
click node_graphics_system "https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/graphics_system.cc"
click node_command_processor "https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/command_processor.cc"
click node_shader_translator "https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/spirv_shader_translator.cc"
click node_graphics_backends "https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/d3d12/d3d12_graphics_system.cc"
click node_input_system "https://github.com/has207/xenia-edge/blob/edge/src/xenia/hid/input_system.cc"
click node_audio_system "https://github.com/has207/xenia-edge/blob/edge/src/xenia/apu/audio_system.cc"
click node_gpu_trace "https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/trace_player.cc"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop_launcher,node_android_launcher,node_android_native_app,node_game_library,node_directory_scanner,node_compatibility_db,node_window_ui toneBlue
class node_emulator,node_kernel,node_scheduler,node_xboxkrnl,node_xam toneAmber
class node_processor,node_ppc_frontend,node_compiler,node_native_backends toneMint
class node_graphics_system,node_command_processor,node_shader_translator,node_graphics_backends,node_gpu_trace toneRose
class node_memory_mmio,node_vfs,node_content_container,node_input_system,node_audio_system toneIndigo
```

## Components

### Host Application

Desktop and Android entry points, library management, and presentation.

- [Desktop launcher](https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/xenia_main.cc): C++ entry point · Hosts the emulator window and game library. · `src/xenia/app/xenia_main.cc`
- [Android launcher](https://github.com/has207/xenia-edge/blob/edge/android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java): Java activity · Starts Android emulator packaging. · `android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java`
- [Android native app](https://github.com/has207/xenia-edge/blob/edge/src/xenia/ui/windowed_app_main_android.cc): native entry · `src/xenia/ui/windowed_app_main_android.cc`
- [Game library](https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/game_library.cc): library service · Maintains configured titles and compatibility metadata. · `src/xenia/app/game_library.cc`
- [Directory scanner](https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/directory_scanner.cc): content discovery · `src/xenia/app/directory_scanner.cc`
- [Compatibility DB](https://github.com/has207/xenia-edge/blob/edge/src/xenia/app/game_compat_db.cc): metadata service · `src/xenia/app/game_compat_db.cc`
- [Window UI and presenter](https://github.com/has207/xenia-edge/blob/edge/src/xenia/ui/presenter.cc): host presentation · Owns native windows, surfaces, overlays, and dialogs. · `src/xenia/ui/presenter.cc`

### Emulator Runtime

Session orchestration and Xbox kernel boundary.

- [Emulator session](https://github.com/has207/xenia-edge/blob/edge/src/xenia/emulator.cc): runtime orchestrator · Assembles guest execution subsystems for a launched title. · `src/xenia/emulator.cc`
- [Xbox kernel state](https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/kernel_state.cc): guest OS boundary · Implements guest objects, system APIs, I/O, and XAM services. · `src/xenia/kernel/kernel_state.cc`
- [Guest scheduler](https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/guest_scheduler.cc): thread scheduler · `src/xenia/kernel/guest_scheduler.cc`
- [Xboxkrnl exports](https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc): guest system module · `src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc`
- [XAM services](https://github.com/has207/xenia-edge/blob/edge/src/xenia/kernel/xam/xam_module.cc): guest system module · `src/xenia/kernel/xam/xam_module.cc`

### CPU Recompilation

Guest PPC execution translated to host-native code.

- [PPC processor](https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/processor.cc): guest CPU runtime · Loads modules and dispatches guest threads. · `src/xenia/cpu/processor.cc`
- [PPC frontend](https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/ppc/ppc_frontend.cc): instruction decoder · Lowers PowerPC instructions into HIR. · `src/xenia/cpu/ppc/ppc_frontend.cc`
- [HIR compiler](https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/compiler/compiler.cc): optimization pipeline · Optimizes and validates translated guest code. · `src/xenia/cpu/compiler/compiler.cc`
- [x64 / AArch64 backends](https://github.com/has207/xenia-edge/blob/edge/src/xenia/cpu/backend/x64/x64_backend.cc): native code generators · Emit and cache host-native code. · `src/xenia/cpu/backend/x64/x64_backend.cc`

### Graphics Translation

Xenos command and shader translation pipeline.

- [Graphics system](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/graphics_system.cc): GPU orchestration · Selects and drives the host graphics backend. · `src/xenia/gpu/graphics_system.cc`
- [Xenos command processor](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/command_processor.cc): GPU command interpreter · Interprets guest command streams and registers. · `src/xenia/gpu/command_processor.cc`
- [Shader translation](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/spirv_shader_translator.cc): microcode translator · Translates guest microcode for host graphics APIs. · `src/xenia/gpu/spirv_shader_translator.cc`
- [D3D12 / Vulkan / Metal](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/d3d12/d3d12_graphics_system.cc): host GPU backends · Submit translated rendering to platform graphics APIs. · `src/xenia/gpu/d3d12/d3d12_graphics_system.cc`
- [GPU trace tooling](https://github.com/has207/xenia-edge/blob/edge/src/xenia/gpu/trace_player.cc): graphics diagnostics · Records and replays reproducible graphics traces. · `src/xenia/gpu/trace_player.cc`

### Guest I/O and Devices

Guest storage, input, audio, and shared memory services.

- [Guest memory and MMIO](https://github.com/has207/xenia-edge/blob/edge/src/xenia/memory.cc): shared infrastructure · Shared guest address space and hardware register plumbing. · `src/xenia/memory.cc`
- [Virtual file system](https://github.com/has207/xenia-edge/blob/edge/src/xenia/vfs/virtual_file_system.cc): guest storage boundary · Abstracts media, containers, archives, and host directories. · `src/xenia/vfs/virtual_file_system.cc`
- [XContent containers](https://github.com/has207/xenia-edge/blob/edge/src/xenia/vfs/devices/xcontent_container_device.cc): VFS device · `src/xenia/vfs/devices/xcontent_container_device.cc`
- [Input system](https://github.com/has207/xenia-edge/blob/edge/src/xenia/hid/input_system.cc): HID emulation · Maps host devices to guest input. · `src/xenia/hid/input_system.cc`
- [Audio system](https://github.com/has207/xenia-edge/blob/edge/src/xenia/apu/audio_system.cc): APU emulation · Emulates audio and XMA output. · `src/xenia/apu/audio_system.cc`

## Connections

- Desktop launcher → Game library: browses titles
- Android launcher → Android native app: starts
- Android native app → Emulator session: creates session
- Game library → Directory scanner: scans
- Game library → Compatibility DB: resolves metadata
- Game library → Emulator session: launches content
- Emulator session → Xbox kernel state: hosts guest OS
- Emulator session → PPC processor: runs guest code
- Emulator session → Graphics system: initializes GPU
- Emulator session → Virtual file system: mounts content
- Emulator session → Input system: initializes HID
- Emulator session → Audio system: initializes APU
- Xbox kernel state → Guest scheduler: schedules threads
- Xbox kernel state → Xboxkrnl exports: exports APIs
- Xbox kernel state → XAM services: provides services
- Xbox kernel state → Virtual file system: guest I/O
- Virtual file system → XContent containers: mounts
- PPC processor → PPC frontend: decodes PPC
- PPC frontend → HIR compiler: produces HIR
- HIR compiler → x64 / AArch64 backends: emits native code
- PPC processor → Guest memory and MMIO: accesses
- Xenos command processor → Shader translation: translates shaders
- Graphics system → Xenos command processor: drives commands
- Xenos command processor → Guest memory and MMIO: reads guest resources
- Shader translation → D3D12 / Vulkan / Metal: produces host shaders
- Graphics system → D3D12 / Vulkan / Metal: submits frames
- Graphics system → Window UI and presenter: presents frames
- Graphics system → GPU trace tooling: records / replays
- Input system → Xbox kernel state: guest input events
- Audio system → Xbox kernel state: guest audio services
