[Bf-blender-cvs] [1dbe26f] blender2.8: OpenGL: simplify debug, use only newer features

Mike Erwin noreply at git.blender.org
Mon Nov 14 03:34:43 CET 2016


Commit: 1dbe26f76ced8f9824dde78c5985cc26b844f5bd
Author: Mike Erwin
Date:   Sat Nov 12 17:18:13 2016 -0600
Branches: blender2.8
https://developer.blender.org/rB1dbe26f76ced8f9824dde78c5985cc26b844f5bd

OpenGL: simplify debug, use only newer features

Drop SciTech support & workarounds for WinCE and OpenGL ES.

AMD_debug_output is still in the code but disabled. Once I verify the newer extensions are available on all the GPU + OS combos we support we can delete this disabled code.

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

M	source/blender/gpu/intern/gpu_debug.c

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

diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c
index c25103d..e306394 100644
--- a/source/blender/gpu/intern/gpu_debug.c
+++ b/source/blender/gpu/intern/gpu_debug.c
@@ -43,11 +43,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+/* control whether we use older AMD_debug_output extension, or just the newer extensions
+ * TODO(merwin): determine whether all supported GPU + OS combos have newer extensions */
+#define LEGACY_DEBUG 0
 
-/* Debug callbacks need the same calling convention as OpenGL functions.
- */
-#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
-    /* Win32 but not WinCE */
+/* Debug callbacks need the same calling convention as OpenGL functions. */
+#if defined(_WIN32)
 #   define APIENTRY __stdcall
 #else
 #   define APIENTRY
@@ -81,22 +82,6 @@ static const char* message_type_name(GLenum message)
 	}
 }
 
-static const char* category_name_amd(GLenum category)
-{
-	switch (category) {
-		case GL_DEBUG_CATEGORY_API_ERROR_AMD: return "API error";
-		case GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: return "window system";
-		case GL_DEBUG_CATEGORY_DEPRECATION_AMD: return "deprecated behavior";
-		case GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: return "undefined behavior";
-		case GL_DEBUG_CATEGORY_PERFORMANCE_AMD: return "performance";
-		case GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: return "shader compiler";
-		case GL_DEBUG_CATEGORY_APPLICATION_AMD: return "application";
-		case GL_DEBUG_CATEGORY_OTHER_AMD: return "other";
-		default: return "???";
-	}
-}
-
-
 static void APIENTRY gpu_debug_proc(
         GLenum source, GLenum type, GLuint UNUSED(id),
         GLenum severity, GLsizei UNUSED(length),
@@ -120,8 +105,23 @@ static void APIENTRY gpu_debug_proc(
 	}
 }
 
+#if LEGACY_DEBUG
+
+static const char* category_name_amd(GLenum category)
+{
+	switch (category) {
+		case GL_DEBUG_CATEGORY_API_ERROR_AMD: return "API error";
+		case GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: return "window system";
+		case GL_DEBUG_CATEGORY_DEPRECATION_AMD: return "deprecated behavior";
+		case GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: return "undefined behavior";
+		case GL_DEBUG_CATEGORY_PERFORMANCE_AMD: return "performance";
+		case GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: return "shader compiler";
+		case GL_DEBUG_CATEGORY_APPLICATION_AMD: return "application";
+		case GL_DEBUG_CATEGORY_OTHER_AMD: return "other";
+		default: return "???";
+	}
+}
 
-#ifndef GLEW_ES_ONLY
 static void APIENTRY gpu_debug_proc_amd(
         GLuint UNUSED(id), GLenum category,
         GLenum severity, GLsizei UNUSED(length),
@@ -143,8 +143,7 @@ static void APIENTRY gpu_debug_proc_amd(
 		fflush(stderr);
 	}
 }
-#endif
-
+#endif /* LEGACY_DEBUG */
 
 #undef APIENTRY
 
@@ -152,137 +151,67 @@ void gpu_debug_init(void)
 {
 	const char success[] = "Successfully hooked OpenGL debug callback.";
 
-#if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY)
-	if (GLEW_VERSION_4_3) {
-		fprintf(stderr, "Using OpenGL 4.3 debug facilities\n");
-		glEnable(GL_DEBUG_OUTPUT);
-		glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
-		glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
-		glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
-		GPU_string_marker(success);
-		return;
-	}
-#endif
-
-	if (GLEW_KHR_debug) {
-#ifndef GLEW_ES_ONLY
-		fprintf(stderr, "Using KHR_debug extension\n");
+	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
+		fprintf(stderr, "Using %s\n", GLEW_VERSION_4_3 ? "OpenGL 4.3 debug facilities" : "KHR_debug extension");
 		glEnable(GL_DEBUG_OUTPUT);
 		glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
 		glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
 		glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
 		GPU_string_marker(success);
-#endif
-		return;
 	}
-
-#ifndef GLEW_ES_ONLY
-	if (GLEW_ARB_debug_output) {
+	else if (GLEW_ARB_debug_output) {
 		fprintf(stderr, "Using ARB_debug_output extension\n");
 		glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
 		glDebugMessageCallbackARB((GLDEBUGPROCARB)gpu_debug_proc, mxGetCurrentContext());
 		glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
 		GPU_string_marker(success);
-
-		return;
 	}
-
-	if (GLEW_AMD_debug_output) {
+#if LEGACY_DEBUG
+	else if (GLEW_AMD_debug_output) {
 		fprintf(stderr, "Using AMD_debug_output extension\n");
 		glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext());
 		glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
 		GPU_string_marker(success);
-
-		return;
 	}
 #endif
-
-	fprintf(stderr, "Failed to hook OpenGL debug callback.\n");
-
-	return;
+	else {
+		fprintf(stderr, "Failed to hook OpenGL debug callback.\n");
+	}
 }
 
 
 void gpu_debug_exit(void)
 {
-#ifndef WITH_GLEW_ES
-#ifndef GLEW_ES_ONLY
-	if (GLEW_VERSION_4_3) {
-		glDebugMessageCallback(NULL, NULL);
-
-		return;
-	}
-#endif
-#endif
-
-	if (GLEW_KHR_debug) {
-#ifndef GLEW_ES_ONLY
+	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
 		glDebugMessageCallback(NULL, NULL);
-#endif
-		return;
 	}
-
-#ifndef GLEW_ES_ONLY
-	if (GLEW_ARB_debug_output) {
+	else if (GLEW_ARB_debug_output) {
 		glDebugMessageCallbackARB(NULL, NULL);
-
-		return;
 	}
-
-	if (GLEW_AMD_debug_output) {
+#if LEGACY_DEBUG
+	else if (GLEW_AMD_debug_output) {
 		glDebugMessageCallbackAMD(NULL, NULL);
-
-		return;
 	}
 #endif
-
-	return;
 }
 
 void GPU_string_marker(const char *buf)
 {
-#ifndef WITH_GLEW_ES
-#ifndef GLEW_ES_ONLY
-	if (GLEW_VERSION_4_3) {
+	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
 		glDebugMessageInsert(
 		        GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
 		        GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf);
-
-		return;
 	}
-#endif
-#endif
-
-	if (GLEW_KHR_debug) {
-#ifndef GLEW_ES_ONLY
-		glDebugMessageInsert(
-		        GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
-		        GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf);
-#endif
-		return;
-	}
-
-#ifndef GLEW_ES_ONLY
-	if (GLEW_ARB_debug_output) {
+	else if (GLEW_ARB_debug_output) {
 		glDebugMessageInsertARB(
 		        GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0,
 		        GL_DEBUG_SEVERITY_LOW_ARB, -1, buf);
-
-		return;
 	}
-
-	if (GLEW_AMD_debug_output) {
+#if LEGACY_DEBUG
+	else if (GLEW_AMD_debug_output) {
 		glDebugMessageInsertAMD(
 		        GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0,
 		        0, buf);
-
-		return;
-	}
-
-	if (GLEW_GREMEDY_string_marker) {
-		glStringMarkerGREMEDY(0, buf);
-
-		return;
 	}
 #endif
 }




More information about the Bf-blender-cvs mailing list