From e6644af3012b62395db9807b9b3865ff42b12e1b Mon Sep 17 00:00:00 2001 From: Shinovon Date: Thu, 24 Jul 2025 07:40:02 +0500 Subject: [PATCH 1/3] Fix performance drop when rendering translucent on PowerVR MBX --- misc/opengl/GLCommon.h | 2 ++ src/Graphics_GL1.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/misc/opengl/GLCommon.h b/misc/opengl/GLCommon.h index 9c8b6f0ee..207c7328d 100644 --- a/misc/opengl/GLCommon.h +++ b/misc/opengl/GLCommon.h @@ -42,6 +42,8 @@ typedef cc_uintptr GLpointer; #define GL_TRIANGLES 0x0004 #define GL_QUADS 0x0007 +#define GL_ZERO 0 +#define GL_ONE 1 #define GL_BLEND 0x0BE2 #define GL_SRC_ALPHA 0x0302 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 02a21331c..4f027d8e1 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -25,6 +25,8 @@ #include "../misc/opengl/GL1Funcs.h" #if defined CC_BUILD_SYMBIAN #include "../misc/opengl/GL2Funcs.h" + +static cc_bool mbx; #endif #if CC_BUILD_MAXSTACK <= (64 * 1024) @@ -84,7 +86,9 @@ void Gfx_Create(void) { #ifdef CC_BUILD_GL11_FALLBACK GLContext_GetAll(coreFuncs, Array_Elems(coreFuncs)); #endif +#ifndef CC_BUILD_GLES customMipmapsLevels = true; +#endif Gfx.BackendType = CC_GFX_BACKEND_GL1; GL_InitCommon(); @@ -335,6 +339,17 @@ static void SetAlphaTest(cc_bool enabled) { void Gfx_DepthOnlyRendering(cc_bool depthOnly) { cc_bool enabled = !depthOnly; +#ifdef CC_BUILD_SYMBIAN + if (mbx) { + if (depthOnly) { + _glBlendFunc(GL_ZERO, GL_ONE); + Gfx_SetAlphaBlending(true); + } else { + _glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + return; + } +#endif SetColorWrite(enabled & gfx_colorMask[0], enabled & gfx_colorMask[1], enabled & gfx_colorMask[2], enabled & gfx_colorMask[3]); @@ -422,6 +437,18 @@ cc_bool Gfx_WarnIfNecessary(void) { Gfx.Limitations |= GFX_LIMIT_VERTEX_ONLY_FOG; return true; } +#if defined CC_BUILD_SYMBIAN + if (String_ContainsConst(&renderer, "SGX")) { + } else if (String_ContainsConst(&renderer, "MBX")) { + Gfx.Limitations |= GFX_LIMIT_VERTEX_ONLY_FOG; + mbx = true; + } else if (!String_ContainsConst(&renderer, "HW")) { + Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer."); + + Gfx.Limitations |= GFX_LIMIT_MINIMAL; + return true; + } +#endif return false; } From aa11859bdabb3e4465e5ca83b33f56a89285b48e Mon Sep 17 00:00:00 2001 From: Shinovon Date: Thu, 24 Jul 2025 12:54:13 +0500 Subject: [PATCH 2/3] Symbian: rewrite main loop --- src/Window_Symbian.cpp | 60 +++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/Window_Symbian.cpp b/src/Window_Symbian.cpp index f9f7609fc..15d32668c 100644 --- a/src/Window_Symbian.cpp +++ b/src/Window_Symbian.cpp @@ -485,35 +485,41 @@ void CCAppUi::HandleCommandL(TInt aCommand) { // CCContainer implementation TInt CCContainer::LoopCallBack(TAny*) { - if (!WindowInfo.Exists) { - Window_RequestClose(); - container->iAppUi->Exit(); - return EFalse; - } - - // launcher -> game -> launcher -> ... loop - launcher: - if (!gameRunning) { - if (Launcher_Tick()) { - return ETrue; + cc_bool run = false; + for (;;) { + if (!WindowInfo.Exists) { + Window_RequestClose(); + container->iAppUi->Exit(); + return EFalse; } - Launcher_Finish(); - - // run game - gameRunning = true; - Game_Setup(); - container->RestartTimerL(100); + + if (run) { + run = false; + ProcessProgramArgs(0, 0); + Game_Setup(); + gameRunning = true; + container->RestartTimerL(100); + } + + if (!gameRunning) { + if (Launcher_Tick()) break; + Launcher_Finish(); + run = true; + continue; + } + + if (!Game_Running) { + gameRunning = false; + Game_Free(); +// Launcher_Setup(); +// container->RestartTimerL(10000); + WindowInfo.Exists = false; + continue; + } + + Game_RenderFrame(); + break; } - - if (!Game_Running) { - // return to launcher - gameRunning = false; - Game_Free(); - Launcher_Setup(); - container->RestartTimerL(10000); - goto launcher; - } - Game_RenderFrame(); return ETrue; } From 9b1af5d3af11e50472d9a82baa245280f6045bfd Mon Sep 17 00:00:00 2001 From: Shinovon Date: Sat, 26 Jul 2025 02:40:44 +0500 Subject: [PATCH 3/3] Try to achieve better performance on MBX by disabling things --- src/Core.h | 1 + src/Graphics_GL1.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core.h b/src/Core.h index 3dc3cea14..abe4086b3 100644 --- a/src/Core.h +++ b/src/Core.h @@ -616,6 +616,7 @@ typedef cc_uint8 cc_bool; #define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL2 #else #define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL1 + #define CC_DISABLE_ANIMATIONS #endif #endif #endif diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 4f027d8e1..88c1fca10 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -440,7 +440,7 @@ cc_bool Gfx_WarnIfNecessary(void) { #if defined CC_BUILD_SYMBIAN if (String_ContainsConst(&renderer, "SGX")) { } else if (String_ContainsConst(&renderer, "MBX")) { - Gfx.Limitations |= GFX_LIMIT_VERTEX_ONLY_FOG; + Gfx.Limitations |= GFX_LIMIT_MINIMAL; mbx = true; } else if (!String_ContainsConst(&renderer, "HW")) { Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer.");