From 6e636a27d06e8aef530af862eeb29c732a178a42 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 11 Jan 2021 16:57:31 +0900 Subject: [PATCH] [renderer] Continue the job of merging SCR_UpdateScreen I think this is probably as merged as it will get (though the update callbacks can probably do with some merging). --- include/QF/plugin/vid_render.h | 4 +-- include/QF/screen.h | 3 +++ include/r_internal.h | 2 +- libs/video/renderer/gl/gl_screen.c | 34 +++++-------------------- libs/video/renderer/gl/namehack.h | 4 +-- libs/video/renderer/glsl/glsl_screen.c | 18 +++---------- libs/video/renderer/glsl/namehack.h | 4 +-- libs/video/renderer/r_screen.c | 31 ++++++++++++++++++++++ libs/video/renderer/sw/screen.c | 30 +--------------------- libs/video/renderer/sw32/namehack.h | 4 +-- libs/video/renderer/sw32/screen.c | 30 +--------------------- libs/video/renderer/vid_render_gl.c | 2 +- libs/video/renderer/vid_render_glsl.c | 2 +- libs/video/renderer/vid_render_sw.c | 2 +- libs/video/renderer/vid_render_sw32.c | 2 +- libs/video/renderer/vid_render_vulkan.c | 4 +-- libs/video/renderer/vulkan/namehack.h | 2 -- nq/source/cl_screen.c | 2 +- qw/source/cl_screen.c | 2 +- ruamoko/qwaq/builtins/qwaq-bi.c | 2 +- 20 files changed, 63 insertions(+), 121 deletions(-) diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index 6de6e9af7..fc011a8b6 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -130,9 +130,6 @@ typedef struct vid_render_funcs_s { void (*Draw_SubPic) (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height); - // scr_funcs is a null terminated array - void (*SCR_UpdateScreen) (double realtime, SCR_Func scr_3dfunc, - SCR_Func *scr_funcs); void (*SCR_DrawRam) (void); void (*SCR_DrawTurtle) (void); void (*SCR_DrawPause) (void); @@ -146,6 +143,7 @@ typedef struct vid_render_funcs_s { void (*Fog_ParseWorldspawn) (struct plitem_s *worldspawn); void (*R_Init) (void); + void (*R_RenderFrame) (SCR_Func scr_3dfunc, SCR_Func *scr_funcs); void (*R_ClearState) (void); void (*R_LoadSkys) (const char *); void (*R_NewMap) (model_t *worldmodel, model_t **models, int num_models); diff --git a/include/QF/screen.h b/include/QF/screen.h index 8dda2deb4..b904f1c7c 100644 --- a/include/QF/screen.h +++ b/include/QF/screen.h @@ -35,6 +35,9 @@ void SCR_Init_Cvars (void); void SCR_Init (void); typedef void (*SCR_Func)(void); +// scr_funcs is a null terminated array +void SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, + SCR_Func *scr_funcs); void SCR_SizeUp (void); void SCR_SizeDown (void); diff --git a/include/r_internal.h b/include/r_internal.h index 547d4d1bf..de11978fa 100644 --- a/include/r_internal.h +++ b/include/r_internal.h @@ -44,7 +44,7 @@ void gl_R_Init (void); void glsl_R_Init (void); void sw_R_Init (void); void sw32_R_Init (void); - +void R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs); void R_Init_Cvars (void); void R_InitEfrags (void); void R_ClearState (void); diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index fbe47106f..5758b5941 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -188,37 +188,23 @@ SCR_TileClear (void) } } -/* - SCR_UpdateScreen - - This is called every frame, and can also be called explicitly to flush - text to the screen. - - WARNING: be very careful calling this from elsewhere, because the refresh - needs almost the entire 256k of stack space! -*/ void -gl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) +gl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { double time1 = 0, time2; static int begun = 0; - if (scr_skipupdate) - return; - - if (begun) + if (begun) { gl_ctx->end_rendering (); - - vr_data.realtime = realtime; + begun = 0; + } vid.numpages = 2 + gl_triplebuffer->int_val; - scr_copytop = 0; + //FIXME forces the status bar to redraw. needed because it does not fully + //update in sw modes but must in gl mode vr_data.scr_copyeverything = 1; - if (!scr_initialized) - return; // not initialized yet - begun = 1; if (r_speeds->int_val) { @@ -227,14 +213,6 @@ gl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) gl_c_alias_polys = 0; } - if (oldfov != scr_fov->value) { // determine size of refresh window - oldfov = scr_fov->value; - vid.recalc_refdef = true; - } - - if (vid.recalc_refdef) - SCR_CalcRefdef (); - // do 3D refresh drawing, and then update the screen scr_3dfunc (); diff --git a/libs/video/renderer/gl/namehack.h b/libs/video/renderer/gl/namehack.h index 075e31836..e33d0aef6 100644 --- a/libs/video/renderer/gl/namehack.h +++ b/libs/video/renderer/gl/namehack.h @@ -69,7 +69,7 @@ #define SCR_CaptureBGR gl_SCR_CaptureBGR #define SCR_ScreenShot gl_SCR_ScreenShot #define SCR_ScreenShot_f gl_SCR_ScreenShot_f -#define SCR_UpdateScreen gl_SCR_UpdateScreen +#define R_RenderFrame gl_R_RenderFrame #define c_alias_polys gl_c_alias_polys #define c_brush_polys gl_c_brush_polys #define r_easter_eggs_f gl_r_easter_eggs_f @@ -125,7 +125,7 @@ #undef SCR_CaptureBGR #undef SCR_ScreenShot #undef SCR_ScreenShot_f -#undef SCR_UpdateScreen +#undef R_RenderFrame #undef c_alias_polys #undef c_brush_polys #undef r_easter_eggs_f diff --git a/libs/video/renderer/glsl/glsl_screen.c b/libs/video/renderer/glsl/glsl_screen.c index 89276999d..098f6a816 100644 --- a/libs/video/renderer/glsl/glsl_screen.c +++ b/libs/video/renderer/glsl/glsl_screen.c @@ -155,8 +155,7 @@ SCR_TileClear (void) } void -glsl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, - SCR_Func *scr_funcs) +glsl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { static int begun = 0; @@ -169,23 +168,14 @@ glsl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, glsl_ctx->end_rendering (); } - vr_data.realtime = realtime; - vr_data.scr_copyeverything = 1; //FIXME useless cvar? vid.numpages = 2 + gl_triplebuffer->int_val; - if (!scr_initialized) - return; - qfeglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); begun = 1; - - if (oldfov != scr_fov->value) { - oldfov = scr_fov->value; - vid.recalc_refdef = true; - } - if (vid.recalc_refdef) - SCR_CalcRefdef (); + //FIXME forces the status bar to redraw. needed because it does not fully + //update in sw modes but must in glsl mode + vr_data.scr_copyeverything = 1; scr_3dfunc (); diff --git a/libs/video/renderer/glsl/namehack.h b/libs/video/renderer/glsl/namehack.h index 7edaed944..aed6d2e21 100644 --- a/libs/video/renderer/glsl/namehack.h +++ b/libs/video/renderer/glsl/namehack.h @@ -72,7 +72,7 @@ #define SCR_CaptureBGR glsl_SCR_CaptureBGR #define SCR_ScreenShot glsl_SCR_ScreenShot #define SCR_ScreenShot_f glsl_SCR_ScreenShot_f -#define SCR_UpdateScreen glsl_SCR_UpdateScreen +#define R_RenderFrame glsl_R_RenderFrame #define c_alias_polys glsl_c_alias_polys #define c_brush_polys glsl_c_brush_polys #define r_easter_eggs_f glsl_r_easter_eggs_f @@ -128,7 +128,7 @@ #undef SCR_CaptureBGR #undef SCR_ScreenShot #undef SCR_ScreenShot_f -#undef SCR_UpdateScreen +#undef R_RenderFrame #undef c_alias_polys #undef c_brush_polys #undef r_easter_eggs_f diff --git a/libs/video/renderer/r_screen.c b/libs/video/renderer/r_screen.c index 6eb307229..db6dcbcf7 100644 --- a/libs/video/renderer/r_screen.c +++ b/libs/video/renderer/r_screen.c @@ -170,6 +170,37 @@ SCR_CalcRefdef (void) vr_funcs->R_ViewChanged (vid.aspect); } +/* + SCR_UpdateScreen + + This is called every frame, and can also be called explicitly to flush + text to the screen. + + WARNING: be very careful calling this from elsewhere, because the refresh + needs almost the entire 256k of stack space! +*/ +void +SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) +{ + if (scr_skipupdate || !scr_initialized) { + return; + } + + vr_data.realtime = realtime; + scr_copytop = vr_data.scr_copyeverything = 0; + + if (oldfov != scr_fov->value) { + oldfov = scr_fov->value; + vid.recalc_refdef = true; + } + + if (vid.recalc_refdef) { + SCR_CalcRefdef (); + } + + vr_funcs->R_RenderFrame (scr_3dfunc, scr_funcs); +} + float CalcFov (float fov_x, float width, float height) { diff --git a/libs/video/renderer/sw/screen.c b/libs/video/renderer/sw/screen.c index 5b69e7a0d..4ab9302c1 100644 --- a/libs/video/renderer/sw/screen.c +++ b/libs/video/renderer/sw/screen.c @@ -178,39 +178,11 @@ SCR_ScreenShot_f (void) dstring_delete (pcxname); } -/* - SCR_UpdateScreen - - This is called every frame, and can also be called explicitly to flush - text to the screen. - - WARNING: be very careful calling this from elsewhere, because the refresh - needs almost the entire 256k of stack space! -*/ void -SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) +R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { vrect_t vrect; - if (scr_skipupdate) - return; - - vr_data.realtime = realtime; - - scr_copytop = 0; - vr_data.scr_copyeverything = 0; - - if (!scr_initialized) - return; // not initialized yet - - if (oldfov != scr_fov->value) { // determine size of refresh window - oldfov = scr_fov->value; - vid.recalc_refdef = true; - } - - if (vid.recalc_refdef) - SCR_CalcRefdef (); - // do 3D refresh drawing, and then update the screen D_EnableBackBufferAccess (); // of all overlay stuff if drawing // directly diff --git a/libs/video/renderer/sw32/namehack.h b/libs/video/renderer/sw32/namehack.h index cbdb673ce..6642d2d54 100644 --- a/libs/video/renderer/sw32/namehack.h +++ b/libs/video/renderer/sw32/namehack.h @@ -110,7 +110,7 @@ #define SCR_CaptureBGR sw32_SCR_CaptureBGR #define SCR_ScreenShot sw32_SCR_ScreenShot #define SCR_ScreenShot_f sw32_SCR_ScreenShot_f -#define SCR_UpdateScreen sw32_SCR_UpdateScreen +#define R_RenderFrame sw32_R_RenderFrame #define TransformVector sw32_TransformVector #define Turbulent sw32_Turbulent #define acolormap sw32_acolormap @@ -351,7 +351,7 @@ extern struct surf_s *sw32_surfaces; #undef SCR_CaptureBGR #undef SCR_ScreenShot #undef SCR_ScreenShot_f -#undef SCR_UpdateScreen +#undef R_RenderFrame #undef TransformVector #undef Turbulent #undef VID_InitBuffers diff --git a/libs/video/renderer/sw32/screen.c b/libs/video/renderer/sw32/screen.c index e4779d8da..543c8602a 100644 --- a/libs/video/renderer/sw32/screen.c +++ b/libs/video/renderer/sw32/screen.c @@ -136,39 +136,11 @@ sw32_SCR_ScreenShot_f (void) dstring_delete (pcxname); } -/* - SCR_UpdateScreen - - This is called every frame, and can also be called explicitly to flush - text to the screen. - - WARNING: be very careful calling this from elsewhere, because the refresh - needs almost the entire 256k of stack space! -*/ void -sw32_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) +sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { vrect_t vrect; - if (scr_skipupdate) - return; - - vr_data.realtime = realtime; - - scr_copytop = 0; - vr_data.scr_copyeverything = 0; - - if (!scr_initialized) - return; // not initialized yet - - if (oldfov != scr_fov->value) { // determine size of refresh window - oldfov = scr_fov->value; - vid.recalc_refdef = true; - } - - if (vid.recalc_refdef) - SCR_CalcRefdef (); - // do 3D refresh drawing, and then update the screen sw32_D_EnableBackBufferAccess (); // of all overlay stuff if drawing // directly diff --git a/libs/video/renderer/vid_render_gl.c b/libs/video/renderer/vid_render_gl.c index 434588894..c27b5d4ac 100644 --- a/libs/video/renderer/vid_render_gl.c +++ b/libs/video/renderer/vid_render_gl.c @@ -93,7 +93,6 @@ vid_render_funcs_t gl_vid_render_funcs = { gl_Draw_Picf, gl_Draw_SubPic, - gl_SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, SCR_DrawPause, @@ -105,6 +104,7 @@ vid_render_funcs_t gl_vid_render_funcs = { gl_Fog_ParseWorldspawn, gl_R_Init, + gl_R_RenderFrame, gl_R_ClearState, gl_R_LoadSkys, gl_R_NewMap, diff --git a/libs/video/renderer/vid_render_glsl.c b/libs/video/renderer/vid_render_glsl.c index f8ca47174..e3b549e35 100644 --- a/libs/video/renderer/vid_render_glsl.c +++ b/libs/video/renderer/vid_render_glsl.c @@ -93,7 +93,6 @@ vid_render_funcs_t glsl_vid_render_funcs = { glsl_Draw_Picf, glsl_Draw_SubPic, - glsl_SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, SCR_DrawPause, @@ -105,6 +104,7 @@ vid_render_funcs_t glsl_vid_render_funcs = { glsl_Fog_ParseWorldspawn, glsl_R_Init, + glsl_R_RenderFrame, glsl_R_ClearState, glsl_R_LoadSkys, glsl_R_NewMap, diff --git a/libs/video/renderer/vid_render_sw.c b/libs/video/renderer/vid_render_sw.c index a418d200c..5c9264381 100644 --- a/libs/video/renderer/vid_render_sw.c +++ b/libs/video/renderer/vid_render_sw.c @@ -86,7 +86,6 @@ vid_render_funcs_t sw_vid_render_funcs = { Draw_Picf, Draw_SubPic, - SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, SCR_DrawPause, @@ -98,6 +97,7 @@ vid_render_funcs_t sw_vid_render_funcs = { 0, sw_R_Init, + R_RenderFrame, R_ClearState, R_LoadSkys, R_NewMap, diff --git a/libs/video/renderer/vid_render_sw32.c b/libs/video/renderer/vid_render_sw32.c index 9fffb0298..be727c8a9 100644 --- a/libs/video/renderer/vid_render_sw32.c +++ b/libs/video/renderer/vid_render_sw32.c @@ -91,7 +91,6 @@ vid_render_funcs_t sw32_vid_render_funcs = { sw32_Draw_Picf, sw32_Draw_SubPic, - sw32_SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, SCR_DrawPause, @@ -103,6 +102,7 @@ vid_render_funcs_t sw32_vid_render_funcs = { 0, sw32_R_Init, + sw32_R_RenderFrame, sw32_R_ClearState, sw32_R_LoadSkys, sw32_R_NewMap, diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 64d8f3766..a61a911a2 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -105,7 +105,7 @@ vulkan_R_Init (void) } static void -vulkan_SCR_UpdateScreen (double time, void (*f)(void), void (**g)(void)) +vulkan_R_RenderFrame (void (*f)(void), void (**g)(void)) { static int count = 0; static double startTime; @@ -324,7 +324,6 @@ vid_render_funcs_t vulkan_vid_render_funcs = { vulkan_Draw_Picf, vulkan_Draw_SubPic, - vulkan_SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, SCR_DrawPause, @@ -336,6 +335,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = { 0,//vulkan_Fog_ParseWorldspawn, vulkan_R_Init, + vulkan_R_RenderFrame, 0,//vulkan_R_ClearState, 0,//vulkan_R_LoadSkys, 0,//vulkan_R_NewMap, diff --git a/libs/video/renderer/vulkan/namehack.h b/libs/video/renderer/vulkan/namehack.h index 7289995f2..17f107080 100644 --- a/libs/video/renderer/vulkan/namehack.h +++ b/libs/video/renderer/vulkan/namehack.h @@ -72,7 +72,6 @@ #define SCR_CaptureBGR vulkan_SCR_CaptureBGR #define SCR_ScreenShot vulkan_SCR_ScreenShot #define SCR_ScreenShot_f vulkan_SCR_ScreenShot_f -#define SCR_UpdateScreen vulkan_SCR_UpdateScreen #define c_alias_polys vulkan_c_alias_polys #define c_brush_polys vulkan_c_brush_polys #define r_easter_eggs_f vulkan_r_easter_eggs_f @@ -128,7 +127,6 @@ #undef SCR_CaptureBGR #undef SCR_ScreenShot #undef SCR_ScreenShot_f -#undef SCR_UpdateScreen #undef c_alias_polys #undef c_brush_polys #undef r_easter_eggs_f diff --git a/nq/source/cl_screen.c b/nq/source/cl_screen.c index c7940e305..509352a1c 100644 --- a/nq/source/cl_screen.c +++ b/nq/source/cl_screen.c @@ -146,5 +146,5 @@ CL_UpdateScreen (double realtime) scr_funcs_normal[3] = r_funcs->SCR_DrawPause; V_PrepBlend (); - r_funcs->SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); + SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); } diff --git a/qw/source/cl_screen.c b/qw/source/cl_screen.c index 5b81f65a7..7827c30db 100644 --- a/qw/source/cl_screen.c +++ b/qw/source/cl_screen.c @@ -147,5 +147,5 @@ CL_UpdateScreen (double realtime) scr_funcs_normal[3] = r_funcs->SCR_DrawPause; V_PrepBlend (); - r_funcs->SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); + SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); } diff --git a/ruamoko/qwaq/builtins/qwaq-bi.c b/ruamoko/qwaq/builtins/qwaq-bi.c index 27a7ae04f..a78dd7763 100644 --- a/ruamoko/qwaq/builtins/qwaq-bi.c +++ b/ruamoko/qwaq/builtins/qwaq-bi.c @@ -127,7 +127,7 @@ bi_refresh (progs_t *pr) IN_ProcessEvents (); //GIB_Thread_Execute (); Cbuf_Execute_Stack (qwaq_cbuf); - r_funcs->SCR_UpdateScreen (con_realtime, bi_3d, bi_2dfuncs); + SCR_UpdateScreen (con_realtime, bi_3d, bi_2dfuncs); R_FLOAT (pr) = con_frametime; }