mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Polymost: Allow compressed ART tiles (r_texcompr 2) to be cached.
git-svn-id: https://svn.eduke32.com/eduke32@5713 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b40f9b5b80
commit
868306abef
3 changed files with 48 additions and 4 deletions
|
@ -69,6 +69,8 @@ enum
|
||||||
CACHEAD_HASALPHA = 2,
|
CACHEAD_HASALPHA = 2,
|
||||||
CACHEAD_COMPRESSED = 4,
|
CACHEAD_COMPRESSED = 4,
|
||||||
CACHEAD_NODOWNSIZE = 8,
|
CACHEAD_NODOWNSIZE = 8,
|
||||||
|
CACHEAD_HASFULLBRIGHT = 16,
|
||||||
|
CACHEAD_NPOTWALL = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
// hicreplctyp hicr->flags bits
|
// hicreplctyp hicr->flags bits
|
||||||
|
|
|
@ -162,6 +162,9 @@ enum {
|
||||||
DAMETH_ONEBITALPHA = 131072,
|
DAMETH_ONEBITALPHA = 131072,
|
||||||
DAMETH_ARTIMMUNITY = 262144,
|
DAMETH_ARTIMMUNITY = 262144,
|
||||||
|
|
||||||
|
DAMETH_HASFULLBRIGHT = 524288,
|
||||||
|
DAMETH_NPOTWALL = 1048576,
|
||||||
|
|
||||||
DAMETH_UPLOADTEXTURE_MASK =
|
DAMETH_UPLOADTEXTURE_MASK =
|
||||||
DAMETH_HI |
|
DAMETH_HI |
|
||||||
DAMETH_NODOWNSIZE |
|
DAMETH_NODOWNSIZE |
|
||||||
|
@ -169,7 +172,9 @@ enum {
|
||||||
DAMETH_NOTEXCOMPRESS |
|
DAMETH_NOTEXCOMPRESS |
|
||||||
DAMETH_HASALPHA |
|
DAMETH_HASALPHA |
|
||||||
DAMETH_ONEBITALPHA |
|
DAMETH_ONEBITALPHA |
|
||||||
DAMETH_ARTIMMUNITY,
|
DAMETH_ARTIMMUNITY |
|
||||||
|
DAMETH_HASFULLBRIGHT |
|
||||||
|
DAMETH_NPOTWALL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
||||||
|
|
|
@ -1031,9 +1031,29 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
||||||
{
|
{
|
||||||
static int32_t fullbrightloadingpass = 0;
|
static int32_t fullbrightloadingpass = 0;
|
||||||
vec2_t siz = { 0, 0 }, tsiz = tilesiz[dapic];
|
vec2_t siz = { 0, 0 }, tsiz = tilesiz[dapic];
|
||||||
|
size_t const picdim = tsiz.x*tsiz.y;
|
||||||
char hasalpha = 0, hasfullbright = 0;
|
char hasalpha = 0, hasfullbright = 0;
|
||||||
int32_t npoty = 0;
|
char npoty = 0;
|
||||||
|
|
||||||
|
texcacheheader cachead;
|
||||||
|
char texcacheid[BMAX_PATH];
|
||||||
|
{
|
||||||
|
// Absolutely disgusting.
|
||||||
|
uint32_t firstint = 0;
|
||||||
|
if (waloff[dapic])
|
||||||
|
Bmemcpy(&firstint, (void *)waloff[dapic], min(4, picdim));
|
||||||
|
sprintf(texcacheid, "%08x", firstint);
|
||||||
|
}
|
||||||
|
texcache_calcid(texcacheid, texcacheid, picdim | ((unsigned)dapal<<24u), DAMETH_NARROW_MASKPROPS(dameth) | ((unsigned)dapic<<8u) | ((unsigned)dashade<<24u), tintpalnum);
|
||||||
|
int32_t gotcache = texcache_readtexheader(texcacheid, &cachead, 0);
|
||||||
|
|
||||||
|
if (gotcache && !texcache_loadtile(&cachead, &doalloc, pth))
|
||||||
|
{
|
||||||
|
hasalpha = !!(cachead.flags & CACHEAD_HASALPHA);
|
||||||
|
hasfullbright = !!(cachead.flags & CACHEAD_HASFULLBRIGHT);
|
||||||
|
npoty = !!(cachead.flags & CACHEAD_NPOTWALL);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!glinfo.texnpot)
|
if (!glinfo.texnpot)
|
||||||
{
|
{
|
||||||
|
@ -1180,12 +1200,14 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
||||||
Bmemcpy(&pic[siz.x * siz.y], pic, siz.x * ydif * sizeof(coltype));
|
Bmemcpy(&pic[siz.x * siz.y], pic, siz.x * ydif * sizeof(coltype));
|
||||||
siz.y = tsiz.y = nextpoty;
|
siz.y = tsiz.y = nextpoty;
|
||||||
|
|
||||||
npoty = PTH_NPOTWALL;
|
npoty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadtexture(doalloc, siz, GL_RGBA, pic, tsiz,
|
uploadtexture(doalloc, siz, GL_RGBA, pic, tsiz,
|
||||||
dameth | DAMETH_ARTIMMUNITY |
|
dameth | DAMETH_ARTIMMUNITY |
|
||||||
(dapic >= MAXUSERTILES ? (DAMETH_NOTEXCOMPRESS|DAMETH_NODOWNSIZE) : 0) | /* never process these short-lived tiles */
|
(dapic >= MAXUSERTILES ? (DAMETH_NOTEXCOMPRESS|DAMETH_NODOWNSIZE) : 0) | /* never process these short-lived tiles */
|
||||||
|
(hasfullbright ? DAMETH_HASFULLBRIGHT : 0) |
|
||||||
|
(npoty ? DAMETH_NPOTWALL : 0) |
|
||||||
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
|
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
|
||||||
|
|
||||||
Bfree(pic);
|
Bfree(pic);
|
||||||
|
@ -1197,9 +1219,24 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
||||||
pth->palnum = dapal;
|
pth->palnum = dapal;
|
||||||
pth->shade = dashade;
|
pth->shade = dashade;
|
||||||
pth->effects = 0;
|
pth->effects = 0;
|
||||||
pth->flags = TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) | (hasalpha*PTH_HASALPHA) | npoty;
|
pth->flags = TO_PTH_CLAMPED(dameth) | TO_PTH_NOTRANSFIX(dameth) | (hasalpha*PTH_HASALPHA) | (npoty*PTH_NPOTWALL);
|
||||||
pth->hicr = NULL;
|
pth->hicr = NULL;
|
||||||
|
|
||||||
|
#if defined USE_GLEXT && !defined EDUKE32_GLES
|
||||||
|
if (!gotcache && glinfo.texcompr && glusetexcache && glusetexcompr == 2 && dapic < MAXUSERTILES)
|
||||||
|
{
|
||||||
|
cachead.quality = 0;
|
||||||
|
cachead.xdim = tsiz.x;
|
||||||
|
cachead.ydim = tsiz.y;
|
||||||
|
|
||||||
|
cachead.flags = (check_nonpow2(siz.x) || check_nonpow2(siz.y)) * CACHEAD_NONPOW2 |
|
||||||
|
npoty * CACHEAD_NPOTWALL |
|
||||||
|
hasalpha * CACHEAD_HASALPHA | hasfullbright * CACHEAD_HASFULLBRIGHT | CACHEAD_NODOWNSIZE;
|
||||||
|
|
||||||
|
texcache_writetex_fromdriver(texcacheid, &cachead);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hasfullbright && !fullbrightloadingpass)
|
if (hasfullbright && !fullbrightloadingpass)
|
||||||
{
|
{
|
||||||
// Load the ONLY texture that'll be assembled with the regular one to
|
// Load the ONLY texture that'll be assembled with the regular one to
|
||||||
|
|
Loading…
Reference in a new issue