Call R_SetFrustum in all renderers.

It turns out glsl, sw and sw32 weren't getting any benefit from R_CullBox
because the frustum wasn't setup :P. Get another 8% out of bigass1
(174->184fps). bigass1 now runs 2x as fast as it did before I started this
optimisation run :)
This commit is contained in:
Bill Currie 2012-07-03 15:57:33 +09:00
parent e58cd75660
commit a8e0bcabf9
7 changed files with 47 additions and 42 deletions

View file

@ -139,6 +139,7 @@ extern vec3_t r_worldmodelorg;
extern mat4_t glsl_projection;
extern mat4_t glsl_view;
void R_SetFrustum (void);
void R_SpriteBegin (void);
void R_SpriteEnd (void);

View file

@ -332,46 +332,6 @@ R_DrawViewModel (void)
qfglDepthRange (gldepthmin, gldepthmax);
}
static inline int
SignbitsForPlane (plane_t *out)
{
int bits, j;
// for fast box on planeside test
bits = 0;
for (j = 0; j < 3; j++) {
if (out->normal[j] < 0)
bits |= 1 << j;
}
return bits;
}
static void
R_SetFrustum (void)
{
int i;
// rotate VPN right by FOV_X/2 degrees
RotatePointAroundVector (frustum[0].normal, vup, vpn,
-(90 - r_refdef.fov_x / 2));
// rotate VPN left by FOV_X/2 degrees
RotatePointAroundVector (frustum[1].normal, vup, vpn,
90 - r_refdef.fov_x / 2);
// rotate VPN up by FOV_Y/2 degrees
RotatePointAroundVector (frustum[2].normal, vright, vpn,
90 - r_refdef.fov_y / 2);
// rotate VPN down by FOV_Y/2 degrees
RotatePointAroundVector (frustum[3].normal, vright, vpn,
-(90 - r_refdef.fov_y / 2));
for (i = 0; i < 4; i++) {
frustum[i].type = PLANE_ANYZ;
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
}
}
void
gl_R_SetupFrame (void)
{

View file

@ -145,10 +145,11 @@ calc_lighting (entity_t *ent, float *ambient, float *shadelight,
unsigned i;
float add;
vec3_t dist;
int light;
VectorSet ( -1, 0, 0, lightvec); //FIXME
*ambient = max (R_LightPoint (ent->origin), max (ent->model->min_light,
ent->min_light) * 128);
light = R_LightPoint (ent->origin);
*ambient = max (light, max (ent->model->min_light, ent->min_light) * 128);
*shadelight = *ambient;
for (i = 0; i < r_maxdlights; i++) {

View file

@ -108,6 +108,7 @@ glsl_R_SetupFrame (void)
VectorCopy (r_refdef.vieworg, r_origin);
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
R_SetFrustum ();
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model);
}

View file

@ -85,3 +85,43 @@ int d_lightstylevalue[256]; // 8.8 fraction of base light value
byte color_white[4] = { 255, 255, 255, 0 }; // alpha will be explicitly set
byte color_black[4] = { 0, 0, 0, 0 }; // alpha will be explicitly set
static inline int
SignbitsForPlane (plane_t *out)
{
int bits, j;
// for fast box on planeside test
bits = 0;
for (j = 0; j < 3; j++) {
if (out->normal[j] < 0)
bits |= 1 << j;
}
return bits;
}
void
R_SetFrustum (void)
{
int i;
// rotate VPN right by FOV_X/2 degrees
RotatePointAroundVector (frustum[0].normal, vup, vpn,
-(90 - r_refdef.fov_x / 2));
// rotate VPN left by FOV_X/2 degrees
RotatePointAroundVector (frustum[1].normal, vup, vpn,
90 - r_refdef.fov_x / 2);
// rotate VPN up by FOV_Y/2 degrees
RotatePointAroundVector (frustum[2].normal, vright, vpn,
90 - r_refdef.fov_y / 2);
// rotate VPN down by FOV_Y/2 degrees
RotatePointAroundVector (frustum[3].normal, vright, vpn,
-(90 - r_refdef.fov_y / 2));
for (i = 0; i < 4; i++) {
frustum[i].type = PLANE_ANYZ;
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
}
}

View file

@ -240,6 +240,7 @@ R_SetupFrame (void)
VectorCopy (r_refdef.vieworg, r_origin);
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
R_SetFrustum ();
// current viewleaf
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model);

View file

@ -237,6 +237,7 @@ sw32_R_SetupFrame (void)
VectorCopy (r_refdef.vieworg, r_origin);
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
R_SetFrustum ();
// current viewleaf
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model);