From 4b6fd42451a80e1f9f96ae24e10bc3e9849d1a62 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 23 Nov 2021 11:54:54 +0800 Subject: [PATCH] CommandBuffer supported DebugMaker --- inc/hgl/graph/VKCommandBuffer.h | 10 ++++++++++ src/SceneGraph/Vulkan/VKCommandBuffer.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/inc/hgl/graph/VKCommandBuffer.h b/inc/hgl/graph/VKCommandBuffer.h index 1ced171a..6a69a749 100644 --- a/inc/hgl/graph/VKCommandBuffer.h +++ b/inc/hgl/graph/VKCommandBuffer.h @@ -4,6 +4,7 @@ #include #include #include +#include VK_NAMESPACE_BEGIN //push constant 一般只有128/256字节,仅能存在矩阵。 //所以我们将每个对象的独立变换矩阵存在push constant中 @@ -26,6 +27,15 @@ public: bool Begin(); bool End(){return(vkEndCommandBuffer(cmd_buf)==VK_SUCCESS);} + +#ifdef _DEBUG + void SetDebugName(const char *); + void BeginRegion(const char *,const Color4f &); + void EndRegion(); +#else + void BeginRegion(const char *,const Color4f &){} + void EndRegion(){} +#endif//_DEBUG };//class GPUCmdBuffer class RenderCmdBuffer:public GPUCmdBuffer diff --git a/src/SceneGraph/Vulkan/VKCommandBuffer.cpp b/src/SceneGraph/Vulkan/VKCommandBuffer.cpp index 18250069..1977c10c 100644 --- a/src/SceneGraph/Vulkan/VKCommandBuffer.cpp +++ b/src/SceneGraph/Vulkan/VKCommandBuffer.cpp @@ -24,4 +24,24 @@ bool GPUCmdBuffer::Begin() return(true); } + +#ifdef _DEBUG +void GPUCmdBuffer::SetDebugName(const char *object_name) +{ + if(dev_attr->debug_maker) + dev_attr->debug_maker->SetCommandBufferName(cmd_buf,object_name); +} + +void GPUCmdBuffer::BeginRegion(const char *region_name,const Color4f &color) +{ + if(dev_attr->debug_maker) + dev_attr->debug_maker->Begin(cmd_buf,region_name,color); +} + +void GPUCmdBuffer::EndRegion() +{ + if(dev_attr->debug_maker) + dev_attr->debug_maker->End(cmd_buf); +} +#endif VK_NAMESPACE_END