2020#include < algorithm>
2121#include < numeric>
2222
23+ #include " core/debug.h"
2324#include " core/device.h"
2425#include " core/pipeline_layout.h"
2526#include " core/shader_module.h"
@@ -287,6 +288,7 @@ std::shared_ptr<vkb::core::CommandBufferC>
287288 const std::vector<std::pair<vkb::scene_graph::NodeC *, vkb::sg::SubMesh *>> &nodes,
288289 uint32_t mesh_start,
289290 uint32_t mesh_end,
291+ uint32_t subpass_index,
290292 size_t thread_index)
291293{
292294 const auto &queue = get_render_context ().get_device ().get_queue_by_flags (VK_QUEUE_GRAPHICS_BIT, 0 );
@@ -298,11 +300,15 @@ std::shared_ptr<vkb::core::CommandBufferC>
298300
299301 secondary_command_buffer->begin (VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, &primary_command_buffer);
300302
301- secondary_command_buffer->set_viewport (0 , {viewport});
303+ {
304+ vkb::ScopedDebugLabel subpass_debug_label{*secondary_command_buffer, fmt::format (" Record secondary command buffer, subpass #{}" , subpass_index).c_str ()};
305+
306+ secondary_command_buffer->set_viewport (0 , {viewport});
302307
303- secondary_command_buffer->set_scissor (0 , {scissor});
308+ secondary_command_buffer->set_scissor (0 , {scissor});
304309
305- record_draw (*secondary_command_buffer, nodes, mesh_start, mesh_end, thread_index);
310+ record_draw (*secondary_command_buffer, nodes, mesh_start, mesh_end, thread_index);
311+ }
306312
307313 secondary_command_buffer->end ();
308314
@@ -378,13 +384,14 @@ void CommandBufferUsage::ForwardSubpassSecondary::draw(vkb::core::CommandBufferC
378384 std::cref (sorted_opaque_nodes),
379385 mesh_start,
380386 mesh_end,
387+ cb_count,
381388 std::placeholders::_1));
382389
383390 secondary_cmd_buf_futures.push_back (std::move (fut));
384391 }
385392 else
386393 {
387- secondary_command_buffers.push_back (record_draw_secondary (primary_command_buffer, sorted_opaque_nodes, mesh_start, mesh_end));
394+ secondary_command_buffers.push_back (record_draw_secondary (primary_command_buffer, sorted_opaque_nodes, mesh_start, mesh_end, cb_count ));
388395 }
389396
390397 mesh_start = mesh_end;
@@ -416,7 +423,8 @@ void CommandBufferUsage::ForwardSubpassSecondary::draw(vkb::core::CommandBufferC
416423 {
417424 if (use_secondary_command_buffers)
418425 {
419- secondary_command_buffers.push_back (record_draw_secondary (primary_command_buffer, sorted_transparent_nodes, 0 , transparent_submeshes));
426+ secondary_command_buffers.push_back (
427+ record_draw_secondary (primary_command_buffer, sorted_transparent_nodes, 0 , transparent_submeshes, state.secondary_cmd_buf_count ));
420428 }
421429 else
422430 {
0 commit comments