MayaFlux 0.2.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 89 of file ComputePress.cpp.

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