From abfda60ff13fbfc4d1e8f11447b1da25386c4f00 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Fri, 17 Jul 2026 21:13:58 -0400 Subject: [PATCH] [Perf] (MG_Backend/DirectGLES): check the unbind cache before activating the texture unit so the bind-0 sweep stops issuing redundant glActiveTexture per draw --- MobileGL/MG_Backend/DirectGLES/Managers.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index f5d9b79c..5b44728b 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -2285,14 +2285,11 @@ namespace MobileGL::MG_Backend::DirectGLES { g_activeTextureUnit = unit; } - void UnbindTexture(Uint unit, GLenum target) { // Active unit will be modified - if (unit != g_activeTextureUnit) { - ActivateTextureUnit(unit); - } - + void UnbindTexture(Uint unit, GLenum target) { // Activates `unit` when an unbind is issued auto targetN = static_cast(MG_Util::ConvertGLEnumToTextureTarget(target)); if (g_boundTexturesCache[unit][targetN] == nullptr) return; + ActivateTextureUnit(unit); g_GLESFuncs.glBindTexture(target, 0); g_boundTexturesCache[unit][targetN] = nullptr; }