mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[renderer] Make R_RenderView private
This is actually a better solution to the renderer directly accessing
client code than provided by 7e078c7f9c
.
Essentially, V_RenderView should not have been calling R_RenderView, and
CL_UpdateScreen should have been calling V_RenderView directly. The
issue was that the renderers expected the world entity model to be valid
at all times. Now, R_RenderView checks the world entity model's validity
and immediately bails if it is not, and R_ClearState (which is called
whenever the client disconnects and thus no longer has a world to
render) clears the world entity model. Thus R_RenderView can (and is)
now called unconditionally from within the renderer, simplifying
renderer-specific variants.
This commit is contained in:
parent
eb828007e9
commit
84a24dbb34
27 changed files with 42 additions and 55 deletions
|
@ -148,7 +148,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_RenderFrame) (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);
|
||||
|
@ -158,7 +158,6 @@ typedef struct vid_render_funcs_s {
|
|||
dlight_t *(*R_AllocDlight) (int key);
|
||||
entity_t *(*R_AllocEntity) (void);
|
||||
void (*R_MaxDlightsCheck) (struct cvar_s *var);
|
||||
void (*R_RenderView) (void);
|
||||
void (*R_DecayLights) (double frametime);
|
||||
|
||||
void (*R_ViewChanged) (void);
|
||||
|
|
|
@ -36,8 +36,7 @@ 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_UpdateScreen (double realtime, SCR_Func *scr_funcs);
|
||||
|
||||
void SCR_SizeUp (void);
|
||||
void SCR_SizeDown (void);
|
||||
|
|
|
@ -45,7 +45,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_RenderFrame (SCR_Func *scr_funcs);
|
||||
void R_Init_Cvars (void);
|
||||
void R_InitEfrags (void);
|
||||
void R_ClearState (void);
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include "QF/screen.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
void SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc,
|
||||
SCR_Func *scr_funcs);
|
||||
void SCR_DrawRam (void);
|
||||
void SCR_DrawFPS (void);
|
||||
void SCR_DrawTime (void);
|
||||
|
|
|
@ -562,7 +562,7 @@ R_RenderView_ (void)
|
|||
return;
|
||||
}
|
||||
if (!r_worldentity.renderer.model) {
|
||||
Sys_Error ("R_RenderView: NULL worldmodel");
|
||||
return;
|
||||
}
|
||||
|
||||
gl_mirror = false;
|
||||
|
|
|
@ -201,7 +201,7 @@ R_Clear (void)
|
|||
}
|
||||
|
||||
void
|
||||
gl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
gl_R_RenderFrame (SCR_Func *scr_funcs)
|
||||
{
|
||||
double time1 = 0, time2;
|
||||
static int begun = 0;
|
||||
|
@ -228,7 +228,7 @@ gl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
}
|
||||
|
||||
// do 3D refresh drawing, and then update the screen
|
||||
scr_3dfunc ();
|
||||
gl_R_RenderView ();
|
||||
|
||||
SCR_SetUpToDrawConsole ();
|
||||
GL_Set2D ();
|
||||
|
|
|
@ -181,6 +181,10 @@ glsl_R_RenderView (void)
|
|||
double t[10] = {};
|
||||
int speeds = r_speeds->int_val;
|
||||
|
||||
if (!r_worldentity.renderer.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (speeds)
|
||||
t[0] = Sys_DoubleTime ();
|
||||
glsl_R_SetupFrame ();
|
||||
|
@ -272,6 +276,7 @@ glsl_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
|||
void
|
||||
glsl_R_ClearState (void)
|
||||
{
|
||||
r_worldentity.renderer.model = 0;
|
||||
R_ClearEfrags ();
|
||||
R_ClearDlights ();
|
||||
glsl_R_ClearParticles ();
|
||||
|
|
|
@ -156,7 +156,7 @@ SCR_TileClear (void)
|
|||
}
|
||||
|
||||
void
|
||||
glsl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
glsl_R_RenderFrame (SCR_Func *scr_funcs)
|
||||
{
|
||||
static int begun = 0;
|
||||
|
||||
|
@ -178,7 +178,7 @@ glsl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
//update in sw modes but must in glsl mode
|
||||
vr_data.scr_copyeverything = 1;
|
||||
|
||||
scr_3dfunc ();
|
||||
glsl_R_RenderView ();
|
||||
|
||||
SCR_SetUpToDrawConsole ();
|
||||
GLSL_Set2D ();
|
||||
|
|
|
@ -199,7 +199,7 @@ SCR_CalcRefdef (void)
|
|||
needs almost the entire 256k of stack space!
|
||||
*/
|
||||
void
|
||||
SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
|
||||
{
|
||||
if (scr_skipupdate || !scr_initialized) {
|
||||
return;
|
||||
|
@ -212,7 +212,7 @@ SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
SCR_CalcRefdef ();
|
||||
}
|
||||
|
||||
r_funcs->R_RenderFrame (scr_3dfunc, scr_funcs);
|
||||
r_funcs->R_RenderFrame (scr_funcs);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -182,7 +182,7 @@ SCR_ScreenShot_f (void)
|
|||
}
|
||||
|
||||
void
|
||||
R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
R_RenderFrame (SCR_Func *scr_funcs)
|
||||
{
|
||||
vrect_t vrect;
|
||||
|
||||
|
@ -202,7 +202,7 @@ R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
D_DisableBackBufferAccess (); // for adapters that can't stay mapped
|
||||
// in for linear writes all the time
|
||||
VID_LockBuffer ();
|
||||
scr_3dfunc ();
|
||||
R_RenderView ();
|
||||
VID_UnlockBuffer ();
|
||||
|
||||
D_EnableBackBufferAccess (); // of all overlay stuff if drawing
|
||||
|
|
|
@ -744,6 +744,9 @@ R_RenderView_ (void)
|
|||
|
||||
if (r_norefresh->int_val)
|
||||
return;
|
||||
if (!r_worldentity.renderer.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
r_warpbuffer = warpbuffer;
|
||||
|
||||
|
@ -1160,6 +1163,7 @@ R_RenderViewFishEye (void)
|
|||
void
|
||||
R_ClearState (void)
|
||||
{
|
||||
r_worldentity.renderer.model = 0;
|
||||
R_ClearEfrags ();
|
||||
R_ClearDlights ();
|
||||
R_ClearParticles ();
|
||||
|
|
|
@ -139,7 +139,7 @@ sw32_SCR_ScreenShot_f (void)
|
|||
}
|
||||
|
||||
void
|
||||
sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
sw32_R_RenderFrame (SCR_Func *scr_funcs)
|
||||
{
|
||||
vrect_t vrect;
|
||||
|
||||
|
@ -159,7 +159,7 @@ sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
sw32_D_DisableBackBufferAccess (); // for adapters that can't stay mapped
|
||||
// in for linear writes all the time
|
||||
VID_LockBuffer ();
|
||||
scr_3dfunc ();
|
||||
sw32_R_RenderView ();
|
||||
VID_UnlockBuffer ();
|
||||
|
||||
sw32_D_EnableBackBufferAccess (); // of all overlay stuff if drawing
|
||||
|
|
|
@ -750,6 +750,9 @@ R_RenderView_ (void)
|
|||
{
|
||||
if (r_norefresh->int_val)
|
||||
return;
|
||||
if (!r_worldentity.renderer.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
sw32_r_warpbuffer = warpbuffer;
|
||||
|
||||
|
@ -868,6 +871,7 @@ sw32_R_InitTurb (void)
|
|||
void
|
||||
sw32_R_ClearState (void)
|
||||
{
|
||||
r_worldentity.renderer.model = 0;
|
||||
R_ClearEfrags ();
|
||||
R_ClearDlights ();
|
||||
sw32_R_ClearParticles ();
|
||||
|
|
|
@ -153,7 +153,6 @@ vid_render_funcs_t gl_vid_render_funcs = {
|
|||
R_AllocDlight,
|
||||
R_AllocEntity,
|
||||
R_MaxDlightsCheck,
|
||||
gl_R_RenderView,
|
||||
R_DecayLights,
|
||||
gl_R_ViewChanged,
|
||||
gl_R_ClearParticles,
|
||||
|
|
|
@ -152,7 +152,6 @@ vid_render_funcs_t glsl_vid_render_funcs = {
|
|||
R_AllocDlight,
|
||||
R_AllocEntity,
|
||||
R_MaxDlightsCheck,
|
||||
glsl_R_RenderView,
|
||||
R_DecayLights,
|
||||
glsl_R_ViewChanged,
|
||||
glsl_R_ClearParticles,
|
||||
|
|
|
@ -149,7 +149,6 @@ vid_render_funcs_t sw_vid_render_funcs = {
|
|||
R_AllocDlight,
|
||||
R_AllocEntity,
|
||||
R_MaxDlightsCheck,
|
||||
R_RenderView,
|
||||
R_DecayLights,
|
||||
R_ViewChanged,
|
||||
R_ClearParticles,
|
||||
|
|
|
@ -154,7 +154,6 @@ vid_render_funcs_t sw32_vid_render_funcs = {
|
|||
R_AllocDlight,
|
||||
R_AllocEntity,
|
||||
R_MaxDlightsCheck,
|
||||
sw32_R_RenderView,
|
||||
R_DecayLights,
|
||||
sw32_R_ViewChanged,
|
||||
sw32_R_ClearParticles,
|
||||
|
|
|
@ -112,7 +112,7 @@ vulkan_R_Init (void)
|
|||
}
|
||||
|
||||
static void
|
||||
vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
||||
vulkan_R_RenderFrame (SCR_Func *scr_funcs)
|
||||
{
|
||||
const VkSubpassContents subpassContents
|
||||
= VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
||||
|
@ -132,13 +132,12 @@ vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
|
||||
frame->framebuffer = vulkan_ctx->framebuffers->a[imageIndex];
|
||||
|
||||
scr_3dfunc ();
|
||||
|
||||
view_draw (vr_data.scr_view);
|
||||
while (*scr_funcs) {
|
||||
(*scr_funcs) ();
|
||||
scr_funcs++;
|
||||
}
|
||||
Vulkan_RenderView (vulkan_ctx);
|
||||
|
||||
Vulkan_FlushText (vulkan_ctx);
|
||||
|
||||
|
@ -222,6 +221,7 @@ vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
static void
|
||||
vulkan_R_ClearState (void)
|
||||
{
|
||||
r_worldentity.renderer.model = 0;
|
||||
R_ClearEfrags ();
|
||||
R_ClearDlights ();
|
||||
Vulkan_ClearParticles (vulkan_ctx);
|
||||
|
@ -244,12 +244,6 @@ vulkan_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
vulkan_R_RenderView (void)
|
||||
{
|
||||
Vulkan_RenderView (vulkan_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
vulkan_Draw_Character (int x, int y, unsigned ch)
|
||||
{
|
||||
|
@ -678,7 +672,6 @@ vid_render_funcs_t vulkan_vid_render_funcs = {
|
|||
R_AllocDlight,
|
||||
R_AllocEntity,
|
||||
R_MaxDlightsCheck,
|
||||
vulkan_R_RenderView,
|
||||
R_DecayLights,
|
||||
vulkan_R_ViewChanged,
|
||||
vulkan_R_ClearParticles,
|
||||
|
|
|
@ -157,6 +157,10 @@ Vulkan_RenderView (vulkan_ctx_t *ctx)
|
|||
double t[9] = {};
|
||||
int speeds = r_speeds->int_val;
|
||||
|
||||
if (!r_worldentity.renderer.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (speeds)
|
||||
t[0] = Sys_DoubleTime ();
|
||||
setup_frame (ctx);
|
||||
|
|
|
@ -328,7 +328,6 @@ void CL_NewTranslation (int slot, struct skin_s *skin);
|
|||
void V_StartPitchDrift (void);
|
||||
void V_StopPitchDrift (void);
|
||||
|
||||
void V_RenderView (void);
|
||||
void V_UpdatePalette (void);
|
||||
void V_Register (void);
|
||||
void V_ParseDamage (void);
|
||||
|
|
|
@ -531,6 +531,7 @@ CL_SetState (cactive_t state)
|
|||
case ca_dedicated:
|
||||
break;
|
||||
case ca_disconnected:
|
||||
CL_ClearState ();
|
||||
cls.signon = so_none;
|
||||
cl.loading = false;
|
||||
VID_SetCaption ("Disconnected");
|
||||
|
|
|
@ -165,5 +165,6 @@ CL_UpdateScreen (double realtime)
|
|||
scr_funcs_normal[3] = r_funcs->SCR_DrawPause;
|
||||
|
||||
V_PrepBlend ();
|
||||
SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]);
|
||||
V_RenderView ();
|
||||
SCR_UpdateScreen (realtime, scr_funcs[index]);
|
||||
}
|
||||
|
|
|
@ -720,8 +720,6 @@ V_RenderView (void)
|
|||
} else {
|
||||
V_CalcRefdef ();
|
||||
}
|
||||
|
||||
r_funcs->R_RenderView ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1145,6 +1145,7 @@ CL_SetState (cactive_t state)
|
|||
if (old_state == ca_active) {
|
||||
// leaving active state
|
||||
IN_ClearStates ();
|
||||
CL_ClearState ();
|
||||
|
||||
// Auto demo recorder stops here
|
||||
if (cl_autorecord->int_val && cls.demorecording)
|
||||
|
|
|
@ -187,5 +187,6 @@ CL_UpdateScreen (double realtime)
|
|||
scr_funcs_normal[3] = r_funcs->SCR_DrawPause;
|
||||
|
||||
V_PrepBlend ();
|
||||
SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]);
|
||||
V_RenderView ();
|
||||
SCR_UpdateScreen (realtime, scr_funcs[index]);
|
||||
}
|
||||
|
|
|
@ -760,8 +760,6 @@ V_RenderView (void)
|
|||
} else {
|
||||
V_CalcRefdef ();
|
||||
}
|
||||
|
||||
r_funcs->R_RenderView ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -96,14 +96,7 @@ bi_printf (progs_t *pr)
|
|||
}
|
||||
|
||||
static progs_t *bi_rprogs;
|
||||
static func_t qc3d, qc2d;
|
||||
|
||||
static void
|
||||
bi_3d (void)
|
||||
{
|
||||
if (qc3d)
|
||||
PR_ExecuteProgram (bi_rprogs, qc3d);
|
||||
}
|
||||
static func_t qc2d;
|
||||
|
||||
static void
|
||||
bi_2d (void)
|
||||
|
@ -128,7 +121,7 @@ bi_refresh (progs_t *pr)
|
|||
IN_ProcessEvents ();
|
||||
//GIB_Thread_Execute ();
|
||||
Cbuf_Execute_Stack (qwaq_cbuf);
|
||||
SCR_UpdateScreen (con_realtime, bi_3d, bi_2dfuncs);
|
||||
SCR_UpdateScreen (con_realtime, bi_2dfuncs);
|
||||
R_FLOAT (pr) = con_frametime;
|
||||
}
|
||||
|
||||
|
@ -138,12 +131,6 @@ bi_refresh_2d (progs_t *pr)
|
|||
qc2d = P_FUNCTION (pr, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_refresh_3d (progs_t *pr)
|
||||
{
|
||||
qc3d = P_FUNCTION (pr, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_shutdown_ (progs_t *pr)
|
||||
{
|
||||
|
@ -154,7 +141,6 @@ static builtin_t builtins[] = {
|
|||
{"printf", bi_printf, -1},
|
||||
{"refresh", bi_refresh, -1},
|
||||
{"refresh_2d", bi_refresh_2d, -1},
|
||||
{"refresh_3d", bi_refresh_3d, -1},
|
||||
{"shutdown", bi_shutdown_, -1},
|
||||
{0}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue