MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_pipeline()

ComputePipelineID MayaFlux::Portal::Graphics::ComputePress::create_pipeline ( ShaderID  shader_id,
const std::vector< std::vector< DescriptorBindingInfo > > &  descriptor_sets = {},
size_t  push_constant_size = 0 
)

Create compute pipeline.

Definition at line 90 of file ComputePress.cpp.

94{
95 if (!is_initialized()) {
97 "ComputePress not initialized");
99 }
100
101 auto shader_module = m_shader_foundry->get_vk_shader_module(shader_id);
102 if (!shader_module) {
104 "Invalid shader ID: {}", shader_id);
106 }
107
108 auto stage = m_shader_foundry->get_shader_stage(shader_id);
109 if (stage != ShaderStage::COMPUTE) {
111 "Shader is not a compute shader (stage: {})", static_cast<int>(stage));
113 }
114
116 PipelineState& state = m_pipelines[id];
117 state.shader_id = shader_id;
118
120
122 m_descriptor_manager = std::make_shared<Core::VKDescriptorManager>();
123 m_descriptor_manager->initialize(device, 1024);
124 }
125
126 for (const auto& set_bindings : descriptor_sets) {
127 Core::DescriptorSetLayoutConfig layout_config;
128
129 for (const auto& binding : set_bindings) {
130 layout_config.add_binding(
131 binding.binding,
132 binding.type,
133 vk::ShaderStageFlagBits::eCompute,
134 1);
135 }
136
137 state.layouts.push_back(m_descriptor_manager->create_layout(device, layout_config));
138 }
139
140 Core::ComputePipelineConfig pipeline_config;
141 pipeline_config.shader = shader_module;
142 pipeline_config.set_layouts = state.layouts;
143
144 if (push_constant_size > 0) {
145 pipeline_config.add_push_constant(
146 vk::ShaderStageFlagBits::eCompute,
147 static_cast<uint32_t>(push_constant_size));
148 }
149
150 state.pipeline = std::make_shared<Core::VKComputePipeline>();
151 if (!state.pipeline->create(device, pipeline_config)) {
153 "Failed to create compute pipeline");
154 m_pipelines.erase(id);
156 }
157
158 state.layout = state.pipeline->get_layout();
159 state.push_constant_size = push_constant_size;
160
162 "Created compute pipeline (ID: {}, {} descriptor sets, {} bytes push constants)",
163 id, state.layouts.size(), push_constant_size);
164
165 return id;
166}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
vk::PhysicalDevice device
Definition VKDevice.cpp:121
std::unordered_map< ComputePipelineID, PipelineState > m_pipelines
bool is_initialized() const
Check if ComputePress is initialized.
std::shared_ptr< Core::VKDescriptorManager > m_descriptor_manager
vk::Device get_device() const
Get logical device handle.
std::shared_ptr< Core::VKShaderModule > get_vk_shader_module(ShaderID shader_id)
ShaderStage get_shader_stage(ShaderID shader_id)
Get shader stage for compiled shader.
@ GPUCompute
GPU compute operations (shaders, GPGPU tasks)
@ Portal
High-level user-facing API layer.
constexpr ComputePipelineID INVALID_COMPUTE_PIPELINE

References MayaFlux::Core::DescriptorSetLayoutConfig::add_binding(), MayaFlux::Core::ComputePipelineConfig::add_push_constant(), MayaFlux::Portal::Graphics::COMPUTE, device, MayaFlux::Portal::Graphics::ShaderFoundry::get_device(), MayaFlux::Portal::Graphics::ShaderFoundry::get_shader_stage(), MayaFlux::Portal::Graphics::ShaderFoundry::get_vk_shader_module(), MayaFlux::Journal::GPUCompute, MayaFlux::Portal::Graphics::INVALID_COMPUTE_PIPELINE, is_initialized(), MayaFlux::Portal::Graphics::ComputePress::PipelineState::layout, MayaFlux::Portal::Graphics::ComputePress::PipelineState::layouts, m_descriptor_manager, m_next_pipeline_id, m_pipelines, m_shader_foundry, MF_ERROR, MF_INFO, MayaFlux::Portal::Graphics::ComputePress::PipelineState::pipeline, MayaFlux::Journal::Portal, MayaFlux::Portal::Graphics::ComputePress::PipelineState::push_constant_size, MayaFlux::Core::ComputePipelineConfig::set_layouts, MayaFlux::Core::ComputePipelineConfig::shader, and MayaFlux::Portal::Graphics::ComputePress::PipelineState::shader_id.

Referenced by create_pipeline_auto().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: