Two tweaks to make the precaching more efficient/less redundant in the game.

First, if we're in Polymer, don't precache tinted tiles that have a highpal
for that certain pal.  Second, don't precache tiles for palnum 251 (the last
non-reserved one, which is used as a crosshair pal). Assuming that there are
no other tints, this cuts the initial precache time and cache size on disk in
half.

git-svn-id: https://svn.eduke32.com/eduke32@2045 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-09-28 20:30:24 +00:00
parent c6f58c8dde
commit bb72f803c4
6 changed files with 35 additions and 12 deletions

View file

@ -310,6 +310,7 @@ void polymer_deletelight(int16_t lighti);
void polymer_invalidatelights(void); void polymer_invalidatelights(void);
void polymer_texinvalidate(void); void polymer_texinvalidate(void);
void polymer_definehighpalookup(char basepalnum, char palnum, char *fn); void polymer_definehighpalookup(char basepalnum, char palnum, char *fn);
int32_t polymer_havehighpalookup(int32_t basepalnum, int32_t palnum);
# ifdef POLYMER_C # ifdef POLYMER_C

View file

@ -23,7 +23,7 @@ int32_t curextra=MAXTILES;
// #define MODEL_POOL_SIZE 20971520 // #define MODEL_POOL_SIZE 20971520
#define model_data_pool (nedpool *) 0 // take it out of the system pool #define model_data_pool (nedpool *) 0 // take it out of the system pool
#define MIN_CACHETIME_PRINT 5 #define MIN_CACHETIME_PRINT 10
static void QuitOnFatalError(const char *msg) static void QuitOnFatalError(const char *msg)
{ {

View file

@ -634,7 +634,7 @@ int32_t culledface;
// EXTERNAL FUNCTIONS // EXTERNAL FUNCTIONS
int32_t polymer_init(void) int32_t polymer_init(void)
{ {
int32_t i, j; int32_t i, j, t = getticks();
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n"); if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n");
@ -730,7 +730,7 @@ int32_t polymer_init(void)
i++; i++;
} }
if (pr_verbosity >= 1) OSD_Printf("PR : Initialization complete.\n"); if (pr_verbosity >= 1) OSD_Printf("PR : Initialization complete in %d ms.\n", getticks()-t);
return (1); return (1);
} }
@ -761,7 +761,7 @@ void polymer_uninit(void)
// } // }
if (prhighpalookups[i][j].map) { if (prhighpalookups[i][j].map) {
bglDeleteTextures(1, &prhighpalookups[i][j].map); bglDeleteTextures(1, &prhighpalookups[i][j].map);
// prhighpalookups[i][j].map = 0; prhighpalookups[i][j].map = 0;
} }
j++; j++;
} }
@ -1504,6 +1504,15 @@ void polymer_definehighpalookup(char basepalnum, char palnum, cha
Bmemcpy(prhighpalookups[basepalnum][palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE); Bmemcpy(prhighpalookups[basepalnum][palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE);
} }
int32_t polymer_havehighpalookup(int32_t basepalnum, int32_t palnum)
{
if ((uint32_t)basepalnum >= MAXBASEPALS || (uint32_t)palnum >= MAXPALOOKUPS)
return 0;
return (prhighpalookups[basepalnum][palnum].data != NULL);
}
// CORE // CORE
static void polymer_displayrooms(int16_t dacursectnum) static void polymer_displayrooms(int16_t dacursectnum)
{ {

View file

@ -212,7 +212,7 @@ int32_t r_parallaxskypanning = 0;
extern int16_t editstatus; extern int16_t editstatus;
#define MIN_CACHETIME_PRINT 5 #define MIN_CACHETIME_PRINT 10
static inline int32_t imod(int32_t a, int32_t b) static inline int32_t imod(int32_t a, int32_t b)
@ -314,8 +314,8 @@ pthtyp *gltexcachead[GLTEXCACHEADSIZ];
int32_t drawingskybox = 0; int32_t drawingskybox = 0;
int32_t gloadtile_art(int32_t,int32_t,int32_t,pthtyp *,int32_t); static int32_t gloadtile_art(int32_t,int32_t,int32_t,pthtyp *,int32_t);
int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char); static int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char);
static int32_t hicprecaching = 0; static int32_t hicprecaching = 0;
pthtyp *gltexcache(int32_t dapicnum, int32_t dapalnum, int32_t dameth) pthtyp *gltexcache(int32_t dapicnum, int32_t dapalnum, int32_t dameth)
{ {
@ -806,6 +806,8 @@ void polymost_glinit()
glusetexcache = 0; glusetexcache = 0;
return; return;
} }
else
initprintf("Opened '%s' as cache file\n", TEXCACHEFILE);
if (glusememcache && !dont_alloc_memcache) if (glusememcache && !dont_alloc_memcache)
{ {
@ -930,6 +932,8 @@ void invalidatecache(void)
glusetexcache = 0; glusetexcache = 0;
return; return;
} }
else
initprintf("Deleted and reopened '%s' as cache file\n", TEXCACHEFILE);
} }
void resizeglcheck() void resizeglcheck()
@ -1158,7 +1162,7 @@ void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt
#endif #endif
} }
int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dameth, pthtyp *pth, int32_t doalloc) static int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dameth, pthtyp *pth, int32_t doalloc)
{ {
coltype *pic, *wpptr; coltype *pic, *wpptr;
int32_t x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy; int32_t x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy;
@ -1685,8 +1689,7 @@ failure:
return -1; return -1;
} }
// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF // --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF
//static static int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp *hicr, int32_t dameth, pthtyp *pth, int32_t doalloc, char effect)
int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp *hicr, int32_t dameth, pthtyp *pth, int32_t doalloc, char effect)
{ {
coltype *pic = NULL, *rpptr; coltype *pic = NULL, *rpptr;
int32_t j, x, y, xsiz=0, ysiz=0, tsizx, tsizy; int32_t j, x, y, xsiz=0, ysiz=0, tsizx, tsizy;
@ -6774,7 +6777,7 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf,
} }
#endif #endif
#else /* POLYMOST */ #else /* if !defined USE_OPENGL */
#include "inttypes.h" #include "inttypes.h"
int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen,

View file

@ -2546,6 +2546,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
makepalookup(CROSSHAIR_PAL,tempbuf,CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1); makepalookup(CROSSHAIR_PAL,tempbuf,CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1);
#ifdef USE_OPENGL #ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
Bmemcpy(&hictinting[CROSSHAIR_PAL], &CrosshairColors, sizeof(palette_t)); Bmemcpy(&hictinting[CROSSHAIR_PAL], &CrosshairColors, sizeof(palette_t));
hictinting[CROSSHAIR_PAL].f = 9; hictinting[CROSSHAIR_PAL].f = 9;
#endif #endif

View file

@ -514,8 +514,17 @@ void G_CacheMapData(void)
for (type=0; type<=1; type++) for (type=0; type<=1; type++)
if (precachehightile[type][i>>3] & pow2char[i&7]) if (precachehightile[type][i>>3] & pow2char[i&7])
{ {
k = 0;
for (k=0; k<MAXPALOOKUPS-RESERVEDPALS && !KB_KeyPressed(sc_Space); k++) for (k=0; k<MAXPALOOKUPS-RESERVEDPALS && !KB_KeyPressed(sc_Space); k++)
polymost_precache(i,k,type); {
// this is the CROSSHAIR_COLOR, see comment in game.c
if (k == MAXPALOOKUPS-RESERVEDPALS-1)
break;
if (rendmode!=4 || !polymer_havehighpalookup(0, k))
polymost_precache(i,k,type);
}
if (r_detailmapping && !KB_KeyPressed(sc_Space)) if (r_detailmapping && !KB_KeyPressed(sc_Space))
polymost_precache(i,DETAILPAL,type); polymost_precache(i,DETAILPAL,type);
if (r_glowmapping && !KB_KeyPressed(sc_Space)) if (r_glowmapping && !KB_KeyPressed(sc_Space))