MayaFlux 1.0.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 443 of file RenderProcessor.cpp.

444{
448 "Cannot allocate descriptor sets without pipeline");
449 }
450 return;
451 }
452
454
456 auto& foundry = Portal::Graphics::get_shader_foundry();
457
458 auto transform_layout = flow.get_view_transform_layout(m_pipeline_id);
459 if (transform_layout) {
460 m_render_transform_descriptor_set_id = foundry.allocate_descriptor_set(transform_layout);
461
462 m_render_transform_ubo = std::make_shared<VKBuffer>(
463 sizeof(Kinesis::RenderTransform),
464 VKBuffer::Usage::UNIFORM,
467
468 foundry.update_descriptor_buffer(
470 0,
471 vk::DescriptorType::eUniformBuffer,
472 m_render_transform_ubo->get_buffer(),
473 0,
474 sizeof(Kinesis::RenderTransform));
475
477 "RenderTransform UBO allocated (pipeline {})", m_pipeline_id);
478 }
479
480 m_descriptor_set_ids = flow.allocate_pipeline_descriptors(m_pipeline_id, 1);
481
482 for (const auto& [binding, tex_binding] : m_texture_bindings) {
483 if (!tex_binding.texture
484 || !tex_binding.texture->is_initialized()
485 || !tex_binding.texture->get_image_view()) {
486 continue;
487 }
488
489 auto config_it = std::ranges::find_if(m_config.bindings,
490 [binding](const auto& pair) {
491 return binding >= pair.second.binding
492 && binding < pair.second.binding + pair.second.count;
493 });
494
495 if (config_it == m_config.bindings.end()) {
497 "No config for binding {}", binding);
498 continue;
499 }
500
501 const uint32_t set_index = config_it->second.set;
502
503 if (set_index == 0) {
506 "Engine descriptor set not allocated for set=0 texture binding {}", binding);
507 continue;
508 }
509 foundry.update_descriptor_image(
511 config_it->second.binding,
512 tex_binding.texture->get_image_view(),
513 tex_binding.sampler,
514 vk::ImageLayout::eShaderReadOnlyOptimal,
515 binding - config_it->second.binding);
516 continue;
517 }
518
519 auto ds_index = resolve_ds_index(set_index);
520 if (!ds_index) {
522 "Descriptor set index {} out of range", binding);
523 continue;
524 }
525
526 foundry.update_descriptor_image(
527 m_descriptor_set_ids[*ds_index],
528 config_it->second.binding,
529 tex_binding.texture->get_image_view(),
530 tex_binding.sampler,
531 vk::ImageLayout::eShaderReadOnlyOptimal,
532 binding - config_it->second.binding);
533 }
534
536 "Allocated {} descriptor sets and updated {} texture bindings",
538
541}
#define MF_ERROR(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
Portal::Graphics::RenderPipelineID m_pipeline_id
std::unordered_map< uint32_t, TextureBinding > m_texture_bindings
Portal::Graphics::DescriptorSetID m_render_transform_descriptor_set_id
std::shared_ptr< VKBuffer > m_render_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:514
@ 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 buffer, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Portal::Graphics::get_render_flow(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Portal::Graphics::INVALID_DESCRIPTOR_SET, MayaFlux::Portal::Graphics::INVALID_RENDER_PIPELINE, MF_DEBUG, MF_ERROR, MF_RT_ERROR, and MayaFlux::Kakshya::UNKNOWN.

+ Here is the call graph for this function: