forked from len0rd/rockbox
quake: merge some fixed-point optimizations from PocketQuake
The PocketQuake project, available below, has some nice fixed-point code: https://web.archive.org/web/20150412233306/http://quake.pocketmatrix.com/PocketQuake0062_src.zip I'd like to see most of them merged into our Quake port. This commit gives +0.9FPS on ipod6g. (A big change given that it was running at only 9.7FPS to begin with!) Change-Id: I91931bdd5c22f14fb28616de938a03b4e7d7b076
This commit is contained in:
parent
3fffabf50d
commit
ee70dad305
10 changed files with 866 additions and 6 deletions
|
@ -27,6 +27,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
qboolean insubmodel;
|
||||
entity_t *currententity;
|
||||
|
||||
#ifdef USE_PQ_OPT1
|
||||
int modelorg_fxp[3];
|
||||
#endif
|
||||
|
||||
vec3_t modelorg, base_modelorg;
|
||||
// modelorg is the viewpoint reletive to
|
||||
// the currently rendering entity
|
||||
|
@ -440,6 +445,10 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_PQ_OPT1
|
||||
int clipplanes_fxp[4][3];
|
||||
int clipdist_fxp[4];
|
||||
#endif
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -449,11 +458,16 @@ R_RecursiveWorldNode
|
|||
void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
||||
{
|
||||
int i, c, side, *pindex;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
mplane_t *plane;
|
||||
msurface_t *surf, **mark;
|
||||
mleaf_t *pleaf;
|
||||
double d, dot;
|
||||
double dot;
|
||||
#ifdef USE_PQ_OPT1
|
||||
int d_fxp;
|
||||
#else
|
||||
double d;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
#endif
|
||||
|
||||
if (node->contents == CONTENTS_SOLID)
|
||||
return; // solid
|
||||
|
@ -477,16 +491,29 @@ void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
|
||||
pindex = pfrustum_indexes[i];
|
||||
|
||||
#ifdef USE_PQ_OPT1
|
||||
d_fxp=node->minmaxs[pindex[0]]*clipplanes_fxp[i][0]+node->minmaxs[pindex[1]]*clipplanes_fxp[i][1]+node->minmaxs[pindex[2]]*clipplanes_fxp[i][2];
|
||||
d_fxp-=clipdist_fxp[i];
|
||||
|
||||
if (d_fxp <= 0)
|
||||
return;
|
||||
|
||||
d_fxp=node->minmaxs[pindex[3]]*clipplanes_fxp[i][0]+node->minmaxs[pindex[4]]*clipplanes_fxp[i][1]+node->minmaxs[pindex[5]]*clipplanes_fxp[i][2];
|
||||
d_fxp-=clipdist_fxp[i];
|
||||
|
||||
if (d_fxp >= 0)
|
||||
clipflags &= ~(1<<i); // node is entirely on screen
|
||||
#else
|
||||
rejectpt[0] = (float)node->minmaxs[pindex[0]];
|
||||
rejectpt[1] = (float)node->minmaxs[pindex[1]];
|
||||
rejectpt[2] = (float)node->minmaxs[pindex[2]];
|
||||
|
||||
|
||||
d = DotProduct (rejectpt, view_clipplanes[i].normal);
|
||||
d -= view_clipplanes[i].dist;
|
||||
|
||||
if (d <= 0)
|
||||
if (d <= 0)
|
||||
return;
|
||||
|
||||
|
||||
acceptpt[0] = (float)node->minmaxs[pindex[3+0]];
|
||||
acceptpt[1] = (float)node->minmaxs[pindex[3+1]];
|
||||
acceptpt[2] = (float)node->minmaxs[pindex[3+2]];
|
||||
|
@ -496,6 +523,7 @@ void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
|
||||
if (d >= 0)
|
||||
clipflags &= ~(1<<i); // node is entirely on screen
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,10 +684,79 @@ void R_RenderWorld (void)
|
|||
|
||||
currententity = &cl_entities[0];
|
||||
VectorCopy (r_origin, modelorg);
|
||||
|
||||
#ifdef USE_PQ_OPT1
|
||||
modelorg_fxp[0]=(int)(r_origin[0]*524288.0);
|
||||
modelorg_fxp[1]=(int)(r_origin[1]*524288.0);
|
||||
modelorg_fxp[2]=(int)(r_origin[2]*524288.0);
|
||||
|
||||
//modelorg_fxp[0]=(int)(r_origin[0]*65536.0);
|
||||
//modelorg_fxp[1]=(int)(r_origin[1]*65536.0);
|
||||
//modelorg_fxp[2]=(int)(r_origin[2]*65536.0);
|
||||
|
||||
vright_fxp[0]=(int)(256.0/vright[0]);
|
||||
if (!vright_fxp[0]) vright_fxp[0]=0x7fffffff;
|
||||
vright_fxp[1]=(int)(256.0/vright[1]);
|
||||
if (!vright_fxp[1]) vright_fxp[1]=0x7fffffff;
|
||||
vright_fxp[2]=(int)(256.0/vright[2]);
|
||||
if (!vright_fxp[2]) vright_fxp[2]=0x7fffffff;
|
||||
|
||||
vpn_fxp[0]=(int)(256.0/vpn[0]);
|
||||
if (!vpn_fxp[0]) vpn_fxp[0]=0x7fffffff;
|
||||
vpn_fxp[1]=(int)(256.0/vpn[1]);
|
||||
if (!vpn_fxp[1]) vpn_fxp[1]=0x7fffffff;
|
||||
vpn_fxp[2]=(int)(256.0/vpn[2]);
|
||||
if (!vpn_fxp[2]) vpn_fxp[2]=0x7fffffff;
|
||||
|
||||
vup_fxp[0]=(int)(256.0/vup[0]);
|
||||
if (!vup_fxp[0]) vup_fxp[0]=0x7fffffff;
|
||||
vup_fxp[1]=(int)(256.0/vup[1]);
|
||||
if (!vup_fxp[1]) vup_fxp[1]=0x7fffffff;
|
||||
vup_fxp[2]=(int)(256.0/vup[2]);
|
||||
if (!vup_fxp[2]) vup_fxp[2]=0x7fffffff;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
clmodel = currententity->model;
|
||||
r_pcurrentvertbase = clmodel->vertexes;
|
||||
|
||||
R_RecursiveWorldNode (clmodel->nodes, 15);
|
||||
#ifdef USE_PQ_OPT2
|
||||
r_pcurrentvertbase_fxp = clmodel->vertexes_fxp;
|
||||
#endif
|
||||
#ifdef USE_PQ_OPT1
|
||||
//Dan Fixed point conversion stuff
|
||||
for (i=0; i<4; i++) {
|
||||
clipplanes_fxp[i][0]=(int)(view_clipplanes[i].normal[0]*65536.0);
|
||||
clipplanes_fxp[i][1]=(int)(view_clipplanes[i].normal[1]*65536.0);
|
||||
clipplanes_fxp[i][2]=(int)(view_clipplanes[i].normal[2]*65536.0);
|
||||
clipdist_fxp[i] =(int)(view_clipplanes[i].dist*65536.0);
|
||||
#ifdef USE_PQ_OPT2
|
||||
view_clipplanes_fxp[i].leftedge=view_clipplanes[i].leftedge;
|
||||
view_clipplanes_fxp[i].rightedge=view_clipplanes[i].rightedge;
|
||||
if (!view_clipplanes[i].normal[0]) view_clipplanes_fxp[i].normal[0]=2<<29;
|
||||
else view_clipplanes_fxp[i].normal[0]=(int)(4096.0f/view_clipplanes[i].normal[0]);
|
||||
if (!view_clipplanes[i].normal[0]) view_clipplanes_fxp[i].normal[0]=2<<29;
|
||||
|
||||
if (!view_clipplanes[i].normal[1]) view_clipplanes_fxp[i].normal[1]=2<<29;
|
||||
else view_clipplanes_fxp[i].normal[1]=(int)(4096.0f/view_clipplanes[i].normal[1]);
|
||||
if (!view_clipplanes[i].normal[1]) view_clipplanes_fxp[i].normal[1]=2<<29;
|
||||
|
||||
if (!view_clipplanes[i].normal[2]) view_clipplanes_fxp[i].normal[2]=2<<29;
|
||||
else view_clipplanes_fxp[i].normal[2]=(int)(4096.0f/view_clipplanes[i].normal[2]);
|
||||
if (!view_clipplanes[i].normal[2]) view_clipplanes_fxp[i].normal[2]=2<<29;
|
||||
|
||||
view_clipplanes_fxp[i].dist=(int)(view_clipplanes[i].dist*128.0f);
|
||||
#endif
|
||||
#if defined(_X86_)&&defined(DEBUG)
|
||||
LogFloat(view_clipplanes[i].normal[0], "view_clipplanes[i].normal[0]", i, -1);
|
||||
LogFloat(view_clipplanes[i].normal[1], "view_clipplanes[i].normal[1]", i, -1);
|
||||
LogFloat(view_clipplanes[i].normal[2], "view_clipplanes[i].normal[2]", i, -1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
R_RecursiveWorldNode (clmodel->nodes, 15);
|
||||
|
||||
// if the driver wants the polygons back to front, play the visible ones back
|
||||
// in that order
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue