# itsnotrexed/leonida architecture

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

- Interactive diagram: https://gitdiagram.com/itsnotrexed/leonida
- Repository: https://github.com/itsnotrexed/leonida

## Overview

Leonida is a static-recompilation project that builds a Windows runtime and extracted assets from a user’s Xbox Series game copy. The documented workflow checks the package, translates shaders, exports assets, prepares the runtime, and optionally creates a GPU pipeline cache. The graph preserves the distinct shader and asset-processing stages, plus the PE loader and import shims. Most tool relationships come from the README’s workflow description; unsampled implementation details are not inferred.

Main entry points: [`make_game.py`](https://github.com/itsnotrexed/leonida/blob/main/make_game.py) (Build orchestrator), [`tools/rpf9dump/Program.cs`](https://github.com/itsnotrexed/leonida/blob/main/tools/rpf9dump/Program.cs) (Archive export), [`tools/tile_probe.py`](https://github.com/itsnotrexed/leonida/blob/main/tools/tile_probe.py) (Texture layout probe), [`runtime/shims/registry.cpp`](https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/registry.cpp) (Shim registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_package["Package validation"]
  node_package_index["Version manifest<br/>[xbox-1.0.2.1.json]"]
  node_builder["Build orchestrator<br/>[make_game.py]"]
end

subgraph group_shaders["Shader translation"]
  node_shader_carve["Shader carving<br/>[shader_carve.py]"]
  node_fssm_unpack["Native unpacking<br/>[fssm_unpack.py]"]
  node_shader_disasm["RDNA disassembly<br/>[shader_disasm.py]"]
  node_shader_ir["Instruction parsing<br/>[shader_ir.py]"]
  node_spirv_translate["SPIR-V translation<br/>[rdna2spirv.py]"]
  node_pipeline_cache["GPU pipeline cache"]
end

subgraph group_assets["Asset export"]
  node_asset_export["Archive export<br/>[Program.cs]"]
  node_model_export["Model export<br/>[Program.cs]"]
  node_texture_export["Texture export<br/>[tex_export.py]"]
  node_audio_support["Audio bank support<br/>[awc_opus.py]"]
end

subgraph group_runtime["Runtime support"]
  node_pe_mapper["PE mapper<br/>[pe_loader.cpp]"]
  node_runtime_cli["Runtime entry<br/>[main.cpp]"]
  node_shim_registry["Shim registry<br/>[registry.cpp]"]
  node_xmem_shim["XMem shim<br/>[xmem.cpp]"]
  node_d3d12_shim["D3D12 shim<br/>[d3d12_xs.cpp]"]
end

subgraph group_research["GPU layout research"]
  node_tile_probe["Texture layout probe<br/>[tile_probe.py]"]
  node_swizzle_search["Swizzle search<br/>[swizzle_search.py]"]
  node_amd_swizzle["AMD detiling<br/>[amd_swizzle.py]"]
  node_bc_feature["Block features<br/>[bc_feature.py]"]
end

node_owner(("Game owner"))

node_owner -->|"supplies copy"| node_builder
node_builder -->|"checks version"| node_package_index
node_builder -->|"runs shader stage"| node_shader_carve
node_shader_carve -->|"passes carved code"| node_fssm_unpack
node_fssm_unpack -->|"passes native code"| node_shader_disasm
node_shader_disasm -.->|"parses disassembly"| node_shader_ir
node_shader_ir -->|"provides instructions"| node_spirv_translate
node_builder -->|"runs asset stage"| node_asset_export
node_asset_export -->|"exports models"| node_model_export
node_asset_export -->|"exports textures"| node_texture_export
node_asset_export -->|"decodes audio banks"| node_audio_support
node_builder -->|"runs runtime stage"| node_runtime_cli
node_runtime_cli -->|"loads image"| node_pe_mapper
node_pe_mapper -->|"resolves shims"| node_shim_registry
node_shim_registry -->|"registers entries"| node_xmem_shim
node_shim_registry -->|"registers entries"| node_d3d12_shim
node_builder -->|"creates cache"| node_pipeline_cache
node_spirv_translate -->|"provides shaders"| node_pipeline_cache
node_tile_probe -->|"supplies features"| node_swizzle_search
node_tile_probe -->|"scores layouts"| node_amd_swizzle
node_tile_probe -.->|"extracts features"| node_bc_feature

click node_package_index "https://github.com/itsnotrexed/leonida/blob/main/game/xbox-1.0.2.1.json"
click node_builder "https://github.com/itsnotrexed/leonida/blob/main/make_game.py"
click node_shader_carve "https://github.com/itsnotrexed/leonida/blob/main/tools/shader_carve.py"
click node_fssm_unpack "https://github.com/itsnotrexed/leonida/blob/main/tools/fssm_unpack.py"
click node_shader_disasm "https://github.com/itsnotrexed/leonida/blob/main/tools/shader_disasm.py"
click node_shader_ir "https://github.com/itsnotrexed/leonida/blob/main/tools/shader_ir.py"
click node_spirv_translate "https://github.com/itsnotrexed/leonida/blob/main/tools/rdna2spirv.py"
click node_pipeline_cache "https://github.com/itsnotrexed/leonida/blob/main/runtime/test/vk_pipeline_check.cpp"
click node_asset_export "https://github.com/itsnotrexed/leonida/blob/main/tools/rpf9dump/Program.cs"
click node_model_export "https://github.com/itsnotrexed/leonida/blob/main/tools/rpf9dump/Program.cs"
click node_texture_export "https://github.com/itsnotrexed/leonida/blob/main/tools/tex_export.py"
click node_audio_support "https://github.com/itsnotrexed/leonida/blob/main/tools/awc_opus.py"
click node_pe_mapper "https://github.com/itsnotrexed/leonida/blob/main/runtime/src/pe_loader.cpp"
click node_runtime_cli "https://github.com/itsnotrexed/leonida/blob/main/runtime/src/main.cpp"
click node_shim_registry "https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/registry.cpp"
click node_xmem_shim "https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/xmem.cpp"
click node_d3d12_shim "https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/d3d12_xs.cpp"
click node_tile_probe "https://github.com/itsnotrexed/leonida/blob/main/tools/tile_probe.py"
click node_swizzle_search "https://github.com/itsnotrexed/leonida/blob/main/tools/swizzle_search.py"
click node_amd_swizzle "https://github.com/itsnotrexed/leonida/blob/main/tools/amd_swizzle.py"
click node_bc_feature "https://github.com/itsnotrexed/leonida/blob/main/tools/bc_feature.py"

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_package_index,node_builder toneBlue
class node_shader_carve,node_fssm_unpack,node_shader_disasm,node_shader_ir,node_spirv_translate,node_pipeline_cache toneAmber
class node_asset_export,node_model_export,node_texture_export,node_audio_support toneMint
class node_pe_mapper,node_runtime_cli,node_shim_registry,node_xmem_shim,node_d3d12_shim toneRose
class node_tile_probe,node_swizzle_search,node_amd_swizzle,node_bc_feature,node_owner toneIndigo
```

## Components

### Package validation

- [Version manifest](https://github.com/itsnotrexed/leonida/blob/main/game/xbox-1.0.2.1.json): `game/xbox-1.0.2.1.json`
- [Build orchestrator](https://github.com/itsnotrexed/leonida/blob/main/make_game.py): `make_game.py`

### Shader translation

- [Shader carving](https://github.com/itsnotrexed/leonida/blob/main/tools/shader_carve.py): `tools/shader_carve.py`
- [Native unpacking](https://github.com/itsnotrexed/leonida/blob/main/tools/fssm_unpack.py): `tools/fssm_unpack.py`
- [RDNA disassembly](https://github.com/itsnotrexed/leonida/blob/main/tools/shader_disasm.py): `tools/shader_disasm.py`
- [Instruction parsing](https://github.com/itsnotrexed/leonida/blob/main/tools/shader_ir.py): `tools/shader_ir.py`
- [SPIR-V translation](https://github.com/itsnotrexed/leonida/blob/main/tools/rdna2spirv.py): `tools/rdna2spirv.py`
- [GPU pipeline cache](https://github.com/itsnotrexed/leonida/blob/main/runtime/test/vk_pipeline_check.cpp): `runtime/test/vk_pipeline_check.cpp`

### Asset export

- [Archive export](https://github.com/itsnotrexed/leonida/blob/main/tools/rpf9dump/Program.cs): `tools/rpf9dump/Program.cs`
- [Model export](https://github.com/itsnotrexed/leonida/blob/main/tools/rpf9dump/Program.cs): `tools/rpf9dump/Program.cs`
- [Texture export](https://github.com/itsnotrexed/leonida/blob/main/tools/tex_export.py): `tools/tex_export.py`
- [Audio bank support](https://github.com/itsnotrexed/leonida/blob/main/tools/awc_opus.py): `tools/awc_opus.py`

### Runtime support

- [PE mapper](https://github.com/itsnotrexed/leonida/blob/main/runtime/src/pe_loader.cpp): `runtime/src/pe_loader.cpp`
- [Runtime entry](https://github.com/itsnotrexed/leonida/blob/main/runtime/src/main.cpp): `runtime/src/main.cpp`
- [Shim registry](https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/registry.cpp): `runtime/shims/registry.cpp`
- [XMem shim](https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/xmem.cpp): `runtime/shims/xmem.cpp`
- [D3D12 shim](https://github.com/itsnotrexed/leonida/blob/main/runtime/shims/d3d12_xs.cpp): `runtime/shims/d3d12_xs.cpp`

### GPU layout research

- [Texture layout probe](https://github.com/itsnotrexed/leonida/blob/main/tools/tile_probe.py): `tools/tile_probe.py`
- [Swizzle search](https://github.com/itsnotrexed/leonida/blob/main/tools/swizzle_search.py): `tools/swizzle_search.py`
- [AMD detiling](https://github.com/itsnotrexed/leonida/blob/main/tools/amd_swizzle.py): `tools/amd_swizzle.py`
- [Block features](https://github.com/itsnotrexed/leonida/blob/main/tools/bc_feature.py): `tools/bc_feature.py`

### Other components

- **Game owner**

## Connections

- Game owner → Build orchestrator: supplies copy (evidence: `README.md`)
- Build orchestrator → Version manifest: checks version (evidence: `README.md`)
- Build orchestrator → Shader carving: runs shader stage (evidence: `README.md`)
- Shader carving → Native unpacking: passes carved code (evidence: `README.md`)
- Native unpacking → RDNA disassembly: passes native code (evidence: `README.md`)
- RDNA disassembly → Instruction parsing: parses disassembly
- Instruction parsing → SPIR-V translation: provides instructions (evidence: `tools/rdna2spirv.py`)
- Build orchestrator → Archive export: runs asset stage (evidence: `README.md`)
- Archive export → Model export: exports models (evidence: `README.md`)
- Archive export → Texture export: exports textures (evidence: `README.md`)
- Archive export → Audio bank support: decodes audio banks (evidence: `README.md`)
- Build orchestrator → Runtime entry: runs runtime stage (evidence: `README.md`)
- Runtime entry → PE mapper: loads image (evidence: `runtime/src/main.cpp`)
- PE mapper → Shim registry: resolves shims (evidence: `runtime/src/pe_loader.cpp`)
- Shim registry → XMem shim: registers entries (evidence: `runtime/shims/xmem.cpp`)
- Shim registry → D3D12 shim: registers entries (evidence: `runtime/shims/d3d12_xs.cpp`)
- Build orchestrator → GPU pipeline cache: creates cache (evidence: `README.md`)
- SPIR-V translation → GPU pipeline cache: provides shaders (evidence: `README.md`)
- Texture layout probe → Swizzle search: supplies features (evidence: `tools/swizzle_search.py`)
- Texture layout probe → AMD detiling: scores layouts (evidence: `tools/amd_swizzle.py`)
- Texture layout probe → Block features: extracts features
