Skip to content

Commit bafd516

Browse files
committed
Fix usage of debug utils labels with secondary command buffers.
1 parent 4edb9fd commit bafd516

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

framework/rendering/render_pipeline.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ void RenderPipeline::draw(vkb::core::CommandBufferC &command_buffer, RenderTarge
113113
command_buffer.next_subpass();
114114
}
115115

116-
if (subpass->get_debug_name().empty())
116+
if (contents != VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
117117
{
118-
subpass->set_debug_name(fmt::format("RP subpass #{}", i));
118+
if (subpass->get_debug_name().empty())
119+
{
120+
subpass->set_debug_name(fmt::format("RP subpass #{}", i));
121+
}
122+
ScopedDebugLabel subpass_debug_label{command_buffer, subpass->get_debug_name().c_str()};
119123
}
120-
ScopedDebugLabel subpass_debug_label{command_buffer, subpass->get_debug_name().c_str()};
121124

122125
subpass->draw(command_buffer);
123126
}

samples/performance/command_buffer_usage/command_buffer_usage.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
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
{

samples/performance/command_buffer_usage/command_buffer_usage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,15 @@ class CommandBufferUsage : public vkb::VulkanSampleC
183183
* @param nodes The meshes to draw
184184
* @param mesh_start Index to the first mesh to draw
185185
* @param mesh_end Index to the mesh where recording will stop (not included)
186+
* @param subpass_index Index of the subpass being recorded
186187
* @param thread_index Identifies the resources allocated for this thread
187188
* @return a pointer to the recorded secondary command buffer
188189
*/
189190
std::shared_ptr<vkb::core::CommandBufferC> record_draw_secondary(vkb::core::CommandBufferC &primary_command_buffer,
190191
const std::vector<std::pair<vkb::scene_graph::NodeC *, vkb::sg::SubMesh *>> &nodes,
191192
uint32_t mesh_start,
192193
uint32_t mesh_end,
194+
uint32_t subpass_index,
193195
size_t thread_index = 0);
194196

195197
VkViewport viewport{};

0 commit comments

Comments
 (0)