From bb72f803c45f91d1430306a447e83928acb1603f Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 28 Sep 2011 20:30:24 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/include/polymer.h | 1 + polymer/eduke32/build/src/mdsprite.c | 2 +- polymer/eduke32/build/src/polymer.c | 15 ++++++++++++--- polymer/eduke32/build/src/polymost.c | 17 ++++++++++------- polymer/eduke32/source/game.c | 1 + polymer/eduke32/source/premap.c | 11 ++++++++++- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index bf7464573..880e4149a 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -310,6 +310,7 @@ void polymer_deletelight(int16_t lighti); void polymer_invalidatelights(void); void polymer_texinvalidate(void); void polymer_definehighpalookup(char basepalnum, char palnum, char *fn); +int32_t polymer_havehighpalookup(int32_t basepalnum, int32_t palnum); # ifdef POLYMER_C diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 3d0bbc7be..f318fd6f5 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -23,7 +23,7 @@ int32_t curextra=MAXTILES; // #define MODEL_POOL_SIZE 20971520 #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) { diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 72bd5bca5..5e6c2fc13 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -634,7 +634,7 @@ int32_t culledface; // EXTERNAL FUNCTIONS 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"); @@ -730,7 +730,7 @@ int32_t polymer_init(void) 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); } @@ -761,7 +761,7 @@ void polymer_uninit(void) // } if (prhighpalookups[i][j].map) { bglDeleteTextures(1, &prhighpalookups[i][j].map); -// prhighpalookups[i][j].map = 0; + prhighpalookups[i][j].map = 0; } j++; } @@ -1504,6 +1504,15 @@ void polymer_definehighpalookup(char basepalnum, char palnum, cha 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 static void polymer_displayrooms(int16_t dacursectnum) { diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index bd5d1f742..fc3e5c726 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -212,7 +212,7 @@ int32_t r_parallaxskypanning = 0; 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) @@ -314,8 +314,8 @@ pthtyp *gltexcachead[GLTEXCACHEADSIZ]; int32_t drawingskybox = 0; -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_art(int32_t,int32_t,int32_t,pthtyp *,int32_t); +static int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char); static int32_t hicprecaching = 0; pthtyp *gltexcache(int32_t dapicnum, int32_t dapalnum, int32_t dameth) { @@ -806,6 +806,8 @@ void polymost_glinit() glusetexcache = 0; return; } + else + initprintf("Opened '%s' as cache file\n", TEXCACHEFILE); if (glusememcache && !dont_alloc_memcache) { @@ -930,6 +932,8 @@ void invalidatecache(void) glusetexcache = 0; return; } + else + initprintf("Deleted and reopened '%s' as cache file\n", TEXCACHEFILE); } void resizeglcheck() @@ -1158,7 +1162,7 @@ void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt #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; int32_t x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy; @@ -1685,8 +1689,7 @@ failure: return -1; } // --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF -//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) +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) { coltype *pic = NULL, *rpptr; 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 -#else /* POLYMOST */ +#else /* if !defined USE_OPENGL */ #include "inttypes.h" int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1fa0dcd1d..f9a6115b8 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -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); #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)); hictinting[CROSSHAIR_PAL].f = 9; #endif diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index f4dbd60f3..c4c82202e 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -514,8 +514,17 @@ void G_CacheMapData(void) for (type=0; type<=1; type++) if (precachehightile[type][i>>3] & pow2char[i&7]) { + k = 0; for (k=0; k