mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
First commit for "Polymost.f", the single precision floating point conversion and optimization of Polymost. This work was primarily done for ARM but it also doubled the framerate on "Clear the Coast" on my i7.
git-svn-id: https://svn.eduke32.com/eduke32@4605 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8148ccf3c3
commit
105bc3f413
5 changed files with 727 additions and 630 deletions
|
@ -2,7 +2,6 @@
|
|||
#define HIGHTILE_PRIV_H
|
||||
|
||||
struct hicskybox_t {
|
||||
int ignore;
|
||||
char *face[6];
|
||||
};
|
||||
|
||||
|
@ -10,13 +9,14 @@ typedef struct hicreplc_t {
|
|||
struct hicreplc_t *next;
|
||||
char *filename;
|
||||
struct hicskybox_t *skybox;
|
||||
char palnum, ignore, flags, filler;
|
||||
char palnum, flags;
|
||||
short filler;
|
||||
float alphacut, xscale, yscale, specpower, specfactor;
|
||||
} hicreplctyp;
|
||||
|
||||
extern palette_t hictinting[MAXPALOOKUPS];
|
||||
extern hicreplctyp *hicreplc[MAXTILES];
|
||||
extern char hicfirstinit;
|
||||
extern int32_t hicinitcounter;
|
||||
|
||||
typedef struct texcachehead_t
|
||||
{
|
||||
|
@ -34,7 +34,8 @@ typedef struct texcachepic_t
|
|||
int border, depth;
|
||||
} texcachepicture;
|
||||
|
||||
hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox);
|
||||
hicreplctyp * hicfindsubst(int picnum, int palnum);
|
||||
hicreplctyp * hicfindskybox(int picnum, int palnum);
|
||||
|
||||
static inline int have_basepal_tint(void)
|
||||
{
|
||||
|
@ -45,16 +46,16 @@ static inline int have_basepal_tint(void)
|
|||
|
||||
static inline void hictinting_apply(float *color, int32_t palnum)
|
||||
{
|
||||
color[0] *= (float)hictinting[palnum].r / 255.0;
|
||||
color[1] *= (float)hictinting[palnum].g / 255.0;
|
||||
color[2] *= (float)hictinting[palnum].b / 255.0;
|
||||
color[0] *= (float)hictinting[palnum].r / 255.f;
|
||||
color[1] *= (float)hictinting[palnum].g / 255.f;
|
||||
color[2] *= (float)hictinting[palnum].b / 255.f;
|
||||
}
|
||||
|
||||
static inline void hictinting_apply_ub(uint8_t *color, int32_t palnum)
|
||||
{
|
||||
color[0] = (uint8_t)(color[0] * (float)hictinting[palnum].r / 255.0);
|
||||
color[1] = (uint8_t)(color[1] * (float)hictinting[palnum].g / 255.0);
|
||||
color[2] = (uint8_t)(color[2] * (float)hictinting[palnum].b / 255.0);
|
||||
color[0] = (uint8_t)(color[0] * (float)hictinting[palnum].r / 255.f);
|
||||
color[1] = (uint8_t)(color[1] * (float)hictinting[palnum].g / 255.f);
|
||||
color[2] = (uint8_t)(color[2] * (float)hictinting[palnum].b / 255.f);
|
||||
}
|
||||
|
||||
// texcacheheader cachead.flags bits
|
||||
|
|
|
@ -11,9 +11,9 @@ typedef struct { char r, g, b, a; } coltype;
|
|||
extern int32_t rendmode;
|
||||
extern float gtang;
|
||||
extern float glox1, gloy1;
|
||||
extern double gxyaspect, grhalfxdown10x;
|
||||
extern double gcosang, gsinang, gcosang2, gsinang2;
|
||||
extern double gchang, gshang, gctang, gstang, gvisibility;
|
||||
extern float gxyaspect, grhalfxdown10x;
|
||||
extern float gcosang, gsinang, gcosang2, gsinang2;
|
||||
extern float gchang, gshang, gctang, gstang, gvisibility;
|
||||
|
||||
struct glfiltermodes {
|
||||
const char *name;
|
||||
|
@ -60,7 +60,7 @@ extern int32_t globalpal;
|
|||
// Compare with polymer_eligible_for_artmap()
|
||||
static inline int32_t eligible_for_tileshades(int32_t picnum, int32_t pal)
|
||||
{
|
||||
return (!usehightile || !hicfindsubst(picnum, pal, 0)) &&
|
||||
return (!usehightile || !hicfindsubst(picnum, pal)) &&
|
||||
(!usemodels || md_tilehasmodel(picnum, pal) < 0);
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp
|
|||
extern int32_t globalnoeffect;
|
||||
extern int32_t drawingskybox;
|
||||
extern int32_t hicprecaching;
|
||||
extern double gyxscale, gxyaspect, ghalfx, grhalfxdown10;
|
||||
extern float gyxscale, gxyaspect, ghalfx, grhalfxdown10;
|
||||
|
||||
extern char ptempbuf[MAXWALLSB<<1];
|
||||
|
||||
|
|
|
@ -16,36 +16,51 @@
|
|||
palette_t hictinting[MAXPALOOKUPS];
|
||||
|
||||
hicreplctyp *hicreplc[MAXTILES];
|
||||
char hicfirstinit = 0;
|
||||
int32_t hicinitcounter = 0;
|
||||
|
||||
//
|
||||
// find the index into hicreplc[] which contains the replacement tile particulars
|
||||
//
|
||||
hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum, int32_t skybox)
|
||||
hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum)
|
||||
{
|
||||
if (!hicfirstinit || (uint32_t)picnum >= (uint32_t)MAXTILES) return NULL;
|
||||
if (!hicreplc[picnum] || !hicinitcounter) return NULL;
|
||||
|
||||
do
|
||||
{
|
||||
if (skybox)
|
||||
{
|
||||
hicreplctyp *hr = hicreplc[picnum];
|
||||
for (; hr; hr = hr->next)
|
||||
if (hr->palnum == palnum && hr->skybox && !hr->skybox->ignore)
|
||||
return hr;
|
||||
}
|
||||
else
|
||||
{
|
||||
hicreplctyp *hr = hicreplc[picnum];
|
||||
for (; hr; hr = hr->next)
|
||||
if (hr->palnum == palnum && !hr->ignore)
|
||||
return hr;
|
||||
}
|
||||
hicreplctyp *hr = hicreplc[picnum];
|
||||
for (; hr; hr = hr->next)
|
||||
if (hr->palnum == palnum)
|
||||
return hr;
|
||||
|
||||
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||
return NULL;
|
||||
|
||||
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS)) break;
|
||||
palnum = 0;
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
|
||||
return NULL; // no replacement found
|
||||
}
|
||||
|
||||
//
|
||||
// this is separate because it's not worth passing an extra parameter which is "0" in 99.9999% of cases
|
||||
// to the regular hicfindsubst() function
|
||||
//
|
||||
hicreplctyp *hicfindskybox(int32_t picnum, int32_t palnum)
|
||||
{
|
||||
if (!hicreplc[picnum] || !hicinitcounter) return NULL;
|
||||
|
||||
do
|
||||
{
|
||||
hicreplctyp *hr = hicreplc[picnum];
|
||||
for (; hr; hr = hr->next)
|
||||
if (hr->skybox && hr->palnum == palnum)
|
||||
return hr;
|
||||
|
||||
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||
return NULL;
|
||||
|
||||
palnum = 0;
|
||||
} while (1);
|
||||
|
||||
return NULL; // no replacement found
|
||||
}
|
||||
|
@ -57,8 +72,7 @@ hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum, int32_t skybox)
|
|||
//
|
||||
void hicinit(void)
|
||||
{
|
||||
int32_t i,j;
|
||||
hicreplctyp *hr, *next;
|
||||
int32_t i;
|
||||
|
||||
for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100%
|
||||
{
|
||||
|
@ -66,7 +80,11 @@ void hicinit(void)
|
|||
hictinting[i].f = 0;
|
||||
}
|
||||
|
||||
if (hicfirstinit)
|
||||
if (hicinitcounter)
|
||||
{
|
||||
hicreplctyp *hr, *next;
|
||||
int32_t j;
|
||||
|
||||
for (i=MAXTILES-1; i>=0; i--)
|
||||
{
|
||||
for (hr=hicreplc[i]; hr;)
|
||||
|
@ -89,10 +107,11 @@ void hicinit(void)
|
|||
hr = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bmemset(hicreplc,0,sizeof(hicreplc));
|
||||
|
||||
hicfirstinit = 1;
|
||||
hicinitcounter++;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +124,7 @@ void hicinit(void)
|
|||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect)
|
||||
{
|
||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
||||
if (!hicfirstinit) hicinit();
|
||||
if (!hicinitcounter) hicinit();
|
||||
|
||||
hictinting[palnum].r = r;
|
||||
hictinting[palnum].g = g;
|
||||
|
@ -124,7 +143,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
|
|||
|
||||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||
if (!hicfirstinit) hicinit();
|
||||
if (!hicinitcounter) hicinit();
|
||||
|
||||
for (hr = hicreplc[picnum]; hr; hr = hr->next)
|
||||
{
|
||||
|
@ -144,7 +163,6 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
|
|||
if (hrn->filename) Bfree(hrn->filename);
|
||||
|
||||
hrn->filename = Xstrdup(filen);
|
||||
hrn->ignore = 0;
|
||||
hrn->alphacut = min(alphacut,1.0);
|
||||
hrn->xscale = xscale;
|
||||
hrn->yscale = yscale;
|
||||
|
@ -187,7 +205,7 @@ int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6])
|
|||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||
for (j=5; j>=0; j--) if (!faces[j]) return -1;
|
||||
if (!hicfirstinit) hicinit();
|
||||
if (!hicinitcounter) hicinit();
|
||||
|
||||
for (hr = hicreplc[picnum]; hr; hr = hr->next)
|
||||
{
|
||||
|
@ -221,7 +239,7 @@ int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6])
|
|||
{
|
||||
hrn->skybox->face[j] = Xstrdup(faces[j]);
|
||||
}
|
||||
hrn->skybox->ignore = 0;
|
||||
|
||||
if (hr == NULL)
|
||||
{
|
||||
hrn->next = hicreplc[picnum];
|
||||
|
@ -242,7 +260,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
|
|||
|
||||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||
if (!hicfirstinit) return 0;
|
||||
if (!hicinitcounter) return 0;
|
||||
|
||||
for (hr = hicreplc[picnum]; hr; hrn = hr, hr = hr->next)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,98 +26,11 @@ static const char *texcache_errorstr[TEXCACHEERRORS] = {
|
|||
"bglGetTexLevelParameteriv failed",
|
||||
};
|
||||
|
||||
// <dashade>: ignored if not in Polymost+r_usetileshades
|
||||
pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
|
||||
static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
|
||||
{
|
||||
int32_t i;
|
||||
pthtyp *pth;
|
||||
|
||||
const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
|
||||
hicreplctyp *const si = usehightile ? hicfindsubst(dapicnum,dapalnum,drawingskybox) : NULL;
|
||||
|
||||
if (getrendermode() != REND_POLYMOST || !r_usetileshades)
|
||||
dashade = 0;
|
||||
|
||||
if (!si)
|
||||
{
|
||||
if (drawingskybox || dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) return NULL;
|
||||
goto tryart;
|
||||
}
|
||||
|
||||
/* if palette > 0 && replacement found
|
||||
* no effects are applied to the texture
|
||||
* else if palette > 0 && no replacement found
|
||||
* effects are applied to the palette 0 texture if it exists
|
||||
*/
|
||||
|
||||
// load a replacement
|
||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||
{
|
||||
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
||||
(si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
||||
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX))
|
||||
== (TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX) &&
|
||||
(drawingskybox>0 ? (pth->skyface == drawingskybox) : 1)
|
||||
)
|
||||
{
|
||||
if (pth->flags & PTH_INVALIDATED)
|
||||
{
|
||||
pth->flags &= ~PTH_INVALIDATED;
|
||||
|
||||
if (gloadtile_hi(dapicnum,dapalnum,drawingskybox,si,dameth,pth,0,
|
||||
(si->palnum>0) ? 0 : hictinting[dapalnum].f)) // reload tile
|
||||
{
|
||||
if (drawingskybox) return NULL;
|
||||
goto tryart; // failed, so try for ART
|
||||
}
|
||||
}
|
||||
|
||||
return(pth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp));
|
||||
|
||||
// possibly fetch an already loaded multitexture :_)
|
||||
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||
for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--)
|
||||
{
|
||||
const pthtyp *pth2;
|
||||
|
||||
for (pth2=texcache.list[i]; pth2; pth2=pth2->next)
|
||||
{
|
||||
if (pth2->hicr && pth2->hicr->filename && Bstrcasecmp(pth2->hicr->filename, si->filename) == 0)
|
||||
{
|
||||
Bmemcpy(pth, pth2, sizeof(pthtyp));
|
||||
pth->picnum = dapicnum;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX;
|
||||
if (pth2->flags & PTH_HASALPHA)
|
||||
pth->flags |= PTH_HASALPHA;
|
||||
pth->hicr = si;
|
||||
|
||||
pth->next = texcache.list[j];
|
||||
texcache.list[j] = pth;
|
||||
|
||||
return(pth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gloadtile_hi(dapicnum,dapalnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f))
|
||||
{
|
||||
Bfree(pth);
|
||||
if (drawingskybox) return NULL;
|
||||
goto tryart; // failed, so try for ART
|
||||
}
|
||||
|
||||
pth->palnum = si->palnum;
|
||||
pth->next = texcache.list[j];
|
||||
texcache.list[j] = pth;
|
||||
|
||||
return(pth);
|
||||
|
||||
tryart:
|
||||
if (hicprecaching) return NULL;
|
||||
|
||||
// load from art
|
||||
|
@ -146,6 +59,120 @@ tryart:
|
|||
return(pth);
|
||||
}
|
||||
|
||||
pthtyp *texcache_fetchmulti(pthtyp *pth, hicreplctyp *si, int32_t dapicnum, int32_t dameth)
|
||||
{
|
||||
int32_t i;
|
||||
const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
|
||||
|
||||
for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--)
|
||||
{
|
||||
const pthtyp *pth2;
|
||||
|
||||
for (pth2=texcache.list[i]; pth2; pth2=pth2->next)
|
||||
{
|
||||
if (pth2->hicr && pth2->hicr->filename && Bstrcasecmp(pth2->hicr->filename, si->filename) == 0)
|
||||
{
|
||||
Bmemcpy(pth, pth2, sizeof(pthtyp));
|
||||
pth->picnum = dapicnum;
|
||||
pth->flags = TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX;
|
||||
if (pth2->flags & PTH_HASALPHA)
|
||||
pth->flags |= PTH_HASALPHA;
|
||||
pth->hicr = si;
|
||||
|
||||
pth->next = texcache.list[j];
|
||||
texcache.list[j] = pth;
|
||||
|
||||
return pth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// <dashade>: ignored if not in Polymost+r_usetileshades
|
||||
pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
|
||||
{
|
||||
int32_t tilestat;
|
||||
pthtyp *pth;
|
||||
|
||||
const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
|
||||
hicreplctyp *si = usehightile ? hicfindsubst(dapicnum, dapalnum) : NULL;
|
||||
|
||||
if (drawingskybox && usehightile)
|
||||
if ((si = hicfindskybox(dapicnum, dapalnum)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!r_usetileshades || getrendermode() != REND_POLYMOST)
|
||||
dashade = 0;
|
||||
|
||||
if (!si)
|
||||
{
|
||||
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) return NULL;
|
||||
return texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||
}
|
||||
|
||||
/* if palette > 0 && replacement found
|
||||
* no effects are applied to the texture
|
||||
* else if palette > 0 && no replacement found
|
||||
* effects are applied to the palette 0 texture if it exists
|
||||
*/
|
||||
|
||||
// load a replacement
|
||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||
{
|
||||
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
||||
(si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
||||
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX))
|
||||
== (TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX) &&
|
||||
(drawingskybox>0 ? (pth->skyface == drawingskybox) : 1)
|
||||
)
|
||||
{
|
||||
if (pth->flags & PTH_INVALIDATED)
|
||||
{
|
||||
pth->flags &= ~PTH_INVALIDATED;
|
||||
|
||||
tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
|
||||
(si->palnum>0) ? 0 : hictinting[dapalnum].f); // reload tile
|
||||
|
||||
if (tilestat)
|
||||
{
|
||||
if (tilestat == -2) // bad filename
|
||||
hicclearsubst(dapicnum, dapalnum);
|
||||
if (drawingskybox) return NULL;
|
||||
return texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||
}
|
||||
}
|
||||
|
||||
return(pth);
|
||||
}
|
||||
}
|
||||
|
||||
pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp));
|
||||
|
||||
// possibly fetch an already loaded multitexture :_)
|
||||
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||
if (texcache_fetchmulti(pth, si, dapicnum, dameth))
|
||||
return pth;
|
||||
|
||||
tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (si->palnum>0) ? 0 : hictinting[dapalnum].f);
|
||||
|
||||
if (tilestat)
|
||||
{
|
||||
if (tilestat == -2) // bad filename
|
||||
hicclearsubst(dapicnum, dapalnum);
|
||||
Bfree(pth);
|
||||
if (drawingskybox) return NULL;
|
||||
return texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||
}
|
||||
|
||||
pth->palnum = si->palnum;
|
||||
pth->next = texcache.list[j];
|
||||
texcache.list[j] = pth;
|
||||
|
||||
return(pth);
|
||||
}
|
||||
|
||||
static void texcache_closefiles(void)
|
||||
{
|
||||
if (texcache.filehandle != -1)
|
||||
|
|
Loading…
Reference in a new issue