Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

vkQuake optimizations & server/client rate independence #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions quakespasm/Quake/cl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ void CL_BaseMove (usercmd_t *cmd)
if (cls.signon != SIGNONS)
return;

CL_AdjustAngles ();

Q_memset (cmd, 0, sizeof(*cmd));

if (in_strafe.state & 1)
Expand Down Expand Up @@ -348,44 +346,47 @@ void CL_SendMove (const usercmd_t *cmd)
buf.cursize = 0;
buf.data = data;

cl.cmd = *cmd;
if (cmd)
{
cl.cmd = *cmd;

//
// send the movement message
//
MSG_WriteByte (&buf, clc_move);
//
// send the movement message
//
MSG_WriteByte (&buf, clc_move);

MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times

for (i=0 ; i<3 ; i++)
//johnfitz -- 16-bit angles for PROTOCOL_FITZQUAKE
if (cl.protocol == PROTOCOL_NETQUAKE)
MSG_WriteAngle (&buf, cl.viewangles[i], cl.protocolflags);
else
MSG_WriteAngle16 (&buf, cl.viewangles[i], cl.protocolflags);
//johnfitz
for (i=0 ; i<3 ; i++)
//johnfitz -- 16-bit angles for PROTOCOL_FITZQUAKE
if (cl.protocol == PROTOCOL_NETQUAKE)
MSG_WriteAngle (&buf, cl.viewangles[i], cl.protocolflags);
else
MSG_WriteAngle16 (&buf, cl.viewangles[i], cl.protocolflags);
//johnfitz

MSG_WriteShort (&buf, cmd->forwardmove);
MSG_WriteShort (&buf, cmd->sidemove);
MSG_WriteShort (&buf, cmd->upmove);
MSG_WriteShort (&buf, cmd->forwardmove);
MSG_WriteShort (&buf, cmd->sidemove);
MSG_WriteShort (&buf, cmd->upmove);

//
// send button bits
//
bits = 0;
//
// send button bits
//
bits = 0;

if ( in_attack.state & 3 )
bits |= 1;
in_attack.state &= ~2;
if ( in_attack.state & 3 )
bits |= 1;
in_attack.state &= ~2;

if (in_jump.state & 3)
bits |= 2;
in_jump.state &= ~2;
if (in_jump.state & 3)
bits |= 2;
in_jump.state &= ~2;

MSG_WriteByte (&buf, bits);
MSG_WriteByte (&buf, bits);

MSG_WriteByte (&buf, in_impulse);
in_impulse = 0;
MSG_WriteByte (&buf, in_impulse);
in_impulse = 0;
}

//
// deliver the message
Expand Down
29 changes: 27 additions & 2 deletions quakespasm/Quake/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ int cl_numvisedicts;
entity_t *cl_visedicts[MAX_VISEDICTS];

extern cvar_t r_lerpmodels, r_lerpmove; //johnfitz
extern float host_netinterval; //Spike

/*
=====================
Expand Down Expand Up @@ -363,7 +364,7 @@ float CL_LerpPoint (void)

f = cl.mtime[0] - cl.mtime[1];

if (!f || cls.timedemo || sv.active)
if (!f || cls.timedemo || (sv.active && !host_netinterval))
{
cl.time = cl.mtime[0];
return 1;
Expand Down Expand Up @@ -663,6 +664,25 @@ int CL_ReadFromServer (void)
return 0;
}

/*
=================
CL_UpdateViewAngles

Spike: split from CL_SendCmd, to do clientside viewangle changes separately from outgoing packets.
=================
*/
void CL_AccumulateCmd (void)
{
if (cls.signon == SIGNONS)
{
//basic keyboard looking
CL_AdjustAngles ();

//accumulate movement from other devices
IN_Move (&cl.pendingcmd);
}
}

/*
=================
CL_SendCmd
Expand All @@ -681,11 +701,16 @@ void CL_SendCmd (void)
CL_BaseMove (&cmd);

// allow mice or other external controllers to add to the move
IN_Move (&cmd);
cmd.forwardmove += cl.pendingcmd.forwardmove;
cmd.sidemove += cl.pendingcmd.sidemove;
cmd.upmove += cl.pendingcmd.upmove;

// send the unreliable message
CL_SendMove (&cmd);
}
else
CL_SendMove (NULL);
memset(&cl.pendingcmd, 0, sizeof(cl.pendingcmd));

if (cls.demoplayback)
{
Expand Down
1 change: 1 addition & 0 deletions quakespasm/Quake/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2007-2008 Kristian Duske
Copyright (C) 2010-2014 QuakeSpasm developers
Copyright (C) 2016 Spike

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down
3 changes: 3 additions & 0 deletions quakespasm/Quake/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ typedef struct
// doesn't accidentally do something the
// first frame
usercmd_t cmd; // last command sent to the server
usercmd_t pendingcmd; // accumulated state from mice+joysticks.

// information for local display
int stats[MAX_CL_STATS]; // health, etc
Expand Down Expand Up @@ -317,9 +318,11 @@ extern kbutton_t in_strafe;
extern kbutton_t in_speed;

void CL_InitInput (void);
void CL_AccumulateCmd (void);
void CL_SendCmd (void);
void CL_SendMove (const usercmd_t *cmd);
int CL_ReadFromServer (void);
void CL_AdjustAngles (void);
void CL_BaseMove (usercmd_t *cmd);

void CL_ParseTEnt (void);
Expand Down
17 changes: 9 additions & 8 deletions quakespasm/Quake/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,17 @@ void Cbuf_InsertText (const char *text)
}
}

//Spike: for renderer/server isolation
void Cbuf_Waited(void)
{
cmd_wait = false;
}

/*
============
Cbuf_Execute

Spike: reworked 'wait' for renderer/server rate independance
============
*/
void Cbuf_Execute (void)
Expand All @@ -149,7 +157,7 @@ void Cbuf_Execute (void)
char line[1024];
int quotes;

while (cmd_text.cursize)
while (cmd_text.cursize && !cmd_wait)
{
// find a \n or ; line break
text = (char *)cmd_text.data;
Expand Down Expand Up @@ -191,13 +199,6 @@ void Cbuf_Execute (void)

// execute the command line
Cmd_ExecuteString (line, src_command);

if (cmd_wait)
{ // skip out while text still remains in buffer, leaving it
// for next frame
cmd_wait = false;
break;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions quakespasm/Quake/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ void Cbuf_Execute (void);
// Normally called once per frame, but may be explicitly invoked.
// Do not call inside a command function!

void Cbuf_Waited (void);
//In vanilla, the 'wait' command is used by both input configs and servers.
//mods do hacky stuff like syncing waits to StartFrame calls.
//thankfully, c2s packets and server logic can both happen at the same intervals.
//so wait sets a flag to inhibit execution of more commands, and we only clear it once we've run a network frame.
//so this function lets the cbuf know when to clear the flag again (instead of part of cbuf_execute).

//===========================================================================

/*
Expand Down
18 changes: 0 additions & 18 deletions quakespasm/Quake/gl_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ void Mod_LoadTexinfo (lump_t *l)
texinfo_t *in;
mtexinfo_t *out;
int i, j, count, miptex;
float len1, len2;
int missing = 0; //johnfitz

in = (texinfo_t *)(mod_base + l->fileofs);
Expand All @@ -943,23 +942,6 @@ void Mod_LoadTexinfo (lump_t *l)
out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
out->vecs[1][j] = LittleFloat (in->vecs[1][j]);
}
len1 = VectorLength (out->vecs[0]);
len2 = VectorLength (out->vecs[1]);
len1 = (len1 + len2)/2;
if (len1 < 0.32)
out->mipadjust = 4;
else if (len1 < 0.49)
out->mipadjust = 3;
else if (len1 < 0.99)
out->mipadjust = 2;
else
out->mipadjust = 1;
#if 0
if (len1 + len2 < 0.001)
out->mipadjust = 1; // don't crash
else
out->mipadjust = 1 / floor((len1+len2)/2 + 0.1);
#endif

miptex = LittleLong (in->miptex);
out->flags = LittleLong (in->flags);
Expand Down
2 changes: 0 additions & 2 deletions quakespasm/Quake/gl_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ typedef struct
typedef struct
{
float vecs[2][4];
float mipadjust;
texture_t *texture;
int flags;
} mtexinfo_t;
Expand All @@ -141,7 +140,6 @@ typedef struct glpoly_s
typedef struct msurface_s
{
int visframe; // should be drawn when node is crossed
qboolean culled; // johnfitz -- for frustum culling
float mins[3]; // johnfitz -- for frustum culling
float maxs[3]; // johnfitz -- for frustum culling

Expand Down
47 changes: 9 additions & 38 deletions quakespasm/Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,48 +272,21 @@ qboolean R_CullBox (vec3_t emins, vec3_t emaxs)
{
int i;
mplane_t *p;
byte signbits;
float vec[3];
for (i = 0;i < 4;i++)
{
p = frustum + i;
switch(p->signbits)
{
default:
case 0:
if (p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2] < p->dist)
return true;
break;
case 1:
if (p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2] < p->dist)
return true;
break;
case 2:
if (p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2] < p->dist)
return true;
break;
case 3:
if (p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2] < p->dist)
return true;
break;
case 4:
if (p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2] < p->dist)
return true;
break;
case 5:
if (p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2] < p->dist)
return true;
break;
case 6:
if (p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2] < p->dist)
return true;
break;
case 7:
if (p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2] < p->dist)
return true;
break;
}
signbits = p->signbits;
vec[0] = ((signbits % 2)<1) ? emaxs[0] : emins[0];
vec[1] = ((signbits % 4)<2) ? emaxs[1] : emins[1];
vec[2] = ((signbits % 8)<4) ? emaxs[2] : emins[2];
if (p->normal[0]*vec[0] + p->normal[1]*vec[1] + p->normal[2]*vec[2] < p->dist)
return true;
}
return false;
}

/*
===============
R_CullModelForEntity -- johnfitz -- uses correct bounds based on rotation
Expand Down Expand Up @@ -585,8 +558,6 @@ void R_SetupView (void)

R_MarkSurfaces (); //johnfitz -- create texture chains from PVS

R_CullSurfaces (); //johnfitz -- do after R_SetFrustum and R_MarkSurfaces

R_UpdateWarpTextures (); //johnfitz -- do this before R_Clear

R_Clear ();
Expand Down
13 changes: 0 additions & 13 deletions quakespasm/Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ static void R_SetClearColor_f (cvar_t *var)
glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0);
}

/*
====================
R_Novis_f -- johnfitz
====================
*/
static void R_VisChanged (cvar_t *var)
{
extern int vis_changed;
vis_changed = 1;
}

/*
===============
R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow_list cvar changes
Expand Down Expand Up @@ -189,7 +178,6 @@ void R_Init (void)
Cvar_SetCallback (&r_wateralpha, R_SetWateralpha_f);
Cvar_RegisterVariable (&r_dynamic);
Cvar_RegisterVariable (&r_novis);
Cvar_SetCallback (&r_novis, R_VisChanged);
Cvar_RegisterVariable (&r_speeds);
Cvar_RegisterVariable (&r_pos);

Expand All @@ -214,7 +202,6 @@ void R_Init (void)
Cvar_RegisterVariable (&r_drawflat);
Cvar_RegisterVariable (&r_flatlightstyles);
Cvar_RegisterVariable (&r_oldskyleaf);
Cvar_SetCallback (&r_oldskyleaf, R_VisChanged);
Cvar_RegisterVariable (&r_drawworld);
Cvar_RegisterVariable (&r_showtris);
Cvar_RegisterVariable (&r_showbboxes);
Expand Down
3 changes: 1 addition & 2 deletions quakespasm/Quake/gl_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,7 @@ void Sky_ProcessTextureChains (void)
continue;

for (s = t->texturechains[chain_world]; s; s = s->texturechain)
if (!s->culled)
Sky_ProcessPoly (s->polys);
Sky_ProcessPoly (s->polys);
}
}

Expand Down
1 change: 0 additions & 1 deletion quakespasm/Quake/glquake.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ void R_NewGame (void);

void R_AnimateLight (void);
void R_MarkSurfaces (void);
void R_CullSurfaces (void);
qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
void R_StoreEfrags (efrag_t **ppefrag);
qboolean R_CullModelForEntity (entity_t *e);
Expand Down
Loading