[Scummvm-git-logs] scummvm master -> 58e96a8755b536307ebd7c79f15c7bfc4bfbf769
sev-
noreply at scummvm.org
Sun Feb 5 21:32:00 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
58e96a8755 OPENGL: Check if GL_TEXTURE_MAX_LEVEL is supported before using it
Commit: 58e96a8755b536307ebd7c79f15c7bfc4bfbf769
https://github.com/scummvm/scummvm/commit/58e96a8755b536307ebd7c79f15c7bfc4bfbf769
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-05T22:31:57+01:00
Commit Message:
OPENGL: Check if GL_TEXTURE_MAX_LEVEL is supported before using it
Changed paths:
engines/stark/gfx/opengltexture.cpp
graphics/opengl/context.cpp
graphics/opengl/context.h
graphics/opengl/system_headers.h
diff --git a/engines/stark/gfx/opengltexture.cpp b/engines/stark/gfx/opengltexture.cpp
index 2f00a283551..ab097324923 100644
--- a/engines/stark/gfx/opengltexture.cpp
+++ b/engines/stark/gfx/opengltexture.cpp
@@ -73,17 +73,15 @@ void OpenGlTexture::setLevelCount(uint32 count) {
_levelCount = count;
if (count >= 1) {
-#if !USE_FORCED_GLES2
- // GLES2 does not allow setting the max provided mipmap level.
+ // GLES1 and GLES2 do not allow setting the max provided mipmap level.
// It expects all the levels to be provided, which is not the case in TLJ.
- // FIXME: Enable mipmapping on GLES2
- if (OpenGLContext.type != OpenGL::kContextGLES2) {
+ // FIXME: Enable mipmapping on GLES without this extension
+ if (OpenGLContext.textureMaxLevelSupported) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, count - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
-#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
@@ -93,7 +91,7 @@ void OpenGlTexture::setLevelCount(uint32 count) {
void OpenGlTexture::addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
assert(level < _levelCount);
- if (level == 0 || OpenGLContext.type != OpenGL::kContextGLES2) {
+ if (level == 0 || OpenGLContext.textureMaxLevelSupported) {
updateLevel(level, surface, palette);
}
}
diff --git a/graphics/opengl/context.cpp b/graphics/opengl/context.cpp
index 91ba6e02036..f66b8227d80 100644
--- a/graphics/opengl/context.cpp
+++ b/graphics/opengl/context.cpp
@@ -71,6 +71,7 @@ void Context::reset() {
textureEdgeClampSupported = false;
textureBorderClampSupported = false;
textureMirrorRepeatSupported = false;
+ textureMaxLevelSupported = false;
}
void Context::initialize(ContextType contextType) {
@@ -186,6 +187,8 @@ void Context::initialize(ContextType contextType) {
textureBorderClampSupported = true;
} else if (token == "GL_ARB_texture_mirrored_repeat") {
textureMirrorRepeatSupported = true;
+ } else if (token == "GL_SGIS_texture_lod" || token == "GL_APPLE_texture_max_level") {
+ textureMaxLevelSupported = true;
}
}
@@ -219,6 +222,7 @@ void Context::initialize(ContextType contextType) {
textureEdgeClampSupported = true;
// No border clamping in GLES2
textureMirrorRepeatSupported = true;
+ // TODO: textureMaxLevelSupported with GLES3
debug(5, "OpenGL: GLES2 context initialized");
} else if (type == kContextGLES) {
// GLES doesn't support shaders natively
@@ -264,10 +268,11 @@ void Context::initialize(ContextType contextType) {
glGetIntegerv(GL_MAX_SAMPLES, (GLint *)&multisampleMaxSamples);
}
- // OpenGL 1.2 and later always has packed pixels and texture edge clamp support
+ // OpenGL 1.2 and later always has packed pixels, texture edge clamp and texture max level support
if (isGLVersionOrHigher(1, 2)) {
packedPixelsSupported = true;
textureEdgeClampSupported = true;
+ textureMaxLevelSupported = true;
}
// OpenGL 1.3 adds texture border clamp support
if (isGLVersionOrHigher(1, 3)) {
@@ -302,6 +307,7 @@ void Context::initialize(ContextType contextType) {
debug(5, "OpenGL: Unpack subimage support: %d", unpackSubImageSupported);
debug(5, "OpenGL: OpenGL ES depth 24 support: %d", OESDepth24);
debug(5, "OpenGL: Texture edge clamping support: %d", textureEdgeClampSupported);
+ debug(5, "OpenGL: Texture max level support: %d", textureMaxLevelSupported);
}
int Context::getGLSLVersion() const {
diff --git a/graphics/opengl/context.h b/graphics/opengl/context.h
index 4ca34f9879c..925ff0607fc 100644
--- a/graphics/opengl/context.h
+++ b/graphics/opengl/context.h
@@ -117,6 +117,9 @@ public:
/** Whether texture coordinate mirrored repeat is available or not. */
bool textureMirrorRepeatSupported;
+ /** Whether texture max level is available or not. */
+ bool textureMaxLevelSupported;
+
private:
/**
* Returns the native GLSL version supported by the driver.
diff --git a/graphics/opengl/system_headers.h b/graphics/opengl/system_headers.h
index 4f8b8d1722b..f26fc141b5f 100644
--- a/graphics/opengl/system_headers.h
+++ b/graphics/opengl/system_headers.h
@@ -99,4 +99,8 @@
#endif
#endif
+#if !defined(GL_TEXTURE_MAX_LEVEL) && defined(GL_TEXTURE_MAX_LEVEL_APPLE)
+ #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE
+#endif
+
#endif
More information about the Scummvm-git-logs
mailing list