diff --git a/src/igl/CommandBuffer.h b/src/igl/CommandBuffer.h index 6a0d93b65e..b13e2b3b11 100644 --- a/src/igl/CommandBuffer.h +++ b/src/igl/CommandBuffer.h @@ -150,7 +150,12 @@ class ICommandBuffer { #if IGL_DEBUG && !defined(IGL_DISABLE_DEBUG_BUFFER_LABEL) #define IGL_DEBUG_BUFFER_LABEL_START(buffer, x) (buffer).pushDebugGroupLabel(x) #define IGL_DEBUG_BUFFER_LABEL_END(buffer) (buffer).popDebugGroupLabel() +#define IGL_DEBUG_BUFFER_LABEL_START_GUARD(buffer, x) \ + IGL_DEBUG_BUFFER_LABEL_START(buffer, x); \ + auto popDebugGroupLabelScope = \ + folly::makeGuard([&cmdBuffer = (buffer)]() { IGL_DEBUG_BUFFER_LABEL_END(cmdBuffer); }); #else #define IGL_DEBUG_BUFFER_LABEL_START(buffer, x) #define IGL_DEBUG_BUFFER_LABEL_END(buffer) +#define IGL_DEBUG_BUFFER_LABEL_START_GUARD(buffer, x) #endif // IGL_DEBUG && !defined(IGL_DISABLE_DEBUG_BUFFER_LABEL)