[Scummvm-git-logs] scummvm master -> 696a1bb31eb5e1492794479ff906bf03ce7df958
bluegr
noreply at scummvm.org
Tue Jun 3 09:02:09 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
94ab820fab OPENGL: Avoid reporting support for software only formats
696a1bb31e OPENGL: Add support for more pixel formats
Commit: 94ab820fab92a0b995af23d48002dba5ee55f1bd
https://github.com/scummvm/scummvm/commit/94ab820fab92a0b995af23d48002dba5ee55f1bd
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-03T12:02:05+03:00
Commit Message:
OPENGL: Avoid reporting support for software only formats
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 9c10f96af4c..ff090576fa6 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -256,6 +256,11 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
// ABGR8888/RGBA8888
formats.push_back(OpenGL::Texture::getRGBAPixelFormat());
+
+ // TODO: Limit these formats to implementations that support them -
+ // currently the Kyra, SCUMM and Trecision engines expect at least
+ // one 16bpp format in this list.
+
// RGB565
formats.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
// RGBA5551
@@ -263,18 +268,6 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
// RGBA4444
formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0));
- // These formats are not natively supported by OpenGL ES implementations,
- // we convert the pixel format internally.
-#ifdef SCUMM_LITTLE_ENDIAN
- // RGBA8888
- formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- // ABGR8888
- formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
- // RGB555, this is used by SCUMM HE 16 bit games.
- formats.push_back(Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
-
formats.push_back(Graphics::PixelFormat::createFormatCLUT8());
return formats;
@@ -431,14 +424,6 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
if (_oldState.gameFormat != _currentState.gameFormat) {
setupNewGameScreen = true;
}
-
- // Check whether the requested format can actually be used.
- Common::List<Graphics::PixelFormat> supportedFormats = getSupportedFormats();
- // In case the requested format is not usable we will fall back to CLUT8.
- if (Common::find(supportedFormats.begin(), supportedFormats.end(), _currentState.gameFormat) == supportedFormats.end()) {
- _currentState.gameFormat = Graphics::PixelFormat::createFormatCLUT8();
- transactionError |= OSystem::kTransactionFormatNotSupported;
- }
#endif
#ifdef USE_SCALERS
Commit: 696a1bb31eb5e1492794479ff906bf03ce7df958
https://github.com/scummvm/scummvm/commit/696a1bb31eb5e1492794479ff906bf03ce7df958
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-03T12:02:05+03:00
Commit Message:
OPENGL: Add support for more pixel formats
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
graphics/opengl/context.cpp
graphics/opengl/context.h
graphics/opengl/texture.h
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index ff090576fa6..12d29f8bba8 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -257,6 +257,11 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
// ABGR8888/RGBA8888
formats.push_back(OpenGL::Texture::getRGBAPixelFormat());
+ if (OpenGLContext.bgraSupported) {
+ // ARGB8888/BGRA8888
+ formats.push_back(OpenGL::Texture::getBGRAPixelFormat());
+ }
+
// TODO: Limit these formats to implementations that support them -
// currently the Kyra, SCUMM and Trecision engines expect at least
// one 16bpp format in this list.
@@ -268,6 +273,37 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
// RGBA4444
formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0));
+#if !USE_FORCED_GLES && !USE_FORCED_GLES2
+ if (OpenGLContext.packedPixelsSupported && !isGLESContext()) {
+#ifdef SCUMM_LITTLE_ENDIAN
+ // RGBA8888
+ formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ // BGRA8888
+ formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0));
+#endif
+#ifdef SCUMM_BIG_ENDIAN
+ // ABGR8888
+ formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
+ // ARGB8888
+ formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24));
+#endif
+ // BGR565
+ formats.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0));
+ // ABGR1555
+ formats.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
+ // ARGB1555
+ formats.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
+ // BGRA5551
+ formats.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 1, 6, 11, 0));
+ // ABGR4444
+ formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12));
+ // ARGB4444
+ formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12));
+ // BGRA4444
+ formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0));
+ }
+#endif // !USE_FORCED_GLES && !USE_FORCED_GLES2
+
formats.push_back(Graphics::PixelFormat::createFormatCLUT8());
return formats;
@@ -1660,6 +1696,11 @@ bool OpenGLGraphicsManager::getGLPixelFormat(const Graphics::PixelFormat &pixelF
glFormat = GL_RGB;
glType = GL_UNSIGNED_BYTE;
return true;
+ } else if (OpenGLContext.bgraSupported && pixelFormat == OpenGL::Texture::getBGRAPixelFormat()) { // ARGB8888 / BGRA8888
+ glIntFormat = isGLESContext() ? GL_BGRA : GL_RGBA;
+ glFormat = GL_BGRA;
+ glType = GL_UNSIGNED_BYTE;
+ return true;
} else if (!OpenGLContext.packedPixelsSupported) {
return false;
} else if (pixelFormat == Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)) { // RGB565
@@ -1688,34 +1729,39 @@ bool OpenGLGraphicsManager::getGLPixelFormat(const Graphics::PixelFormat &pixelF
glFormat = GL_RGBA;
glType = GL_UNSIGNED_INT_8_8_8_8;
return true;
-#endif
- } else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) { // RGB555
- glIntFormat = GL_RGB;
- glFormat = GL_BGRA;
- glType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
- return true;
- } else if (pixelFormat == Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)) { // ARGB4444
+ } else if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0)) { // BGRA8888
glIntFormat = GL_RGBA;
glFormat = GL_BGRA;
- glType = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ glType = GL_UNSIGNED_INT_8_8_8_8;
return true;
+#endif
#ifdef SCUMM_BIG_ENDIAN
} else if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) { // ABGR8888
glIntFormat = GL_RGBA;
glFormat = GL_RGBA;
glType = GL_UNSIGNED_INT_8_8_8_8_REV;
return true;
-#endif
- } else if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0)) { // BGRA8888
+ } else if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)) { // ARGB8888
glIntFormat = GL_RGBA;
glFormat = GL_BGRA;
- glType = GL_UNSIGNED_INT_8_8_8_8;
+ glType = GL_UNSIGNED_INT_8_8_8_8_REV;
return true;
+#endif
} else if (pixelFormat == Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0)) { // BGR565
glIntFormat = GL_RGB;
glFormat = GL_RGB;
glType = GL_UNSIGNED_SHORT_5_6_5_REV;
return true;
+ } else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)) { // ABGR1555
+ glIntFormat = GL_RGB;
+ glFormat = GL_RGBA;
+ glType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ return true;
+ } else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)) { // ARGB1555
+ glIntFormat = GL_RGB;
+ glFormat = GL_BGRA;
+ glType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ return true;
} else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 1, 1, 6, 11, 0)) { // BGRA5551
glIntFormat = GL_RGBA;
glFormat = GL_BGRA;
@@ -1726,6 +1772,11 @@ bool OpenGLGraphicsManager::getGLPixelFormat(const Graphics::PixelFormat &pixelF
glFormat = GL_RGBA;
glType = GL_UNSIGNED_SHORT_4_4_4_4_REV;
return true;
+ } else if (pixelFormat == Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)) { // ARGB4444
+ glIntFormat = GL_RGBA;
+ glFormat = GL_BGRA;
+ glType = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ return true;
} else if (pixelFormat == Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)) { // BGRA4444
glIntFormat = GL_RGBA;
glFormat = GL_BGRA;
diff --git a/graphics/opengl/context.cpp b/graphics/opengl/context.cpp
index 3e573c9d6d5..a04c9546d8f 100644
--- a/graphics/opengl/context.cpp
+++ b/graphics/opengl/context.cpp
@@ -71,6 +71,7 @@ void Context::reset() {
framebufferObjectSupported = false;
framebufferObjectMultisampleSupported = false;
multisampleMaxSamples = -1;
+ bgraSupported = false;
packedPixelsSupported = false;
packedDepthStencilSupported = false;
unpackSubImageSupported = false;
@@ -182,6 +183,8 @@ void Context::initialize(ContextType contextType) {
multitextureSupported = true;
} else if (token == "GL_ARB_framebuffer_object") {
framebufferObjectSupported = true;
+ } else if (token == "GL_EXT_bgra" || token == "GL_EXT_texture_format_BGRA8888") {
+ bgraSupported = true;
} else if (token == "GL_EXT_packed_pixels" || token == "GL_APPLE_packed_pixels") {
packedPixelsSupported = true;
} else if (token == "GL_EXT_packed_depth_stencil" || token == "GL_OES_packed_depth_stencil") {
@@ -287,6 +290,7 @@ void Context::initialize(ContextType contextType) {
// OpenGL 1.2 and later always has packed pixels, texture edge clamp and texture max level support
if (isGLVersionOrHigher(1, 2)) {
+ bgraSupported = true;
packedPixelsSupported = true;
textureEdgeClampSupported = true;
textureMaxLevelSupported = true;
@@ -331,6 +335,7 @@ void Context::initialize(ContextType contextType) {
debug(5, "OpenGL: FBO support: %d", framebufferObjectSupported);
debug(5, "OpenGL: Multisample FBO support: %d", framebufferObjectMultisampleSupported);
debug(5, "OpenGL: Multisample max number: %d", multisampleMaxSamples);
+ debug(5, "OpenGL: BGRA support: %d", bgraSupported);
debug(5, "OpenGL: Packed pixels support: %d", packedPixelsSupported);
debug(5, "OpenGL: Packed depth stencil support: %d", packedDepthStencilSupported);
debug(5, "OpenGL: Unpack subimage support: %d", unpackSubImageSupported);
diff --git a/graphics/opengl/context.h b/graphics/opengl/context.h
index 50d4ca6772e..4d1909d623a 100644
--- a/graphics/opengl/context.h
+++ b/graphics/opengl/context.h
@@ -99,6 +99,9 @@ public:
*/
int multisampleMaxSamples;
+ /** Whether BGRA support is available or not. */
+ bool bgraSupported;
+
/** Whether packed pixels support is available or not. */
bool packedPixelsSupported;
diff --git a/graphics/opengl/texture.h b/graphics/opengl/texture.h
index 5a5e4d9ca6b..93c7193948b 100644
--- a/graphics/opengl/texture.h
+++ b/graphics/opengl/texture.h
@@ -164,6 +164,14 @@ public:
#endif
}
+ static inline const Graphics::PixelFormat getBGRAPixelFormat() {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
+#else
+ return Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
+#endif
+ }
+
protected:
const GLenum _glIntFormat;
const GLenum _glFormat;
More information about the Scummvm-git-logs
mailing list