392{
394 if (buffer->has_vertex_layout()) {
395 auto vertex_layout = buffer->get_vertex_layout();
396 if (vertex_layout.has_value()) {
398 .semantic_layout = vertex_layout.value(),
399 .use_reflection = false
400 };
401 }
402 }
403 }
404
406 return;
407 }
408
410 return;
411 }
412
414 if (!local_layout) {
416 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
417 return;
418 }
419
421
424
425 vk::Format color_format = static_cast<vk::Format>(
427
428 auto cmd_id = foundry.begin_secondary_commands(color_format);
429 auto cmd = foundry.get_command_buffer(cmd_id);
430
431 uint32_t width = 0, height = 0;
433
434 if (width > 0 && height > 0) {
435 auto cmd = foundry.get_command_buffer(cmd_id);
436
437 vk::Viewport viewport {
438 0.0F,
439 static_cast<float>(height),
440 static_cast<float>(width),
441 -static_cast<float>(height),
442 0.0F,
443 1.0F
444 };
445 cmd.setViewport(0, 1, &viewport);
446
447 vk::Rect2D scissor { { 0, 0 }, { width, height } };
448 cmd.setScissor(0, 1, &scissor);
449 }
450
452
453 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
454 if (!descriptor_bindings.empty()) {
455 for (const auto& binding : descriptor_bindings) {
458 "Descriptor set index {} out of range", binding.set);
459 continue;
460 }
461
462 foundry.update_descriptor_buffer(
464 binding.binding,
465 binding.type,
466 binding.buffer_info.buffer,
467 binding.buffer_info.offset,
468 binding.buffer_info.range);
469 }
470 }
471
474 }
475
480
481 auto& staging = buffer->get_pipeline_context().push_constant_staging;
482
483 if (!staging.empty()) {
484 if (staging.size() < sizeof(Kinesis::ViewTransform)) {
485 staging.resize(std::max(staging.size(), sizeof(Kinesis::ViewTransform)));
486 }
487 std::memcpy(staging.data(), &vt, sizeof(Kinesis::ViewTransform));
488 } else {
490 }
491 }
492
493 const auto& staging = buffer->get_pipeline_context();
494 if (!staging.push_constant_staging.empty()) {
495 flow.push_constants(
496 cmd_id,
498 staging.push_constant_staging.data(),
499 staging.push_constant_staging.size());
501 flow.push_constants(
502 cmd_id,
506 }
507
509
510 flow.bind_vertex_buffers(cmd_id, { buffer });
511
512 uint32_t draw_count = 0;
515 } else {
516 auto current_layout = buffer->get_vertex_layout();
517 if (!current_layout.has_value() || current_layout->vertex_count == 0) {
519 "Vertex layout has zero vertices, skipping draw");
520 return;
521 }
522 draw_count = current_layout->vertex_count;
523 }
524
526
527 foundry.end_commands(cmd_id);
528
531
533 "Recorded secondary command buffer {} for window '{}'",
535}
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
#define MF_RT_DEBUG(comp, ctx,...)
std::unordered_map< std::shared_ptr< VKBuffer >, VertexInfo > m_buffer_info
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::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.
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.
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.