yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #1196 from linkmauve/khr_debug

Add optional GL_KHR_debug support
This commit is contained in:
bunnei 2016-01-12 22:54:52 -05:00
commit 6a261e825c
3 changed files with 648 additions and 384 deletions

File diff suppressed because it is too large Load Diff

View File

@ -595,6 +595,29 @@ PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample; PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform; PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
PFNGLFRONTFACEPROC glad_glFrontFace; PFNGLFRONTFACEPROC glad_glFrontFace;
int GLAD_GL_KHR_debug;
PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
PFNGLOBJECTLABELPROC glad_glObjectLabel;
PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
PFNGLGETPOINTERVPROC glad_glGetPointerv;
PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR;
PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR;
PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR;
PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR;
PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR;
PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR;
PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR;
PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR;
PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR;
PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR;
PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR;
static void load_GL_VERSION_1_0(GLADloadproc load) { static void load_GL_VERSION_1_0(GLADloadproc load) {
if(!GLAD_GL_VERSION_1_0) return; if(!GLAD_GL_VERSION_1_0) return;
glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace"); glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace");
@ -1008,8 +1031,34 @@ static void load_GL_VERSION_3_3(GLADloadproc load) {
glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui"); glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui");
glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv"); glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv");
} }
static void load_GL_KHR_debug(GLADloadproc load) {
if(!GLAD_GL_KHR_debug) return;
glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)load("glDebugMessageControl");
glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)load("glDebugMessageInsert");
glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)load("glDebugMessageCallback");
glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)load("glGetDebugMessageLog");
glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)load("glPushDebugGroup");
glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)load("glPopDebugGroup");
glad_glObjectLabel = (PFNGLOBJECTLABELPROC)load("glObjectLabel");
glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)load("glGetObjectLabel");
glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)load("glObjectPtrLabel");
glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)load("glGetObjectPtrLabel");
glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load("glGetPointerv");
glad_glDebugMessageControlKHR = (PFNGLDEBUGMESSAGECONTROLKHRPROC)load("glDebugMessageControlKHR");
glad_glDebugMessageInsertKHR = (PFNGLDEBUGMESSAGEINSERTKHRPROC)load("glDebugMessageInsertKHR");
glad_glDebugMessageCallbackKHR = (PFNGLDEBUGMESSAGECALLBACKKHRPROC)load("glDebugMessageCallbackKHR");
glad_glGetDebugMessageLogKHR = (PFNGLGETDEBUGMESSAGELOGKHRPROC)load("glGetDebugMessageLogKHR");
glad_glPushDebugGroupKHR = (PFNGLPUSHDEBUGGROUPKHRPROC)load("glPushDebugGroupKHR");
glad_glPopDebugGroupKHR = (PFNGLPOPDEBUGGROUPKHRPROC)load("glPopDebugGroupKHR");
glad_glObjectLabelKHR = (PFNGLOBJECTLABELKHRPROC)load("glObjectLabelKHR");
glad_glGetObjectLabelKHR = (PFNGLGETOBJECTLABELKHRPROC)load("glGetObjectLabelKHR");
glad_glObjectPtrLabelKHR = (PFNGLOBJECTPTRLABELKHRPROC)load("glObjectPtrLabelKHR");
glad_glGetObjectPtrLabelKHR = (PFNGLGETOBJECTPTRLABELKHRPROC)load("glGetObjectPtrLabelKHR");
glad_glGetPointervKHR = (PFNGLGETPOINTERVKHRPROC)load("glGetPointervKHR");
}
static void find_extensionsGL(void) { static void find_extensionsGL(void) {
get_exts(); get_exts();
GLAD_GL_KHR_debug = has_ext("GL_KHR_debug");
} }
static void find_coreGL(void) { static void find_coreGL(void) {
@ -1086,6 +1135,7 @@ int gladLoadGLLoader(GLADloadproc load) {
load_GL_VERSION_3_3(load); load_GL_VERSION_3_3(load);
find_extensionsGL(); find_extensionsGL();
load_GL_KHR_debug(load);
return GLVersion.major != 0 || GLVersion.minor != 0; return GLVersion.major != 0 || GLVersion.minor != 0;
} }
@ -1343,6 +1393,7 @@ static void load_GL_ES_VERSION_3_0(GLADloadproc load) {
} }
static void find_extensionsGLES2(void) { static void find_extensionsGLES2(void) {
get_exts(); get_exts();
GLAD_GL_KHR_debug = has_ext("GL_KHR_debug");
} }
static void find_coreGLES2(void) { static void find_coreGLES2(void) {
@ -1399,6 +1450,7 @@ int gladLoadGLES2Loader(GLADloadproc load) {
load_GL_ES_VERSION_3_0(load); load_GL_ES_VERSION_3_0(load);
find_extensionsGLES2(); find_extensionsGLES2();
load_GL_KHR_debug(load);
return GLVersion.major != 0 || GLVersion.minor != 0; return GLVersion.major != 0 || GLVersion.minor != 0;
} }

View File

@ -394,6 +394,58 @@ void RendererOpenGL::SetWindow(EmuWindow* window) {
render_window = window; render_window = window;
} }
static const char* GetSource(GLenum source) {
#define RET(s) case GL_DEBUG_SOURCE_##s: return #s
switch (source) {
RET(API);
RET(WINDOW_SYSTEM);
RET(SHADER_COMPILER);
RET(THIRD_PARTY);
RET(APPLICATION);
RET(OTHER);
default:
UNREACHABLE();
}
#undef RET
}
static const char* GetType(GLenum type) {
#define RET(t) case GL_DEBUG_TYPE_##t: return #t
switch (type) {
RET(ERROR);
RET(DEPRECATED_BEHAVIOR);
RET(UNDEFINED_BEHAVIOR);
RET(PORTABILITY);
RET(PERFORMANCE);
RET(OTHER);
RET(MARKER);
default:
UNREACHABLE();
}
#undef RET
}
static void DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* user_param) {
Log::Level level;
switch (severity) {
case GL_DEBUG_SEVERITY_HIGH:
level = Log::Level::Error;
break;
case GL_DEBUG_SEVERITY_MEDIUM:
level = Log::Level::Warning;
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
level = Log::Level::Info;
break;
case GL_DEBUG_SEVERITY_LOW:
level = Log::Level::Debug;
break;
}
LOG_GENERIC(Log::Class::Render_OpenGL, level, "%s %s %d: %s",
GetSource(source), GetType(type), id, message);
}
/// Initialize the renderer /// Initialize the renderer
void RendererOpenGL::Init() { void RendererOpenGL::Init() {
render_window->MakeCurrent(); render_window->MakeCurrent();
@ -404,6 +456,11 @@ void RendererOpenGL::Init() {
exit(-1); exit(-1);
} }
if (GLAD_GL_KHR_debug) {
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(DebugHandler, nullptr);
}
LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION)); LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR));
LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER));