From ea0babc5c00e77576f1ac6ff5135f585f25440d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Nov 2024 22:35:49 +0100 Subject: [PATCH] dont draw final screen texture twice if you use native res no need to saves some performance --- src/i_video.h | 2 ++ src/sdl/i_video.c | 27 ++++++++++++++++++++++++++- src/sdl/ogl_sdl.c | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/i_video.h b/src/i_video.h index bbf85c006..ee2875026 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,6 +139,8 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); +boolean I_CheckNativeRes(void); + #ifdef USE_FBO_OGL #if defined (__unix__) extern boolean xwaylandcrap; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f9d44d62f..ce0cbc322 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -706,10 +706,35 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } +boolean I_CheckNativeRes(void) +{ + static int oldwidth = 0, oldheight = 0; + static boolean resstate = false; + int currentDisplayIndex = 0; + SDL_DisplayMode curmode; + + if (oldwidth == vid.width && oldheight == vid.height) + { + return resstate; + } + + currentDisplayIndex = SDL_GetWindowDisplayIndex(window); + + if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) + { + return resstate; + } + + resstate = ((vid.width == curmode.w) && (vid.height == curmode.h)); + oldwidth = vid.width; + oldheight = vid.height; + return resstate; +} + #ifdef USE_FBO_OGL void I_DownSample(void) { - if (!cv_glframebuffer.value || !supportFBO) //no sense to do this crap if we cant benefit from it + if (!cv_glframebuffer.value || !supportFBO || I_CheckNativeRes()) //no sense to do this crap if we cant benefit from it { downsample = false; return; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index a3ee438fa..fafcc8900 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -300,6 +300,12 @@ void OglSdlFinishUpdate(boolean waitvbl) // Sryder: We need to draw the final screen texture again into the other buffer in the original position so that // effects that want to take the old screen can do so after this + if ((!I_CheckNativeRes()) // well we dont need it on native res it seems +#ifdef USE_FBO_OGL + && (!UseScreenFBO()) +#endif + ) + HWR_DrawScreenFinalTexture(realwidth, realheight); //HWR_DrawScreenFinalTexture(realwidth, realheight); //GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, realwidth, realheight);