# petrgeorgievsky/gtarenderhook architecture

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

- Interactive diagram: https://gitdiagram.com/petrgeorgievsky/gtarenderhook
- Repository: https://github.com/petrgeorgievsky/gtarenderhook

## Overview

##### Core Project Type and Purpose
- This project is a game mod/rendering hook designed to intercept and redirect GTA’s (GTA 3, GTA VC, GTA SA) native rendering calls.
- It implements two graphics backends – one based on DirectX 11 and one on Vulkan (with experimental ray tracing features) – and uses a shared memory task queue to decouple game rendering from a more advanced, external GPU processing pipeline.

##### Break Down the Main Components
a. Hook Modules for Multiple GTA Versions:
- Components like “gtaRenderHook”, “gta_3_render_hook”, “gta_sa_render_hook”, and “gta_vc_render_hook” represent different versions.
- Their role is to intercept game rendering functions and forward frame data or commands.

b. Shared Memory Task Queue:
- This is the communication bridge between the game’s rendering code and the external rendering engine.
- It queues tasks (such as asset uploads, command lists, resolution queries, etc.) for asynchronous processing.

c. Rendering Engine Backends:
- The rendering engine is implemented in libraries such as “rh_engine_lib” and “rw_rh_engine_lib”.
- This engine handles resource loading, asset management (textures, materials, meshes), building acceleration structures (BLAS/TLAS), compute shader-driven animation, ray-tracing pipelines, deferred shading, and post-processing effects.
- It has separate pipelines for DirectX 11 and Vulkan (including advanced ray tracing using vk_nv_ray_tracing, soon to be replaced by KHR).

d. GPU and Shader Integration:
- The system makes heavy use of shader programs (HLSL for DirectX, GLSL/comp shader for Vulkan) stored in dedicated shader directories.
- These shaders implement various effects such as ambient occlusion, tiled light culling, bilateral blurring, deferred composition, and reflections.

e. Build & Test Infrastructure (Auxiliary):
- Directories like “Tests” contain several subprojects that demonstrate or stress-test individual rendering features.
- CMake files, configuration files, and project files (Visual Studio solutions) indicate that the system is modular and can be built per component.

##### Final Checklist for the Principal Software Engineer
- Component is clearly labeled.
- Essential architectural elements: multiple GTA hook versions, the shared memory task queue, the dual graphics API implementations (DirectX 11 and Vulkan with ray tracing), and the supporting modules (configuration, debugging, and tests).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["GAME PROCESS (GTA Execution)"]:::external

    subgraph "HOOK LAYER"
        B["gtaRenderHook - General Hook Module"]:::hook
        C["gta_3_render_hook - GTA 3 Hook"]:::hook
        D["gta_sa_render_hook - GTA SA Hook"]:::hook
        E["gta_vc_render_hook - GTA VC Hook"]:::hook
        F["gtaRenderHook Shaders"]:::shader
    end

    A -->|"triggers_hooks"| B
    B -->|"calls"| C
    B --> D
    B --> E
    B --> F

    subgraph "SHARED MEMORY TASK QUEUE"
        SM["Shared Memory Task Queue"]:::mem
        SMHeader["Queue Client Header"]:::mem
        SMSource["Queue Client Source"]:::mem
    end

    F -->|"forwards_tasks"| SM
    SM --> SMHeader
    SM --> SMSource

    subgraph "RENDERING ENGINE"
        subgraph "DirectX 11 Renderer"
            DX["D3D11 Renderer Backend"]:::dx
            DXShaders["D3D11 Shaders"]:::shader
            DX -->|"executes_render_passes"| DXShaders
        end
        subgraph "Vulkan Renderer"
            VUL["Vulkan Renderer Backend (Experimental Ray Tracing)"]:::vulkan
            VULShaders["Vulkan Shaders"]:::shader
            VUL -->|"executes_render_passes"| VULShaders
        end
    end

    SM -->|"sends_task_data"| DX
    SM -->|"sends_task_data"| VUL

    DXShaders -->|"outputs_to_GPU"| GPU["GPU & Output Device"]:::gpu
    VULShaders -->|"outputs_to_GPU"| GPU

    H["Config & Debug Utilities"]:::external
    H -->|"provides_config"| B
    H -->|"provides_debug"| DX

    T["Tests - Build & Integration Tests"]:::test
    T ---|"validates"| B
    T ---|"validates"| DX
    T ---|"validates"| VUL

    click B "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/gtaRenderHook"
    click C "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/gta_3_render_hook"
    click D "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/gta_sa_render_hook"
    click E "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/gta_vc_render_hook"
    click F "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/gtaRenderHook/shaders"
    click SMHeader "https://github.com/petrgeorgievsky/gtarenderhook/blob/development/rw_rh_engine_lib/ipc/shared_memory_queue_client.h"
    click SMSource "https://github.com/petrgeorgievsky/gtarenderhook/blob/development/rw_rh_engine_lib/ipc/shared_memory_queue_client.cpp"
    click DX "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/rh_engine_lib/Engine/D3D11Impl"
    click VUL "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/rh_engine_lib/Engine/VulkanImpl"
    click DXShaders "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/shaders/d3d11"
    click VULShaders "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/shaders/vulkan"
    click T "https://github.com/petrgeorgievsky/gtarenderhook/tree/development/Tests"

    classDef external fill:#f0f,stroke:#333,stroke-width:2px;
    classDef hook fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef mem fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef dx fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef vulkan fill:#ffe599,stroke:#333,stroke-width:2px;
    classDef shader fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef gpu fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef test fill:#c9daf8,stroke:#333,stroke-width:2px;
```
