From d996bc779318cc51464bc42f1dfc5fe0f59fb8c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Nov 2024 22:40:20 +0100 Subject: [PATCH] only apply palrender postprocess shader once --- src/hardware/hw_main.c | 4 ++-- src/hardware/hw_main.h | 2 +- src/hardware/r_opengl/r_opengl.c | 26 ++++++++++++++++---------- src/sdl/ogl_sdl.c | 4 ++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f272a151d..b19af4b8d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5718,9 +5718,9 @@ void HWR_MakeScreenFinalTexture(void) GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) { - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); } #endif // HWRENDER diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index f612d8fd6..192fdf521 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -131,7 +131,7 @@ void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader); // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e6ff6db06..ab1ce9e6f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3463,7 +3463,7 @@ void GL_MakeScreenTexture(int tex) tex_downloaded = screenTextures[tex]; } -void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height) +void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader) { float xfix, yfix; float origaspect, newaspect; @@ -3530,12 +3530,15 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height) pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - // godawful but you can only ever run ONE shader per renderpass and since i dont want to draw an extra screen texture when you downsample from higher resolution (essentially killing performance) - // so i combined the palette postprocess with this crap - if (HWR_ShouldUsePaletteRendering() && (!(HWR_UseShader() && fbo_shader && !WipeInAction))) - pglUseProgram(gl_shaders[SHADER_PALETTE_POSTPROCESS].program); // palette postprocess shader - else if (HWR_UseShader() && fbo_shader && !WipeInAction) // this looks awful with wipes - pglUseProgram(gl_shaders[SHADER_DOWNSAMPLE].program); + if (useshader) + { + // godawful but you can only ever run ONE shader per renderpass and since i dont want to draw an extra screen texture when you downsample from higher resolution (essentially killing performance) + // so i combined the palette postprocess with this crap + if (HWR_ShouldUsePaletteRendering() && (!(HWR_UseShader() && fbo_shader && !WipeInAction))) + pglUseProgram(gl_shaders[SHADER_PALETTE_POSTPROCESS].program); // palette postprocess shader + else if (HWR_UseShader() && fbo_shader && !WipeInAction) // this looks awful with wipes + pglUseProgram(gl_shaders[SHADER_DOWNSAMPLE].program); + } pglColor4ubv(white); @@ -3543,9 +3546,12 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height) pglVertexPointer(3, GL_FLOAT, 0, off); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - if (HWR_ShouldUsePaletteRendering() || (HWR_UseShader() && fbo_shader && !WipeInAction)) - pglUseProgram(0); + + if (useshader) + { + if (HWR_ShouldUsePaletteRendering() || (HWR_UseShader() && fbo_shader && !WipeInAction)) + pglUseProgram(0); + } tex_downloaded = screenTextures[tex]; } diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index fafcc8900..f0b1374ff 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -284,7 +284,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #endif //HWR_DrawScreenFinalTexture(sdlw, sdlh); - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh); + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh, true); #ifdef USE_FBO_OGL if (UseScreenFBO()) @@ -305,7 +305,7 @@ void OglSdlFinishUpdate(boolean waitvbl) && (!UseScreenFBO()) #endif ) - HWR_DrawScreenFinalTexture(realwidth, realheight); + HWR_DrawScreenFinalTexture(realwidth, realheight, false); //HWR_DrawScreenFinalTexture(realwidth, realheight); //GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, realwidth, realheight);