mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Factor out hictinting array accesses.
git-svn-id: https://svn.eduke32.com/eduke32@6216 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
70245fc4f1
commit
a032b829bf
6 changed files with 58 additions and 42 deletions
|
@ -48,23 +48,26 @@ hicreplctyp * hicfindskybox(int picnum, int palnum);
|
||||||
|
|
||||||
static inline int have_basepal_tint(void)
|
static inline int have_basepal_tint(void)
|
||||||
{
|
{
|
||||||
return (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
polytint_t const & tint = hictinting[MAXPALOOKUPS-1];
|
||||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
return (tint.r != 255 ||
|
||||||
hictinting[MAXPALOOKUPS-1].b != 255);
|
tint.g != 255 ||
|
||||||
|
tint.b != 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hictinting_apply(float *color, int32_t palnum)
|
static inline void hictinting_apply(float *color, int32_t palnum)
|
||||||
{
|
{
|
||||||
color[0] *= (float)hictinting[palnum].r * (1.f/255.f);
|
polytint_t const & tint = hictinting[palnum];
|
||||||
color[1] *= (float)hictinting[palnum].g * (1.f/255.f);
|
color[0] *= (float)tint.r * (1.f/255.f);
|
||||||
color[2] *= (float)hictinting[palnum].b * (1.f/255.f);
|
color[1] *= (float)tint.g * (1.f/255.f);
|
||||||
|
color[2] *= (float)tint.b * (1.f/255.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hictinting_apply_ub(uint8_t *color, int32_t palnum)
|
static inline void hictinting_apply_ub(uint8_t *color, int32_t palnum)
|
||||||
{
|
{
|
||||||
color[0] = (uint8_t)(color[0] * (float)hictinting[palnum].r * (1.f/255.f));
|
polytint_t const & tint = hictinting[palnum];
|
||||||
color[1] = (uint8_t)(color[1] * (float)hictinting[palnum].g * (1.f/255.f));
|
color[0] = (uint8_t)(color[0] * (float)tint.r * (1.f/255.f));
|
||||||
color[2] = (uint8_t)(color[2] * (float)hictinting[palnum].b * (1.f/255.f));
|
color[1] = (uint8_t)(color[1] * (float)tint.g * (1.f/255.f));
|
||||||
|
color[2] = (uint8_t)(color[2] * (float)tint.b * (1.f/255.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// texcacheheader cachead.flags bits
|
// texcacheheader cachead.flags bits
|
||||||
|
|
|
@ -76,8 +76,9 @@ void hicinit(void)
|
||||||
|
|
||||||
for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100%
|
for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100%
|
||||||
{
|
{
|
||||||
hictinting[i].r = hictinting[i].g = hictinting[i].b = 0xff;
|
polytint_t & tint = hictinting[i];
|
||||||
hictinting[i].f = 0;
|
tint.r = tint.g = tint.b = 0xff;
|
||||||
|
tint.f = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hicinitcounter)
|
if (hicinitcounter)
|
||||||
|
@ -123,10 +124,11 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, polytintflags_t e
|
||||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
||||||
if (!hicinitcounter) hicinit();
|
if (!hicinitcounter) hicinit();
|
||||||
|
|
||||||
hictinting[palnum].r = r;
|
polytint_t & tint = hictinting[palnum];
|
||||||
hictinting[palnum].g = g;
|
tint.r = r;
|
||||||
hictinting[palnum].b = b;
|
tint.g = g;
|
||||||
hictinting[palnum].f = effect;
|
tint.b = b;
|
||||||
|
tint.f = effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -823,9 +823,10 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
|
|
||||||
char *cptr = britable[gammabrightness ? 0 : curbrightness];
|
char *cptr = britable[gammabrightness ? 0 : curbrightness];
|
||||||
|
|
||||||
int32_t r = (glinfo.bgra) ? hictinting[pal].r : hictinting[pal].b;
|
polytint_t const & tint = hictinting[pal];
|
||||||
int32_t g = hictinting[pal].g;
|
int32_t r = (glinfo.bgra) ? tint.r : tint.b;
|
||||||
int32_t b = (glinfo.bgra) ? hictinting[pal].b : hictinting[pal].r;
|
int32_t g = tint.g;
|
||||||
|
int32_t b = (glinfo.bgra) ? tint.b : tint.r;
|
||||||
|
|
||||||
char al = 255;
|
char al = 255;
|
||||||
char onebitalpha = 1;
|
char onebitalpha = 1;
|
||||||
|
@ -2192,7 +2193,8 @@ static int32_t polymost_md3draw(md3model_t *m, const uspritetype *tspr)
|
||||||
|
|
||||||
// tinting
|
// tinting
|
||||||
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
||||||
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[globalpal].f;
|
||||||
|
if (!(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (!(m->flags&1))
|
if (!(m->flags&1))
|
||||||
hictinting_apply(pc, globalpal);
|
hictinting_apply(pc, globalpal);
|
||||||
|
|
|
@ -4198,14 +4198,15 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
|
||||||
if (pth)
|
if (pth)
|
||||||
{
|
{
|
||||||
// tinting
|
// tinting
|
||||||
if (!(hictinting[palnum].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[palnum].f;
|
||||||
|
if (!(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (pth->flags & PTH_HIGHTILE)
|
if (pth->flags & PTH_HIGHTILE)
|
||||||
{
|
{
|
||||||
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL))
|
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (tintflags & HICTINT_APPLYOVERALTPAL))
|
||||||
hictinting_apply(glcolors[i], palnum);
|
hictinting_apply(glcolors[i], palnum);
|
||||||
}
|
}
|
||||||
else if (hictinting[palnum].f & HICTINT_USEONART)
|
else if (tintflags & HICTINT_USEONART)
|
||||||
hictinting_apply(glcolors[i], palnum);
|
hictinting_apply(glcolors[i], palnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4289,14 +4290,15 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
|
||||||
if (pth)
|
if (pth)
|
||||||
{
|
{
|
||||||
// tinting
|
// tinting
|
||||||
if (!(hictinting[palnum].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[palnum].f;
|
||||||
|
if (!(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (pth->flags & PTH_HIGHTILE)
|
if (pth->flags & PTH_HIGHTILE)
|
||||||
{
|
{
|
||||||
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL))
|
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (tintflags & HICTINT_APPLYOVERALTPAL))
|
||||||
hictinting_apply(color, palnum);
|
hictinting_apply(color, palnum);
|
||||||
}
|
}
|
||||||
else if (hictinting[palnum].f & HICTINT_USEONART)
|
else if (tintflags & HICTINT_USEONART)
|
||||||
hictinting_apply(color, palnum);
|
hictinting_apply(color, palnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4517,7 +4519,8 @@ static void polymer_drawmdsprite(uspritetype *tspr)
|
||||||
prhighpalookups[curbasepal][tspr->pal].map);
|
prhighpalookups[curbasepal][tspr->pal].map);
|
||||||
|
|
||||||
// tinting
|
// tinting
|
||||||
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[tspr->pal].f;
|
||||||
|
if (!usinghighpal && !(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (!(m->flags&1))
|
if (!(m->flags&1))
|
||||||
hictinting_apply_ub(color, tspr->pal);
|
hictinting_apply_ub(color, tspr->pal);
|
||||||
|
@ -4990,14 +4993,15 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
||||||
(GLubyte)(getshadefactor(shade) * 0xFF);
|
(GLubyte)(getshadefactor(shade) * 0xFF);
|
||||||
|
|
||||||
// tinting
|
// tinting
|
||||||
if (!(hictinting[pal].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[pal].f;
|
||||||
|
if (!(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (pth->flags & PTH_HIGHTILE)
|
if (pth->flags & PTH_HIGHTILE)
|
||||||
{
|
{
|
||||||
if (pth->palnum != pal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[pal].f & HICTINT_APPLYOVERALTPAL))
|
if (pth->palnum != pal || (pth->effects & HICTINT_IN_MEMORY) || (tintflags & HICTINT_APPLYOVERALTPAL))
|
||||||
hictinting_apply_ub(material->diffusemodulation, pal);
|
hictinting_apply_ub(material->diffusemodulation, pal);
|
||||||
}
|
}
|
||||||
else if (hictinting[pal].f & HICTINT_USEONART)
|
else if (tintflags & HICTINT_USEONART)
|
||||||
hictinting_apply_ub(material->diffusemodulation, pal);
|
hictinting_apply_ub(material->diffusemodulation, pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1374,9 +1374,10 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
|
|
||||||
char *cptr = britable[gammabrightness ? 0 : curbrightness];
|
char *cptr = britable[gammabrightness ? 0 : curbrightness];
|
||||||
|
|
||||||
int32_t r = (glinfo.bgra) ? hictinting[dapalnum].r : hictinting[dapalnum].b;
|
polytint_t const & tint = hictinting[dapalnum];
|
||||||
int32_t g = hictinting[dapalnum].g;
|
int32_t r = (glinfo.bgra) ? tint.r : tint.b;
|
||||||
int32_t b = (glinfo.bgra) ? hictinting[dapalnum].b : hictinting[dapalnum].r;
|
int32_t g = tint.g;
|
||||||
|
int32_t b = (glinfo.bgra) ? tint.b : tint.r;
|
||||||
|
|
||||||
char al = 255;
|
char al = 255;
|
||||||
char onebitalpha = 1;
|
char onebitalpha = 1;
|
||||||
|
@ -1835,14 +1836,15 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
||||||
if (pth)
|
if (pth)
|
||||||
{
|
{
|
||||||
// tinting
|
// tinting
|
||||||
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
|
polytintflags_t const tintflags = hictinting[globalpal].f;
|
||||||
|
if (!(tintflags & HICTINT_PRECOMPUTED))
|
||||||
{
|
{
|
||||||
if (pth->flags & PTH_HIGHTILE)
|
if (pth->flags & PTH_HIGHTILE)
|
||||||
{
|
{
|
||||||
if (pth->palnum != globalpal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[globalpal].f & HICTINT_APPLYOVERALTPAL))
|
if (pth->palnum != globalpal || (pth->effects & HICTINT_IN_MEMORY) || (tintflags & HICTINT_APPLYOVERALTPAL))
|
||||||
hictinting_apply(pc, globalpal);
|
hictinting_apply(pc, globalpal);
|
||||||
}
|
}
|
||||||
else if (hictinting[globalpal].f & HICTINT_USEONART)
|
else if (tintflags & HICTINT_USEONART)
|
||||||
hictinting_apply(pc, globalpal);
|
hictinting_apply(pc, globalpal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,12 @@ static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, i
|
||||||
pthtyp *pth;
|
pthtyp *pth;
|
||||||
int32_t tintpalnum = -1;
|
int32_t tintpalnum = -1;
|
||||||
int32_t searchpalnum = dapalnum;
|
int32_t searchpalnum = dapalnum;
|
||||||
|
polytintflags_t const tintflags = hictinting[dapalnum].f;
|
||||||
|
|
||||||
if (hictinting[dapalnum].f & HICTINT_USEONART)
|
if (tintflags & HICTINT_USEONART)
|
||||||
{
|
{
|
||||||
tintpalnum = dapalnum;
|
tintpalnum = dapalnum;
|
||||||
if (!(hictinting[dapalnum].f & HICTINT_APPLYOVERPALSWAP))
|
if (!(tintflags & HICTINT_APPLYOVERPALSWAP))
|
||||||
searchpalnum = 0;
|
searchpalnum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,14 +128,16 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
* effects are applied to the palette 0 texture if it exists
|
* effects are applied to the palette 0 texture if it exists
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const int32_t checktintpal = (hictinting[dapalnum].f & HICTINT_APPLYOVERALTPAL) ? 0 : si->palnum;
|
polytintflags_t const tintflags = hictinting[dapalnum].f;
|
||||||
const int32_t checkcachepal = (hictinting[dapalnum].f & HICTINT_IN_MEMORY) || ((hictinting[dapalnum].f & HICTINT_APPLYOVERALTPAL) && si->palnum > 0) ? dapalnum : si->palnum;
|
|
||||||
|
const int32_t checktintpal = (tintflags & HICTINT_APPLYOVERALTPAL) ? 0 : si->palnum;
|
||||||
|
const int32_t checkcachepal = (tintflags & HICTINT_IN_MEMORY) || ((tintflags & HICTINT_APPLYOVERALTPAL) && si->palnum > 0) ? dapalnum : si->palnum;
|
||||||
|
|
||||||
// load a replacement
|
// load a replacement
|
||||||
for (pthtyp *pth = texcache.list[j]; pth; pth = pth->next)
|
for (pthtyp *pth = texcache.list[j]; pth; pth = pth->next)
|
||||||
{
|
{
|
||||||
if (pth->picnum == dapicnum && pth->palnum == checkcachepal &&
|
if (pth->picnum == dapicnum && pth->palnum == checkcachepal &&
|
||||||
(checktintpal > 0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
(checktintpal > 0 ? 1 : (pth->effects == tintflags)) &&
|
||||||
(pth->flags & (PTH_CLAMPED | PTH_HIGHTILE | PTH_SKYBOX | PTH_NOTRANSFIX)) ==
|
(pth->flags & (PTH_CLAMPED | PTH_HIGHTILE | PTH_SKYBOX | PTH_NOTRANSFIX)) ==
|
||||||
(TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) |
|
(TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) |
|
||||||
PTH_HIGHTILE | (drawingskybox > 0) * PTH_SKYBOX) &&
|
PTH_HIGHTILE | (drawingskybox > 0) * PTH_SKYBOX) &&
|
||||||
|
@ -145,7 +148,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
pth->flags &= ~PTH_INVALIDATED;
|
pth->flags &= ~PTH_INVALIDATED;
|
||||||
|
|
||||||
int32_t tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
|
int32_t tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
|
||||||
(checktintpal > 0) ? 0 : hictinting[dapalnum].f); // reload tile
|
(checktintpal > 0) ? 0 : tintflags); // reload tile
|
||||||
|
|
||||||
if (!tilestat)
|
if (!tilestat)
|
||||||
continue;
|
continue;
|
||||||
|
@ -166,7 +169,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
return pth;
|
return pth;
|
||||||
|
|
||||||
int32_t tilestat =
|
int32_t tilestat =
|
||||||
gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (checktintpal > 0) ? 0 : hictinting[dapalnum].f);
|
gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (checktintpal > 0) ? 0 : tintflags);
|
||||||
|
|
||||||
if (!tilestat)
|
if (!tilestat)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue