fix nv2a_debug on mac

yeah yeah, we should probably be using glext...
This commit is contained in:
espes 2015-08-14 15:18:17 +10:00
parent d62d63845e
commit 779d4d4734
3 changed files with 48 additions and 5 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -26,6 +26,8 @@
#include <stdarg.h>
#include <assert.h>
#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