From 779d4d47343a6a9c46865f799d211c9fbb9ecd09 Mon Sep 17 00:00:00 2001 From: espes Date: Fri, 14 Aug 2015 15:18:17 +1000 Subject: [PATCH] fix nv2a_debug on mac yeah yeah, we should probably be using glext... --- gl/glextensions.c | 14 ++++++++++++++ gl/glextensions.h | 16 ++++++++++++++++ hw/xbox/nv2a_debug.c | 23 ++++++++++++++++++----- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/gl/glextensions.c b/gl/glextensions.c index a7c9b7a667..06463fcf4c 100644 --- a/gl/glextensions.c +++ b/gl/glextensions.c @@ -21,6 +21,16 @@ #ifdef __APPLE__ void (*glFrameTerminatorGREMEDY)(void); + +void (*glDebugMessageInsert) (GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, + const GLchar *buf); +void (*glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, + const GLchar *message); +void (*glPopDebugGroup)(void); +void (*glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, + const GLchar *label); + #endif void glextensions_init(void) @@ -28,5 +38,9 @@ void glextensions_init(void) #ifdef __APPLE__ glFrameTerminatorGREMEDY = glo_get_extension_proc("glFrameTerminatorGREMEDY"); + glDebugMessageInsert = glo_get_extension_proc("glDebugMessageInsert"); + glPushDebugGroup = glo_get_extension_proc("glPushDebugGroup"); + glPopDebugGroup = glo_get_extension_proc("glPopDebugGroup"); + glObjectLabel = glo_get_extension_proc("glObjectLabel"); #endif } diff --git a/gl/glextensions.h b/gl/glextensions.h index b10c184130..585b11a5e0 100644 --- a/gl/glextensions.h +++ b/gl/glextensions.h @@ -20,7 +20,23 @@ #define GLEXTEENSIONS_H_ #ifdef __APPLE__ +#include "gl/gloffscreen.h" extern void (*glFrameTerminatorGREMEDY)(void); + +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_DEBUG_OUTPUT 0x92E0 + +extern void (*glDebugMessageInsert) (GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, + const GLchar *buf); +extern void (*glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, + const GLchar *message); +extern void (*glPopDebugGroup)(void); +extern void (*glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, + const GLchar *label); + #endif void glextensions_init(void); diff --git a/hw/xbox/nv2a_debug.c b/hw/xbox/nv2a_debug.c index 63f107644d..7e1b38907e 100644 --- a/hw/xbox/nv2a_debug.c +++ b/hw/xbox/nv2a_debug.c @@ -26,6 +26,8 @@ #include #include +#include "gl/glextensions.h" + void gl_debug_message(bool cc, const char *fmt, ...) { size_t n; @@ -35,8 +37,11 @@ void gl_debug_message(bool cc, const char *fmt, ...) n = vsnprintf(buffer, sizeof(buffer), fmt, ap); assert(n <= sizeof(buffer)); va_end(ap); - glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, - 0, GL_DEBUG_SEVERITY_NOTIFICATION, n, buffer); + + if(glDebugMessageInsert) { + glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, + 0, GL_DEBUG_SEVERITY_NOTIFICATION, n, buffer); + } if (cc) { fwrite(buffer, sizeof(char), n, stdout); fputc('\n', stdout); @@ -55,14 +60,20 @@ void gl_debug_group_begin(const char *fmt, ...) /* Check for errors before entering group */ assert(glGetError() == GL_NO_ERROR); - glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, n, buffer); + + if (glPushDebugGroup) { + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, n, buffer); + } } void gl_debug_group_end(void) { /* Check for errors when leaving group */ assert(glGetError() == GL_NO_ERROR); - glPopDebugGroup(); + + if (glPopDebugGroup) { + glPopDebugGroup(); + } } void gl_debug_label(GLenum target, GLuint name, const char *fmt, ...) @@ -75,7 +86,9 @@ void gl_debug_label(GLenum target, GLuint name, const char *fmt, ...) assert(n <= sizeof(buffer)); va_end(ap); - glObjectLabel(target, name, n, buffer); + if (glObjectLabel) { + glObjectLabel(target, name, n, buffer); + } } #endif