473{
475 if (buffer->has_vertex_layout()) {
476 auto vertex_layout = buffer->get_vertex_layout();
477 if (vertex_layout.has_value()) {
479 .semantic_layout = vertex_layout.value(),
480 .use_reflection = false
481 };
482 }
483 }
484 }
485
487 return;
488 }
489
491 return;
492 }
493
495 if (!local_layout) {
497 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
498 return;
499 }
500
502
505
506 vk::Format color_format = static_cast<vk::Format>(
508
510 ? vk::Format::eD32Sfloat
511 : vk::Format::eUndefined;
512
513 auto cmd_id = foundry.begin_secondary_commands(color_format, depth_format);
514 auto cmd = foundry.get_command_buffer(cmd_id);
515
516 uint32_t
width = 0, height = 0;
518
519 if (
width > 0 && height > 0) {
520 auto cmd = foundry.get_command_buffer(cmd_id);
521
522 vk::Viewport viewport {
523 0.0F,
524 static_cast<float>(height),
525 static_cast<float>(
width),
526 -static_cast<float>(height),
527 0.0F,
528 1.0F
529 };
530 cmd.setViewport(0, 1, &viewport);
531
532 vk::Rect2D scissor { { 0, 0 }, {
width, height } };
533 cmd.setScissor(0, 1, &scissor);
534 }
535
537
538 auto& engine_bindings = buffer->get_engine_context().ssbo_bindings;
539 for (const auto& binding : engine_bindings) {
540 if (binding.set == 0 && binding.binding == 0) {
542 "Engine SSBO at binding=0 is reserved for ViewTransform UBO");
543 continue;
544 }
547 "Engine SSBO binding {} skipped: engine descriptor set not allocated", binding.binding);
548 continue;
549 }
550 foundry.update_descriptor_buffer(
552 binding.binding,
553 binding.type,
554 binding.buffer_info.buffer,
555 binding.buffer_info.offset,
556 binding.buffer_info.range);
557 }
558
559 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
560 if (!descriptor_bindings.empty()) {
561 for (const auto& binding : descriptor_bindings) {
563 if (!ds_index) {
565 "Descriptor set index {} out of range or reserved", binding.set);
566 continue;
567 }
568
569 foundry.update_descriptor_buffer(
571 binding.binding,
572 binding.type,
573 binding.buffer_info.buffer,
574 binding.buffer_info.offset,
575 binding.buffer_info.range);
576 }
577 }
578
581 }
582
583 {
584 Kinesis::ViewTransform vt;
589 }
590
592 std::memcpy(
594 &vt,
595 sizeof(Kinesis::ViewTransform));
596 }
597 }
598
600 flow.bind_descriptor_sets(
603 0);
604 }
605
607 flow.bind_descriptor_sets(
610 1);
611 }
612
613 const auto& staging = buffer->get_pipeline_context();
614 if (!staging.push_constant_staging.empty()) {
615 flow.push_constants(
616 cmd_id,
618 staging.push_constant_staging.data(),
619 staging.push_constant_staging.size());
621 flow.push_constants(
622 cmd_id,
626 }
627
629
630 flow.bind_vertex_buffers(cmd_id, { buffer });
631
632 uint32_t draw_count = 0;
635 } else {
636 auto current_layout = buffer->get_vertex_layout();
637 if (!current_layout.has_value() || current_layout->vertex_count == 0) {
639 "Vertex layout has zero vertices, skipping draw");
640 return;
641 }
642 draw_count = current_layout->vertex_count;
643 }
644
645 if (buffer->has_index_buffer()) {
646 const auto index_count = static_cast<uint32_t>(
647 buffer->get_index_buffer_size() / sizeof(uint32_t));
648 flow.bind_index_buffer(cmd_id, buffer);
650 } else {
652 }
653
654 foundry.end_commands(cmd_id);
655
658
660 "Recorded secondary command buffer {} for window '{}'",
662}
#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< uint8_t > m_push_constant_data
std::vector< Portal::Graphics::DescriptorSetID > m_descriptor_set_ids
@ 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.