From 39fc0b5af67aa2dc0763394b0727e919840f9f57 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 29 Dec 2024 23:06:39 +1100 Subject: debug markers --- c2.cpp | 12 +++++++++++- video.cpp | 19 +++++++++++++++++++ video.hpp | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/c2.cpp b/c2.cpp index 264f071..936638d 100644 --- a/c2.cpp +++ b/c2.cpp @@ -182,7 +182,11 @@ extern "C" int entrypoint() { draw.vertex_count = 3; draw.instance_count = 1; - dev->get_ctx().submit(draw, pip, pass); + Context& ctx = dev->get_ctx(); + + ctx.debug_push("autism triangle"); + ctx.submit(draw, pip, pass); + ctx.debug_pop(); pb.begin_rp(); pb.rp_depth_target(dev->get_depth_target(), 1.0f); @@ -213,6 +217,7 @@ extern "C" int entrypoint() { raxis )); monkey->update_transforms(); + ctx.debug_push("depth prepass"); monkey->render( dev, &frame_arena, @@ -220,6 +225,8 @@ extern "C" int entrypoint() { transform, projection ); + ctx.debug_pop(); + ctx.debug_push("forward"); monkey->render( dev, &frame_arena, @@ -227,8 +234,11 @@ extern "C" int entrypoint() { transform, projection ); + ctx.debug_pop(); + ctx.debug_push("ui"); ui->render(&frame_arena, dev->get_backbuffer()); + ctx.debug_pop(); r += 10; rot += 0.05f; diff --git a/video.cpp b/video.cpp index 586a78e..165dd9b 100644 --- a/video.cpp +++ b/video.cpp @@ -2303,6 +2303,25 @@ void Context::transition(Texture_Id id, Resource_State state) { ); } +void Context::debug_push(const char* name) { +#ifdef DEBUG + VkDebugUtilsLabelEXT l{}; + Context_Vk* ctx = (Context_Vk*)this; + l.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; + l.pLabelName = name; + vkCmdBeginDebugUtilsLabelEXT(ctx->cb, &l); +#else + (void)name; +#endif +} + +void Context::debug_pop() { +#ifdef DEBUG + Context_Vk* ctx = (Context_Vk*)this; + vkCmdEndDebugUtilsLabelEXT(ctx->cb); +#endif +} + std::pair Context_Vk::begin_rp( const Render_Pass& rp ) { diff --git a/video.hpp b/video.hpp index 9b64543..c89c60a 100644 --- a/video.hpp +++ b/video.hpp @@ -467,6 +467,8 @@ struct Context { void copy(Buffer_Id dst, Buffer_Id src); void copy(Texture_Id dst, Buffer_Id src); void transition(Texture_Id id, Resource_State state); + void debug_push(const char* name); + void debug_pop(); }; struct Shader : public Asset { -- cgit v1.2.3-54-g00ecf