[Bf-blender-cvs] [8eda18f789d] master: GPUDebug: Add function to test if inside a debug group

Clément Foucault noreply at git.blender.org
Wed Sep 16 01:40:58 CEST 2020


Commit: 8eda18f789dc95a2b526df473ee16c75a4e87229
Author: Clément Foucault
Date:   Wed Sep 16 01:36:32 2020 +0200
Branches: master
https://developer.blender.org/rB8eda18f789dc95a2b526df473ee16c75a4e87229

GPUDebug: Add function to test if inside a debug group

This is a nice way to check certain GPU codepaths only for some
regions or callers paths.

===================================================================

M	source/blender/gpu/GPU_debug.h
M	source/blender/gpu/intern/gpu_debug.cc

===================================================================

diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h
index a219222b759..8e8d889b387 100644
--- a/source/blender/gpu/GPU_debug.h
+++ b/source/blender/gpu/GPU_debug.h
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include "BLI_sys_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -32,6 +34,7 @@ extern "C" {
 void GPU_debug_group_begin(const char *name);
 void GPU_debug_group_end(void);
 void GPU_debug_get_groups_names(int name_buf_len, char *r_name_buf);
+bool GPU_debug_group_match(const char *ref);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/gpu/intern/gpu_debug.cc b/source/blender/gpu/intern/gpu_debug.cc
index d4b55d7e758..a0608f52c4a 100644
--- a/source/blender/gpu/intern/gpu_debug.cc
+++ b/source/blender/gpu/intern/gpu_debug.cc
@@ -73,4 +73,22 @@ void GPU_debug_get_groups_names(int name_buf_len, char *r_name_buf)
     sz += BLI_snprintf_rlen(r_name_buf + sz, name_buf_len - sz, "%s > ", name.data());
   }
   r_name_buf[sz - 2] = ':';
-}
\ No newline at end of file
+}
+
+/* Return true if inside a debug group with the same name. */
+bool GPU_debug_group_match(const char *ref)
+{
+  /* Otherwise there will be no names. */
+  BLI_assert(G.debug & G_DEBUG_GPU);
+  Context *ctx = Context::get();
+  if (ctx == nullptr) {
+    return false;
+  }
+  DebugStack &stack = ctx->debug_stack;
+  for (StringRef &name : stack) {
+    if (STREQ(name.data(), ref)) {
+      return true;
+    }
+  }
+  return false;
+}



More information about the Bf-blender-cvs mailing list