# madebyjordan/longshot architecture

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

- Interactive diagram: https://gitdiagram.com/madebyjordan/longshot
- Repository: https://github.com/madebyjordan/longshot

## Overview

Longshot is a native Windows/Linux static recompilation of Ocarina of Time for Switch 2, not an emulator. Its user workflow starts with the user’s own game files, builds a local game folder with Longshot Builder, then runs the game; the README says both the builder and game-folder launcher check Longshot releases for updates. Internally, the sampled shader tool documents capture, lowering, Maxwell translation, and SPIR-V emission; the renderer’s draw path assembles WebGPU pipelines and submits draws. Several runtime connections are omitted because their call sites were not sampled.

Main entry points: [`gpu/shadertool.cpp`](https://github.com/madebyjordan/longshot/blob/main/gpu/shadertool.cpp) (Shader Tool), [`builder/linux/hookshot_builder.py`](https://github.com/madebyjordan/longshot/blob/main/builder/linux/hookshot_builder.py) (Linux Builder), [`gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp`](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp) (Shader IR), [`host/hos.h`](https://github.com/madebyjordan/longshot/blob/main/host/hos.h) (Host Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Local Build"]
  node_builder["Linux Builder"]
  node_winbuilder["Windows Builder<br/>[MainWindow.xaml.cs]"]
  node_gamebuild["Game Builder<br/>[make_game.py]"]
  node_update["Release Updates<br/>[linux_update.py]"]
end

subgraph group_runtime["Native Runtime"]
  node_launcher["Game Launcher<br/>[standalone.py]"]
end

subgraph group_shader["Shader Recompilation"]
  node_shader_tool["Shader Tool<br/>[shadertool.cpp]"]
  node_ampere["Ampere Lowering<br/>[lower_to_maxwell.h]"]
  node_maxwell["Maxwell Frontend"]
  node_ir["Shader IR<br/>[program.cpp]"]
  node_irblocks["IR Blocks<br/>[basic_block.h]"]
  node_irvalues["IR Values<br/>[value.h]"]
  node_optimize["IR Optimization"]
  node_spirv["SPIR-V Backend<br/>[emit_spirv.h]"]
  node_header["Program Metadata<br/>[program_header.h]"]
end

subgraph group_render["GPU Rendering"]
  node_renderer["Render Core<br/>[rx_core.cpp]"]
  node_draw["Draw Pipeline<br/>[rx_draw.cpp]"]
  node_renderstate["Renderer State<br/>[rx_internal.h]"]
  node_gpu_vk["Vulkan Backend<br/>[vk_main.cpp]"]
end

subgraph group_host["Host Services"]
  node_hostmain["Host Runtime<br/>[hos_main.c]"]
  node_hostapi["Host Services<br/>[hos.h]"]
  node_native_nvn["Native NVN<br/>[nvn_native.c]"]
  node_audio["Audio Services<br/>[nn_audio.c]"]
end

node_user(("Game owner"))

node_user -->|"builds locally"| node_builder
node_user -->|"builds locally"| node_winbuilder
node_builder -->|"invokes build"| node_gamebuild
node_gamebuild -.->|"creates game folder"| node_launcher
node_launcher -.->|"starts runtime"| node_hostmain
node_hostmain -.->|"uses host API"| node_hostapi
node_hostapi -->|"provides audio"| node_audio
node_hostapi -->|"provides graphics"| node_native_nvn
node_native_nvn -->|"uses renderer API"| node_renderstate
node_renderer -->|"uses shared state"| node_renderstate
node_draw -->|"reads renderer state"| node_renderstate
node_draw -.->|"uses Vulkan backend"| node_gpu_vk
node_shader_tool -->|"reads program header"| node_header
node_shader_tool -->|"captures and lowers"| node_ampere
node_shader_tool -->|"translates instructions"| node_maxwell
node_shader_tool -->|"emits SPIR-V"| node_spirv
node_maxwell -->|"produces program"| node_ir
node_ir -->|"uses blocks"| node_irblocks
node_ir -->|"dumps values"| node_irvalues
node_optimize -->|"rewrites blocks"| node_irblocks
node_optimize -->|"rewrites values"| node_irvalues
node_builder -->|"checks updates"| node_update
node_user -.->|"receives updates"| node_update

click node_builder "https://github.com/madebyjordan/longshot/blob/main/builder/linux/hookshot_builder.py"
click node_winbuilder "https://github.com/madebyjordan/longshot/blob/main/builder/HookshotBuilder/MainWindow.xaml.cs"
click node_gamebuild "https://github.com/madebyjordan/longshot/blob/main/nx2/make_game.py"
click node_launcher "https://github.com/madebyjordan/longshot/blob/main/nx2/standalone.py"
click node_hostmain "https://github.com/madebyjordan/longshot/blob/main/host/hos_main.c"
click node_hostapi "https://github.com/madebyjordan/longshot/blob/main/host/hos.h"
click node_native_nvn "https://github.com/madebyjordan/longshot/blob/main/host/nvn_native.c"
click node_renderer "https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_core.cpp"
click node_draw "https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_draw.cpp"
click node_renderstate "https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_internal.h"
click node_shader_tool "https://github.com/madebyjordan/longshot/blob/main/gpu/shadertool.cpp"
click node_ampere "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h"
click node_maxwell "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.h"
click node_ir "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp"
click node_irblocks "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/basic_block.h"
click node_irvalues "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/value.h"
click node_optimize "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp"
click node_spirv "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h"
click node_header "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/program_header.h"
click node_gpu_vk "https://github.com/madebyjordan/longshot/blob/main/gpu/vk/vk_main.cpp"
click node_audio "https://github.com/madebyjordan/longshot/blob/main/host/nn_audio.c"
click node_update "https://github.com/madebyjordan/longshot/blob/main/builder/linux/linux_update.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_builder,node_winbuilder,node_gamebuild,node_update toneBlue
class node_launcher toneAmber
class node_shader_tool,node_ampere,node_maxwell,node_ir,node_irblocks,node_irvalues,node_optimize,node_spirv,node_header toneMint
class node_renderer,node_draw,node_renderstate,node_gpu_vk toneRose
class node_hostmain,node_hostapi,node_native_nvn,node_audio,node_user toneIndigo
```

## Components

### Local Build

- [Linux Builder](https://github.com/madebyjordan/longshot/blob/main/builder/linux/hookshot_builder.py): `builder/linux/hookshot_builder.py`
- [Windows Builder](https://github.com/madebyjordan/longshot/blob/main/builder/HookshotBuilder/MainWindow.xaml.cs): `builder/HookshotBuilder/MainWindow.xaml.cs`
- [Game Builder](https://github.com/madebyjordan/longshot/blob/main/nx2/make_game.py): `nx2/make_game.py`
- [Release Updates](https://github.com/madebyjordan/longshot/blob/main/builder/linux/linux_update.py): `builder/linux/linux_update.py`

### Native Runtime

- [Game Launcher](https://github.com/madebyjordan/longshot/blob/main/nx2/standalone.py): `nx2/standalone.py`

### Shader Recompilation

- [Shader Tool](https://github.com/madebyjordan/longshot/blob/main/gpu/shadertool.cpp): `gpu/shadertool.cpp`
- [Ampere Lowering](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h): `gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h`
- [Maxwell Frontend](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.h): `gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.h`
- [Shader IR](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp): `gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp`
- [IR Blocks](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/basic_block.h): `gpu/vk/eden/shader_recompiler/frontend/ir/basic_block.h`
- [IR Values](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/value.h): `gpu/vk/eden/shader_recompiler/frontend/ir/value.h`
- [IR Optimization](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp): `gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp`
- [SPIR-V Backend](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h): `gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h`
- [Program Metadata](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/eden/shader_recompiler/program_header.h): `gpu/vk/eden/shader_recompiler/program_header.h`

### GPU Rendering

- [Render Core](https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_core.cpp): `gpu/render/rx_core.cpp`
- [Draw Pipeline](https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_draw.cpp): `gpu/render/rx_draw.cpp`
- [Renderer State](https://github.com/madebyjordan/longshot/blob/main/gpu/render/rx_internal.h): `gpu/render/rx_internal.h`
- [Vulkan Backend](https://github.com/madebyjordan/longshot/blob/main/gpu/vk/vk_main.cpp): `gpu/vk/vk_main.cpp`

### Host Services

- [Host Runtime](https://github.com/madebyjordan/longshot/blob/main/host/hos_main.c): `host/hos_main.c`
- [Host Services](https://github.com/madebyjordan/longshot/blob/main/host/hos.h): `host/hos.h`
- [Native NVN](https://github.com/madebyjordan/longshot/blob/main/host/nvn_native.c): `host/nvn_native.c`
- [Audio Services](https://github.com/madebyjordan/longshot/blob/main/host/nn_audio.c): `host/nn_audio.c`

### Other components

- **Game owner**

## Connections

- Game owner → Linux Builder: builds locally
- Game owner → Windows Builder: builds locally
- Linux Builder → Game Builder: invokes build (evidence: `builder/linux/hookshot_builder.py`)
- Game Builder → Game Launcher: creates game folder (evidence: `nx2/make_game.py`)
- Game Launcher → Host Runtime: starts runtime
- Host Runtime → Host Services: uses host API
- Host Services → Audio Services: provides audio (evidence: `host/nn_audio.c`)
- Host Services → Native NVN: provides graphics (evidence: `host/nvn_native.c`)
- Native NVN → Renderer State: uses renderer API (evidence: `host/nvn_native.c`)
- Render Core → Renderer State: uses shared state (evidence: `gpu/render/rx_internal.h`)
- Draw Pipeline → Renderer State: reads renderer state (evidence: `gpu/render/rx_draw.cpp`)
- Draw Pipeline → Vulkan Backend: uses Vulkan backend
- Shader Tool → Program Metadata: reads program header (evidence: `gpu/shadertool.cpp`)
- Shader Tool → Ampere Lowering: captures and lowers (evidence: `gpu/shadertool.cpp`)
- Shader Tool → Maxwell Frontend: translates instructions (evidence: `gpu/shadertool.cpp`)
- Shader Tool → SPIR-V Backend: emits SPIR-V (evidence: `gpu/shadertool.cpp`)
- Maxwell Frontend → Shader IR: produces program
- Shader IR → IR Blocks: uses blocks (evidence: `gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp`)
- Shader IR → IR Values: dumps values (evidence: `gpu/vk/eden/shader_recompiler/frontend/ir/program.cpp`)
- IR Optimization → IR Blocks: rewrites blocks (evidence: `gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp`)
- IR Optimization → IR Values: rewrites values (evidence: `gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp`)
- Linux Builder → Release Updates: checks updates (evidence: `builder/linux/hookshot_builder.py`)
- Game owner → Release Updates: receives updates
