Polymost: Add HICR_ARTIMMUNITY and DAMETH_ARTIMMUNITY, which currently function identically to NOTEXCOMPRESS and NODOWNSIZE combined, and are only used when:

1. Using an ART tile
2. Using a hightile defined through the tilefromtexture "texture" subtoken
3. Using a hightile that, if downsized, will be smaller than the ART tile for that tilenum (tenuous)

git-svn-id: https://svn.eduke32.com/eduke32@5647 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-03-07 11:21:55 +00:00
parent 97219ea3e6
commit 7dd054069f
6 changed files with 24 additions and 15 deletions

View file

@ -78,6 +78,7 @@ enum
HICR_FORCEFILTER = 2,
HICR_NODOWNSIZE = 16,
HICR_ARTIMMUNITY = 32,
};
// hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits

View file

@ -160,6 +160,9 @@ enum {
DAMETH_NOTEXCOMPRESS = 32768,
DAMETH_HASALPHA = 65536,
DAMETH_ONEBITALPHA = 131072,
DAMETH_ARTIMMUNITY = 262144,
DAMETH_UPLOADTEXTURE_MASK = DAMETH_HI|DAMETH_NODOWNSIZE|DAMETH_NOFIX|DAMETH_NOTEXCOMPRESS|DAMETH_HASALPHA|DAMETH_ONEBITALPHA|DAMETH_ARTIMMUNITY,
};
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
@ -170,6 +173,8 @@ EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_CLAMPED) == DAMETH_CLAMPED)
EDUKE32_STATIC_ASSERT(TO_DAMETH_NODOWNSIZE(HICR_NODOWNSIZE) == DAMETH_NODOWNSIZE);
#define TO_DAMETH_NOTEXCOMPRESS(hicr_flags) (((hicr_flags)&HICR_NOTEXCOMPRESS)<<15)
EDUKE32_STATIC_ASSERT(TO_DAMETH_NOTEXCOMPRESS(HICR_NOTEXCOMPRESS) == DAMETH_NOTEXCOMPRESS);
#define TO_DAMETH_ARTIMMUNITY(hicr_flags) (((hicr_flags)&HICR_ARTIMMUNITY)<<13)
EDUKE32_STATIC_ASSERT(TO_DAMETH_ARTIMMUNITY(HICR_ARTIMMUNITY) == DAMETH_ARTIMMUNITY);
// Do we want a NPOT-y-as-classic texture for this <dameth> and <ysiz>?
static inline int polymost_want_npotytex(int32_t dameth, int32_t ysiz)

View file

@ -279,7 +279,7 @@ static int32_t Defs_ImportTileFromTexture(char const * const fn, int32_t const t
#ifdef USE_OPENGL
if (istexture)
hicsetsubsttex(tile, 0, fn, (float)(255-alphacut) * (1.f/255.f), 1.0f, 1.0f, 1.0f, 1.0f, HICR_NOTEXCOMPRESS|HICR_NODOWNSIZE);
hicsetsubsttex(tile, 0, fn, (float)(255-alphacut) * (1.f/255.f), 1.0f, 1.0f, 1.0f, 1.0f, HICR_ARTIMMUNITY);
#endif
return 1;
@ -299,7 +299,7 @@ static int32_t Defs_ImportTileFromTexture(char const * const fn, int32_t const t
#ifdef USE_OPENGL
if (istexture)
hicsetsubsttex(tile, 0, fn, (float)(255-alphacut) * (1.f/255.f), 1.0f, 1.0f, 1.0, 1.0, HICR_NOTEXCOMPRESS|HICR_NODOWNSIZE);
hicsetsubsttex(tile, 0, fn, (float)(255-alphacut) * (1.f/255.f), 1.0f, 1.0f, 1.0, 1.0, HICR_ARTIMMUNITY);
#else
UNREFERENCED_PARAMETER(istexture);
#endif

View file

@ -906,6 +906,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
DAMETH_HI | DAMETH_MASK |
TO_DAMETH_NODOWNSIZE(sk->flags) |
TO_DAMETH_NOTEXCOMPRESS(sk->flags) |
TO_DAMETH_ARTIMMUNITY(sk->flags) |
(hasalpha ? DAMETH_HASALPHA : 0));
Bfree(pic);
@ -959,17 +960,17 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
if (glinfo.texcompr && glusetexcompr && glusetexcache)
if (!gotcache && !(sk->flags & HICR_NOTEXCOMPRESS))
if (!gotcache && !(sk->flags & HICR_NOTEXCOMPRESS) && !(sk->flags & HICR_ARTIMMUNITY))
{
const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
// save off the compressed version
cachead.quality = (sk->flags & HICR_NODOWNSIZE) ? 0 : r_downsize;
cachead.quality = (sk->flags & (HICR_NODOWNSIZE|HICR_ARTIMMUNITY)) ? 0 : r_downsize;
cachead.xdim = tsiz.x>>cachead.quality;
cachead.ydim = tsiz.y>>cachead.quality;
cachead.flags = nonpow2*CACHEAD_NONPOW2 | (hasalpha ? CACHEAD_HASALPHA : 0) |
(sk->flags & HICR_NODOWNSIZE ? CACHEAD_NODOWNSIZE : 0);
(sk->flags & (HICR_NODOWNSIZE|HICR_ARTIMMUNITY) ? CACHEAD_NODOWNSIZE : 0);
/// OSD_Printf("Caching \"%s\"\n",fn);
texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead);

View file

@ -673,13 +673,14 @@ static int32_t polymost_glTexImage2D_error(int32_t * intexfmt, int32_t const **i
void uploadtexture(int32_t doalloc, vec2_t siz, int32_t texfmt,
coltype *pic, vec2_t tsiz, int32_t dameth)
{
const int artimmunity = !!(dameth & DAMETH_ARTIMMUNITY);
const int hi = !!(dameth & DAMETH_HI);
const int nodownsize = !!(dameth & DAMETH_NODOWNSIZE);
const int nodownsize = !!(dameth & DAMETH_NODOWNSIZE) || artimmunity;
const int nomiptransfix = !!(dameth & DAMETH_NOFIX);
const int hasalpha = !!(dameth & DAMETH_HASALPHA) && (dameth & DAMETH_MASKPROPS) != DAMETH_NOMASK;
#if !defined EDUKE32_GLES
const int texcompress_ok = !(dameth & DAMETH_NOTEXCOMPRESS);
const int texcompress_ok = !(dameth & DAMETH_NOTEXCOMPRESS) && !artimmunity;
int32_t intexfmt;
if (glinfo.texcompr && glusetexcompr && texcompress_ok)
@ -693,7 +694,7 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t texfmt,
int32_t intexfmt = **intexfmt_master;
#endif
dameth &= ~(DAMETH_HI|DAMETH_NODOWNSIZE|DAMETH_NOFIX|DAMETH_NOTEXCOMPRESS|DAMETH_HASALPHA|DAMETH_ONEBITALPHA);
dameth &= ~DAMETH_UPLOADTEXTURE_MASK;
if (gltexmaxsize <= 0)
{
@ -1002,7 +1003,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
}
uploadtexture(doalloc, siz, GL_RGBA, pic, tsiz,
dameth | DAMETH_NOFIX | DAMETH_NOTEXCOMPRESS |
dameth | DAMETH_ARTIMMUNITY |
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
Bfree(pic);
@ -1267,7 +1268,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
// end CODEDUP
if (tsiz.x>>r_downsize <= tilesiz[dapic].x || tsiz.y>>r_downsize <= tilesiz[dapic].y)
hicr->flags |= (HICR_NODOWNSIZE + HICR_NOTEXCOMPRESS);
hicr->flags |= HICR_ARTIMMUNITY;
if ((doalloc&3)==1)
bglGenTextures(1, &pth->glpic); //# of textures (make OpenGL allocate structure)
@ -1281,6 +1282,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
dameth | DAMETH_HI | DAMETH_NOFIX |
TO_DAMETH_NODOWNSIZE(hicr->flags) |
TO_DAMETH_NOTEXCOMPRESS(hicr->flags) |
TO_DAMETH_ARTIMMUNITY(hicr->flags) |
(hasalpha ? DAMETH_HASALPHA : 0));
Bfree(pic);
@ -1301,7 +1303,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
polymost_setuptexture(dameth, hicr->flags & HICR_FORCEFILTER ? TEXFILTER_ON : -1);
if (tsiz.x>>r_downsize <= tilesiz[dapic].x || tsiz.y>>r_downsize <= tilesiz[dapic].y)
hicr->flags |= HICR_NODOWNSIZE | HICR_NOTEXCOMPRESS;
hicr->flags |= HICR_ARTIMMUNITY;
pth->picnum = dapic;
pth->effects = effect;
@ -1312,18 +1314,18 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
pth->skyface = facen;
pth->hicr = hicr;
if (!gotcache && glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & HICR_NOTEXCOMPRESS))
if (!gotcache && glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & HICR_NOTEXCOMPRESS) && !(hicr->flags & HICR_ARTIMMUNITY))
{
const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
// save off the compressed version
cachead.quality = (hicr->flags & HICR_NODOWNSIZE) ? 0 : r_downsize;
cachead.quality = (hicr->flags & (HICR_NODOWNSIZE|HICR_ARTIMMUNITY)) ? 0 : r_downsize;
cachead.xdim = tsiz.x >> cachead.quality;
cachead.ydim = tsiz.y >> cachead.quality;
// handle nodownsize:
cachead.flags = nonpow2 * CACHEAD_NONPOW2 | (hasalpha ? CACHEAD_HASALPHA : 0) |
(hicr->flags & HICR_NODOWNSIZE ? CACHEAD_NODOWNSIZE : 0);
(hicr->flags & (HICR_NODOWNSIZE|HICR_ARTIMMUNITY) ? CACHEAD_NODOWNSIZE : 0);
/// OSD_Printf("Caching \"%s\"\n", fn);
texcache_writetex(fn, picfillen + (dapalnum << 8), dameth, effect, &cachead);

View file

@ -507,7 +507,7 @@ int32_t texcache_readtexheader(const char *fn, int32_t len, int32_t dameth, char
if (!(head->flags & CACHEAD_COMPRESSED) && glusetexcache == 2)
READTEXHEADER_FAILURE(4);
// handle nocompress
// handle nodownsize
if (!modelp && !(head->flags & CACHEAD_NODOWNSIZE) && head->quality != r_downsize)
return 0;