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 325 of file RenderProcessor.cpp.

326{
329 "Cannot allocate descriptor sets without pipeline");
330 return;
331 }
332
334
336 auto& foundry = Portal::Graphics::get_shader_foundry();
337
338 auto vt_layout = flow.get_view_transform_layout(m_pipeline_id);
339 if (vt_layout) {
340 m_view_transform_descriptor_set_id = foundry.allocate_descriptor_set(vt_layout);
341
342 m_view_transform_ubo = std::make_shared<VKBuffer>(
343 sizeof(Kinesis::ViewTransform),
347
348 foundry.update_descriptor_buffer(
350 0,
351 vk::DescriptorType::eUniformBuffer,
352 m_view_transform_ubo->get_buffer(),
353 0,
354 sizeof(Kinesis::ViewTransform));
355
357 "ViewTransform UBO allocated (pipeline {})", m_pipeline_id);
358 }
359
360 m_descriptor_set_ids = flow.allocate_pipeline_descriptors(m_pipeline_id, 1);
361
362 for (const auto& [binding, tex_binding] : m_texture_bindings) {
363 if (!tex_binding.texture
364 || !tex_binding.texture->is_initialized()
365 || !tex_binding.texture->get_image_view()) {
366 continue;
367 }
368
369 auto config_it = std::ranges::find_if(m_config.bindings,
370 [binding](const auto& pair) {
371 return binding >= pair.second.binding
372 && binding < pair.second.binding + pair.second.count;
373 });
374
375 if (config_it == m_config.bindings.end()) {
377 "No config for binding {}", binding);
378 continue;
379 }
380
381 const uint32_t set_index = config_it->second.set;
382
383 if (set_index == 0) {
386 "Engine descriptor set not allocated for set=0 texture binding {}", binding);
387 continue;
388 }
389 foundry.update_descriptor_image(
391 config_it->second.binding,
392 tex_binding.texture->get_image_view(),
393 tex_binding.sampler,
394 vk::ImageLayout::eShaderReadOnlyOptimal,
395 binding - config_it->second.binding);
396 continue;
397 }
398
399 auto ds_index = resolve_ds_index(set_index);
400 if (!ds_index) {
402 "Descriptor set index {} out of range", binding);
403 continue;
404 }
405
406 foundry.update_descriptor_image(
407 m_descriptor_set_ids[*ds_index],
408 config_it->second.binding,
409 tex_binding.texture->get_image_view(),
410 tex_binding.sampler,
411 vk::ImageLayout::eShaderReadOnlyOptimal,
412 binding - config_it->second.binding);
413 }
414
416 "Allocated {} descriptor sets and updated {} texture bindings",
418
419 update_descriptors(buffer);
421}
#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:462
@ 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: