From b8483376c42474fff3e3a561aefc4d3d03d7e821 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Nov 2024 22:29: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 | 7 ++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/i_video.h b/src/i_video.h index fc71df557..76055a6aa 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 73a1f992d..1dcfe57a7 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -755,10 +755,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 2b94669ed..3d57b1f14 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -271,7 +271,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 - HWR_DrawScreenFinalTexture(realwidth, realheight); + if ((!I_CheckNativeRes()) // well we dont need it on native res it seems +#ifdef USE_FBO_OGL + && (!UseScreenFBO()) +#endif + ) + HWR_DrawScreenFinalTexture(realwidth, realheight); } EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette)