From 2344552ba8b96f13287e9b6b60ecd1c53426c4f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 May 2026 16:26:30 +0200 Subject: [PATCH] Opengl: enable stencil testing only when portals are used maybe a bit of perf on non portal maps, prob neglible but why not --- src/hardware/hw_main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8919e3ed4..7de18f756 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5691,7 +5691,11 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(boolean skybox, boolean drawsky) { - GL_EnableStencilTest(); + // NetUpdate below may cause this to be false midrender if toggled + const boolean useportals = HWR_UsePortals(); + + if (useportals) + GL_EnableStencilTest(); // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5718,12 +5722,13 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) NetUpdate(); portalclipline = NULL; - if (UNLIKELY(HWR_UsePortals())) + if (useportals) HWR_RenderViewpoint(NULL, 0, !skybox); else HWR_RenderViewpoint(NULL, 0, !skybox); - GL_DisableStencilTest(); + if (useportals) + GL_DisableStencilTest(); // Check for new console commands. NetUpdate();