[Bf-blender-cvs] [00808eb] master: Make OpenGL debug contexts a flag --debug-gpu instead of a compile time option.

Antony Riakiotakis noreply at git.blender.org
Thu Jul 2 19:30:29 CEST 2015


Commit: 00808eb39ac04c484fcabac6b18666cb2a0191e7
Author: Antony Riakiotakis
Date:   Thu Jul 2 19:30:08 2015 +0200
Branches: master
https://developer.blender.org/rB00808eb39ac04c484fcabac6b18666cb2a0191e7

Make OpenGL debug contexts a flag --debug-gpu instead of a compile time
option.

This makes sense, since contexts get created at runtime, there is little
reason to require recompilation for this.

Only works on linux currently, will be doing more OSs later

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

M	CMakeLists.txt
M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_ContextGLX.h
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp
M	intern/ghost/intern/GHOST_WindowX11.h
M	source/blender/blenkernel/BKE_global.h
M	source/blender/gpu/GPU_debug.h
M	source/blender/gpu/intern/gpu_debug.c
M	source/blender/gpu/intern/gpu_init_exit.c
M	source/blender/gpu/intern/gpu_private.h
M	source/blender/windowmanager/intern/wm_window.c
M	source/creator/creator.c

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f710662..8b14ec8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -411,7 +411,6 @@ option(WITH_GL_EGL              "Use the EGL OpenGL system library instead of th
 option(WITH_GL_PROFILE_COMPAT   "Support using the OpenGL 'compatibility' profile. (deprecated)"                                                    ON )
 option(WITH_GL_PROFILE_CORE     "Support using the OpenGL 3.2+ 'core' profile."                                                                     OFF)
 option(WITH_GL_PROFILE_ES20     "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)"                                  OFF)
-option(WITH_GPU_DEBUG           "Create a debug OpenGL context (allows inserting custom messages and getting notifications for bad GL use)"         OFF)
 
 mark_as_advanced(
 	WITH_GLEW_MX
@@ -420,7 +419,6 @@ mark_as_advanced(
 	WITH_GL_PROFILE_COMPAT
 	WITH_GL_PROFILE_CORE
 	WITH_GL_PROFILE_ES20
-	WITH_GPU_DEBUG
 )
 
 if(WITH_GL_PROFILE_COMPAT)
@@ -2351,10 +2349,6 @@ if(WITH_GL_EGL)
 	list(APPEND GL_DEFINITIONS -DWITH_EGL)
 endif()
 
-if(WITH_GPU_DEBUG)
-	list(APPEND GL_DEFINITIONS -DWITH_GPU_DEBUG)
-endif()
-
 #-----------------------------------------------------------------------------
 # Configure OpenMP.
 if(WITH_OPENMP)
@@ -2862,7 +2856,6 @@ if(FIRST_RUN)
 	info_cfg_option(WITH_GL_PROFILE_COMPAT)
 	info_cfg_option(WITH_GL_PROFILE_CORE)
 	info_cfg_option(WITH_GL_PROFILE_ES20)
-	info_cfg_option(WITH_GPU_DEBUG)
 	if(WIN32)
 		info_cfg_option(WITH_GL_ANGLE)
 	endif()
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 752a45c..7a73af3 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -57,7 +57,8 @@ typedef struct {
 
 typedef enum {
 	GHOST_glStereoVisual = (1 << 0),
-	GHOST_glWarnSupport  = (1 << 1)
+	GHOST_glWarnSupport  = (1 << 1),
+	GHOST_glDebugContext = (1 << 2),
 } GHOST_GLFlags;
 
 
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index b33c0b5..04fe58a 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -46,11 +46,8 @@ extern "C" GLXEWContext *glxewContext;
 
 
 #ifndef GHOST_OPENGL_GLX_CONTEXT_FLAGS
-#  ifdef WITH_GPU_DEBUG
-#    define GHOST_OPENGL_GLX_CONTEXT_FLAGS GLX_CONTEXT_DEBUG_BIT_ARB
-#  else
-#    define GHOST_OPENGL_GLX_CONTEXT_FLAGS 0
-#  endif
+/* leave as convenience define for the future */
+#define GHOST_OPENGL_GLX_CONTEXT_FLAGS 0
 #endif
 
 #ifndef GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 4523739..325cba0 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -306,7 +306,7 @@ createWindow(const STR_String& title,
 	                             left, top, width, height,
 	                             state, parentWindow, type,
 	                             ((glSettings.flags & GHOST_glStereoVisual) != 0), exclusive,
-	                             glSettings.numOfAASamples);
+	                             glSettings.numOfAASamples, (glSettings.flags & GHOST_glDebugContext) != 0);
 
 	if (window) {
 		/* Both are now handle in GHOST_WindowX11.cpp
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index bd0d682..9c66900 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -272,8 +272,7 @@ static XVisualInfo *x11_visualinfo_from_glx(
 }
 
 GHOST_WindowX11::
-GHOST_WindowX11(
-        GHOST_SystemX11 *system,
+GHOST_WindowX11(GHOST_SystemX11 *system,
         Display *display,
         const STR_String &title,
         GHOST_TInt32 left,
@@ -285,7 +284,7 @@ GHOST_WindowX11(
         GHOST_TDrawingContextType type,
         const bool stereoVisual,
         const bool exclusive,
-        const GHOST_TUns16 numOfAASamples)
+        const GHOST_TUns16 numOfAASamples, const bool is_debug)
     : GHOST_Window(width, height, state, stereoVisual, exclusive, numOfAASamples),
       m_display(display),
       m_visualInfo(NULL),
@@ -301,7 +300,8 @@ GHOST_WindowX11(
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
       m_xic(NULL),
 #endif
-      m_valid_setup(false)
+      m_valid_setup(false),
+      m_is_debug_context(is_debug)
 {
 	if (type == GHOST_kDrawingContextTypeOpenGL) {
 		m_visualInfo = x11_visualinfo_from_glx(m_display, stereoVisual, &m_wantNumOfAASamples);
@@ -1284,7 +1284,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 		        m_visualInfo,
 		        GLX_CONTEXT_OPENGL_CORE_PROFILE_BIT,
 		        3, 2,
-		        GHOST_OPENGL_GLX_CONTEXT_FLAGS,
+		        GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 		        GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 #elif defined(WITH_GL_PROFILE_ES20)
 		GHOST_Context *context = new GHOST_ContextGLX(
@@ -1295,7 +1295,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 		        m_visualInfo,
 		        GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
 		        2, 0,
-		        GHOST_OPENGL_GLX_CONTEXT_FLAGS,
+		        GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 		        GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 #elif defined(WITH_GL_PROFILE_COMPAT)
 		GHOST_Context *context = new GHOST_ContextGLX(
@@ -1306,7 +1306,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 		        m_visualInfo,
 		        0, // profile bit
 		        0, 0,
-		        GHOST_OPENGL_GLX_CONTEXT_FLAGS,
+		        GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 		        GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 #else
 #  error
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 77287c1..5beb7b4 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -88,7 +88,8 @@ public:
 	    GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
 	    const bool stereoVisual = false,
 	    const bool exclusive = false,
-	    const GHOST_TUns16 numOfAASamples = 0
+	    const GHOST_TUns16 numOfAASamples = 0,
+	    const bool is_debug = false
 	    );
 
 	bool
@@ -354,6 +355,7 @@ private:
 #endif
 
 	bool m_valid_setup;
+	bool m_is_debug_context;
 
 	void icccmSetState(int state);
 	int icccmGetState() const;
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 7585dc2..8a3ffc6 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -128,6 +128,7 @@ enum {
 	G_DEBUG_SIMDATA =   (1 << 9), /* sim debug data display */
 	G_DEBUG_GPU_MEM =   (1 << 10), /* gpu memory in status bar */
 	G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 11),  /* sinle threaded depsgraph */
+	G_DEBUG_GPU =        (1 << 12), /* gpu debug */
 };
 
 #define G_DEBUG_ALL  (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h
index f89df2b..2c1728b 100644
--- a/source/blender/gpu/GPU_debug.h
+++ b/source/blender/gpu/GPU_debug.h
@@ -49,9 +49,9 @@ const char *gpuErrorString(GLenum err);
 /* prints current OpenGL state */
 void GPU_state_print(void);
 
-void gpu_assert_no_gl_errors(const char *file, int line, const char *str);
+void GPU_assert_no_gl_errors(const char *file, int line, const char *str);
 
-#  define GPU_ASSERT_NO_GL_ERRORS(str) gpu_assert_no_gl_errors(__FILE__, __LINE__, (str))
+#  define GPU_ASSERT_NO_GL_ERRORS(str) GPU_assert_no_gl_errors(__FILE__, __LINE__, (str))
 
 #  define GPU_CHECK_ERRORS_AROUND(glProcCall)                      \
        (                                             \
@@ -61,14 +61,8 @@ void gpu_assert_no_gl_errors(const char *file, int line, const char *str);
        )
 
 
-#ifdef WITH_GPU_DEBUG
 /* inserts a debug marker message for the debug context messaging system */
-void gpu_string_marker(size_t size, const char *str);
-
-#  define GPU_STRING_MARKER(size, str) gpu_string_marker((size), (str))
-#else /* WITH_GPU_DEBUG */
-#  define GPU_STRING_MARKER(len, str)  ((void)(size),(void)(str))
-#endif /* WITH_GPU_DEBUG */
+void GPU_string_marker(size_t size, const char *str);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c
index d06c154..3066467 100644
--- a/source/blender/gpu/intern/gpu_debug.c
+++ b/source/blender/gpu/intern/gpu_debug.c
@@ -153,8 +153,6 @@ const char* gpuErrorString(GLenum err)
 }
 
 
-#ifdef WITH_GPU_DEBUG
-
 /* Debug callbacks need the same calling convention as OpenGL functions.
  */
 #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
@@ -191,10 +189,10 @@ void gpu_debug_init(void)
 
 #if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY)
 	if (GLEW_VERSION_4_3) {
-		//glEnable(GL_DEBUG_OUTPUT);
+		glEnable(GL_DEBUG_OUTPUT);
 		glDebugMessageCallback(gpu_debug_proc, mxGetCurrentContext());
 		glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
-		GPU_STRING_MARKER(sizeof(success), success);
+		GPU_string_marker(sizeof(success), success);
 		return;
 	}
 #endif
@@ -203,7 +201,7 @@ void gpu_debug_init(void)
 #ifndef GLEW_ES_ONLY
 			glDebugMessageCallback(gpu_debug_proc, mxGetCurrentContext());
 			glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
-			GPU_STRING_MARKER(sizeof(success), success);
+			GPU_string_marker(sizeof(success), success);
 #endif
 		return;
 	}
@@ -212,7 +210,7 @@ void gpu_debug_init(void)
 	if (GLEW_ARB_debug_output) {
 		glDebugMessageCallbackARB(gpu_debug_proc, mxGetCurrentContext());
 		glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
-		GPU_STRING_MARKER(sizeof(success), success);
+		GPU_string_marker(sizeof(success), success);
 
 		return;
 	}
@@ -220,7 +218,7 @@ void gpu_debug_init(void)
 	if (GLEW_AMD_debug_output) {
 		glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext());
 		glDebugM

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list