mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
[model] Make firstmarksurface an int instead of pointer
While it takes one extra step to grab the marksurface pointer, R_MarkLeaves and R_MarkLights (the two actual users) seem to be either the same speed or fractionally faster (by a few microseconds). I imagine the loss gone to the extra fetch is made up for by better bandwidth while traversing the leafs array (mleaf_t now fits in a single cache line, so leafs are cache-aligned since hunk allocations are aligned).
This commit is contained in:
parent
8ce463cbed
commit
0f7e6734f7
4 changed files with 17 additions and 9 deletions
|
@ -199,7 +199,7 @@ typedef struct mleaf_s {
|
|||
byte *compressed_vis;
|
||||
efrag_t *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
int key; // BSP sequence number for leaf's contents
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
|
|
@ -683,8 +683,9 @@ Mod_SetLeafFlags (mod_brush_t *brush)
|
|||
for (unsigned i = 0; i < brush->modleafs; i++) {
|
||||
int flags = 0;
|
||||
mleaf_t *leaf = &brush->leafs[i];
|
||||
msurface_t **msurf = brush->marksurfaces + leaf->firstmarksurface;
|
||||
for (int j = 0; j < leaf->nummarksurfaces; j++) {
|
||||
msurface_t *surf = leaf->firstmarksurface[j];
|
||||
msurface_t *surf = *msurf++;
|
||||
flags |= surf->flags;
|
||||
}
|
||||
brush->leaf_flags[i] = flags;
|
||||
|
@ -780,7 +781,7 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp)
|
|||
p = in->contents;
|
||||
out->contents = p;
|
||||
|
||||
out->firstmarksurface = brush->marksurfaces + in->firstmarksurface;
|
||||
out->firstmarksurface = in->firstmarksurface;
|
||||
out->nummarksurfaces = in->nummarksurfaces;
|
||||
|
||||
p = in->visofs;
|
||||
|
@ -795,12 +796,18 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp)
|
|||
|
||||
// gl underwater warp
|
||||
if (out->contents != CONTENTS_EMPTY) {
|
||||
for (j = 0; j < out->nummarksurfaces; j++)
|
||||
out->firstmarksurface[j]->flags |= SURF_UNDERWATER;
|
||||
msurface_t **msurf = brush->marksurfaces + out->firstmarksurface;
|
||||
for (j = 0; j < out->nummarksurfaces; j++) {
|
||||
msurface_t *surf = *msurf++;
|
||||
surf->flags |= SURF_UNDERWATER;
|
||||
}
|
||||
}
|
||||
if (isnotmap) {
|
||||
for (j = 0; j < out->nummarksurfaces; j++)
|
||||
out->firstmarksurface[j]->flags |= SURF_DONTWARP;
|
||||
msurface_t **msurf = brush->marksurfaces + out->firstmarksurface;
|
||||
for (j = 0; j < out->nummarksurfaces; j++) {
|
||||
msurface_t *surf = *msurf++;
|
||||
surf->flags |= SURF_DONTWARP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ R_MarkLeaves (mleaf_t *viewleaf)
|
|||
if (set_is_member (vis, i)) {
|
||||
leaf = &brush->leafs[i + 1];
|
||||
if ((c = leaf->nummarksurfaces)) {
|
||||
mark = leaf->firstmarksurface;
|
||||
mark = brush->marksurfaces + leaf->firstmarksurface;
|
||||
do {
|
||||
(*mark)->visframe = r_visframecount;
|
||||
mark++;
|
||||
|
|
|
@ -304,8 +304,9 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
|
|||
continue;
|
||||
if (R_CullBox (r_refdef.frustum, leaf->mins, leaf->maxs))
|
||||
continue;
|
||||
msurface_t **msurf = brush->marksurfaces + leaf->firstmarksurface;
|
||||
for (m = 0; m < leaf->nummarksurfaces; m++) {
|
||||
msurface_t *surf = leaf->firstmarksurface[m];
|
||||
msurface_t *surf = *msurf++;
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
mark_surfaces (surf, lightorigin, light, lightnum);
|
||||
|
|
Loading…
Reference in a new issue