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

◆ initialize_descriptors()

void MayaFlux::Buffers::RenderProcessor::initialize_descriptors ( const std::shared_ptr< VKBuffer > &  buffer)
overrideprotectedvirtual

Implements MayaFlux::Buffers::ShaderProcessor.

Definition at line 343 of file RenderProcessor.cpp.

344{
347 "Cannot allocate descriptor sets without pipeline");
348 return;
349 }
350
352
354 auto& foundry = Portal::Graphics::get_shader_foundry();
355
356 auto vt_layout = flow.get_view_transform_layout(m_pipeline_id);
357 if (vt_layout) {
358 m_view_transform_descriptor_set_id = foundry.allocate_descriptor_set(vt_layout);
359
360 m_view_transform_ubo = std::make_shared<VKBuffer>(
361 sizeof(Kinesis::ViewTransform),
365
366 foundry.update_descriptor_buffer(
368 0,
369 vk::DescriptorType::eUniformBuffer,
370 m_view_transform_ubo->get_buffer(),
371 0,
372 sizeof(Kinesis::ViewTransform));
373
375 "ViewTransform UBO allocated (pipeline {})", m_pipeline_id);
376 }
377
378 m_descriptor_set_ids = flow.allocate_pipeline_descriptors(m_pipeline_id, 1);
379
380 for (const auto& [binding, tex_binding] : m_texture_bindings) {
381 if (!tex_binding.texture
382 || !tex_binding.texture->is_initialized()
383 || !tex_binding.texture->get_image_view()) {
384 continue;
385 }
386
387 auto config_it = std::ranges::find_if(m_config.bindings,
388 [binding](const auto& pair) {
389 return binding >= pair.second.binding
390 && binding < pair.second.binding + pair.second.count;
391 });
392
393 if (config_it == m_config.bindings.end()) {
395 "No config for binding {}", binding);
396 continue;
397 }
398
399 const uint32_t set_index = config_it->second.set;
400
401 if (set_index == 0) {
404 "Engine descriptor set not allocated for set=0 texture binding {}", binding);
405 continue;
406 }
407 foundry.update_descriptor_image(
409 config_it->second.binding,
410 tex_binding.texture->get_image_view(),
411 tex_binding.sampler,
412 vk::ImageLayout::eShaderReadOnlyOptimal,
413 binding - config_it->second.binding);
414 continue;
415 }
416
417 auto ds_index = resolve_ds_index(set_index);
418 if (!ds_index) {
420 "Descriptor set index {} out of range", binding);
421 continue;
422 }
423
424 foundry.update_descriptor_image(
425 m_descriptor_set_ids[*ds_index],
426 config_it->second.binding,
427 tex_binding.texture->get_image_view(),
428 tex_binding.sampler,
429 vk::ImageLayout::eShaderReadOnlyOptimal,
430 binding - config_it->second.binding);
431 }
432
434 "Allocated {} descriptor sets and updated {} texture bindings",
436
437 update_descriptors(buffer);
439}
#define MF_ERROR(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Portal::Graphics::DescriptorSetID m_view_transform_descriptor_set_id
Portal::Graphics::RenderPipelineID m_pipeline_id
std::unordered_map< uint32_t, TextureBinding > m_texture_bindings
std::shared_ptr< VKBuffer > m_view_transform_ubo
std::optional< uint32_t > resolve_ds_index(uint32_t set) const
Resolve logical descriptor set index to actual index.
virtual void on_descriptors_created()
Called after descriptor sets are created.
virtual void update_descriptors(const std::shared_ptr< VKBuffer > &buffer)
virtual void on_before_descriptors_create()
Called before descriptor sets are created.
std::vector< Portal::Graphics::DescriptorSetID > m_descriptor_set_ids
void ensure_initialized(const std::shared_ptr< VKBuffer > &buffer)
Definition VKBuffer.cpp:471
@ UNIFORM
Uniform buffer (host-visible)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ UNKNOWN
Unknown or undefined modality.
constexpr RenderPipelineID INVALID_RENDER_PIPELINE
MAYAFLUX_API RenderFlow & get_render_flow()
Get the global render flow instance.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
constexpr DescriptorSetID INVALID_DESCRIPTOR_SET
std::unordered_map< std::string, ShaderBinding > bindings

References MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::VKBufferProcessor::ensure_initialized(), MayaFlux::Portal::Graphics::get_render_flow(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Portal::Graphics::INVALID_DESCRIPTOR_SET, MayaFlux::Portal::Graphics::INVALID_RENDER_PIPELINE, MayaFlux::Buffers::ShaderProcessor::m_config, MayaFlux::Buffers::ShaderProcessor::m_descriptor_set_ids, m_pipeline_id, m_texture_bindings, m_view_transform_descriptor_set_id, m_view_transform_ubo, MF_DEBUG, MF_ERROR, MF_RT_ERROR, MayaFlux::Buffers::ShaderProcessor::on_before_descriptors_create(), MayaFlux::Buffers::ShaderProcessor::on_descriptors_created(), MayaFlux::Buffers::ShaderProcessor::resolve_ds_index(), MayaFlux::Buffers::VKBuffer::UNIFORM, MayaFlux::Kakshya::UNKNOWN, and MayaFlux::Buffers::ShaderProcessor::update_descriptors().

+ Here is the call graph for this function: