MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
BackendPipelineManager.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "vulkan/vulkan.hpp"
4
6struct ComputeService;
7}
8
9namespace MayaFlux::Core {
10
11class VKContext;
12class VKShaderModule;
13class VKDescriptorManager;
14class VKComputePipeline;
15class VKGraphicsPipeline;
16
17struct GraphicsPipelineConfig;
18
19/**
20 * @class BackendPipelineManager
21 * @brief Manages Vulkan pipelines (compute, graphics) and related resources
22 */
23class MAYAFLUX_API BackendPipelineManager {
24public:
25 explicit BackendPipelineManager(VKContext& context);
27
28 void setup_backend_service(const std::shared_ptr<Registry::Service::ComputeService>& compute_service);
29
30 // ========================================================================
31 // Sampler management
32 // ========================================================================
33
34 /** @brief Create a shader module from SPIR-V binary
35 * @param spirv_path Path to the SPIR-V binary file
36 * @param stage Shader stage (e.g., vertex, fragment, compute)
37 * @return Shared pointer to the created VKShaderModule
38 */
39 std::shared_ptr<VKShaderModule> create_shader_module(const std::string& spirv_path, uint32_t stage);
40
41 // ========================================================================
42 // Descriptor management
43 // ========================================================================
44
45 /** @brief Create a descriptor manager for managing descriptor sets
46 * @param pool_size Number of descriptor sets to allocate in the pool
47 * @return Shared pointer to the created VKDescriptorManager
48 */
49 std::shared_ptr<VKDescriptorManager> create_descriptor_manager(uint32_t pool_size);
50
51 /** @brief Create a descriptor set layout
52 * @param manager Descriptor manager to use for allocation
53 * @param bindings Vector of pairs specifying binding index and descriptor type
54 * @return Created vk::DescriptorSetLayout
55 */
56 vk::DescriptorSetLayout create_descriptor_layout(
57 const std::shared_ptr<VKDescriptorManager>& manager,
58 const std::vector<std::pair<uint32_t, uint32_t>>& bindings);
59
60 // ========================================================================
61 // Pipeline management
62 // ========================================================================
63
64 /** @brief Create a compute pipeline
65 * @param shader Shader module to use for the compute pipeline
66 * @param layouts Vector of descriptor set layouts used by the pipeline
67 * @param push_constant_size Size of push constant range in bytes
68 * @return Shared pointer to the created VKComputePipeline
69 */
70 std::shared_ptr<VKComputePipeline> create_compute_pipeline(
71 const std::shared_ptr<VKShaderModule>& shader,
72 const std::vector<vk::DescriptorSetLayout>& layouts,
73 uint32_t push_constant_size);
74
75 /**
76 * @brief Create graphics pipeline
77 * @param config Graphics pipeline configuration
78 * @return Shared pointer to created pipeline, or nullptr on failure
79 */
80 std::shared_ptr<VKGraphicsPipeline> create_graphics_pipeline(
81 const GraphicsPipelineConfig& config);
82
83 // ========================================================================
84 // Cleanup
85 // ========================================================================
86
87 /** @brief Cleanup a compute resource allocated by the backend
88 * @param resource Pointer to the resource to cleanup
89 */
90 void cleanup_compute_resource(void* resource);
91
92 void cleanup();
93
94private:
96
97 std::vector<std::shared_ptr<VKShaderModule>> m_managed_shaders;
98 std::vector<std::shared_ptr<VKDescriptorManager>> m_managed_descriptor_managers;
99 std::vector<std::shared_ptr<VKComputePipeline>> m_managed_compute_pipelines;
100 std::vector<std::shared_ptr<VKGraphicsPipeline>> m_managed_graphics_pipelines;
101
102 void track_shader(const std::shared_ptr<VKShaderModule>& shader);
103 void track_descriptor_manager(const std::shared_ptr<VKDescriptorManager>& manager);
104 void track_compute_pipeline(const std::shared_ptr<VKComputePipeline>& pipeline);
105 void track_graphics_pipeline(const std::shared_ptr<VKGraphicsPipeline>& pipeline);
106};
107
108} // namespace MayaFlux::Core
std::vector< std::shared_ptr< VKComputePipeline > > m_managed_compute_pipelines
std::vector< std::shared_ptr< VKDescriptorManager > > m_managed_descriptor_managers
std::vector< std::shared_ptr< VKGraphicsPipeline > > m_managed_graphics_pipelines
std::vector< std::shared_ptr< VKShaderModule > > m_managed_shaders
Manages Vulkan pipelines (compute, graphics) and related resources.
High-level wrapper for Vulkan instance and device.
Definition VKContext.hpp:16
Configuration for creating a graphics pipeline.