[Scummvm-git-logs] scummvm master -> f5acbd6d62bab5063074a1eb32b45ebb6ea5105b
bluegr
noreply at scummvm.org
Mon Apr 6 05:08:44 UTC 2026
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:
b66cc85b0d OPENGL: Move custom XRGB1555->RGB565 conversion path to common code
f5acbd6d62 3DS: Move custom XRGB1555->RGBA5551 conversion path to common code
Commit: b66cc85b0d12303d8fce1d41500cfdf99417d80d
https://github.com/scummvm/scummvm/commit/b66cc85b0d12303d8fce1d41500cfdf99417d80d
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-06T08:08:39+03:00
Commit Message:
OPENGL: Move custom XRGB1555->RGB565 conversion path to common code
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/texture.cpp
backends/graphics/opengl/texture.h
graphics/blit/blit-fast.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 04aee379c76..888e9b53abd 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1721,7 +1721,7 @@ Surface *OpenGLGraphicsManager::createSurface(const Graphics::PixelFormat &forma
// Since SCUMM uses this pixel format for some games (and there is no
// hope for this to change anytime soon) we use pixel format
// conversion to a supported texture format.
- return new TextureSurfaceRGB555();
+ return new FakeTextureSurface(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), format);
} else {
return new FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), format);
}
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index b0c14345121..77656b85dac 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -335,43 +335,6 @@ void FakeTextureSurface::applyPaletteAndMask(byte *dst, const byte *src, uint ds
}
}
-TextureSurfaceRGB555::TextureSurfaceRGB555()
- : FakeTextureSurface(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) {
-}
-
-void TextureSurfaceRGB555::updateGLTexture() {
- if (!isDirty()) {
- return;
- }
-
- // Convert color space.
- Graphics::Surface *outSurf = TextureSurface::getSurface();
-
- const Common::Rect dirtyArea = getDirtyArea();
-
- uint16 *dst = (uint16 *)outSurf->getBasePtr(dirtyArea.left, dirtyArea.top);
- const uint dstAdd = outSurf->pitch - 2 * dirtyArea.width();
-
- const uint16 *src = (const uint16 *)_rgbData.getBasePtr(dirtyArea.left, dirtyArea.top);
- const uint srcAdd = _rgbData.pitch - 2 * dirtyArea.width();
-
- for (int height = dirtyArea.height(); height > 0; --height) {
- for (int width = dirtyArea.width(); width > 0; --width) {
- const uint16 color = *src++;
-
- *dst++ = ((color & 0x7C00) << 1) // R
- | (((color & 0x03E0) << 1) | ((color & 0x0200) >> 4)) // G
- | (color & 0x001F); // B
- }
-
- src = (const uint16 *)((const byte *)src + srcAdd);
- dst = (uint16 *)((byte *)dst + dstAdd);
- }
-
- // Do generic handling of updating the texture.
- TextureSurface::updateGLTexture();
-}
-
#ifdef USE_SCALERS
ScaledTextureSurface::ScaledTextureSurface(GLenum glIntFormat, GLenum glFormat, GLenum glType, const Graphics::PixelFormat &format, const Graphics::PixelFormat &fakeFormat)
diff --git a/backends/graphics/opengl/texture.h b/backends/graphics/opengl/texture.h
index 15bf163ac6a..a78b915b0f1 100644
--- a/backends/graphics/opengl/texture.h
+++ b/backends/graphics/opengl/texture.h
@@ -237,14 +237,6 @@ protected:
uint8 *_mask;
};
-class TextureSurfaceRGB555 : public FakeTextureSurface {
-public:
- TextureSurfaceRGB555();
- ~TextureSurfaceRGB555() override {}
-
- void updateGLTexture() override;
-};
-
#ifdef USE_SCALERS
class ScaledTextureSurface : public FakeTextureSurface {
public:
diff --git a/graphics/blit/blit-fast.cpp b/graphics/blit/blit-fast.cpp
index 8f2200792c7..bb0da5fec84 100644
--- a/graphics/blit/blit-fast.cpp
+++ b/graphics/blit/blit-fast.cpp
@@ -55,10 +55,35 @@ static void swapBlit(byte *dst, const byte *src,
}
}
+static void fastBlit_XRGB1555_RGB565(byte *dst, const byte *src,
+ const uint dstPitch, const uint srcPitch,
+ const uint w, const uint h) {
+ // Faster, but larger, to provide optimized handling for each case.
+ const uint srcDelta = (srcPitch - w * sizeof(uint16));
+ const uint dstDelta = (dstPitch - w * sizeof(uint16));
+
+ for (uint y = 0; y < h; ++y) {
+ for (uint x = 0; x < w; ++x) {
+ uint16 col = *(const uint16 *)src;
+
+ col = ((col & 0x7C00) << 1) // R
+ | (((col & 0x03E0) << 1) | ((col & 0x0200) >> 4)) // G
+ | (col & 0x001F); // B
+
+ *(uint16 *)dst = col;
+
+ src += sizeof(uint16);
+ dst += sizeof(uint16);
+ }
+ src += srcDelta;
+ dst += dstDelta;
+ }
+}
+
} // End of anonymous namespace
// TODO: Add fast 24<->32bpp conversion
-// TODO: Add fast 16<->16bpp conversion
+// TODO: Add fast 16bpp RGB <-> 16bpp BGR conversion
struct FastBlitLookup {
FastBlitFunc func;
Graphics::PixelFormat srcFmt, dstFmt;
@@ -89,10 +114,20 @@ static const FastBlitLookup fastBlitFuncs_4to4[] = {
};
+static const FastBlitLookup fastBlitFuncs_2to2[] = {
+ { fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // XRGB1555 -> RGB565
+ { fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // XBGR1555 -> BGR565
+ { fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // ARGB1555 -> RGB565
+ { fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // ABGR1555 -> BGR565
+};
+
#ifdef SCUMMVM_NEON
static const FastBlitLookup fastBlitFuncs_NEON[] = {
// 16-bit with NEON
- { fastBlitNEON_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // XRGB1555 -> RGB565
+ { fastBlitNEON_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // XRGB1555 -> RGB565
+ { fastBlitNEON_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // XBGR1555 -> BGR565
+ { fastBlitNEON_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // ARGB1555 -> RGB565
+ { fastBlitNEON_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // ABGR1555 -> BGR565
};
#endif
@@ -132,6 +167,20 @@ FastBlitFunc getFastBlitFunc(const PixelFormat &dstFmt, const PixelFormat &srcFm
}
#endif
+ if (srcBpp == 2 && dstBpp == 2) {
+ table = fastBlitFuncs_2to2;
+ length = ARRAYSIZE(fastBlitFuncs_2to2);
+
+ for (size_t i = 0; i < length; i++) {
+ if (srcFmt != table[i].srcFmt)
+ continue;
+ if (dstFmt != table[i].dstFmt)
+ continue;
+
+ return table[i].func;
+ }
+ }
+
return nullptr;
}
Commit: f5acbd6d62bab5063074a1eb32b45ebb6ea5105b
https://github.com/scummvm/scummvm/commit/f5acbd6d62bab5063074a1eb32b45ebb6ea5105b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-06T08:08:39+03:00
Commit Message:
3DS: Move custom XRGB1555->RGBA5551 conversion path to common code
Changed paths:
backends/platform/3ds/osystem-graphics.cpp
backends/platform/3ds/osystem.cpp
backends/platform/3ds/osystem.h
graphics/blit/blit-fast.cpp
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index f1736aa30af..7895b4e44e8 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -220,6 +220,8 @@ void OSystem_3DS::initSize(uint width, uint height,
else
_gameScreen.create(width, height, _pfGame);
+ _blitFunc = Graphics::getFastBlitFunc(_gameTopTexture.format, _pfGame);
+
_focusDirty = true;
_focusRect = Common::Rect(_gameWidth, _gameHeight);
@@ -365,28 +367,6 @@ void OSystem_3DS::grabPalette(byte *colors, uint start, uint num) const {
memcpy(colors, _palette + 3 * start, 3 * num);
}
-// TODO: Move this into common code
-// TODO: Convert two pixels at once using 32-bit loads and stores
-static void copyRect555To5551(byte *dst, const byte *src, const uint dstPitch, const uint srcPitch,
- const uint w, const uint h) {
- // Faster, but larger, to provide optimized handling for each case.
- const uint srcDelta = (srcPitch - w * sizeof(uint16));
- const uint dstDelta = (dstPitch - w * sizeof(uint16));
-
- for (uint y = 0; y < h; ++y) {
- for (uint x = 0; x < w; ++x) {
- uint16 col = *(const uint16 *)src;
- col = (col << 1) | 1;
- *(uint16 *)dst = col;
-
- src += sizeof(uint16);
- dst += sizeof(uint16);
- }
- src += srcDelta;
- dst += dstDelta;
- }
-}
-
void OSystem_3DS::fillScreen(uint32 col) {
fillScreen(Common::Rect(getWidth(), getHeight()), col);
}
@@ -424,8 +404,8 @@ void OSystem_3DS::flushGameScreen() {
const byte *src = (const byte *)_gameScreen.getBasePtr(r.left, r.top);
byte *dst = (byte *)_gameTopTexture.getBasePtr(r.left, r.top);
- if (_pfGame == Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) {
- copyRect555To5551(dst, src, _gameTopTexture.pitch, _gameScreen.pitch,
+ if (_blitFunc) {
+ _blitFunc(dst, src, _gameTopTexture.pitch, _gameScreen.pitch,
r.width(), r.height());
} else if (_gfxState.gfxMode == &_modeCLUT8) {
Graphics::crossBlitMap(dst, src, _gameTopTexture.pitch, _gameScreen.pitch,
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index 137a5b1d5b5..c9883f53e46 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -88,7 +88,8 @@ OSystem_3DS::OSystem_3DS():
_showCursor(true),
_snapToBorder(true),
_stretchToFit(false),
- _screen(kScreenBoth)
+ _screen(kScreenBoth),
+ _blitFunc(nullptr)
{
chdir("sdmc:/");
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 8eddd741b4f..2bada3221c3 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -25,6 +25,7 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
#include "backends/base-backend.h"
+#include "graphics/blit.h"
#include "graphics/dirtyrects.h"
#include "graphics/paletteman.h"
#include "base/main.h"
@@ -231,6 +232,7 @@ private:
TransactionDetails _transactionDetails;
GfxState _gfxState, _oldGfxState;
+ Graphics::FastBlitFunc _blitFunc;
Graphics::PixelFormat _pfDefaultTexture;
Graphics::PixelFormat _pfGame, _oldPfGame;
Graphics::PixelFormat _pfCursor;
diff --git a/graphics/blit/blit-fast.cpp b/graphics/blit/blit-fast.cpp
index bb0da5fec84..4fe69a1d29f 100644
--- a/graphics/blit/blit-fast.cpp
+++ b/graphics/blit/blit-fast.cpp
@@ -80,6 +80,29 @@ static void fastBlit_XRGB1555_RGB565(byte *dst, const byte *src,
}
}
+static void fastBlit_XRGB1555_RGBA5551(byte *dst, const byte *src,
+ const uint dstPitch, const uint srcPitch,
+ const uint w, const uint h) {
+ // Faster, but larger, to provide optimized handling for each case.
+ const uint srcDelta = (srcPitch - w * sizeof(uint16));
+ const uint dstDelta = (dstPitch - w * sizeof(uint16));
+
+ for (uint y = 0; y < h; ++y) {
+ for (uint x = 0; x < w; ++x) {
+ uint16 col = *(const uint16 *)src;
+
+ col = (col << 1) | 1;
+
+ *(uint16 *)dst = col;
+
+ src += sizeof(uint16);
+ dst += sizeof(uint16);
+ }
+ src += srcDelta;
+ dst += dstDelta;
+ }
+}
+
} // End of anonymous namespace
// TODO: Add fast 24<->32bpp conversion
@@ -119,6 +142,9 @@ static const FastBlitLookup fastBlitFuncs_2to2[] = {
{ fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // XBGR1555 -> BGR565
{ fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) }, // ARGB1555 -> RGB565
{ fastBlit_XRGB1555_RGB565, Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0) }, // ABGR1555 -> BGR565
+
+ { fastBlit_XRGB1555_RGBA5551, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0) }, // XRGB1555 -> RGBA5551
+ { fastBlit_XRGB1555_RGBA5551, Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), Graphics::PixelFormat(2, 5, 5, 5, 1, 1, 6, 11, 0) }, // XBGR1555 -> BGRA5551
};
#ifdef SCUMMVM_NEON
More information about the Scummvm-git-logs
mailing list