MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VKContext.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "VKDevice.hpp"
5
6namespace MayaFlux::Core {
7
8class Window;
9
10/**
11 * @class VKContext
12 * @brief High-level wrapper for Vulkan instance and device
13 *
14 * Manages the complete Vulkan context lifecycle.
15 */
16class VKContext {
17public:
18 VKContext() = default;
19 ~VKContext() = default;
20
21 /**
22 * @brief Initialize Vulkan context
23 * @param global_config Global graphics configuration
24 * @param enable_validation Enable validation layers
25 * @param required_extensions Required instance extensions
26 * @return true if successful
27 */
28 bool initialize(const GlobalGraphicsConfig& graphics_config, bool enable_validation = true,
29 const std::vector<const char*>& required_extensions = {});
30
31 /**
32 * @brief Cleanup all Vulkan resources
33 */
34 void cleanup();
35
36 /**
37 * @brief Get Vulkan instance
38 */
39 [[nodiscard]] vk::Instance get_instance() const { return m_instance.get_instance(); }
40
41 /**
42 * @brief Get physical device
43 */
44 [[nodiscard]] vk::PhysicalDevice get_physical_device() const { return m_device.get_physical_device(); }
45
46 /**
47 * @brief Get logical device
48 */
49 [[nodiscard]] vk::Device get_device() const { return m_device.get_device(); }
50
51 /**
52 * @brief Get graphics queue
53 */
54 [[nodiscard]] vk::Queue get_graphics_queue() const { return m_device.get_graphics_queue(); }
55
56 /**
57 * @brief Get compute queue
58 */
59 [[nodiscard]] vk::Queue get_compute_queue() const { return m_device.get_compute_queue(); }
60
61 /**
62 * @brief Get transfer queue
63 */
64 [[nodiscard]] vk::Queue get_transfer_queue() const { return m_device.get_transfer_queue(); }
65
66 /**
67 * @brief Get queue family indices
68 */
69 [[nodiscard]] const QueueFamilyIndices& get_queue_families() const
70 {
72 }
73
74 /**
75 * @brief Update presentation support for a surface
76 * @param surface Surface to check
77 * @return true if presentation is supported
78 */
79 bool update_present_family(vk::SurfaceKHR surface);
80
81 /**
82 * @brief Create surface from window's native handles
83 * @param window Window to create surface for
84 * @return Surface handle, or null on failure
85 */
86 vk::SurfaceKHR create_surface(std::shared_ptr<Window> window);
87
88 /**
89 * @brief Destroy a specific surface
90 * Called when window is unregistered
91 */
92 void destroy_surface(vk::SurfaceKHR surface);
93
94 /**
95 * @brief Wait for device idle
96 */
97 void wait_idle() const { m_device.wait_idle(); }
98
99 /**
100 * @brief Get graphics surface info
101 */
103
104private:
107
109
110 std::vector<vk::SurfaceKHR> m_surfaces;
111};
112
113}
void wait_idle() const
Wait for device idle.
Definition VKContext.hpp:97
bool update_present_family(vk::SurfaceKHR surface)
Update presentation support for a surface.
vk::Device get_device() const
Get logical device.
Definition VKContext.hpp:49
vk::Queue get_compute_queue() const
Get compute queue.
Definition VKContext.hpp:59
vk::SurfaceKHR create_surface(std::shared_ptr< Window > window)
Create surface from window's native handles.
Definition VKContext.cpp:56
const GraphicsSurfaceInfo & get_surface_info() const
Get graphics surface info.
vk::Queue get_graphics_queue() const
Get graphics queue.
Definition VKContext.hpp:54
std::vector< vk::SurfaceKHR > m_surfaces
void cleanup()
Cleanup all Vulkan resources.
GlobalGraphicsConfig m_graphics_config
vk::Queue get_transfer_queue() const
Get transfer queue.
Definition VKContext.hpp:64
vk::PhysicalDevice get_physical_device() const
Get physical device.
Definition VKContext.hpp:44
vk::Instance get_instance() const
Get Vulkan instance.
Definition VKContext.hpp:39
const QueueFamilyIndices & get_queue_families() const
Get queue family indices.
Definition VKContext.hpp:69
void destroy_surface(vk::SurfaceKHR surface)
Destroy a specific surface Called when window is unregistered.
High-level wrapper for Vulkan instance and device.
Definition VKContext.hpp:16
vk::PhysicalDevice get_physical_device() const
Get physical device handle.
Definition VKDevice.hpp:59
const QueueFamilyIndices & get_queue_families() const
Get queue family indices.
Definition VKDevice.hpp:84
vk::Device get_device() const
Get logical device handle.
Definition VKDevice.hpp:64
vk::Queue get_graphics_queue() const
Get graphics queue.
Definition VKDevice.hpp:69
vk::Queue get_compute_queue() const
Get compute queue (may be same as graphics)
Definition VKDevice.hpp:74
vk::Queue get_transfer_queue() const
Get transfer queue (may be same as graphics)
Definition VKDevice.hpp:79
void wait_idle() const
Wait for the device to become idle.
Definition VKDevice.hpp:96
Manages Vulkan physical device selection and logical device creation.
Definition VKDevice.hpp:32
vk::Instance get_instance() const
Get the Vulkan instance handle.
Manages Vulkan instance creation and validation layers.
void initialize()
Definition main.cpp:11
GraphicsSurfaceInfo surface_info
System-wide configuration for visual stream processing.
System-wide configuration for visual stream processing.
Stores indices of queue families we need.
Definition VKDevice.hpp:13