[Scummvm-git-logs] scummvm master -> 4a3f280f1a60a4a57b5e5dbff9827715e99629a5

bluegr noreply at scummvm.org
Mon Sep 2 08:13:13 UTC 2024


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:
1e7c8913fd 3DS: Support more texture formats
c473c77523 3DS: Move larger surfaces into VRAM
4a3f280f1a 3DS: Limit the linear heap to 10 MB


Commit: 1e7c8913fddcbe2b46973b2345293c5ea74e0536
    https://github.com/scummvm/scummvm/commit/1e7c8913fddcbe2b46973b2345293c5ea74e0536
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-09-02T11:13:09+03:00

Commit Message:
3DS: Support more texture formats

Changed paths:
    backends/platform/3ds/osystem-graphics.cpp
    backends/platform/3ds/osystem.h


diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 6dfd1777c08..cff7030ba2c 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -34,26 +34,30 @@
 		 GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
 		 GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) |                           \
 		 GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
-#define TEXTURE_TRANSFER_FLAGS(fmt)                             \
+#define TEXTURE_TRANSFER_FLAGS(in, out)                             \
 		(GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) |  \
-		 GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(fmt) | \
-		 GX_TRANSFER_OUT_FORMAT(fmt) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
+		 GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(in) | \
+		 GX_TRANSFER_OUT_FORMAT(out) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
 #define DEFAULT_MODE _modeRGBA8
 
 namespace N3DS {
 /* Group the various enums, values, etc. needed for
  * each graphics mode into instaces of GfxMode3DS */
 static const GfxMode3DS _modeRGBA8 = { Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
-									   GPU_RGBA8, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA8) };
+									   GPU_RGBA8, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA8, GX_TRANSFER_FMT_RGBA8) };
+static const GfxMode3DS _modeRGBX8 = { Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
+									   GPU_RGB8, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA8, GX_TRANSFER_FMT_RGB8) };
 static const GfxMode3DS _modeRGB565 = { Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
-										GPU_RGB565, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB565) };
+										GPU_RGB565, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB565, GX_TRANSFER_FMT_RGB565) };
 static const GfxMode3DS _modeRGB555 = { Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0),
-										GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) };
+										GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1, GX_TRANSFER_FMT_RGB5A1) };
 static const GfxMode3DS _modeRGB5A1 = { Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0),
-										GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) };
-static const GfxMode3DS _modeCLUT8 = _modeRGBA8;
+										GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1, GX_TRANSFER_FMT_RGB5A1) };
+static const GfxMode3DS _modeRGBA4 = { Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0),
+										GPU_RGBA4, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA4, GX_TRANSFER_FMT_RGBA4) };
+static const GfxMode3DS _modeCLUT8 = _modeRGBX8;
 
-static const GfxMode3DS *gfxModes[] = { &_modeRGBA8, &_modeRGB565, &_modeRGB555, &_modeRGB5A1, &_modeCLUT8 };
+static const GfxMode3DS *gfxModes[] = { &_modeRGBX8, &_modeRGB565, &_modeRGB555, &_modeRGB5A1, &_modeRGBA4, &_modeCLUT8 };
 
 
 void OSystem_3DS::init3DSGraphics() {
@@ -161,7 +165,9 @@ GraphicsModeID OSystem_3DS::chooseMode(Graphics::PixelFormat *format) {
 	if (format->bytesPerPixel > 2) {
 		return RGBA8;
 	} else if (format->bytesPerPixel > 1) {
-		if (format->gBits() > 5) {
+		if (format->aBits() > 1) {
+			return RGBA4;
+		} else if (format->gBits() > 5) {
 			return RGB565;
 		} else if (format->aBits() == 0) {
 			return RGB555;
@@ -178,6 +184,7 @@ bool OSystem_3DS::setGraphicsMode(GraphicsModeID modeID) {
 	case RGB565:
 	case RGB555:
 	case RGB5A1:
+	case RGBA4:
 	case CLUT8:
 		_gfxState.gfxMode = gfxModes[modeID];
 		return true;
@@ -274,6 +281,7 @@ Common::List<Graphics::PixelFormat> OSystem_3DS::getSupportedFormats() const {
 	list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); // GPU_RGBA8
 	list.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); // GPU_RGB565
 	list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); // GPU_RGBA5551
+	list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)); // GPU_RGBA4
 
 	// The following formats require software conversion
 	list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); // RGB555 (needed for FMTOWNS?)
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index dd715799a6a..6a53d51940b 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -55,6 +55,7 @@ enum GraphicsModeID {
 	RGB565,
 	RGB555,
 	RGB5A1,
+	RGBA4,
 	CLUT8
 };
 


Commit: c473c77523bd60c9a69d745c73a0f1f002e69f7a
    https://github.com/scummvm/scummvm/commit/c473c77523bd60c9a69d745c73a0f1f002e69f7a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-09-02T11:13:09+03:00

Commit Message:
3DS: Move larger surfaces into VRAM

Changed paths:
    backends/platform/3ds/osystem-graphics.cpp
    backends/platform/3ds/sprite.cpp
    backends/platform/3ds/sprite.h


diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index cff7030ba2c..ffdef26b826 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -30,9 +30,9 @@
 
 // Used to transfer the final rendered display to the framebuffer
 #define DISPLAY_TRANSFER_FLAGS                                                    \
-		(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) |                    \
-		 GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
-		 GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) |                           \
+		(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) |                   \
+		 GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | \
+		 GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) |                          \
 		 GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
 #define TEXTURE_TRANSFER_FLAGS(in, out)                             \
 		(GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) |  \
@@ -72,13 +72,13 @@ void OSystem_3DS::init3DSGraphics() {
 	int topScreenWidth = gfxIsWide() ? 800 : 400;
 
 	_renderTargetTop =
-	    C3D_RenderTargetCreate(240, topScreenWidth, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
+	    C3D_RenderTargetCreate(240, topScreenWidth, GPU_RB_RGB8, -1);
 	C3D_RenderTargetClear(_renderTargetTop, C3D_CLEAR_ALL, 0x0000000, 0);
 	C3D_RenderTargetSetOutput(_renderTargetTop, GFX_TOP, GFX_LEFT,
 	                          DISPLAY_TRANSFER_FLAGS);
 
 	_renderTargetBottom =
-	    C3D_RenderTargetCreate(240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
+	    C3D_RenderTargetCreate(240, 320, GPU_RB_RGB8, -1);
 	C3D_RenderTargetClear(_renderTargetBottom, C3D_CLEAR_ALL, 0x00000000, 0);
 	C3D_RenderTargetSetOutput(_renderTargetBottom, GFX_BOTTOM, GFX_LEFT,
 	                          DISPLAY_TRANSFER_FLAGS);
@@ -107,6 +107,8 @@ void OSystem_3DS::init3DSGraphics() {
 
 	C3D_DepthTest(false, GPU_GEQUAL, GPU_WRITE_ALL);
 	C3D_CullFace(GPU_CULL_NONE);
+
+	_overlay.create(320, 240, &DEFAULT_MODE, true);
 }
 
 void OSystem_3DS::destroy3DSGraphics() {
@@ -221,8 +223,7 @@ void OSystem_3DS::initSize(uint width, uint height,
 		_transactionDetails.formatChanged = true;
 	}
 
-	_gameTopTexture.create(width, height, _gfxState.gfxMode);
-	_overlay.create(400, 320, &DEFAULT_MODE);
+	_gameTopTexture.create(width, height, _gfxState.gfxMode, true);
 	_gameScreen.create(width, height, _pfGame);
 
 	_focusDirty = true;
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
index afe3978abda..ef3ac19dc64 100644
--- a/backends/platform/3ds/sprite.cpp
+++ b/backends/platform/3ds/sprite.cpp
@@ -48,7 +48,7 @@ Sprite::~Sprite() {
 	//
 }
 
-void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode) {
+void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode, bool vram) {
 	free();
 
 	actualWidth = width;
@@ -62,7 +62,11 @@ void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode) {
 
 	if (width && height) {
 		pixels = linearAlloc(h * pitch);
-		C3D_TexInit(&texture, w, h, mode->textureFormat);
+		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);
 		assert(pixels && texture.data);
 		clear();
 	}
diff --git a/backends/platform/3ds/sprite.h b/backends/platform/3ds/sprite.h
index f8a0cf4f99c..848f5b0eb9f 100644
--- a/backends/platform/3ds/sprite.h
+++ b/backends/platform/3ds/sprite.h
@@ -41,7 +41,7 @@ class Sprite : public Graphics::Surface {
 public:
 	Sprite();
 	~Sprite();
-	void create(uint16 width, uint16 height, const GfxMode3DS *mode);
+	void create(uint16 width, uint16 height, const GfxMode3DS *mode, bool vram = false);
 	void free();
 	void convertToInPlace(const Graphics::PixelFormat &dstFormat, const byte *palette = 0);
 	void transfer();


Commit: 4a3f280f1a60a4a57b5e5dbff9827715e99629a5
    https://github.com/scummvm/scummvm/commit/4a3f280f1a60a4a57b5e5dbff9827715e99629a5
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-09-02T11:13:09+03:00

Commit Message:
3DS: Limit the linear heap to 10 MB

Changed paths:
    backends/platform/3ds/main.cpp


diff --git a/backends/platform/3ds/main.cpp b/backends/platform/3ds/main.cpp
index beaf214a6a9..033d8fac035 100644
--- a/backends/platform/3ds/main.cpp
+++ b/backends/platform/3ds/main.cpp
@@ -32,6 +32,10 @@ enum {
 // Set the size of the stack.
 u32 __stacksize__ = 64 * 1024;
 
+// Set the size of the linear heap to allow a larger application heap.
+u32 __ctru_heap_size        = 0;
+u32 __ctru_linear_heap_size = 10 * 1024 * 1024;
+
 int main(int argc, char *argv[]) {
 	// Initialize basic libctru stuff
 	cfguInit();




More information about the Scummvm-git-logs mailing list