278{
280 if (buffer->has_vertex_layout()) {
281 auto vertex_layout = buffer->get_vertex_layout();
282 if (vertex_layout.has_value()) {
284 .semantic_layout = vertex_layout.value(),
285 .use_reflection = false
286 };
287 }
288 }
289 }
290
292 return;
293 }
294
296 return;
297 }
298
299 auto vertex_layout = buffer->get_vertex_layout();
300 if (!vertex_layout.has_value()) {
302 "VKBuffer has no vertex layout set. Use buffer->set_vertex_layout()");
303 return;
304 }
305
306 if (vertex_layout->vertex_count == 0) {
308 "Vertex layout has zero vertices, skipping draw");
309 return;
310 }
311
312 if (vertex_layout->attributes.empty()) {
314 "Vertex layout has no attributes");
315 return;
316 }
317
319
322
323 vk::Format color_format = static_cast<vk::Format>(
325
326 auto cmd_id = foundry.begin_secondary_commands(color_format);
327 auto cmd = foundry.get_command_buffer(cmd_id);
328
329 uint32_t width = 0, height = 0;
331
332 if (width > 0 && height > 0) {
333 auto cmd = foundry.get_command_buffer(cmd_id);
334
335 vk::Viewport viewport { 0.0F, 0.0F, static_cast<float>(width), static_cast<float>(height), 0.0F, 1.0F };
336 cmd.setViewport(0, 1, &viewport);
337
338 vk::Rect2D scissor { { 0, 0 }, { width, height } };
339 cmd.setScissor(0, 1, &scissor);
340 }
341
343
344 auto& descriptor_bindings = buffer->get_pipeline_context().descriptor_buffer_bindings;
345 if (!descriptor_bindings.empty()) {
346 for (const auto& binding : descriptor_bindings) {
349 "Descriptor set index {} out of range", binding.set);
350 continue;
351 }
352
353 foundry.update_descriptor_buffer(
355 binding.binding,
356 binding.type,
357 binding.buffer_info.buffer,
358 binding.buffer_info.offset,
359 binding.buffer_info.range);
360 }
361 }
362
365 }
366
367 const auto& staging = buffer->get_pipeline_context();
368 if (!staging.push_constant_staging.empty()) {
369 flow.push_constants(
370 cmd_id,
372 staging.push_constant_staging.data(),
373 staging.push_constant_staging.size());
375 flow.push_constants(
376 cmd_id,
380 }
381
383
384 flow.bind_vertex_buffers(cmd_id, { buffer });
385
386 flow.draw(cmd_id, vertex_layout->vertex_count);
387
388 foundry.end_commands(cmd_id);
389
392
394 "Recorded secondary command buffer {} for window '{}'",
396}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(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.
Portal::Graphics::RenderPipelineID m_pipeline_id
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.