[Scummvm-git-logs] scummvm master -> 3c8b58af953545cdf129b9eb1285dc3ca0e9b6ac

lephilousophe noreply at scummvm.org
Sun Oct 9 15:26:03 UTC 2022


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a205c79a98 OPENGL: Allow to get last call error status
3a7f2aa1ee BACKENDS: OPENGL: Allow callers to check for texture setSize result
3c8b58af95 BACKENDS: OPENGL: Don't use glGetTexLevelParameteriv


Commit: a205c79a98b3bb3d9d8bd95294aa5b336c63537b
    https://github.com/scummvm/scummvm/commit/a205c79a98b3bb3d9d8bd95294aa5b336c63537b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-09T17:25:35+02:00

Commit Message:
OPENGL: Allow to get last call error status

Changed paths:
    graphics/opengl/debug.cpp
    graphics/opengl/debug.h


diff --git a/graphics/opengl/debug.cpp b/graphics/opengl/debug.cpp
index c32c4e720dc..c5273cb7bb4 100644
--- a/graphics/opengl/debug.cpp
+++ b/graphics/opengl/debug.cpp
@@ -28,8 +28,6 @@
 
 #if defined(USE_OPENGL)
 
-#ifdef OPENGL_DEBUG
-
 namespace OpenGL {
 
 namespace {
@@ -62,17 +60,18 @@ void clearGLError() {
 		;
 }
 
-void checkGLError(const char *expr, const char *file, int line) {
+bool checkGLError(const char *expr, const char *file, int line) {
+	bool ret = false;
 	GLenum error;
 
 	while ((error = glGetError()) != GL_NO_ERROR) {
 		// We cannot use error here because we do not know whether we have a
 		// working screen or not.
 		warning("GL ERROR: %s on %s (%s:%d)", getGLErrStr(error).c_str(), expr, file, line);
+		ret = true;
 	}
+	return ret;
 }
 } // End of namespace OpenGL
 
 #endif
-
-#endif
diff --git a/graphics/opengl/debug.h b/graphics/opengl/debug.h
index 0a567bd9c1f..a39dfc68ac4 100644
--- a/graphics/opengl/debug.h
+++ b/graphics/opengl/debug.h
@@ -26,25 +26,30 @@
 
 #define OPENGL_DEBUG
 
-#ifdef OPENGL_DEBUG
-
 namespace OpenGL {
 void clearGLError();
-void checkGLError(const char *expr, const char *file, int line);
+bool checkGLError(const char *expr, const char *file, int line);
 } // End of namespace OpenGL
 
+#define GL_WRAP_CHECK(err, call, name) do { OpenGL::clearGLError(); (call); err = OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
+#ifdef OPENGL_DEBUG
 #define GL_WRAP_DEBUG(call, name) do { OpenGL::clearGLError(); (call); OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
 #else
 #define GL_WRAP_DEBUG(call, name) do { (call); } while (false)
 #endif
 
+// This macro will set boolean err to true if there was an error and display them in the console
+#define GL_CALL_CHECK(err, x)      GL_WRAP_CHECK(err, x, x)
+// This macro will check for errors and display them in the console only when OPENGL_DEBUG is enabled
 #define GL_CALL(x)                 GL_WRAP_DEBUG(x, x)
+// This macro will execute the call only when the context is valid and will check errors only when OPENGL_DEBUG is enabled
 #define GL_CALL_SAFE(func, params) \
 	do { \
 		if (OpenGLContext.type != kContextNone) { \
 			GL_CALL(func params); \
 		} \
 	} while (0)
+// This macro will assign result of x to var and check for errors when OPENGL_DEBUG is enabled
 #define GL_ASSIGN(var, x)          GL_WRAP_DEBUG(var = x, x)
 
 #endif


Commit: 3a7f2aa1eefaec75497b0f88d56c122d4f711b95
    https://github.com/scummvm/scummvm/commit/3a7f2aa1eefaec75497b0f88d56c122d4f711b95
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-09T17:25:35+02:00

Commit Message:
BACKENDS: OPENGL: Allow callers to check for texture setSize result

Changed paths:
    backends/graphics/opengl/framebuffer.cpp
    backends/graphics/opengl/framebuffer.h
    backends/graphics/opengl/texture.cpp
    backends/graphics/opengl/texture.h


diff --git a/backends/graphics/opengl/framebuffer.cpp b/backends/graphics/opengl/framebuffer.cpp
index 1daa2d02eab..969b02de060 100644
--- a/backends/graphics/opengl/framebuffer.cpp
+++ b/backends/graphics/opengl/framebuffer.cpp
@@ -225,8 +225,10 @@ void TextureTarget::create() {
 	_needUpdate = true;
 }
 
-void TextureTarget::setSize(uint width, uint height) {
-	_texture->setSize(width, height);
+bool TextureTarget::setSize(uint width, uint height) {
+	if (!_texture->setSize(width, height)) {
+		return false;
+	}
 
 	const uint texWidth  = _texture->getWidth();
 	const uint texHeight = _texture->getHeight();
@@ -263,6 +265,7 @@ void TextureTarget::setSize(uint width, uint height) {
 		applyViewport();
 		applyProjectionMatrix();
 	}
+	return true;
 }
 #endif // !USE_FORCED_GLES
 
diff --git a/backends/graphics/opengl/framebuffer.h b/backends/graphics/opengl/framebuffer.h
index f29fdd2b36d..914c01a253c 100644
--- a/backends/graphics/opengl/framebuffer.h
+++ b/backends/graphics/opengl/framebuffer.h
@@ -175,7 +175,7 @@ public:
 	/**
 	 * Set size of the texture target.
 	 */
-	void setSize(uint width, uint height);
+	bool setSize(uint width, uint height);
 
 	/**
 	 * Query pointer to underlying GL texture.
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 3faa5ed1336..cd8ad7e7f4f 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -103,7 +103,7 @@ void GLTexture::bind() const {
 	GL_CALL(glBindTexture(GL_TEXTURE_2D, _glTexture));
 }
 
-void GLTexture::setSize(uint width, uint height) {
+bool GLTexture::setSize(uint width, uint height) {
 	const uint oldWidth  = _width;
 	const uint oldHeight = _height;
 
@@ -138,10 +138,15 @@ void GLTexture::setSize(uint width, uint height) {
 		// Allocate storage for OpenGL texture if necessary.
 		if (oldWidth != _width || oldHeight != _height) {
 			bind();
-			GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, _glIntFormat, _width,
-			                     _height, 0, _glFormat, _glType, nullptr));
+			bool error;
+			GL_CALL_CHECK(error, glTexImage2D(GL_TEXTURE_2D, 0, _glIntFormat, _width, _height,
+			             0, _glFormat, _glType, nullptr));
+			if (error) {
+				return false;
+			}
 		}
 	}
+	return true;
 }
 
 void GLTexture::updateArea(const Common::Rect &area, const Graphics::Surface &src) {
diff --git a/backends/graphics/opengl/texture.h b/backends/graphics/opengl/texture.h
index 1d3fb7769ff..dd19ca36efe 100644
--- a/backends/graphics/opengl/texture.h
+++ b/backends/graphics/opengl/texture.h
@@ -86,8 +86,9 @@ public:
 	 *
 	 * @param width  The desired logical width.
 	 * @param height The desired logical height.
+	 * @return Whether the call was successful
 	 */
-	void setSize(uint width, uint height);
+	bool setSize(uint width, uint height);
 
 	/**
 	 * Copy image data to the texture.


Commit: 3c8b58af953545cdf129b9eb1285dc3ca0e9b6ac
    https://github.com/scummvm/scummvm/commit/3c8b58af953545cdf129b9eb1285dc3ca0e9b6ac
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-09T17:25:35+02:00

Commit Message:
BACKENDS: OPENGL: Don't use glGetTexLevelParameteriv

This function doesn't work in GLES2

Changed paths:
    backends/graphics/opengl/pipelines/libretro.cpp


diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index a3ff0fa030f..a4b0ed2cbf4 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -438,12 +438,7 @@ bool LibRetroPipeline::setupFBOs() {
 		pass.shaderPass->applyScale(sourceW, sourceH, viewportW, viewportH, &sourceW, &sourceH);
 
 		// Resize FBO to fit the output of the pass.
-		pass.target->setSize((uint)sourceW, (uint)sourceH);
-		// Make sure it has been set correctly
-		GLint width = 0, height = 0;
-		GL_CALL(glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,  GL_TEXTURE_WIDTH, &width));
-		GL_CALL(glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,  GL_TEXTURE_HEIGHT, &height));
-		if ((uint)width != (uint)sourceW || (uint)height != (uint)sourceH) {
+		if (!pass.target->setSize((uint)sourceW, (uint)sourceH)) {
 			return false;
 		}
 




More information about the Scummvm-git-logs mailing list