[renderer] Get timegraph and zgraph working

Only for sw and gl right now, but this sorts out the issues that
prevented the graphs working at all.
This commit is contained in:
Bill Currie 2022-03-15 15:42:43 +09:00
parent 5a57280aa9
commit 91d7a80dff
13 changed files with 58 additions and 39 deletions

View file

@ -108,7 +108,7 @@ typedef struct vid_render_funcs_s {
void (*begin_frame) (void);
void (*render_view) (void);
void (*set_2d) (void);
void (*set_2d) (int scaled);
void (*end_frame) (void);
vid_model_funcs_t *model_funcs;

View file

@ -46,8 +46,12 @@ void SCR_UpdateScreen (struct transform_s *camera, double realtime,
void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y);
struct tex_s *SCR_SnapScreen (unsigned width, unsigned height);
extern struct cvar_s *hud_fps, *hud_time;
extern struct cvar_s *hud_fps, *hud_time, *r_timegraph, *r_zgraph;
extern int scr_copytop;
extern qboolean scr_skipupdate;
struct view_s;
void R_TimeGraph (struct view_s *view);
void R_ZGraph (struct view_s *view);
#endif//__QF_screen_h

View file

@ -281,7 +281,7 @@ extern int r_maxvalidedgeoffset;
void R_AliasClipTriangle (mtriangle_t *ptri);
extern float r_time1;
extern double r_time1;
extern int r_frustum_indexes[4*6];
extern int r_maxsurfsseen, r_maxedgesseen;
extern qboolean r_dowarpold, r_viewchanged;
@ -296,8 +296,6 @@ extern vec3_t lightspot;
void R_StoreEfrags (const efrag_t *ppefrag);
void R_TimeRefresh_f (void);
void R_TimeGraph (void);
void R_ZGraph (void);
void R_PrintAliasStats (void);
void R_PrintTimes (void);
void R_AnimateLight (void);

View file

@ -370,11 +370,6 @@ R_RenderView_ (void)
// render normal view
R_RenderScene ();
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_zgraph->int_val)
R_ZGraph ();
}
static void R_RenderViewFishEye (void);

View file

@ -35,6 +35,8 @@
#include "QF/plugin.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "r_internal.h"
@ -48,26 +50,24 @@ int graphval;
Performance monitoring tool
*/
void
R_TimeGraph (void)
R_TimeGraph (view_t *view)
{
static int timex;
int a;
int l;
//XXX float r_time2;
double r_time2;
static int r_timings[MAX_TIMINGS];
int timings[MAX_TIMINGS];
int x, o;
int o;
//XXX r_time2 = Sys_DoubleTime ();
r_time2 = Sys_DoubleTime ();
a = graphval;
r_timings[timex] = a;
r_timings[timex] = (r_time2 - r_time1) * 10000;
//printf ("%d %g\n", r_timings[timex], r_time2 - r_time1);
l = MAX_TIMINGS;
if (l > r_refdef.vrect.width)
l = r_refdef.vrect.width;
x = r_refdef.vrect.width - l;
o = 0;
a = timex - l;
if (a < 0) {
@ -78,16 +78,16 @@ R_TimeGraph (void)
a = 0;
}
memcpy (timings + o, r_timings + a, l * sizeof (timings[0]));
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, r_timings,
MAX_TIMINGS, vr_data.graphheight->int_val);
vr_funcs->R_LineGraph (view->xabs, view->yabs, r_timings,
MAX_TIMINGS, 200);//vr_data.graphheight->int_val);
timex = (timex + 1) % MAX_TIMINGS;
}
void
R_ZGraph (void)
R_ZGraph (view_t *view)
{
int x, w;
int w;
static int height[256];
if (r_refdef.vrect.width <= 256)
@ -97,7 +97,6 @@ R_ZGraph (void)
height[r_framecount & 255] = ((int) r_refdef.frame.position[2]) & 31;
x = 0;
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height,
vr_funcs->R_LineGraph (view->xabs, view->yabs, height,
w, vr_data.graphheight->int_val);
}

View file

@ -52,7 +52,7 @@ double r_realtime;
double r_frametime;
entity_t *r_view_model;
entity_t *r_player_entity;
float r_time1;
double r_time1;
int r_lineadj;
qboolean r_active;
int r_init;

View file

@ -188,10 +188,11 @@ SCR_UpdateScreen (transform_t *camera, double realtime, SCR_Func *scr_funcs)
r_funcs->begin_frame ();
r_funcs->render_view ();
r_funcs->set_2d();
r_funcs->set_2d (0);
view_draw (r_data->scr_view);
r_funcs->set_2d (1);
while (*scr_funcs) {
(*scr_funcs)();
(*scr_funcs) ();
scr_funcs++;
}
r_funcs->end_frame ();

View file

@ -798,12 +798,6 @@ R_RenderView_ (void)
if (r_dowarp)
D_WarpScreen ();
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_zgraph->int_val)
R_ZGraph ();
if (r_aliasstats->int_val)
R_PrintAliasStats ();

View file

@ -261,9 +261,13 @@ gl_render_view (void)
}
static void
gl_set_2d (void)
gl_set_2d (int scaled)
{
GL_Set2DScaled ();
if (scaled) {
GL_Set2DScaled ();
} else {
GL_Set2D ();
}
}
static void

View file

@ -221,9 +221,13 @@ glsl_render_view (void)
}
static void
glsl_set_2d (void)
glsl_set_2d (int scaled)
{
GLSL_Set2DScaled ();
if (scaled) {
GLSL_Set2DScaled ();
} else {
GLSL_Set2D ();
}
}
static void

View file

@ -145,7 +145,7 @@ sw_render_view (void)
}
static void
sw_set_2d (void)
sw_set_2d (int scaled)
{
}

View file

@ -285,7 +285,7 @@ vulkan_render_view (void)
}
static void
vulkan_set_2d (void)
vulkan_set_2d (int scaled)
{
}

View file

@ -56,6 +56,8 @@
#include "nq/include/client.h"
static view_t *net_view;
static view_t *timegraph_view;
static view_t *zgraph_view;
static view_t *loading_view;
static void
@ -94,6 +96,8 @@ scr_draw_views (void)
net_view->visible = (!cls.demoplayback
&& realtime - cl.last_servermessage >= 0.3);
loading_view->visible = cl.loading;
timegraph_view->visible = r_timegraph->int_val;
zgraph_view->visible = r_zgraph->int_val;
view_draw (r_data->vid->conview);
}
@ -146,6 +150,22 @@ CL_UpdateScreen (double realtime)
view_add (r_data->scr_view, net_view);
}
if (!timegraph_view) {
view_t *parent = r_data->scr_view;
timegraph_view = view_new (0, 0, parent->xlen, 100, grav_southwest);
timegraph_view->draw = R_TimeGraph;
timegraph_view->visible = 0;
view_add (parent, timegraph_view);
}
if (!zgraph_view) {
view_t *parent = r_data->scr_view;
zgraph_view = view_new (0, 0, parent->xlen, 100, grav_southwest);
zgraph_view->draw = R_ZGraph;
zgraph_view->visible = 0;
view_add (parent, zgraph_view);
}
if (!loading_view) {
const char *name = "gfx/loading.lmp";
qpic_t *pic = r_funcs->Draw_CachePic (name, 1);