# ragnarok93/lsfg-vk-android architecture

> Architecture diagram of the GitHub repository ragnarok93/lsfg-vk-android, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ragnarok93/lsfg-vk-android
- Repository: https://github.com/ragnarok93/lsfg-vk-android

## Overview

This repository provides an implicit Vulkan layer for Android frame generation, with a companion GTK configuration UI. The principal runtime path intercepts an application's swapchain and present calls, obtains frame inputs, dispatches LSFG compute work, and chains generated frames into presentation; disabled mode passes presentation through. The graph preserves the preprocessing, optical-flow, generation, Android AHardwareBuffer, synchronization, and telemetry capabilities described by the README. Runtime wiring is based on the README and sampled excerpts; unsampled hooks and integration details are represented only where documented.

Main entry points: [`framegen/v3.1p_src/context.cpp`](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/context.cpp) (LSFG context), [`src/context.cpp`](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/context.cpp) (Runtime context), [`src/layer_android.cpp`](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/layer_android.cpp) (Vulkan layer), [`src/hooks.cpp`](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/hooks.cpp) (WSI hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Vulkan runtime"]
  node_layer["Vulkan layer<br/>[layer_android.cpp]"]
  node_hooks["WSI hooks<br/>[hooks.cpp]"]
  node_context["Runtime context<br/>[context.cpp]"]
  node_scheduler["Adaptive scheduler"]
end

subgraph group_generation["Frame generation"]
  node_extract["Shader extraction<br/>[extract.cpp]"]
  node_gencontext["LSFG context<br/>[context.cpp]"]
  node_mipmaps["Mipmaps<br/>[mipmaps.cpp]"]
  node_alpha["Alpha stage<br/>[alpha.cpp]"]
  node_beta["Beta stage<br/>[beta.cpp]"]
  node_gamma["Gamma stage<br/>[gamma.cpp]"]
  node_delta["Delta stage<br/>[delta.cpp]"]
  node_generate["Frame synthesis<br/>[generate.cpp]"]
  node_core["Vulkan resources<br/>[device.cpp]"]
end

subgraph group_android["Android interoperability"]
  node_ahb["AHardwareBuffer"]
  node_diagnostics["Android diagnostics"]
end

subgraph group_configuration["Configuration and UI"]
  node_config["Runtime config<br/>[config.cpp]"]
  node_configfile["Config file"]
  node_ui["Settings UI<br/>[main_handler.rs]"]
  node_ui_config["UI config store<br/>[config.rs]"]
end

node_app(("Vulkan application"))

node_app -->|"Vulkan calls"| node_layer
node_layer -->|"dispatches WSI"| node_hooks
node_hooks -->|"routes present"| node_context
node_context -->|"reads settings"| node_config
node_context -.->|"adapts output"| node_scheduler
node_context -->|"submits frames"| node_gencontext
node_extract -->|"supplies shaders"| node_gencontext
node_gencontext -->|"dispatches"| node_mipmaps
node_gencontext -->|"dispatches"| node_alpha
node_gencontext -->|"dispatches"| node_beta
node_gencontext -->|"dispatches"| node_gamma
node_gencontext -->|"dispatches"| node_delta
node_gencontext -->|"dispatches"| node_generate
node_gencontext -->|"uses Vulkan"| node_core
node_ahb -->|"shares images"| node_gencontext
node_gencontext -->|"returns output"| node_ahb
node_hooks -->|"presents frames"| node_app
node_layer -.->|"records provenance"| node_diagnostics
node_configfile -->|"loads settings"| node_config
node_ui -->|"edits profiles"| node_ui_config
node_ui_config -->|"persists settings"| node_configfile

click node_layer "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/layer_android.cpp"
click node_hooks "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/hooks.cpp"
click node_context "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/context.cpp"
click node_config "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/config/config.cpp"
click node_scheduler "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/adaptive_scheduler.cpp"
click node_extract "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/extract/extract.cpp"
click node_gencontext "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/context.cpp"
click node_mipmaps "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/mipmaps.cpp"
click node_alpha "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/alpha.cpp"
click node_beta "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/beta.cpp"
click node_gamma "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/gamma.cpp"
click node_delta "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/delta.cpp"
click node_generate "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/generate.cpp"
click node_core "https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/src/core/device.cpp"
click node_diagnostics "https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/android_diagnostics.cpp"
click node_ui "https://github.com/ragnarok93/lsfg-vk-android/blob/release/ui/src/ui/main_handler.rs"
click node_ui_config "https://github.com/ragnarok93/lsfg-vk-android/blob/release/ui/src/config.rs"

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_layer,node_hooks,node_context,node_scheduler toneBlue
class node_extract,node_gencontext,node_mipmaps,node_alpha,node_beta,node_gamma,node_delta,node_generate,node_core toneAmber
class node_ahb,node_diagnostics toneMint
class node_config,node_configfile,node_ui,node_ui_config toneRose
class node_app toneIndigo
```

## Components

### Vulkan runtime

- [Vulkan layer](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/layer_android.cpp): `src/layer_android.cpp`
- [WSI hooks](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/hooks.cpp): `src/hooks.cpp`
- [Runtime context](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/context.cpp): `src/context.cpp`
- [Adaptive scheduler](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/adaptive_scheduler.cpp): `src/adaptive_scheduler.cpp`

### Frame generation

- [Shader extraction](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/extract/extract.cpp): `src/extract/extract.cpp`
- [LSFG context](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/context.cpp): `framegen/v3.1p_src/context.cpp`
- [Mipmaps](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/mipmaps.cpp): `framegen/v3.1p_src/shaders/mipmaps.cpp`
- [Alpha stage](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/alpha.cpp): `framegen/v3.1p_src/shaders/alpha.cpp`
- [Beta stage](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/beta.cpp): `framegen/v3.1p_src/shaders/beta.cpp`
- [Gamma stage](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/gamma.cpp): `framegen/v3.1p_src/shaders/gamma.cpp`
- [Delta stage](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/delta.cpp): `framegen/v3.1p_src/shaders/delta.cpp`
- [Frame synthesis](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/v3.1p_src/shaders/generate.cpp): `framegen/v3.1p_src/shaders/generate.cpp`
- [Vulkan resources](https://github.com/ragnarok93/lsfg-vk-android/blob/release/framegen/src/core/device.cpp): `framegen/src/core/device.cpp`

### Android interoperability

- **AHardwareBuffer**
- [Android diagnostics](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/android_diagnostics.cpp): `src/android_diagnostics.cpp`

### Configuration and UI

- [Runtime config](https://github.com/ragnarok93/lsfg-vk-android/blob/release/src/config/config.cpp): `src/config/config.cpp`
- **Config file**
- [Settings UI](https://github.com/ragnarok93/lsfg-vk-android/blob/release/ui/src/ui/main_handler.rs): `ui/src/ui/main_handler.rs`
- [UI config store](https://github.com/ragnarok93/lsfg-vk-android/blob/release/ui/src/config.rs): `ui/src/config.rs`

### Other components

- **Vulkan application**

## Connections

- Vulkan application → Vulkan layer: Vulkan calls
- Vulkan layer → WSI hooks: dispatches WSI
- WSI hooks → Runtime context: routes present
- Runtime context → Runtime config: reads settings
- Runtime context → Adaptive scheduler: adapts output
- Runtime context → LSFG context: submits frames
- Shader extraction → LSFG context: supplies shaders
- LSFG context → Mipmaps: dispatches
- LSFG context → Alpha stage: dispatches
- LSFG context → Beta stage: dispatches
- LSFG context → Gamma stage: dispatches
- LSFG context → Delta stage: dispatches
- LSFG context → Frame synthesis: dispatches
- LSFG context → Vulkan resources: uses Vulkan
- AHardwareBuffer → LSFG context: shares images
- LSFG context → AHardwareBuffer: returns output
- WSI hooks → Vulkan application: presents frames
- Vulkan layer → Android diagnostics: records provenance
- Config file → Runtime config: loads settings
- Settings UI → UI config store: edits profiles
- UI config store → Config file: persists settings
