468{
470 if (buffer->has_vertex_layout()) {
471 auto vertex_layout = buffer->get_vertex_layout();
472 if (vertex_layout.has_value()) {
474 .semantic_layout = vertex_layout.value(),
475 .use_reflection = false
476 };
477 }
478 }
479 }
480
482 return;
483 }
484
486 return;
487 }
488
490 if (!local_layout) {
492 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
493 return;
494 }
495
497
500
501 vk::Format color_format = static_cast<vk::Format>(
503
505 ? vk::Format::eD32Sfloat
506 : vk::Format::eUndefined;
507
508 auto cmd_id = foundry.begin_secondary_commands(color_format, depth_format);
509 auto cmd = foundry.get_command_buffer(cmd_id);
510
513
515 auto cmd = foundry.get_command_buffer(cmd_id);
516
517 vk::Viewport viewport {
518 0.0F,
519 static_cast<float>(
height),
520 static_cast<float>(
width),
521 -
static_cast<float>(
height),
522 0.0F,
523 1.0F
524 };
525 cmd.setViewport(0, 1, &viewport);
526
527 vk::Rect2D scissor { { 0, 0 }, {
width,
height } };
528 cmd.setScissor(0, 1, &scissor);
529 }
530
532
533 auto& engine_bindings = buffer->get_engine_context().ssbo_bindings;
534 for (const auto& binding : engine_bindings) {
535 if (binding.set == 0 && binding.binding == 0) {
537 "Engine SSBO at binding=0 is reserved for ViewTransform UBO");
538 continue;
539 }
542 "Engine SSBO binding {} skipped: engine descriptor set not allocated", binding.binding);
543 continue;
544 }
545 foundry.update_descriptor_buffer(
547 binding.binding,
548 binding.type,
549 binding.buffer_info.buffer,
550 binding.buffer_info.offset,
551 binding.buffer_info.range);
552 }
553
554 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
555 if (!descriptor_bindings.empty()) {
556 for (const auto& binding : descriptor_bindings) {
558 if (!ds_index) {
560 "Descriptor set index {} out of range or reserved", binding.set);
561 continue;
562 }
563
564 foundry.update_descriptor_buffer(
566 binding.binding,
567 binding.type,
568 binding.buffer_info.buffer,
569 binding.buffer_info.offset,
570 binding.buffer_info.range);
571 }
572 }
573
576 }
577
578 {
579 Kinesis::ViewTransform vt;
584 }
585
587 std::memcpy(
589 &vt,
590 sizeof(Kinesis::ViewTransform));
591 }
592 }
593
595 flow.bind_descriptor_sets(
598 0);
599 }
600
602 flow.bind_descriptor_sets(
605 1);
606 }
607
609 if (!push_data.empty()) {
610 flow.push_constants(
612 }
613
615
616 flow.bind_vertex_buffers(cmd_id, { buffer });
617
618 uint32_t draw_count = 0;
621 } else {
622 auto current_layout = buffer->get_vertex_layout();
623 if (!current_layout.has_value() || current_layout->vertex_count == 0) {
625 "Vertex layout has zero vertices, skipping draw");
626 return;
627 }
628 draw_count = current_layout->vertex_count;
629 }
630
631 if (buffer->has_index_buffer()) {
632 const auto index_count = static_cast<uint32_t>(
633 buffer->get_index_buffer_size() / sizeof(uint32_t));
634 flow.bind_index_buffer(cmd_id, buffer);
636 } else {
638 }
639
640 foundry.end_commands(cmd_id);
641
644
646 "Recorded secondary command buffer {} for window '{}'",
648}
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
#define MF_RT_DEBUG(comp, ctx,...)
Portal::Graphics::DescriptorSetID m_view_transform_descriptor_set_id
std::unordered_map< std::shared_ptr< VKBuffer >, VertexInfo > m_buffer_info
bool m_view_transform_active
Registry::Service::DisplayService * m_display_service
uint32_t m_instance_count
bool on_before_execute(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer) override
Called before each process callback.
std::function< Kinesis::ViewTransform()> m_view_transform_source
Portal::Graphics::RenderPipelineID m_pipeline_id
std::optional< Kinesis::ViewTransform > m_view_transform
const Kakshya::VertexLayout * get_or_cache_vertex_layout(std::unordered_map< std::shared_ptr< VKBuffer >, VertexInfo > &buffer_info, const std::shared_ptr< VKBuffer > &buffer)
std::shared_ptr< Core::Window > m_target_window
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.
std::vector< Portal::Graphics::DescriptorSetID > m_descriptor_set_ids
std::vector< uint8_t > resolve_push_constants(const std::shared_ptr< VKBuffer > &buffer) const
This processor's push constant data with buffer-staged fragments overlaid at their declared offsets.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ Kinesis
General mathematical and physics algorithns.
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::function< int(const std::shared_ptr< void > &)> get_swapchain_format
Get actual swapchain format for a window.
std::function< void(const std::shared_ptr< void > &, uint32_t &, uint32_t &)> get_swapchain_extent
Get swapchain extent for a window.