mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[qw] Clean up netgraph somewhat
The renderer's LineGraph now takes a height parameter, and netgraph now uses cl_* cvars instead of r_* (which never really made sense), including it's own height cvar (the render graphs still use r_graphheight).
This commit is contained in:
parent
c4ee7ff68a
commit
91eeae5186
13 changed files with 161 additions and 59 deletions
|
@ -155,7 +155,7 @@ typedef struct vid_render_funcs_s {
|
|||
void (*R_AddEfrags) (mod_brush_t *brush, entity_t *ent);
|
||||
void (*R_RemoveEfrags) (entity_t *ent);
|
||||
void (*R_EnqueueEntity) (struct entity_s *ent); //FIXME should not be here
|
||||
void (*R_LineGraph) (int x, int y, int *h_vals, int count);
|
||||
void (*R_LineGraph) (int x, int y, int *h_vals, int count, int height);
|
||||
dlight_t *(*R_AllocDlight) (int key);
|
||||
entity_t *(*R_AllocEntity) (void);
|
||||
void (*R_MaxDlightsCheck) (struct cvar_s *var);
|
||||
|
|
|
@ -54,7 +54,7 @@ extern vid_render_funcs_t *vid_render_funcs;
|
|||
extern refdef_t r_refdef;
|
||||
extern int r_viewsize;
|
||||
|
||||
void R_LineGraph (int x, int y, int *h_vals, int count);
|
||||
void R_LineGraph (int x, int y, int *h_vals, int count, int height);
|
||||
|
||||
void Fog_Update (float density, float red, float green, float blue,
|
||||
float time);
|
||||
|
|
|
@ -71,7 +71,7 @@ gl_R_InitGraphTextures (int base)
|
|||
}
|
||||
|
||||
void
|
||||
gl_R_LineGraph (int x, int y, int *h_vals, int count)
|
||||
gl_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
||||
{
|
||||
byte color;
|
||||
byte *dest;
|
||||
|
@ -80,7 +80,7 @@ gl_R_LineGraph (int x, int y, int *h_vals, int count)
|
|||
if (!count)
|
||||
return;
|
||||
|
||||
s = r_graphheight->int_val;
|
||||
s = height;
|
||||
|
||||
size = s * count;
|
||||
if (size > graph_size[graph_index]) {
|
||||
|
|
|
@ -265,7 +265,7 @@ glsl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
}
|
||||
|
||||
void
|
||||
glsl_R_LineGraph (int x, int y, int *h_vals, int count)
|
||||
glsl_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/draw.h"
|
||||
#include "QF/render.h"
|
||||
#include "QF/plugin.h"
|
||||
|
@ -52,8 +54,9 @@ R_TimeGraph (void)
|
|||
int a;
|
||||
int l;
|
||||
//XXX float r_time2;
|
||||
static int r_timings[MAX_TIMINGS];
|
||||
int x;
|
||||
static int r_timings[MAX_TIMINGS];
|
||||
int timings[MAX_TIMINGS];
|
||||
int x, o;
|
||||
|
||||
//XXX r_time2 = Sys_DoubleTime ();
|
||||
|
||||
|
@ -65,15 +68,18 @@ R_TimeGraph (void)
|
|||
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) {
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2,
|
||||
&r_timings[a + MAX_TIMINGS], -a);
|
||||
x -= a;
|
||||
memcpy (timings + o, r_timings + a + MAX_TIMINGS,
|
||||
-a * sizeof (timings[0]));
|
||||
o -= a;
|
||||
l += a;
|
||||
a = 0;
|
||||
}
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l);
|
||||
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);
|
||||
|
||||
timex = (timex + 1) % MAX_TIMINGS;
|
||||
}
|
||||
|
@ -92,5 +98,6 @@ R_ZGraph (void)
|
|||
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
|
||||
|
||||
x = 0;
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height, w);
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height,
|
||||
w, vr_data.graphheight->int_val);
|
||||
}
|
||||
|
|
|
@ -40,13 +40,13 @@
|
|||
Called by only R_DisplayTime
|
||||
*/
|
||||
void
|
||||
R_LineGraph (int x, int y, int *h_vals, int count)
|
||||
R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
||||
{
|
||||
int h, i, s, color;
|
||||
byte *dest;
|
||||
|
||||
// FIXME: disable on no-buffer adapters, or put in the driver
|
||||
s = r_graphheight->int_val;
|
||||
s = height;
|
||||
|
||||
while (count--) {
|
||||
dest = ((byte*)vid.buffer) + vid.rowbytes * y + x++;
|
||||
|
|
|
@ -46,12 +46,12 @@
|
|||
Called by only R_DisplayTime
|
||||
*/
|
||||
void
|
||||
sw32_R_LineGraph (int x, int y, int *h_vals, int count)
|
||||
sw32_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
||||
{
|
||||
int h, i, s, color;
|
||||
|
||||
// FIXME: disable on no-buffer adapters, or put in the driver
|
||||
s = r_graphheight->int_val;
|
||||
s = height;
|
||||
|
||||
while (count--) {
|
||||
h = *h_vals++;
|
||||
|
|
|
@ -236,7 +236,7 @@ vulkan_R_NewMap (model_t *worldmodel, model_t **models, int num_models)
|
|||
}
|
||||
|
||||
static void
|
||||
vulkan_R_LineGraph (int x, int y, int *h_vals, int count)
|
||||
vulkan_R_LineGraph (int x, int y, int *h_vals, int count, int height)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -329,12 +329,6 @@ Vulkan_Draw_UncachePic (const char *path, vulkan_ctx_t *ctx)
|
|||
Hash_Free (dctx->pic_cache, Hash_Del (dctx->pic_cache, path));
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_Draw_TextBox (int x, int y, int width, int lines, byte alpha,
|
||||
vulkan_ctx_t *ctx)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_Draw_Shutdown (vulkan_ctx_t *ctx)
|
||||
{
|
||||
|
@ -587,6 +581,67 @@ Vulkan_Draw_Crosshair (vulkan_ctx_t *ctx)
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_Draw_TextBox (int x, int y, int width, int lines, byte alpha,
|
||||
vulkan_ctx_t *ctx)
|
||||
{
|
||||
drawctx_t *dctx = ctx->draw_context;
|
||||
drawframe_t *frame = &dctx->frames.a[ctx->curFrame];
|
||||
|
||||
quat_t color = {1, 1, 1, 1};
|
||||
qpic_t *p;
|
||||
int cx, cy, n;
|
||||
#define draw(px, py, pp) \
|
||||
draw_pic (px, py, pp->width, pp->height, pp, \
|
||||
0, 0, pp->width, pp->height, color, frame);
|
||||
|
||||
color[3] = alpha;
|
||||
// draw left side
|
||||
cx = x;
|
||||
cy = y;
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_tl.lmp", true, ctx);
|
||||
draw (cx, cy, p);
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_ml.lmp", true, ctx);
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
draw (cx, cy, p);
|
||||
}
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_bl.lmp", true, ctx);
|
||||
draw (cx, cy + 8, p);
|
||||
|
||||
// draw middle
|
||||
cx += 8;
|
||||
while (width > 0) {
|
||||
cy = y;
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_tm.lmp", true, ctx);
|
||||
draw (cx, cy, p);
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_mm.lmp", true, ctx);
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
if (n == 1)
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_mm2.lmp", true, ctx);
|
||||
draw (cx, cy, p);
|
||||
}
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_bm.lmp", true, ctx);
|
||||
draw (cx, cy + 8, p);
|
||||
width -= 2;
|
||||
cx += 16;
|
||||
}
|
||||
|
||||
// draw right side
|
||||
cy = y;
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_tr.lmp", true, ctx);
|
||||
draw (cx, cy, p);
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_mr.lmp", true, ctx);
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
draw (cx, cy, p);
|
||||
}
|
||||
p = Vulkan_Draw_CachePic ("gfx/box_br.lmp", true, ctx);
|
||||
draw (cx, cy + 8, p);
|
||||
#undef draw
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_Draw_Pic (int x, int y, qpic_t *pic, vulkan_ctx_t *ctx)
|
||||
{
|
||||
|
|
|
@ -270,9 +270,11 @@ typedef struct client_state_s {
|
|||
/*
|
||||
cvars
|
||||
*/
|
||||
extern struct cvar_s *r_netgraph;
|
||||
extern struct cvar_s *r_netgraph_alpha;
|
||||
extern struct cvar_s *r_netgraph_box;
|
||||
extern struct cvar_s *cl_netgraph;
|
||||
extern struct cvar_s *cl_netgraph_height;
|
||||
extern struct cvar_s *cl_netgraph_alpha;
|
||||
extern struct cvar_s *cl_netgraph_box;
|
||||
|
||||
extern struct cvar_s *cl_upspeed;
|
||||
extern struct cvar_s *cl_forwardspeed;
|
||||
extern struct cvar_s *cl_backspeed;
|
||||
|
@ -331,8 +333,10 @@ extern struct cbuf_s *cl_stbuf;
|
|||
|
||||
void Cvar_Info (struct cvar_s *var);
|
||||
|
||||
struct view_s;
|
||||
extern struct view_s *cl_netgraph_view;
|
||||
void CL_NetGraph (struct view_s *view);
|
||||
void CL_NetGraph_Init_Cvars (void);
|
||||
|
||||
void CL_UpdateScreen (double realtime);
|
||||
|
||||
void CL_SetState (cactive_t state);
|
||||
|
|
|
@ -1311,19 +1311,12 @@ CL_Init_Cvars (void)
|
|||
CL_Cam_Init_Cvars ();
|
||||
CL_Input_Init_Cvars ();
|
||||
CL_Prediction_Init_Cvars ();
|
||||
CL_NetGraph_Init_Cvars ();
|
||||
Game_Init_Cvars ();
|
||||
Pmove_Init_Cvars ();
|
||||
Team_Init_Cvars ();
|
||||
V_Init_Cvars ();
|
||||
|
||||
r_netgraph = Cvar_Get ("r_netgraph", "0", CVAR_NONE, NULL,
|
||||
"Toggle the display of a graph showing network "
|
||||
"performance");
|
||||
r_netgraph_alpha = Cvar_Get ("r_netgraph_alpha", "0.5", CVAR_ARCHIVE, NULL,
|
||||
"Net graph translucency");
|
||||
r_netgraph_box = Cvar_Get ("r_netgraph_box", "1", CVAR_ARCHIVE, NULL,
|
||||
"Draw box around net graph");
|
||||
|
||||
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
||||
|
||||
cl_model_crcs = Cvar_Get ("cl_model_crcs", "1", CVAR_ARCHIVE, NULL,
|
||||
|
|
|
@ -48,41 +48,85 @@
|
|||
#include "qw/include/client.h"
|
||||
#include "sbar.h"
|
||||
|
||||
cvar_t *r_netgraph;
|
||||
cvar_t *r_netgraph_alpha;
|
||||
cvar_t *r_netgraph_box;
|
||||
cvar_t *cl_netgraph;
|
||||
cvar_t *cl_netgraph_alpha;
|
||||
cvar_t *cl_netgraph_box;
|
||||
cvar_t *cl_netgraph_height;
|
||||
view_t *cl_netgraph_view;
|
||||
|
||||
static void
|
||||
cl_netgraph_f (cvar_t *var)
|
||||
{
|
||||
if (cl_netgraph_view) {
|
||||
cl_netgraph_view->visible = var->int_val != 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cl_netgraph_height_f (cvar_t *var)
|
||||
{
|
||||
if (var->int_val < 32) {
|
||||
Cvar_Set (var, "32");
|
||||
}
|
||||
if (cl_netgraph_view) {
|
||||
view_resize (cl_netgraph_view, cl_netgraph_view->xlen,
|
||||
var->int_val + 25);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CL_NetGraph (view_t *view)
|
||||
{
|
||||
int lost, a, l, x, y, i;
|
||||
int lost, a, l, x, y, i, o;
|
||||
int timings[NET_TIMINGS];
|
||||
|
||||
x = view->xabs;
|
||||
y = view->yabs;
|
||||
|
||||
if (r_netgraph_box->int_val)
|
||||
if (cl_netgraph_box->int_val) {
|
||||
r_funcs->Draw_TextBox (x, y, NET_TIMINGS / 8,
|
||||
r_data->graphheight->int_val / 8 + 1,
|
||||
r_netgraph_alpha->value * 255);
|
||||
cl_netgraph_height->int_val / 8 + 1,
|
||||
cl_netgraph_alpha->value * 255);
|
||||
}
|
||||
|
||||
lost = CL_CalcNet ();
|
||||
x = view->xabs + 8;
|
||||
y = view->yabs + view->ylen - 9;
|
||||
|
||||
l = NET_TIMINGS;
|
||||
if (l > r_data->refdef->vrect.width - 8)
|
||||
l = r_data->refdef->vrect.width - 8;
|
||||
if (l > view->xlen - 8)
|
||||
l = view->xlen - 8;
|
||||
i = cls.netchan.outgoing_sequence & NET_TIMINGSMASK;
|
||||
a = i - l;
|
||||
o = 0;
|
||||
if (a < 0) {
|
||||
r_funcs->R_LineGraph (x, y, &packet_latency[a + NET_TIMINGS], -a);
|
||||
x -= a;
|
||||
memcpy (timings + o, packet_latency + a + NET_TIMINGS,
|
||||
-a * sizeof (timings[0]));
|
||||
o -= a;
|
||||
l += a;
|
||||
a = 0;
|
||||
}
|
||||
r_funcs->R_LineGraph (x, y, &packet_latency[a], l);
|
||||
memcpy (timings + o, packet_latency + a, l * sizeof (timings[0]));
|
||||
r_funcs->R_LineGraph (x, y, timings,
|
||||
NET_TIMINGS, cl_netgraph_height->int_val);
|
||||
|
||||
x = view->xabs + 8;
|
||||
y = view->yabs + 8;
|
||||
r_funcs->Draw_String (x, y, va (0, "%3i%% packet loss", lost));
|
||||
}
|
||||
|
||||
void
|
||||
CL_NetGraph_Init_Cvars (void)
|
||||
{
|
||||
cl_netgraph = Cvar_Get ("cl_netgraph", "0", CVAR_NONE, cl_netgraph_f,
|
||||
"Toggle the display of a graph showing network "
|
||||
"performance");
|
||||
cl_netgraph_alpha = Cvar_Get ("cl_netgraph_alpha", "0.5", CVAR_ARCHIVE, 0,
|
||||
"Net graph translucency");
|
||||
cl_netgraph_box = Cvar_Get ("cl_netgraph_box", "1", CVAR_ARCHIVE, 0,
|
||||
" Draw box around net graph");
|
||||
cl_netgraph_height = Cvar_Get ("cl_netgraph_height", "32", CVAR_ARCHIVE,
|
||||
cl_netgraph_height_f,
|
||||
"Set the fullscale (1s) height of the "
|
||||
"graph");
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
|
||||
static view_t *net_view;
|
||||
static view_t *loading_view;
|
||||
static view_t *graph_view;
|
||||
|
||||
static void
|
||||
draw_pic (view_t *view)
|
||||
|
@ -94,11 +93,11 @@ scr_draw_views (void)
|
|||
- cls.netchan.incoming_acknowledged)
|
||||
>= UPDATE_BACKUP - 1);
|
||||
loading_view->visible = cl.loading;
|
||||
graph_view->visible = r_netgraph->int_val != 0;
|
||||
cl_netgraph_view->visible = cl_netgraph->int_val != 0;
|
||||
|
||||
//FIXME don't do every frame
|
||||
view_move (graph_view, graph_view->xpos, sb_lines);
|
||||
view_setgravity (graph_view,
|
||||
view_move (cl_netgraph_view, cl_netgraph_view->xpos, sb_lines);
|
||||
view_setgravity (cl_netgraph_view,
|
||||
hud_swap->int_val ? grav_southeast : grav_southwest);
|
||||
|
||||
view_draw (r_data->vid->conview);
|
||||
|
@ -165,14 +164,14 @@ CL_UpdateScreen (double realtime)
|
|||
view_add (r_data->vid->conview, loading_view);
|
||||
}
|
||||
|
||||
if (!graph_view) {
|
||||
graph_view = view_new (0, -24,
|
||||
NET_TIMINGS + 16,
|
||||
r_data->graphheight->int_val + 25,
|
||||
grav_southwest);
|
||||
graph_view->draw = CL_NetGraph;
|
||||
graph_view->visible = 0;
|
||||
view_add (r_data->vid->conview, graph_view);
|
||||
if (!cl_netgraph_view) {
|
||||
cl_netgraph_view = view_new (0, sb_lines,
|
||||
NET_TIMINGS + 16,
|
||||
cl_netgraph_height->int_val + 25,
|
||||
grav_southwest);
|
||||
cl_netgraph_view->draw = CL_NetGraph;
|
||||
cl_netgraph_view->visible = 0;
|
||||
view_add (r_data->vid->conview, cl_netgraph_view);
|
||||
}
|
||||
|
||||
//FIXME not every time
|
||||
|
|
Loading…
Reference in a new issue