455{
457 if (buffer->has_vertex_layout()) {
458 auto vertex_layout = buffer->get_vertex_layout();
459 if (vertex_layout.has_value()) {
461 .semantic_layout = vertex_layout.value(),
462 .use_reflection = false
463 };
464 }
465 }
466 }
467
469 return;
470 }
471
473 return;
474 }
475
477 if (!local_layout) {
479 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
480 return;
481 }
482
484
487
488 vk::Format color_format = static_cast<vk::Format>(
490
491 auto cmd_id = foundry.begin_secondary_commands(color_format);
492 auto cmd = foundry.get_command_buffer(cmd_id);
493
494 uint32_t
width = 0, height = 0;
496
497 if (
width > 0 && height > 0) {
498 auto cmd = foundry.get_command_buffer(cmd_id);
499
500 vk::Viewport viewport {
501 0.0F,
502 static_cast<float>(height),
503 static_cast<float>(
width),
504 -static_cast<float>(height),
505 0.0F,
506 1.0F
507 };
508 cmd.setViewport(0, 1, &viewport);
509
510 vk::Rect2D scissor { { 0, 0 }, {
width, height } };
511 cmd.setScissor(0, 1, &scissor);
512 }
513
515
516 auto& engine_bindings = buffer->get_engine_context().ssbo_bindings;
517 for (const auto& binding : engine_bindings) {
518 if (binding.set == 0 && binding.binding == 0) {
520 "Engine SSBO at binding=0 is reserved for ViewTransform UBO");
521 continue;
522 }
525 "Engine SSBO binding {} skipped: engine descriptor set not allocated", binding.binding);
526 continue;
527 }
528 foundry.update_descriptor_buffer(
530 binding.binding,
531 binding.type,
532 binding.buffer_info.buffer,
533 binding.buffer_info.offset,
534 binding.buffer_info.range);
535 }
536
537 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
538 if (!descriptor_bindings.empty()) {
539 for (const auto& binding : descriptor_bindings) {
541 if (!ds_index) {
543 "Descriptor set index {} out of range or reserved", binding.set);
544 continue;
545 }
546
547 foundry.update_descriptor_buffer(
549 binding.binding,
550 binding.type,
551 binding.buffer_info.buffer,
552 binding.buffer_info.offset,
553 binding.buffer_info.range);
554 }
555 }
556
559 }
560
561 {
562 Kinesis::ViewTransform vt;
567 }
568
570 std::memcpy(
572 &vt,
573 sizeof(Kinesis::ViewTransform));
574 }
575 }
576
578 flow.bind_descriptor_sets(
581 0);
582 }
583
585 flow.bind_descriptor_sets(
588 1);
589 }
590
591 const auto& staging = buffer->get_pipeline_context();
592 if (!staging.push_constant_staging.empty()) {
593 flow.push_constants(
594 cmd_id,
596 staging.push_constant_staging.data(),
597 staging.push_constant_staging.size());
599 flow.push_constants(
600 cmd_id,
604 }
605
607
608 flow.bind_vertex_buffers(cmd_id, { buffer });
609
610 uint32_t draw_count = 0;
613 } else {
614 auto current_layout = buffer->get_vertex_layout();
615 if (!current_layout.has_value() || current_layout->vertex_count == 0) {
617 "Vertex layout has zero vertices, skipping draw");
618 return;
619 }
620 draw_count = current_layout->vertex_count;
621 }
622
623 if (buffer->has_index_buffer()) {
624 const auto index_count = static_cast<uint32_t>(
625 buffer->get_index_buffer_size() / sizeof(uint32_t));
626 flow.bind_index_buffer(cmd_id, buffer);
627 flow.draw_indexed(cmd_id, index_count, 1, 0, 0, 0);
628 } else {
630 }
631
632 foundry.end_commands(cmd_id);
633
636
638 "Recorded secondary command buffer {} for window '{}'",
640}
#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
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.