MayaFlux 0.4.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 = MemoryStrategy::BALANCED;
39
40 /** @brief Command buffer pooling strategy */
41 enum class CommandPooling : uint8_t {
42 PER_THREAD, ///< One pool per thread
43 SHARED, ///< Shared pool
44 PER_QUEUE ///< One pool per queue family
45 } command_pooling = CommandPooling::PER_THREAD;
46
47 /** @brief Maximum number of frames in flight (GPU pipelining) */
48 uint32_t max_frames_in_flight = 2;
49
50 /** @brief Enable compute queue (separate from graphics) */
51 bool enable_compute_queue = true;
52
53 /** @brief Enable transfer queue (separate from graphics) */
54 bool enable_transfer_queue = false;
55
56 /** @brief Shader compilation strategy */
57 enum class ShaderCompilation : uint8_t {
58 RUNTIME, ///< Compile at runtime
59 PRECOMPILED, ///< Use pre-compiled SPIR-V
60 CACHED ///< Cache compiled shaders
61 } shader_compilation = ShaderCompilation::CACHED;
62
63 /** @brief Shader cache directory (if caching enabled) */
64 std::filesystem::path shader_cache_dir = "cache/shaders";
65
66 /** @brief Backend-specific extensions to request */
67 std::vector<std::string> required_extensions;
68 std::vector<std::string> optional_extensions;
69};
70
71/**
72 * @struct GraphicsResourceLimits
73 * @brief Resource limits and budgets for graphics subsystem
74 *
75 * Prevents runaway resource usage, similar to audio buffer limits.
76 */
77struct MAYAFLUX_API GraphicsResourceLimits {
78 /** @brief Maximum number of concurrent windows */
79 uint32_t max_windows = 16;
80
81 /** @brief Maximum staging buffer size (MB) */
82 uint32_t max_staging_buffer_mb = 256;
83
84 /** @brief Maximum compute buffer size (MB) */
85 uint32_t max_compute_buffer_mb = 1024;
86
87 /** @brief Maximum texture cache size (MB) */
88 uint32_t max_texture_cache_mb = 2048;
89
90 /** @brief Maximum number of descriptor sets */
91 uint32_t max_descriptor_sets = 1024;
92
93 /** @brief Maximum number of pipeline state objects */
94 uint32_t max_pipelines = 256;
95};
96
97//==============================================================================
98// GLOBAL VISUAL STREAM INFO (Parallel to GlobalStreamInfo)
99//==============================================================================
100
101/**
102 * @struct GraphicsSurfaceInfo
103 * @brief System-wide configuration for visual stream processing
104 *
105 * Defines technical parameters for ALL windows/visual streams in the system.
106 * This is set once at subsystem initialization, similar to audio sample rate.
107 * Individual windows inherit these defaults but can override specific params.
108 */
109struct MAYAFLUX_API GraphicsSurfaceInfo {
110
111 /**
112 * @enum SurfaceFormat
113 * @brief Default pixel format for window surfaces (Vulkan-compatible)
114 */
115 enum class SurfaceFormat : uint8_t {
116 B8G8R8A8_SRGB, ///< Most common - 8-bit SRGB
117 R8G8B8A8_SRGB, ///< Alternative 8-bit SRGB
118 B8G8R8A8_UNORM, ///< 8-bit linear
119 R8G8B8A8_UNORM, ///< 8-bit linear
120 R16G16B16A16_SFLOAT, ///< 16-bit float HDR
121 A2B10G10R10_UNORM, ///< 10-bit HDR
122 R32G32B32A32_SFLOAT, ///< 32-bit float
123 };
124
125 /** @brief Default surface format for new windows */
126 SurfaceFormat format = SurfaceFormat::B8G8R8A8_SRGB;
127
128 /**
129 * @enum ColorSpace
130 * @brief Default color space for window surfaces
131 */
132 enum class ColorSpace : uint8_t {
133 SRGB_NONLINEAR, ///< Standard sRGB
134 EXTENDED_SRGB, ///< Extended sRGB for HDR
135 HDR10_ST2084, ///< HDR10 PQ
136 DISPLAY_P3, ///< DCI-P3
137 };
138
139 /** @brief Default color space for new windows */
140 ColorSpace color_space = ColorSpace::SRGB_NONLINEAR;
141
142 /**
143 * @enum PresentMode
144 * @brief Frame presentation strategy
145 */
146 enum class PresentMode : uint8_t {
147 IMMEDIATE, ///< No vsync, tear possible
148 MAILBOX, ///< Triple buffering, no tear
149 FIFO, ///< Vsync, no tear
150 FIFO_RELAXED, ///< Vsync, tear if late
151 };
152
153 /** @brief Default presentation mode for new windows */
154 PresentMode present_mode = PresentMode::FIFO;
155
156 /** @brief Default number of swapchain images (double/triple buffering) */
157 uint32_t image_count = 3;
158
159 /** @brief Enable region-based processing by default */
160 bool enable_regions = true;
161
162 /** @brief Maximum regions per window container */
163 uint32_t max_regions_per_window = 256;
164
165 /** @brief Enable HDR output if available */
166 bool enable_hdr {};
167
168 /** @brief Measure and report actual frame times */
169 bool measure_frame_time {};
170
171 /** @brief Backend-specific configuration parameters */
172 std::unordered_map<std::string, std::any> backend_options;
173};
174
175/**
176 * @struct GlfwPreInitConfig
177 * @brief Configuration hints for GLFW initialization
178 *
179 * Set before initializing the GLFW library. These affect how GLFW sets up
180 * its internal state and platform integration.
181 */
183 /**
184 * @enum Platform
185 * @brief Force a specific windowing platform on Linux
186 */
187 enum class Platform {
188 Default,
189 Wayland,
190 X11
191 } platform
193
194 /** this prevents crash on some wayland compositors */
196
198 bool cocoa_menubar = true;
199
200 /** @brief Request OpenGL debug context (if using OpenGL backend) */
201 bool headless {};
202};
203
204/**
205 * @struct TextConfig
206 * @brief Default font configuration for Portal::Text.
207 *
208 * When present, GraphicsSubsystem initializes Portal::Text and attempts to
209 * load the specified font as the system default. Users may call
210 * Portal::Text::set_default_font() at any time after initialization to
211 * replace or augment this.
212 *
213 * When absent, Portal::Text is still initialized but no default atlas is
214 * created; any call to InkPress that requires a default atlas will log an
215 * error until the user sets one explicitly.
216 */
218 /** @brief Font family name forwarded to Platform::find_font(). */
219 std::string family;
220
221 /** @brief Optional style hint (e.g. "Regular", "Bold"). */
222 std::string style;
223
224 /** @brief Glyph rasterization height in pixels. */
225 uint32_t pixel_size { 24 };
226
227 /** @brief Atlas texture dimension (power of two). */
228 uint32_t atlas_size { 512 };
229};
230
231struct MAYAFLUX_API GlobalGraphicsConfig {
232 /** @brief Pre-initialization configuration for GLFW */
234
235 /** @brief System-wide configuration for visual stream processing */
237
238 /** @brief Graphics backend configuration */
240
241 /** @brief Resource limits */
243
244 /**
245 * @enum WindowingBackend
246 * @brief Windowing library selection
247 */
248 enum class WindowingBackend : uint8_t {
249 GLFW, ///< GLFW3 (default, cross-platform)
250 SDL, ///< SDL2 (alternative, if implemented)
251 NATIVE, ///< Platform-native (Win32/X11/Cocoa, if implemented)
252 NONE ///< No windowing (offscreen rendering only)
253 };
254
255 /**
256 * @enum VisualApi
257 * @brief Supported graphics APIs (backend selection)
258 */
259 enum class GraphicsApi : uint8_t {
260 VULKAN,
261 OPENGL,
262 METAL,
263 DIRECTX12
264 };
265
266 /** @brief Target frame rate for visual processing (Hz) */
267 uint32_t target_frame_rate = 60;
268
269 /** @brief Selected windowing backend */
270 WindowingBackend windowing_backend = WindowingBackend::GLFW;
271
272 /** @brief Selected graphics API for rendering */
273 GraphicsApi requested_api = GraphicsApi::VULKAN;
274
275 /** @brief Default font for Portal::Text. */
276 TextConfig text_config {
277#if defined(MAYAFLUX_PLATFORM_LINUX)
278 "sans-serif", "", 24, 512
279#elif defined(MAYAFLUX_PLATFORM_MACOS)
280 "Helvetica Neue", "", 24, 512
281#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
282 "Segoe UI", "", 24, 512
283#else
284 "sans-serif", "", 24, 512
285#endif
286 };
287};
288
289//==============================================================================
290// PER-WINDOW CREATION INFO (Parallel to audio ChannelConfig)
291//==============================================================================
292
293/**
294 * @struct WindowCreateInfo
295 * @brief Configuration for creating a single window instance
296 *
297 * Lightweight per-window parameters. Most settings inherited from
298 * GraphicsSurfaceInfo. This is like creating a new audio channel - you specify
299 * only what differs from global defaults.
300 */
301struct MAYAFLUX_API WindowCreateInfo {
302 /** @brief Window title/identifier */
303 std::string title { "MayaFlux Window" };
304
305 /** @brief Initial window dimensions */
306 uint32_t width { 1920 };
307 uint32_t height { 1080 };
308
309 /** @brief Target monitor ID (-1 = primary monitor) */
310 int32_t monitor_id { -1 };
311
312 /** @brief Start in fullscreen mode */
313 bool fullscreen {};
314
315 /** @brief Window can be resized by user */
316 bool resizable { true };
317
318 /** @brief Show OS window decorations (title bar, borders) */
319 bool decorated { true };
320
321 /** @brief Transparent framebuffer (compositing) */
322 bool transparent {};
323
324 /** @brief Window always on top */
325 bool floating {};
326
327 /** @brief Register this window for processing (if false, no grpahics API handles visuals) */
328 bool register_for_processing { true };
329
330 /** @brief Override global surface format (nullopt = use global default) */
331 std::optional<GraphicsSurfaceInfo::SurfaceFormat> surface_format;
332
333 /** @brief Override global present mode (nullopt = use global default) */
334 std::optional<GraphicsSurfaceInfo::PresentMode> present_mode;
335
336 /** @brief Container dimensions (channels) */
337 struct {
338 uint32_t color_channels { 4 };
339 bool has_depth {};
340 bool has_stencil {};
341 } container_format;
342
343 std::array<float, 4> clear_color { { 0.0F, 0.0F, 0.0F, 1.0F } };
344};
345
346//==============================================================================
347// WINDOW RUNTIME STATE (Read-only, updated by subsystem)
348//==============================================================================
349
350/**
351 * @struct WindowState
352 * @brief Runtime state of a window (mutable by system, read by user)
353 *
354 * You don't set these - the windowing subsystem updates them as events occur.
355 */
357 uint32_t current_width = 0;
358 uint32_t current_height = 0;
359
360 bool is_visible = true;
361 bool is_focused = false;
362 bool is_minimized = false;
363 bool is_maximized = false;
364 bool is_hovered = false;
365
366 uint64_t frame_count = 0;
367 double last_present_time = 0.0;
368 double average_frame_time = 0.0;
369};
370
371//==============================================================================
372// INPUT CONFIGURATION (Runtime mutable)
373//==============================================================================
374
375/**
376 * @enum CursorMode
377 * @brief Cursor visibility and behavior
378 */
379enum class CursorMode : uint8_t {
380 NORMAL, ///< Visible and movable
381 HIDDEN, ///< Invisible but movable
382 DISABLED, ///< Invisible and locked (FPS camera)
383 CAPTURED, ///< Invisible, locked, raw motion
384};
385
386/**
387 * @struct InputConfig
388 * @brief Input configuration for a window
389 *
390 * Can be changed at runtime via window->set_input_config()
391 */
401
402//==============================================================================
403// WINDOW EVENTS
404//==============================================================================
405
406/**
407 * @enum WindowEventType
408 * @brief Types of window and input events
409 */
437
438/**
439 * @struct WindowEvent
440 * @brief Event data for window and input events
441 */
444 double timestamp;
445
446 struct ResizeData {
447 uint32_t width, height;
448 };
449 struct KeyData {
450 int16_t key;
451 int32_t scancode, mods;
452 };
454 double x, y;
455 };
457 int8_t button;
458 int32_t mods;
459 };
460 struct ScrollData {
462 };
463
464 using EventData = std::variant<
465 std::monostate,
467 KeyData,
471 std::any>;
472
474
475 WindowEvent() = default;
476 WindowEvent(const WindowEvent&) = default;
477 WindowEvent(WindowEvent&&) noexcept = default;
478 WindowEvent& operator=(const WindowEvent&) = default;
479 WindowEvent& operator=(WindowEvent&&) noexcept = default;
480 ~WindowEvent() = default;
481};
482
483using WindowEventCallback = std::function<void(const WindowEvent&)>;
484
485//==============================================================================
486// MONITOR INFORMATION (System query, not per-window config)
487//==============================================================================
488
489/**
490 * @struct VideoMode
491 * @brief Monitor video mode
492 */
493struct VideoMode {
494 uint32_t width, height;
495 uint32_t refresh_rate;
496 uint8_t red_bits, green_bits, blue_bits;
497
498 bool operator==(const VideoMode& other) const
499 {
500 return width == other.width && height == other.height && refresh_rate == other.refresh_rate;
501 }
502};
503
504/**
505 * @struct MonitorInfo
506 * @brief Information about a physical display
507 */
509 int32_t id;
510 std::string name;
511 int32_t width_mm, height_mm;
513 bool is_primary = false;
514};
515
516} // namespace MayaFlux::Core
uint32_t width
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.
std::string style
Optional style hint (e.g.
uint32_t atlas_size
Atlas texture dimension (power of two).
uint32_t pixel_size
Glyph rasterization height in pixels.
std::string family
Font family name forwarded to Platform::find_font().
Default font configuration for Portal::Text.
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)