From b8effaf42c47f536cc7753823eced1568fa76b46 Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 19 Jul 2021 04:12:29 -0400 Subject: [PATCH] [client] egl: use glGetError and codes for errors in gl* functions We used to use DEBUG_EGL_ERROR for gl* functions, which just yields EGL_SUCCESS even when there are errors. --- client/renderers/EGL/egldebug.c | 15 +++++++++++++++ client/renderers/EGL/egldebug.h | 7 +++++++ client/renderers/EGL/texture.c | 8 ++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/client/renderers/EGL/egldebug.c b/client/renderers/EGL/egldebug.c index 1744e818..761c3ab5 100644 --- a/client/renderers/EGL/egldebug.c +++ b/client/renderers/EGL/egldebug.c @@ -19,6 +19,7 @@ */ #include "egldebug.h" +#include #include const char * egl_getErrorStr(void) @@ -43,3 +44,17 @@ const char * egl_getErrorStr(void) default : return "UNKNOWN"; } } + +const char * gl_getErrorStr(void) +{ + switch (glGetError()) + { + case GL_NO_ERROR : return "GL_NO_ERROR"; + case GL_INVALID_ENUM : return "GL_INVALID_ENUM"; + case GL_INVALID_VALUE : return "GL_INVALID_VALUE"; + case GL_INVALID_OPERATION : return "GL_INVALID_OPERATION"; + case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION"; + case GL_OUT_OF_MEMORY : return "GL_OUT_OF_MEMORY"; + default : return "UNKNOWN"; + } +} diff --git a/client/renderers/EGL/egldebug.h b/client/renderers/EGL/egldebug.h index 004c46a3..892c1151 100644 --- a/client/renderers/EGL/egldebug.h +++ b/client/renderers/EGL/egldebug.h @@ -21,9 +21,16 @@ #include "common/debug.h" const char * egl_getErrorStr(void); +const char * gl_getErrorStr(void); #define DEBUG_EGL_WARN(fmt, ...) \ DEBUG_WARN(fmt " (%s)", ##__VA_ARGS__, egl_getErrorStr()) #define DEBUG_EGL_ERROR(fmt, ...) \ DEBUG_ERROR(fmt " (%s)", ##__VA_ARGS__, egl_getErrorStr()) + +#define DEBUG_GL_WARN(fmt, ...) \ + DEBUG_WARN(fmt " (%s)", ##__VA_ARGS__, gl_getErrorStr()) + +#define DEBUG_GL_ERROR(fmt, ...) \ + DEBUG_ERROR(fmt " (%s)", ##__VA_ARGS__, gl_getErrorStr()) diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index 1becc9f5..cecb1fa7 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -156,7 +156,7 @@ static bool egl_texture_map(EGL_Texture * texture, uint8_t i) if (!texture->buf[i].map) { - DEBUG_EGL_ERROR("glMapBufferRange failed for %d of %lu bytes", i, + DEBUG_GL_ERROR("glMapBufferRange failed for %d of %lu bytes", i, texture->pboBufferSize); } @@ -447,7 +447,7 @@ bool egl_texture_update_from_dma(EGL_Texture * texture, const FrameBuffer * fram void * new = realloc(texture->dmaImages, newCount * sizeof *texture->dmaImages); if (!new) { - DEBUG_EGL_ERROR("Failed to allocate memory"); + DEBUG_ERROR("Failed to allocate memory"); eglDestroyImage(texture->display, image); return false; } @@ -487,7 +487,7 @@ bool egl_texture_update_from_dma(EGL_Texture * texture, const FrameBuffer * fram case GL_WAIT_FAILED: case GL_INVALID_VALUE: - DEBUG_EGL_ERROR("glClientWaitSync failed"); + DEBUG_GL_ERROR("glClientWaitSync failed"); } glDeleteSync(fence); @@ -572,7 +572,7 @@ enum EGL_TexStatus egl_texture_bind(EGL_Texture * texture) case GL_INVALID_VALUE: glDeleteSync(texture->buf[b].sync); texture->buf[b].sync = 0; - DEBUG_EGL_ERROR("glClientWaitSync failed"); + DEBUG_GL_ERROR("glClientWaitSync failed"); return EGL_TEX_STATUS_ERROR; } }