MayaFlux 0.1.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< DescriptorBindingConfig > > &  descriptor_sets = {},
size_t  push_constant_size = 0 
)

Create compute pipeline.

Definition at line 83 of file ComputePress.cpp.

87{
88 auto shader_module = m_shader_foundry->get_vk_shader_module(shader_id);
89 if (!shader_module) {
91 "Invalid shader ID: {}", shader_id);
93 }
94
95 auto stage = m_shader_foundry->get_shader_stage(shader_id);
96 if (stage != ShaderStage::COMPUTE) {
98 "Shader is not a compute shader (stage: {})", static_cast<int>(stage));
100 }
101
103 PipelineState& state = m_pipelines[id];
104 state.shader_id = shader_id;
105
106 auto device = m_shader_foundry->get_device();
107
109 m_descriptor_manager = std::make_shared<Core::VKDescriptorManager>();
110 m_descriptor_manager->initialize(device, 1024);
111 }
112
113 for (const auto& set_bindings : descriptor_sets) {
114 Core::DescriptorSetLayoutConfig layout_config;
115
116 for (const auto& binding : set_bindings) {
117 layout_config.add_binding(
118 binding.binding,
119 binding.type,
120 vk::ShaderStageFlagBits::eCompute,
121 1);
122 }
123
124 state.layouts.push_back(m_descriptor_manager->create_layout(device, layout_config));
125 }
126
127 Core::ComputePipelineConfig pipeline_config;
128 pipeline_config.shader = shader_module;
129 pipeline_config.set_layouts = state.layouts;
130
131 if (push_constant_size > 0) {
132 pipeline_config.add_push_constant(
133 vk::ShaderStageFlagBits::eCompute,
134 static_cast<uint32_t>(push_constant_size));
135 }
136
137 state.pipeline = std::make_shared<Core::VKComputePipeline>();
138 if (!state.pipeline->create(device, pipeline_config)) {
140 "Failed to create compute pipeline");
141 m_pipelines.erase(id);
143 }
144
145 state.layout = state.pipeline->get_layout();
146
148 "Created compute pipeline (ID: {}, {} descriptor sets, {} bytes push constants)",
149 id, state.layouts.size(), push_constant_size);
150
151 return id;
152}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::unordered_map< ComputePipelineID, PipelineState > m_pipelines
std::shared_ptr< Core::VKDescriptorManager > m_descriptor_manager
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, 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, 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::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: