mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 01:41:10 +00:00
[model] Move parent pointer out of leaf/node struct
The node struct was 72 bytes thus two cache line. Moving the pointer into the brush model data block allows nodes to fit in a single cache line (not that they're aligned yet, but that's next). It doesn't seem to have made any difference to performance (at least in the vulkan renderer), but it hasn't hurt, either, as the only place that needed the parent pointer was R_MarkLeaves.
This commit is contained in:
parent
ebb73e19b2
commit
bc7858bb87
3 changed files with 23 additions and 17 deletions
|
@ -179,8 +179,6 @@ typedef struct mnode_s {
|
|||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
|
||||
// node specific
|
||||
plane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
|
@ -198,8 +196,6 @@ typedef struct mleaf_s {
|
|||
float mins[3];
|
||||
float maxs[3];
|
||||
|
||||
struct mnode_s *parent;
|
||||
|
||||
// leaf specific
|
||||
byte *compressed_vis;
|
||||
efrag_t *efrags;
|
||||
|
@ -274,6 +270,9 @@ typedef struct mod_brush_s {
|
|||
byte *lightdata;
|
||||
char *entities; //FIXME should not be here
|
||||
|
||||
mnode_t **node_parents;
|
||||
mnode_t **leaf_parents;
|
||||
|
||||
unsigned int checksum;
|
||||
unsigned int checksum2;
|
||||
} mod_brush_t;
|
||||
|
|
|
@ -585,13 +585,15 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_SetParent (mnode_t *node, mnode_t *parent)
|
||||
Mod_SetParent (mod_brush_t *brush, mnode_t *node, mnode_t *parent)
|
||||
{
|
||||
node->parent = parent;
|
||||
if (node->contents < 0)
|
||||
if (node->contents < 0) {
|
||||
brush->leaf_parents[(mleaf_t *)node - brush->leafs] = parent;
|
||||
return;
|
||||
Mod_SetParent (node->children[0], node);
|
||||
Mod_SetParent (node->children[1], node);
|
||||
}
|
||||
brush->node_parents[node - brush->nodes] = parent;
|
||||
Mod_SetParent (brush, node->children[0], node);
|
||||
Mod_SetParent (brush, node->children[1], node);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -646,7 +648,10 @@ Mod_LoadNodes (model_t *mod, bsp_t *bsp)
|
|||
}
|
||||
}
|
||||
|
||||
Mod_SetParent (brush->nodes, NULL); // sets nodes and leafs
|
||||
size_t size = (brush->numleafs + brush->numnodes) * sizeof (mnode_t *);
|
||||
brush->node_parents = Hunk_AllocName (size, mod->name);
|
||||
brush->leaf_parents = brush->node_parents + brush->numnodes;
|
||||
Mod_SetParent (brush, brush->nodes, NULL); // sets nodes and leafs
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -54,6 +54,7 @@ R_MarkLeaves (void)
|
|||
mleaf_t *leaf;
|
||||
mnode_t *node;
|
||||
msurface_t **mark;
|
||||
mod_brush_t *brush = &r_worldentity.model->brush;
|
||||
|
||||
if (r_oldviewleaf == r_viewleaf && !r_novis->int_val)
|
||||
return;
|
||||
|
@ -67,13 +68,13 @@ R_MarkLeaves (void)
|
|||
r_oldviewleaf = 0; // so vis will be recalcualted when novis gets
|
||||
// turned off
|
||||
vis = solid;
|
||||
memset (solid, 0xff, (r_worldentity.model->brush.numleafs + 7) >> 3);
|
||||
memset (solid, 0xff, (brush->numleafs + 7) >> 3);
|
||||
} else
|
||||
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
|
||||
|
||||
for (i = 0; (int) i < r_worldentity.model->brush.numleafs; i++) {
|
||||
for (i = 0; (int) i < brush->numleafs; i++) {
|
||||
if (vis[i >> 3] & (1 << (i & 7))) {
|
||||
leaf = &r_worldentity.model->brush.leafs[i + 1];
|
||||
leaf = &brush->leafs[i + 1];
|
||||
if ((c = leaf->nummarksurfaces)) {
|
||||
mark = leaf->firstmarksurface;
|
||||
do {
|
||||
|
@ -81,13 +82,14 @@ R_MarkLeaves (void)
|
|||
mark++;
|
||||
} while (--c);
|
||||
}
|
||||
node = (mnode_t *) leaf;
|
||||
do {
|
||||
leaf->visframe = r_visframecount;
|
||||
node = brush->leaf_parents[leaf - brush->leafs];
|
||||
while (node) {
|
||||
if (node->visframe == r_visframecount)
|
||||
break;
|
||||
node->visframe = r_visframecount;
|
||||
node = node->parent;
|
||||
} while (node);
|
||||
node = brush->node_parents[node - brush->nodes];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue