[Scummvm-git-logs] scummvm branch-2-9 -> ea62aeb77f277822ad8f117c2a6c49d81d92d7cb
ccawley2011
noreply at scummvm.org
Thu May 8 15:01:14 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:
d15591d020 3DS: Fix improper memory freeing (Sprite.vertices)
ea62aeb77f 3DS: Fix top screen not fully rendering in some cases
Commit: d15591d020280fb11d1c8c8ee5483cc5742fa2e0
https://github.com/scummvm/scummvm/commit/d15591d020280fb11d1c8c8ee5483cc5742fa2e0
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2025-05-08T15:19:16+01:00
Commit Message:
3DS: Fix improper memory freeing (Sprite.vertices)
Changed paths:
backends/platform/3ds/osystem-graphics.cpp
backends/platform/3ds/sprite.cpp
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 649e5d41335..3f36e9bcd28 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -113,12 +113,7 @@ void OSystem_3DS::init3DSGraphics() {
void OSystem_3DS::destroy3DSGraphics() {
_gameScreen.free();
- _gameTopTexture.free();
- _gameBottomTexture.free();
_cursor.free();
- _cursorTexture.free();
- _overlay.free();
- _activityIcon.free();
shaderProgramFree(&_program);
DVLB_Free(_dvlb);
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
index ef3ac19dc64..04054ab6af6 100644
--- a/backends/platform/3ds/sprite.cpp
+++ b/backends/platform/3ds/sprite.cpp
@@ -45,7 +45,8 @@ Sprite::Sprite()
}
Sprite::~Sprite() {
- //
+ free();
+ linearFree(vertices);
}
void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode, bool vram) {
@@ -84,7 +85,6 @@ void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode, bool vr
}
void Sprite::free() {
- linearFree(vertices);
linearFree(pixels);
C3D_TexDelete(&texture);
pixels = 0;
Commit: ea62aeb77f277822ad8f117c2a6c49d81d92d7cb
https://github.com/scummvm/scummvm/commit/ea62aeb77f277822ad8f117c2a6c49d81d92d7cb
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2025-05-08T15:19:33+01:00
Commit Message:
3DS: Fix top screen not fully rendering in some cases
When only the top screen is set to be used, the overlay must have a width of 400.
Changed paths:
backends/platform/3ds/osystem-graphics.cpp
backends/platform/3ds/sprite.cpp
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 3f36e9bcd28..c3488f5d017 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -108,7 +108,7 @@ void OSystem_3DS::init3DSGraphics() {
C3D_DepthTest(false, GPU_GEQUAL, GPU_WRITE_ALL);
C3D_CullFace(GPU_CULL_NONE);
- _overlay.create(320, 240, &DEFAULT_MODE, true);
+ // _overlay initialized in updateSize()
}
void OSystem_3DS::destroy3DSGraphics() {
@@ -228,6 +228,18 @@ void OSystem_3DS::initSize(uint width, uint height,
}
void OSystem_3DS::updateSize() {
+ // Initialize _overlay here so that it can be reinitialized when _screen is changed.
+
+ // Overlay sprite must have a width matching or exceeding that of the screen to
+ // which it's set to render, otherwise portions of the screen will not render.
+ // _screen == kScreenTop
+ // >>> overlay renders to top screen
+ // >>> top screen is 400 pixels wide
+ // _screen == (kScreenBottom | kScreenBoth)
+ // >>> overlay renders to bottom screen
+ // >>> bottom screen is 320 pixels wide
+ _overlay.create(_screen == kScreenTop ? 400 : 320, 240, &DEFAULT_MODE, true);
+
if (_stretchToFit) {
_gameTopX = _gameTopY = _gameBottomX = _gameBottomY = 0;
_gameTopTexture.setScale(400.f / _gameWidth, 240.f / _gameHeight);
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
index 04054ab6af6..01294e384d9 100644
--- a/backends/platform/3ds/sprite.cpp
+++ b/backends/platform/3ds/sprite.cpp
@@ -50,24 +50,40 @@ Sprite::~Sprite() {
}
void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode, bool vram) {
- free();
+ int16 wPow = MAX<uint16>(Common::nextHigher2(width), 64u);
+ int16 hPow = MAX<uint16>(Common::nextHigher2(height), 64u);
+
+ bool pwrW_hChanged = (wPow != w) || (hPow != h);
+ bool sfcBppChanged = (mode->surfaceFormat.bytesPerPixel != format.bytesPerPixel);
+ bool texFmtChanged = (mode->textureFormat != texture.fmt);
+
+ bool srfDataReinitNeeded = (pwrW_hChanged || sfcBppChanged || !pixels);
+ bool textureReinitNeeded = (pwrW_hChanged || texFmtChanged || !texture.data);
actualWidth = width;
actualHeight = height;
format = mode->surfaceFormat;
textureTransferFlags = mode->textureTransferFlags;
- w = MAX<uint16>(Common::nextHigher2(width), 64u);
- h = MAX<uint16>(Common::nextHigher2(height), 64u);
+ w = wPow;
+ h = hPow;
pitch = w * format.bytesPerPixel;
dirtyPixels = true;
if (width && height) {
- pixels = linearAlloc(h * pitch);
- if (vram) {
- if (!C3D_TexInitVRAM(&texture, w, h, mode->textureFormat))
+ // Don't needlessly reinitialize surface pixels.
+ if (srfDataReinitNeeded) {
+ linearFree(pixels);
+ pixels = linearAlloc(h * pitch);
+ }
+ // Don't needlessly reinitialize C3D_Tex data.
+ if (textureReinitNeeded) {
+ C3D_TexDelete(&texture);
+ if (vram) {
+ if (!C3D_TexInitVRAM(&texture, w, h, mode->textureFormat))
+ C3D_TexInit(&texture, w, h, mode->textureFormat);
+ } else
C3D_TexInit(&texture, w, h, mode->textureFormat);
- } else
- C3D_TexInit(&texture, w, h, mode->textureFormat);
+ }
assert(pixels && texture.data);
clear();
}
More information about the Scummvm-git-logs
mailing list