From fe8b8d798cee3288df263f46919590a9db94bfdd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jan 2025 21:54:36 +0100 Subject: [PATCH] inline bunch of one line HWR things --- src/hardware/hw_main.c | 52 +--------------------------------- src/hardware/hw_main.h | 64 ++++++++++++++++++++++++++++++++++-------- src/sdl/ogl_sdl.c | 6 ++-- 3 files changed, 56 insertions(+), 66 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9ea3710c7..7ae6629be 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -322,26 +322,11 @@ static void CV_glpalettedepth_OnChange(void) // Lighting // ========================================================================== -boolean HWR_UseShader(void) -{ - return (cv_glshaders.value && gl_shadersavailable); -} - static void HWR_SetShaderState(void) { GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } -boolean HWR_ShouldUsePaletteRendering(void) -{ - return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); -} - -boolean HWR_PalRenderFlashpal(void) -{ - return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); -} - void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { (void)papersprite; @@ -3221,7 +3206,7 @@ static gl_vissprite_t *gl_visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = // HWR_ClearSprites // Called at frame start. // -------------------------------------------------------------------------- -static void HWR_ClearSprites(void) +static inline void HWR_ClearSprites(void) { gl_visspritecount = 0; } @@ -5823,11 +5808,6 @@ static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD #endif } -INT32 HWR_GetTextureUsed(void) -{ - return GL_GetTextureUsed(); -} - static void HWR_DoPostProcessor(player_t *player) { GL_UnSetShader(); @@ -5915,21 +5895,6 @@ static void HWR_DoPostProcessor(player_t *player) // Flipping of the screen isn't done here anymore } -void HWR_StartScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); -} - -void HWR_EndScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); -} - -void HWR_DrawIntermissionBG(void) -{ - GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); -} - void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) { static char lumpname[9] = "FADEmmss"; @@ -5964,19 +5929,4 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END); } -void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) -{ - GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); -} - -void HWR_MakeScreenFinalTexture(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); -} - -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) -{ - 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 63be2b1da..97b5ee61d 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -20,6 +20,7 @@ #ifndef __HWR_MAIN_H__ #define __HWR_MAIN_H__ +#include "hw_gl.h" #include "hw_glob.h" #include "hw_data.h" #include "hw_defs.h" @@ -29,6 +30,7 @@ #include "../d_player.h" #include "../r_defs.h" #include "../m_perfstats.h" +#include "../v_video.h" #define GLENCORE @@ -117,10 +119,6 @@ void HWR_SetTransform(float fpov); void HWR_ClearClipper(void); void HWR_SetStencilState(int state, int level); -boolean HWR_UseShader(void); -boolean HWR_ShouldUsePaletteRendering(void); -boolean HWR_PalRenderFlashpal(void); - // My original intention was to split hw_main.c // into files like hw_bsp.c, hw_sprites.c... @@ -129,17 +127,44 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); -// Get amount of memory used by gpu textures in bytes -INT32 HWR_GetTextureUsed(void); +// Get amount of memory used by gpu textures in bytes; +FUNCINLINE static ATTRINLINE INT32 HWR_GetTextureUsed(void) +{ + return GL_GetTextureUsed(); +} // hw_main.c: Post-rendering -void HWR_StartScreenWipe(void); -void HWR_EndScreenWipe(void); -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, boolean useshader); + +FUNCINLINE static ATTRINLINE void HWR_StartScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); +} + +FUNCINLINE static ATTRINLINE void HWR_EndScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawIntermissionBG(void) +{ + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); +} + +FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) +{ + GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); +} + +FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) +{ + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); +} // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom @@ -190,4 +215,19 @@ extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; extern consvar_t cv_glflashpal; +FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) +{ + return (cv_glshaders.value && gl_shadersavailable); +} + +FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) +{ + return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); +} + +FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) +{ + return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); +} + #endif diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index cccd6869f..a2819dc0b 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -288,9 +288,9 @@ void OglSdlFinishUpdate(boolean waitvbl) #endif #ifdef USE_FBO_OGL - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh, (HWR_ShouldUsePaletteRendering() || fbo_shader)); + HWR_DrawScreenFinalTexture(sdlw, sdlh, (HWR_ShouldUsePaletteRendering() || fbo_shader)); #else - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh, HWR_ShouldUsePaletteRendering()); + HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); #endif #ifdef USE_FBO_OGL @@ -312,7 +312,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #else if (!I_CheckNativeRes() || WipeInAction) #endif - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, realwidth, realheight, false); + HWR_DrawScreenFinalTexture(realwidth, realheight, false); #if defined (__unix__) #ifdef USE_FBO_OGL