MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GlobalGraphicsInfo.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Core {
4
5//==============================================================================
6// GRAPHICS BACKEND CONFIGURATION (Vulkan/OpenGL/etc.)
7//==============================================================================
8
9/**
10 * @struct GraphicsBackendInfo
11 * @brief Configuration for graphics API backend (Vulkan/OpenGL/etc.)
12 *
13 * Separate from windowing - this is GPU/rendering configuration.
14 * GraphicsSurfaceInfo handles windows, this handles the graphics API.
15 */
16struct MAYAFLUX_API GraphicsBackendInfo {
17 /** @brief Enable validation layers (debug builds) */
18 bool enable_validation = true;
19
20 /** @brief Enable GPU debug markers (for profiling tools) */
21 bool enable_debug_markers = false;
22
23 /** @brief Required device features (Vulkan-specific) */
24 struct {
25 bool compute_shaders = true;
26 bool geometry_shaders = false;
27 bool tessellation_shaders = false;
28 bool multi_viewport = false;
29 bool sampler_anisotropy = true;
30 bool fill_mode_non_solid = false;
31 } required_features;
32
33 /** @brief Memory allocation strategy */
34 enum class MemoryStrategy : uint8_t {
35 CONSERVATIVE, ///< Minimize allocations
36 BALANCED, ///< Balance speed and memory
37 AGGRESSIVE ///< Maximize performance
38 } memory_strategy
39 = MemoryStrategy::BALANCED;
40
41 /** @brief Command buffer pooling strategy */
42 enum class CommandPooling : uint8_t {
43 PER_THREAD, ///< One pool per thread
44 SHARED, ///< Shared pool
45 PER_QUEUE ///< One pool per queue family
46 } command_pooling
47 = CommandPooling::PER_THREAD;
48
49 /** @brief Maximum number of frames in flight (GPU pipelining) */
50 uint32_t max_frames_in_flight = 2;
51
52 /** @brief Enable compute queue (separate from graphics) */
53 bool enable_compute_queue = true;
54
55 /** @brief Enable transfer queue (separate from graphics) */
56 bool enable_transfer_queue = false;
57
58 /** @brief Shader compilation strategy */
59 enum class ShaderCompilation : uint8_t {
60 RUNTIME, ///< Compile at runtime
61 PRECOMPILED, ///< Use pre-compiled SPIR-V
62 CACHED ///< Cache compiled shaders
63 } shader_compilation
64 = ShaderCompilation::CACHED;
65
66 /** @brief Shader cache directory (if caching enabled) */
67 std::filesystem::path shader_cache_dir = "cache/shaders";
68
69 /** @brief Backend-specific extensions to request */
70 std::vector<std::string> required_extensions;
71 std::vector<std::string> optional_extensions;
72};
73
74/**
75 * @struct GraphicsResourceLimits
76 * @brief Resource limits and budgets for graphics subsystem
77 *
78 * Prevents runaway resource usage, similar to audio buffer limits.
79 */
80struct MAYAFLUX_API GraphicsResourceLimits {
81 /** @brief Maximum number of concurrent windows */
82 uint32_t max_windows = 16;
83
84 /** @brief Maximum staging buffer size (MB) */
85 uint32_t max_staging_buffer_mb = 256;
86
87 /** @brief Maximum compute buffer size (MB) */
88 uint32_t max_compute_buffer_mb = 1024;
89
90 /** @brief Maximum texture cache size (MB) */
91 uint32_t max_texture_cache_mb = 2048;
92
93 /** @brief Maximum number of descriptor sets */
94 uint32_t max_descriptor_sets = 1024;
95
96 /** @brief Maximum number of pipeline state objects */
97 uint32_t max_pipelines = 256;
98};
99
100//==============================================================================
101// GLOBAL VISUAL STREAM INFO (Parallel to GlobalStreamInfo)
102//==============================================================================
103
104/**
105 * @struct GraphicsSurfaceInfo
106 * @brief System-wide configuration for visual stream processing
107 *
108 * Defines technical parameters for ALL windows/visual streams in the system.
109 * This is set once at subsystem initialization, similar to audio sample rate.
110 * Individual windows inherit these defaults but can override specific params.
111 */
112struct MAYAFLUX_API GraphicsSurfaceInfo {
113
114 /**
115 * @enum SurfaceFormat
116 * @brief Default pixel format for window surfaces (Vulkan-compatible)
117 */
118 enum class SurfaceFormat : uint8_t {
119 B8G8R8A8_SRGB, ///< Most common - 8-bit SRGB
120 R8G8B8A8_SRGB, ///< Alternative 8-bit SRGB
121 B8G8R8A8_UNORM, ///< 8-bit linear
122 R8G8B8A8_UNORM, ///< 8-bit linear
123 R16G16B16A16_SFLOAT, ///< 16-bit float HDR
124 A2B10G10R10_UNORM, ///< 10-bit HDR
125 R32G32B32A32_SFLOAT, ///< 32-bit float
126 };
127
128 /** @brief Default surface format for new windows */
129 SurfaceFormat format = SurfaceFormat::R8G8B8A8_SRGB;
130
131 /**
132 * @enum ColorSpace
133 * @brief Default color space for window surfaces
134 */
135 enum class ColorSpace : uint8_t {
136 SRGB_NONLINEAR, ///< Standard sRGB
137 EXTENDED_SRGB, ///< Extended sRGB for HDR
138 HDR10_ST2084, ///< HDR10 PQ
139 DISPLAY_P3, ///< DCI-P3
140 };
141
142 /** @brief Default color space for new windows */
143 ColorSpace color_space = ColorSpace::SRGB_NONLINEAR;
144
145 /**
146 * @enum PresentMode
147 * @brief Frame presentation strategy
148 */
149 enum class PresentMode : uint8_t {
150 IMMEDIATE, ///< No vsync, tear possible
151 MAILBOX, ///< Triple buffering, no tear
152 FIFO, ///< Vsync, no tear
153 FIFO_RELAXED, ///< Vsync, tear if late
154 };
155
156 /** @brief Default presentation mode for new windows */
157 PresentMode present_mode = PresentMode::FIFO;
158
159 /** @brief Default number of swapchain images (double/triple buffering) */
160 uint32_t image_count = 3;
161
162 /** @brief Enable region-based processing by default */
163 bool enable_regions = true;
164
165 /** @brief Maximum regions per window container */
166 uint32_t max_regions_per_window = 256;
167
168 /** @brief Enable HDR output if available */
169 bool enable_hdr {};
170
171 /** @brief Measure and report actual frame times */
172 bool measure_frame_time {};
173
174 /** @brief Backend-specific configuration parameters */
175 std::unordered_map<std::string, std::any> backend_options;
176};
177
178/**
179 * @struct GlfwPreInitConfig
180 * @brief Configuration hints for GLFW initialization
181 *
182 * Set before initializing the GLFW library. These affect how GLFW sets up
183 * its internal state and platform integration.
184 */
186 /**
187 * @enum Platform
188 * @brief Force a specific windowing platform on Linux
189 */
190 enum class Platform {
191 Default,
192 Wayland,
193 X11
194 } platform
196
197 /** this prevents crash on some wayland compositors */
199
201 bool cocoa_menubar = true;
202
203 /** @brief Request OpenGL debug context (if using OpenGL backend) */
204 bool headless {};
205};
206
207struct MAYAFLUX_API GlobalGraphicsConfig {
208 /** @brief Pre-initialization configuration for GLFW */
210
211 /** @brief System-wide configuration for visual stream processing */
213
214 /** @brief Graphics backend configuration */
216
217 /** @brief Resource limits */
219
220 /**
221 * @enum WindowingBackend
222 * @brief Windowing library selection
223 */
224 enum class WindowingBackend : uint8_t {
225 GLFW, ///< GLFW3 (default, cross-platform)
226 SDL, ///< SDL2 (alternative, if implemented)
227 NATIVE, ///< Platform-native (Win32/X11/Cocoa, if implemented)
228 NONE ///< No windowing (offscreen rendering only)
229 };
230
231 /**
232 * @enum VisualApi
233 * @brief Supported graphics APIs (backend selection)
234 */
235 enum class GraphicsApi : uint8_t {
236 VULKAN,
237 OPENGL,
238 METAL,
239 DIRECTX12
240 };
241
242 /** @brief Target frame rate for visual processing (Hz) */
243 uint32_t target_frame_rate = 60;
244
245 /** @brief Selected windowing backend */
246 WindowingBackend windowing_backend = WindowingBackend::GLFW;
247
248 /** @brief Selected graphics API for rendering */
249 GraphicsApi requested_api = GraphicsApi::VULKAN;
250};
251
252//==============================================================================
253// PER-WINDOW CREATION INFO (Parallel to audio ChannelConfig)
254//==============================================================================
255
256/**
257 * @struct WindowCreateInfo
258 * @brief Configuration for creating a single window instance
259 *
260 * Lightweight per-window parameters. Most settings inherited from
261 * GraphicsSurfaceInfo. This is like creating a new audio channel - you specify
262 * only what differs from global defaults.
263 */
264struct MAYAFLUX_API WindowCreateInfo {
265 /** @brief Window title/identifier */
266 std::string title = "MayaFlux Window";
267
268 /** @brief Initial window dimensions */
269 uint32_t width = 1920;
270 uint32_t height = 1080;
271
272 /** @brief Target monitor ID (-1 = primary monitor) */
273 int32_t monitor_id = -1;
274
275 /** @brief Start in fullscreen mode */
276 bool fullscreen = false;
277
278 /** @brief Window can be resized by user */
279 bool resizable = true;
280
281 /** @brief Show OS window decorations (title bar, borders) */
282 bool decorated = true;
283
284 /** @brief Transparent framebuffer (compositing) */
285 bool transparent = false;
286
287 /** @brief Window always on top */
288 bool floating = false;
289
290 /** @brief Register this window for processing (if false, no grpahics API handles visuals) */
291 bool register_for_processing = true;
292
293 /** @brief Override global surface format (nullopt = use global default) */
294 std::optional<GraphicsSurfaceInfo::SurfaceFormat> surface_format;
295
296 /** @brief Override global present mode (nullopt = use global default) */
297 std::optional<GraphicsSurfaceInfo::PresentMode> present_mode;
298
299 /** @brief Container dimensions (channels) */
300 struct {
301 uint32_t color_channels = 4;
302 bool has_depth = false;
303 bool has_stencil = false;
304 } container_format;
305};
306
307//==============================================================================
308// WINDOW RUNTIME STATE (Read-only, updated by subsystem)
309//==============================================================================
310
311/**
312 * @struct WindowState
313 * @brief Runtime state of a window (mutable by system, read by user)
314 *
315 * You don't set these - the windowing subsystem updates them as events occur.
316 */
318 uint32_t current_width = 0;
319 uint32_t current_height = 0;
320
321 bool is_visible = true;
322 bool is_focused = false;
323 bool is_minimized = false;
324 bool is_maximized = false;
325 bool is_hovered = false;
326
327 uint64_t frame_count = 0;
328 double last_present_time = 0.0;
329 double average_frame_time = 0.0;
330};
331
332//==============================================================================
333// INPUT CONFIGURATION (Runtime mutable)
334//==============================================================================
335
336/**
337 * @enum CursorMode
338 * @brief Cursor visibility and behavior
339 */
340enum class CursorMode : uint8_t {
341 NORMAL, ///< Visible and movable
342 HIDDEN, ///< Invisible but movable
343 DISABLED, ///< Invisible and locked (FPS camera)
344 CAPTURED, ///< Invisible, locked, raw motion
345};
346
347/**
348 * @struct InputConfig
349 * @brief Input configuration for a window
350 *
351 * Can be changed at runtime via window->set_input_config()
352 */
362
363//==============================================================================
364// WINDOW EVENTS
365//==============================================================================
366
367/**
368 * @enum WindowEventType
369 * @brief Types of window and input events
370 */
398
399/**
400 * @struct WindowEvent
401 * @brief Event data for window and input events
402 */
405 double timestamp;
406
407 struct ResizeData {
408 uint32_t width, height;
409 };
410 struct KeyData {
411 int32_t key, scancode, mods;
412 };
414 double x, y;
415 };
417 int32_t button, mods;
418 };
419 struct ScrollData {
421 };
422
423 using EventData = std::variant<
424 std::monostate,
426 KeyData,
430 std::any>;
431
433
434 WindowEvent() = default;
435 WindowEvent(const WindowEvent&) = default;
436 WindowEvent(WindowEvent&&) noexcept = default;
437 WindowEvent& operator=(const WindowEvent&) = default;
438 WindowEvent& operator=(WindowEvent&&) noexcept = default;
439 ~WindowEvent() = default;
440};
441;
442
443using WindowEventCallback = std::function<void(const WindowEvent&)>;
444
445//==============================================================================
446// MONITOR INFORMATION (System query, not per-window config)
447//==============================================================================
448
449/**
450 * @struct VideoMode
451 * @brief Monitor video mode
452 */
453struct VideoMode {
454 uint32_t width, height;
455 uint32_t refresh_rate;
456 uint8_t red_bits, green_bits, blue_bits;
457
458 bool operator==(const VideoMode& other) const
459 {
460 return width == other.width && height == other.height && refresh_rate == other.refresh_rate;
461 }
462};
463
464/**
465 * @struct MonitorInfo
466 * @brief Information about a physical display
467 */
469 int32_t id;
470 std::string name;
471 int32_t width_mm, height_mm;
473 bool is_primary = false;
474};
475
476} // namespace MayaFlux::Core
CursorMode
Cursor visibility and behavior.
@ DISABLED
Invisible and locked (FPS camera)
@ NORMAL
Visible and movable.
@ CAPTURED
Invisible, locked, raw motion.
@ HIDDEN
Invisible but movable.
WindowEventType
Types of window and input events.
std::function< void(const WindowEvent &)> WindowEventCallback
enum MayaFlux::Core::GlfwPreInitConfig::Platform platform
bool headless
Request OpenGL debug context (if using OpenGL backend)
Platform
Force a specific windowing platform on Linux.
bool disable_libdecor
this prevents crash on some wayland compositors
Configuration hints for GLFW initialization.
GraphicsSurfaceInfo surface_info
System-wide configuration for visual stream processing.
WindowingBackend
Windowing library selection.
GlfwPreInitConfig glfw_preinit_config
Pre-initialization configuration for GLFW.
GraphicsResourceLimits resource_limits
Resource limits.
GraphicsBackendInfo backend_info
Graphics backend configuration.
std::vector< std::string > required_extensions
Backend-specific extensions to request.
MemoryStrategy
Memory allocation strategy.
std::vector< std::string > optional_extensions
CommandPooling
Command buffer pooling strategy.
ShaderCompilation
Shader compilation strategy.
Configuration for graphics API backend (Vulkan/OpenGL/etc.)
Resource limits and budgets for graphics subsystem.
ColorSpace
Default color space for window surfaces.
SurfaceFormat
Default pixel format for window surfaces (Vulkan-compatible)
PresentMode
Frame presentation strategy.
std::unordered_map< std::string, std::any > backend_options
Backend-specific configuration parameters.
System-wide configuration for visual stream processing.
Input configuration for a window.
Information about a physical display.
bool operator==(const VideoMode &other) const
std::optional< GraphicsSurfaceInfo::PresentMode > present_mode
Override global present mode (nullopt = use global default)
std::optional< GraphicsSurfaceInfo::SurfaceFormat > surface_format
Override global surface format (nullopt = use global default)
Configuration for creating a single window instance.
std::variant< std::monostate, ResizeData, KeyData, MousePosData, MouseButtonData, ScrollData, std::any > EventData
WindowEvent(const WindowEvent &)=default
WindowEvent(WindowEvent &&) noexcept=default
Event data for window and input events.
Runtime state of a window (mutable by system, read by user)