/** * @file system/interfaces/graphics.h * @brief Abstract graphics system interface for dependency injection * * @copyright Copyright (c) 2026 Tom Clay * All rights reserved. * * @license BSD 3-Clause License * See LICENSE file in the project root for full license text. */ #pragma once #include // Forward declarations namespace rex::runtime { class FunctionDispatcher; } namespace rex::ui { class WindowedAppContext; } namespace rex::system { class KernelState; } namespace rex::system { class IGraphicsSystem { public: virtual ~IGraphicsSystem() = default; // Build the provider + presenter. Safe to call standalone (without a // Runtime) to stand up a window + ImGui for an installer. Idempotent. // Must be called before SetupGuestGpu if presentation is desired: some // backends (e.g. Vulkan) bake swapchain support into the provider, and // a headless provider from SetupGuestGpu cannot be upgraded in place. virtual X_STATUS SetupPresentation(ui::WindowedAppContext* app_context) = 0; // Wire the GPU into the guest address space: MMIO, command processor, // vsync worker. Needs the Runtime's dispatcher + kernel state. If // SetupPresentation has not been called, a headless provider is built. virtual X_STATUS SetupGuestGpu(runtime::FunctionDispatcher* function_dispatcher, KernelState* kernel_state) = 0; virtual bool has_presentation() const = 0; // One-shot convenience for callers that don't care about the split. X_STATUS Setup(runtime::FunctionDispatcher* function_dispatcher, KernelState* kernel_state, ui::WindowedAppContext* app_context, bool with_presentation) { if (with_presentation && !has_presentation()) { X_STATUS status = SetupPresentation(app_context); if (XFAILED(status)) { return status; } } return SetupGuestGpu(function_dispatcher, kernel_state); } virtual void Shutdown() = 0; }; } // namespace rex::system