# itsnotrexed/hookshot architecture

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

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

## Overview

Hookshot is a native Windows/Linux static recompilation of Ocarina of Time for Switch 2: the player supplies game files, and Hookshot builds a PC game that runs with a reimplemented system layer and Vulkan graphics. The README documents the build-and-play workflow and major features; sampled code shows the shader translation stages and NVN command recording. Several runtime subsystems are represented by their exact enclosing directories because their implementation files were not sampled, so those links are documented or marked unverified.

Main entry points: [`host/hos_main.c`](https://github.com/itsnotrexed/hookshot/blob/main/host/hos_main.c) (Native game), [`builder/HookshotBuilder/BuilderHome.cs`](https://github.com/itsnotrexed/hookshot/blob/main/builder/HookshotBuilder/BuilderHome.cs) (Hookshot Builder), [`gpu/vk/eden/shader_recompiler/frontend/ir/program.h`](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.h) (Shader IR), [`builder/linux/hookshot_builder.py`](https://github.com/itsnotrexed/hookshot/blob/main/builder/linux/hookshot_builder.py) (Linux Builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build and launch"]
  node_builder["Hookshot Builder<br/>[BuilderHome.cs]"]
  node_linux_builder["Linux Builder"]
end

subgraph group_runtime["Game runtime"]
  node_native_game["Native game<br/>[hos_main.c]"]
  node_system_layer["System reimplementation"]
  node_input_audio["Input and audio"]
  node_mods_saves["Mods and saves"]
end

subgraph group_graphics["Graphics and shaders"]
  node_nvn["NVN recording<br/>[nvn_native.c]"]
  node_vulkan["Vulkan renderer"]
  node_shader_capture["Shader capture<br/>[program_capture.h]"]
  node_shader_lowering["Ampere lowering<br/>[lower_to_maxwell.h]"]
  node_control_flow["Maxwell control flow<br/>[control_flow.h]"]
  node_shader_translate["Shader translation"]
  node_shader_ir["Shader IR<br/>[program.h]"]
  node_ir_opt["IR optimization"]
  node_spirv["SPIR-V emission<br/>[emit_spirv.cpp]"]
  node_pipeline_cache[("Pipeline cache")]
end

subgraph group_player["Player features"]
  node_menu_debug["Menu and debug tools"]
  node_upscaling["Upscaling and framegen"]
  node_save_editor["Save editor<br/>[server.py]"]
  node_saves["Save backups<br/>[Saves.cs]"]
end

node_player(("Player"))
node_game_input["Game files"]
node_external_updates["Update service"]

node_player -->|"starts build"| node_builder
node_player -->|"starts build"| node_linux_builder
node_game_input -->|"supplies files"| node_builder
node_game_input -->|"supplies files"| node_linux_builder
node_builder -->|"builds game"| node_native_game
node_linux_builder -->|"builds game"| node_native_game
node_player -->|"launches"| node_native_game
node_native_game -.->|"uses"| node_system_layer
node_native_game -->|"uses"| node_input_audio
node_native_game -->|"loads"| node_mods_saves
node_player -->|"configures"| node_menu_debug
node_menu_debug -->|"selects"| node_upscaling
node_native_game -->|"records GPU calls"| node_nvn
node_nvn -->|"replays commands"| node_vulkan
node_shader_capture -->|"lowers shaders"| node_shader_lowering
node_shader_lowering -->|"builds CFG"| node_control_flow
node_control_flow -->|"translates program"| node_shader_translate
node_shader_translate -.->|"produces IR"| node_shader_ir
node_shader_ir -->|"optimizes"| node_ir_opt
node_shader_ir -->|"emits SPIR-V"| node_spirv
node_spirv -.->|"provides shaders"| node_vulkan
node_vulkan -.->|"caches pipelines"| node_pipeline_cache
node_player -->|"edits saves"| node_save_editor
node_save_editor -.->|"writes with backups"| node_saves
node_player -->|"gets updates"| node_external_updates
node_external_updates -.->|"updates launcher"| node_builder

click node_builder "https://github.com/itsnotrexed/hookshot/blob/main/builder/HookshotBuilder/BuilderHome.cs"
click node_linux_builder "https://github.com/itsnotrexed/hookshot/blob/main/builder/linux/hookshot_builder.py"
click node_native_game "https://github.com/itsnotrexed/hookshot/blob/main/host/hos_main.c"
click node_system_layer "https://github.com/itsnotrexed/hookshot/tree/main/host"
click node_input_audio "https://github.com/itsnotrexed/hookshot/tree/main/host"
click node_mods_saves "https://github.com/itsnotrexed/hookshot/tree/main/host"
click node_menu_debug "https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk"
click node_nvn "https://github.com/itsnotrexed/hookshot/blob/main/host/nvn_native.c"
click node_vulkan "https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk"
click node_shader_capture "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ampere/program_capture.h"
click node_shader_lowering "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ampere/lower_to_maxwell.h"
click node_control_flow "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/control_flow.h"
click node_shader_translate "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.cpp"
click node_shader_ir "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.h"
click node_ir_opt "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp"
click node_spirv "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp"
click node_upscaling "https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk"
click node_pipeline_cache "https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/pipeline_cache_file.h"
click node_save_editor "https://github.com/itsnotrexed/hookshot/blob/main/nx2/saveedit/server.py"
click node_saves "https://github.com/itsnotrexed/hookshot/blob/main/builder/HookshotBuilder/Saves.cs"

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_linux_builder toneBlue
class node_native_game,node_system_layer,node_input_audio,node_mods_saves toneAmber
class node_nvn,node_vulkan,node_shader_capture,node_shader_lowering,node_control_flow,node_shader_translate,node_shader_ir,node_ir_opt,node_spirv,node_pipeline_cache toneMint
class node_menu_debug,node_upscaling,node_save_editor,node_saves toneRose
class node_player,node_game_input,node_external_updates toneIndigo
```

## Components

### Build and launch

- [Hookshot Builder](https://github.com/itsnotrexed/hookshot/blob/main/builder/HookshotBuilder/BuilderHome.cs): `builder/HookshotBuilder/BuilderHome.cs`
- [Linux Builder](https://github.com/itsnotrexed/hookshot/blob/main/builder/linux/hookshot_builder.py): `builder/linux/hookshot_builder.py`

### Game runtime

- [Native game](https://github.com/itsnotrexed/hookshot/blob/main/host/hos_main.c): `host/hos_main.c`
- [System reimplementation](https://github.com/itsnotrexed/hookshot/tree/main/host): `host`
- [Input and audio](https://github.com/itsnotrexed/hookshot/tree/main/host): `host`
- [Mods and saves](https://github.com/itsnotrexed/hookshot/tree/main/host): `host`

### Graphics and shaders

- [NVN recording](https://github.com/itsnotrexed/hookshot/blob/main/host/nvn_native.c): `host/nvn_native.c`
- [Vulkan renderer](https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk): `gpu/vk`
- [Shader capture](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ampere/program_capture.h): `gpu/vk/eden/shader_recompiler/frontend/ampere/program_capture.h`
- [Ampere lowering](https://github.com/itsnotrexed/hookshot/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 control flow](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/control_flow.h): `gpu/vk/eden/shader_recompiler/frontend/maxwell/control_flow.h`
- [Shader translation](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.cpp): `gpu/vk/eden/shader_recompiler/frontend/maxwell/translate_program.cpp`
- [Shader IR](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/frontend/ir/program.h): `gpu/vk/eden/shader_recompiler/frontend/ir/program.h`
- [IR optimization](https://github.com/itsnotrexed/hookshot/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 emission](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp): `gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp`
- [Pipeline cache](https://github.com/itsnotrexed/hookshot/blob/main/gpu/vk/pipeline_cache_file.h): `gpu/vk/pipeline_cache_file.h`

### Player features

- [Menu and debug tools](https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk): `gpu/vk`
- [Upscaling and framegen](https://github.com/itsnotrexed/hookshot/tree/main/gpu/vk): `gpu/vk`
- [Save editor](https://github.com/itsnotrexed/hookshot/blob/main/nx2/saveedit/server.py): `nx2/saveedit/server.py`
- [Save backups](https://github.com/itsnotrexed/hookshot/blob/main/builder/HookshotBuilder/Saves.cs): `builder/HookshotBuilder/Saves.cs`

### Other components

- **Player**
- **Game files**
- **Update service**

## Connections

- Player → Hookshot Builder: starts build
- Player → Linux Builder: starts build
- Game files → Hookshot Builder: supplies files
- Game files → Linux Builder: supplies files
- Hookshot Builder → Native game: builds game
- Linux Builder → Native game: builds game
- Player → Native game: launches
- Native game → System reimplementation: uses
- Native game → Input and audio: uses
- Native game → Mods and saves: loads
- Player → Menu and debug tools: configures
- Menu and debug tools → Upscaling and framegen: selects
- Native game → NVN recording: records GPU calls (evidence: `host/nvn_native.c`)
- NVN recording → Vulkan renderer: replays commands (evidence: `host/nvn_native.c`)
- Shader capture → Ampere lowering: lowers shaders (evidence: `nx2/bake_ds/bake_ds.cpp`)
- Ampere lowering → Maxwell control flow: builds CFG (evidence: `nx2/bake_ds/bake_ds.cpp`)
- Maxwell control flow → Shader translation: translates program
- Shader translation → Shader IR: produces IR
- Shader IR → IR optimization: optimizes (evidence: `gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp`)
- Shader IR → SPIR-V emission: emits SPIR-V
- SPIR-V emission → Vulkan renderer: provides shaders
- Vulkan renderer → Pipeline cache: caches pipelines
- Player → Save editor: edits saves
- Save editor → Save backups: writes with backups
- Player → Update service: gets updates
- Update service → Hookshot Builder: updates launcher
