From 486fdecbccb4837b8cefefa0befb6f70988ee906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Fri, 24 Jul 2020 14:55:03 -0700 Subject: [PATCH] Cleanup. --- src/renderer_vk.cpp | 6 +++-- src/renderer_vk.h | 66 ++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 7737fd476..b0732892d 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -2263,8 +2263,10 @@ VK_IMPORT_DEVICE vkSetDebugUtilsObjectNameEXT = stubSetDebugUtilsObjectNameEXT; } - if (NULL == vkCmdBeginDebugUtilsLabelEXT - || NULL == vkCmdEndDebugUtilsLabelEXT) + if (!s_extension[Extension::EXT_debug_utils].m_supported + || NULL == vkCmdBeginDebugUtilsLabelEXT + || NULL == vkCmdEndDebugUtilsLabelEXT + ) { vkCmdBeginDebugUtilsLabelEXT = stubCmdBeginDebugUtilsLabelEXT; vkCmdEndDebugUtilsLabelEXT = stubCmdEndDebugUtilsLabelEXT; diff --git a/src/renderer_vk.h b/src/renderer_vk.h index 718fc297f..8d35358f8 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -228,47 +228,45 @@ # define VK_CHECK(_call) _call #endif // BGFX_CONFIG_DEBUG +#if BGFX_CONFIG_DEBUG_ANNOTATION +# define BGFX_VK_BEGIN_DEBUG_UTILS_LABEL(_name, _abgr) \ + BX_MACRO_BLOCK_BEGIN \ + VkDebugUtilsLabelEXT dul; \ + dul.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; \ + dul.pNext = NULL; \ + dul.pLabelName = _name; \ + dul.color[0] = ((_abgr >> 24) & 0xff) / 255.0f; \ + dul.color[1] = ((_abgr >> 16) & 0xff) / 255.0f; \ + dul.color[2] = ((_abgr >> 8) & 0xff) / 255.0f; \ + dul.color[3] = ((_abgr >> 0) & 0xff) / 255.0f; \ + vkCmdBeginDebugUtilsLabelEXT(m_commandBuffer, &dul); \ + BX_MACRO_BLOCK_END + +# define BGFX_VK_END_DEBUG_UTILS_LABEL() \ + BX_MACRO_BLOCK_BEGIN \ + vkCmdEndDebugUtilsLabelEXT(m_commandBuffer); \ + BX_MACRO_BLOCK_END +#else +# define BGFX_VK_BEGIN_DEBUG_UTILS_LABEL(_view, _abgr) BX_UNUSED(_view, _abgr) +# define BGFX_VK_END_DEBUG_UTILS_LABEL() BX_NOOP +#endif // BGFX_CONFIG_DEBUG_ANNOTATION + #define BGFX_VK_PROFILER_BEGIN(_view, _abgr) \ BX_MACRO_BLOCK_BEGIN \ - if (s_extension[Extension::EXT_debug_utils].m_supported ) \ - { \ - VkDebugUtilsLabelEXT dul; \ - dul.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; \ - dul.pNext = NULL; \ - dul.pLabelName = s_viewName[view]; \ - dul.color[0] = ((_abgr >> 24) & 0xff) / 255.0f; \ - dul.color[1] = ((_abgr >> 16) & 0xff) / 255.0f; \ - dul.color[2] = ((_abgr >> 8) & 0xff) / 255.0f; \ - dul.color[3] = ((_abgr >> 0) & 0xff) / 255.0f; \ - vkCmdBeginDebugUtilsLabelEXT(m_commandBuffer, &dul); \ - } \ + BGFX_VK_BEGIN_DEBUG_UTILS_LABEL(s_viewName[view], _abgr); \ BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \ BX_MACRO_BLOCK_END -#define BGFX_VK_PROFILER_BEGIN_LITERAL(_name, _abgr) \ - BX_MACRO_BLOCK_BEGIN \ - if (s_extension[Extension::EXT_debug_utils].m_supported ) \ - { \ - VkDebugUtilsLabelEXT dul; \ - dul.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; \ - dul.pNext = NULL; \ - dul.pLabelName = "" _name; \ - dul.color[0] = ((_abgr >> 24) & 0xff) / 255.0f; \ - dul.color[1] = ((_abgr >> 16) & 0xff) / 255.0f; \ - dul.color[2] = ((_abgr >> 8) & 0xff) / 255.0f; \ - dul.color[3] = ((_abgr >> 0) & 0xff) / 255.0f; \ - vkCmdBeginDebugUtilsLabelEXT(m_commandBuffer, &dul); \ - } \ - BGFX_PROFILER_BEGIN_LITERAL("" _name, _abgr); \ +#define BGFX_VK_PROFILER_BEGIN_LITERAL(_name, _abgr) \ + BX_MACRO_BLOCK_BEGIN \ + BGFX_VK_BEGIN_DEBUG_UTILS_LABEL(_name, _abgr); \ + BGFX_PROFILER_BEGIN_LITERAL("" _name, _abgr); \ BX_MACRO_BLOCK_END -#define BGFX_VK_PROFILER_END() \ - BX_MACRO_BLOCK_BEGIN \ - BGFX_PROFILER_END(); \ - if (s_extension[Extension::EXT_debug_utils].m_supported ) \ - { \ - vkCmdEndDebugUtilsLabelEXT(m_commandBuffer); \ - } \ +#define BGFX_VK_PROFILER_END() \ + BX_MACRO_BLOCK_BEGIN \ + BGFX_PROFILER_END(); \ + BGFX_VK_END_DEBUG_UTILS_LABEL(); \ BX_MACRO_BLOCK_END namespace bgfx { namespace vk