[Bf-blender-cvs] [2de9bf1138] blender2.8: skip OpenGL debug logic on Apple

Mike Erwin noreply at git.blender.org
Tue Feb 28 10:40:02 CET 2017


Commit: 2de9bf1138768bce6bd0698d5185fee97520a600
Author: Mike Erwin
Date:   Tue Feb 28 04:38:30 2017 -0500
Branches: blender2.8
https://developer.blender.org/rB2de9bf1138768bce6bd0698d5185fee97520a600

skip OpenGL debug logic on Apple

ifdef out most debugging code since Apple does not implement any debug extensions. We can revisit this if they ever do (don't expect that).

Changed output message so Mac users don't think --debug-gpu is broken.

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

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 4be85096a5..bfda589b45 100644
--- a/source/blender/gpu/intern/gpu_debug.c
+++ b/source/blender/gpu/intern/gpu_debug.c
@@ -43,16 +43,18 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifndef __APPLE__ /* only non-Apple systems implement OpenGL debug callbacks */
+
 /* control whether we use older AMD_debug_output extension
  * some supported GPU + OS combos do not have the newer extensions */
-#define LEGACY_DEBUG 1
+ #define LEGACY_DEBUG 1
 
 /* Debug callbacks need the same calling convention as OpenGL functions. */
-#if defined(_WIN32)
-#   define APIENTRY __stdcall
-#else
-#   define APIENTRY
-#endif
+ #if defined(_WIN32)
+  #define APIENTRY __stdcall
+ #else
+  #define APIENTRY
+ #endif
 
 
 static const char* source_name(GLenum source)
@@ -105,7 +107,7 @@ static void APIENTRY gpu_debug_proc(
 	}
 }
 
-#if LEGACY_DEBUG
+ #if LEGACY_DEBUG
 
 static const char* category_name_amd(GLenum category)
 {
@@ -143,12 +145,16 @@ static void APIENTRY gpu_debug_proc_amd(
 		fflush(stderr);
 	}
 }
-#endif /* LEGACY_DEBUG */
+ #endif /* LEGACY_DEBUG */
 
-#undef APIENTRY
+ #undef APIENTRY
+#endif /* not Apple */
 
 void gpu_debug_init(void)
 {
+#ifdef __APPLE__
+	fprintf(stderr, "OpenGL debug callback is not available on Apple.\n");
+#else /* not Apple */
 	const char success[] = "Successfully hooked OpenGL debug callback.";
 
 	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
@@ -166,37 +172,43 @@ void gpu_debug_init(void)
 		glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
 		GPU_string_marker(success);
 	}
-#if LEGACY_DEBUG
+ #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);
 	}
-#endif
+ #endif
 	else {
 		fprintf(stderr, "Failed to hook OpenGL debug callback.\n");
 	}
+#endif /* not Apple */
 }
 
 
 void gpu_debug_exit(void)
 {
+#ifndef __APPLE__
 	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
 		glDebugMessageCallback(NULL, NULL);
 	}
 	else if (GLEW_ARB_debug_output) {
 		glDebugMessageCallbackARB(NULL, NULL);
 	}
-#if LEGACY_DEBUG
+ #if LEGACY_DEBUG
 	else if (GLEW_AMD_debug_output) {
 		glDebugMessageCallbackAMD(NULL, NULL);
 	}
+ #endif
 #endif
 }
 
 void GPU_string_marker(const char *buf)
 {
+#ifdef __APPLE__
+	UNUSED_VARS(buf);
+#else /* not Apple */
 	if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
 		glDebugMessageInsert(
 		        GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
@@ -207,13 +219,14 @@ void GPU_string_marker(const char *buf)
 		        GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0,
 		        GL_DEBUG_SEVERITY_LOW_ARB, -1, buf);
 	}
-#if LEGACY_DEBUG
+ #if LEGACY_DEBUG
 	else if (GLEW_AMD_debug_output) {
 		glDebugMessageInsertAMD(
 		        GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0,
 		        0, buf);
 	}
-#endif
+ #endif
+#endif /* not Apple */
 }
 
 void GPU_print_error_debug(const char *str)




More information about the Bf-blender-cvs mailing list