[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).
This commit is contained in:
Bill Currie 2021-01-11 16:57:31 +09:00
parent 88d48944cb
commit 6e636a27d0
20 changed files with 63 additions and 121 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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 ();

View file

@ -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

View file

@ -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 ();

View file

@ -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

View file

@ -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)
{

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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

View file

@ -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]);
}

View file

@ -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]);
}

View file

@ -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;
}