diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index a768cfc64..fa0de9ce0 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -2206,24 +2206,26 @@ static void polymer_emptybuckets(void) prcanbucket = 0; } +static hashtable_t h_buckets ={ 2048, NULL }; + static _prbucket* polymer_findbucket(int16_t tilenum, char pal) { - _prbucket *bucketptr = prbuckethead; + char propstr[16]; + + Bsprintf(propstr, "%d_%d", tilenum, pal); + + _prbucket *bucketptr = prbuckethead ? (_prbucket *)hash_find(&h_buckets, propstr) : NULL; // find bucket - while (bucketptr != NULL) - { - if (bucketptr->tilenum == tilenum && bucketptr->pal == pal) - break; - - bucketptr = bucketptr->next; - } // no buckets or no bucket found, create one - if (bucketptr == NULL) + if (bucketptr == NULL || (intptr_t)bucketptr == -1) { bucketptr = (_prbucket *)Xmalloc(sizeof (_prbucket)); + if (h_buckets.items == NULL) + hash_init(&h_buckets); + // insert, since most likely to use same pattern next frame // will need to reorder by MRU first every once in a while // or move to hashing lookup @@ -2238,6 +2240,8 @@ static _prbucket* polymer_findbucket(int16_t tilenum, char pal) bucketptr->count = 0; bucketptr->buffersize = 1024; bucketptr->indices = (GLuint *)Xmalloc(bucketptr->buffersize * sizeof(GLuint)); + + hash_add(&h_buckets, propstr, (intptr_t)bucketptr, 1); } return bucketptr; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 52a539c8c..41829aa3f 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -5778,7 +5778,7 @@ void polymost_initosdfuncs(void) { "r_pr_verbosity", "verbosity level of the polymer renderer", (void *) &pr_verbosity, CVAR_INT, 0, 3 }, { "r_pr_wireframe", "toggles wireframe mode", (void *) &pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 1 }, { "r_pr_vbos", "contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void *) &pr_vbos, CVAR_INT | CVAR_RESTARTVID, 0, 2 }, - { "r_pr_buckets", "controls batching of primitives. 0: no batching. 1: buckets of materials.", (void *)&pr_buckets, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, + { "r_pr_buckets", "controls batching of primitives. 0: no batching. 1: buckets of materials.", (void *)&pr_buckets, CVAR_BOOL | CVAR_NOSAVE | CVAR_RESTARTVID, 0, 1 }, { "r_pr_gpusmoothing", "toggles model animation interpolation", (void *)&pr_gpusmoothing, CVAR_INT, 0, 1 }, { "r_pr_overrideparallax", "overrides parallax mapping scale and bias values with values from the pr_parallaxscale and pr_parallaxbias cvars; use it to fine-tune DEF tokens", (void *) &pr_overrideparallax, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_parallaxscale", "overriden parallax mapping offset scale", (void *) &pr_parallaxscale, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 },