474{
476 if (buffer->has_vertex_layout()) {
477 auto vertex_layout = buffer->get_vertex_layout();
478 if (vertex_layout.has_value()) {
480 .semantic_layout = vertex_layout.value(),
481 .use_reflection = false
482 };
483 }
484 }
485 }
486
488 return;
489 }
490
492 return;
493 }
494
496 if (!local_layout) {
498 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
499 return;
500 }
501
503
506
507 vk::Format color_format = static_cast<vk::Format>(
509
511 ? vk::Format::eD32Sfloat
512 : vk::Format::eUndefined;
513
514 auto cmd_id = foundry.begin_secondary_commands(color_format, depth_format);
515 auto cmd = foundry.get_command_buffer(cmd_id);
516
519
521 auto cmd = foundry.get_command_buffer(cmd_id);
522
523 vk::Viewport viewport {
524 0.0F,
525 static_cast<float>(
height),
526 static_cast<float>(
width),
527 -
static_cast<float>(
height),
528 0.0F,
529 1.0F
530 };
531 cmd.setViewport(0, 1, &viewport);
532
533 vk::Rect2D scissor { { 0, 0 }, {
width,
height } };
534 cmd.setScissor(0, 1, &scissor);
535 }
536
538
539 auto& engine_bindings = buffer->get_engine_context().ssbo_bindings;
540 for (const auto& binding : engine_bindings) {
541 if (binding.set == 0 && binding.binding == 0) {
543 "Engine SSBO at binding=0 is reserved for ViewTransform UBO");
544 continue;
545 }
548 "Engine SSBO binding {} skipped: engine descriptor set not allocated", binding.binding);
549 continue;
550 }
551 foundry.update_descriptor_buffer(
553 binding.binding,
554 binding.type,
555 binding.buffer_info.buffer,
556 binding.buffer_info.offset,
557 binding.buffer_info.range);
558 }
559
560 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
561 if (!descriptor_bindings.empty()) {
562 for (const auto& binding : descriptor_bindings) {
564 if (!ds_index) {
566 "Descriptor set index {} out of range or reserved", binding.set);
567 continue;
568 }
569
570 foundry.update_descriptor_buffer(
572 binding.binding,
573 binding.type,
574 binding.buffer_info.buffer,
575 binding.buffer_info.offset,
576 binding.buffer_info.range);
577 }
578 }
579
582 }
583
584 {
585 Kinesis::ViewTransform vt;
590 }
591
593 std::memcpy(
595 &vt,
596 sizeof(Kinesis::ViewTransform));
597 }
598 }
599
601 flow.bind_descriptor_sets(
604 0);
605 }
606
608 flow.bind_descriptor_sets(
611 1);
612 }
613
615 if (!push_data.empty()) {
616 flow.push_constants(
618 }
619
621
622 flow.bind_vertex_buffers(cmd_id, { buffer });
623
624 uint32_t draw_count = 0;
627 } else {
628 auto current_layout = buffer->get_vertex_layout();
629 if (!current_layout.has_value() || current_layout->vertex_count == 0) {
631 "Vertex layout has zero vertices, skipping draw");
632 return;
633 }
634 draw_count = current_layout->vertex_count;
635 }
636
637 if (buffer->has_index_buffer()) {
638 const auto index_count = static_cast<uint32_t>(
639 buffer->get_index_buffer_size() / sizeof(uint32_t));
640 flow.bind_index_buffer(cmd_id, buffer);
642 } else {
644 }
645
646 foundry.end_commands(cmd_id);
647
650
652 "Recorded secondary command buffer {} for window '{}'",
654}
#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.