$ show optiscaler/OptiScaler
OptiScaler is a graphics enhancement tool that intercepts upscaler calls from games and redirects them to user-selected backends, enabling upscaler replacement (e.g., DLSS to FSR/XeSS) and frame generation. It functions as a DLL that hooks into DirectX 11/12 and Vulkan APIs to inject custom rendering behavior. The architecture is modular with clear separation between hooking systems, upscaler implementations, frame generation, low-latency technologies, and configuration management. Key entry points include dllmain.h (DLL entry point), hooking modules in hooks/, feature providers in upscalers/, and frame generation implementations in framegen/. The system relies heavily on external SDKs (NVIDIA NGX, AMD FidelityFX, Intel XeSS) and uses Detours for API interception. While well-structured with good abstraction patterns, the codebase shows signs of maintenance complexity due to supporting multiple APIs and upscaler versions, creating combinatorial complexity in testing and compatibility.
The LLM identified 5 files worth highlighting for reuse:
Defines the common interface for all upscaler features across APIs (DX11, DX12, Vulkan). Enables runtime switching between different upscaling technologies (DLSS, FSR, XeSS) through a clean abstraction layer. Demonstrates strong interface segregation and polymorphism principles, allowing new upscalers to be added with minimal impact on core systems.
Implements the provider pattern for creating API-specific upscaler instances based on user configuration. Centralizes the creation logic for DX12 upscalers and handles API-specific initialization details. Shows good encapsulation of object creation and lifecycle management.
Provides safe Detours hooking utilities with validation macros and error handling. Abstracts the complexity of API hooking while providing consistent patterns for hook installation and removal across the codebase. Demonstrates careful resource management and error checking in a notoriously fragile area of code.
Implements a thread-safe singleton for sharing runtime state between modules (frame times, feature flags, GPU stats). Uses proper synchronization mechanisms and provides centralized access to critical runtime information. Shows good practice in managing shared state in a multi-threaded graphics environment.
Abstracts shader compilation and resource management across different graphics APIs. Provides a common interface for loading, compiling, and managing shaders while handling API-specific differences internally. Demonstrates good separation of concerns between shader logic and API-specific implementation details.