From 7c76f4e65ca3dd9a27dc8033cd651253c3eb8e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 17 Sep 2020 20:48:24 +0200 Subject: [PATCH] Minor improvement to gl_debug_log.h --- ext/native/gfx/gl_debug_log.cpp | 4 +++- ext/native/gfx/gl_debug_log.h | 4 ++-- ext/native/thin3d/GLQueueRunner.cpp | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ext/native/gfx/gl_debug_log.cpp b/ext/native/gfx/gl_debug_log.cpp index 078b4ed843..fc66ccf1dd 100644 --- a/ext/native/gfx/gl_debug_log.cpp +++ b/ext/native/gfx/gl_debug_log.cpp @@ -34,9 +34,11 @@ std::string GLEnumToString(uint16_t value) { } } -void CheckGLError(const char *file, int line) { +bool CheckGLError(const char *file, int line) { GLenum err = glGetError(); if (err != GL_NO_ERROR) { ERROR_LOG(G3D, "GL error %s on %s:%d", GLEnumToString(err).c_str(), file, line); + return false; } + return true; } diff --git a/ext/native/gfx/gl_debug_log.h b/ext/native/gfx/gl_debug_log.h index ae22ab1700..d6d37c4271 100644 --- a/ext/native/gfx/gl_debug_log.h +++ b/ext/native/gfx/gl_debug_log.h @@ -10,8 +10,8 @@ #if defined(DEBUG_OPENGL) -void CheckGLError(const char *file, int line); -#define CHECK_GL_ERROR_IF_DEBUG() CheckGLError(__FILE__, __LINE__) +bool CheckGLError(const char *file, int line); +#define CHECK_GL_ERROR_IF_DEBUG() if (!CheckGLError(__FILE__, __LINE__)) __debugbreak(); #else diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index 9c380ee622..c5da0e4c21 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -1146,6 +1146,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last if (!tex) { break; } + CHECK_GL_ERROR_IF_DEBUG(); if (tex->canWrap) { if (tex->wrapS != c.textureSampler.wrapS) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c.textureSampler.wrapS); @@ -1156,14 +1157,17 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last tex->wrapT = c.textureSampler.wrapT; } } + CHECK_GL_ERROR_IF_DEBUG(); if (tex->magFilter != c.textureSampler.magFilter) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, c.textureSampler.magFilter); tex->magFilter = c.textureSampler.magFilter; } + CHECK_GL_ERROR_IF_DEBUG(); if (tex->minFilter != c.textureSampler.minFilter) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c.textureSampler.minFilter); tex->minFilter = c.textureSampler.minFilter; } + CHECK_GL_ERROR_IF_DEBUG(); if (tex->anisotropy != c.textureSampler.anisotropy) { if (c.textureSampler.anisotropy != 0.0f) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, c.textureSampler.anisotropy);