Remove GrTexInfo

This commit is contained in:
Jaime Passos 2020-07-06 00:35:48 -03:00
parent abeedc4b65
commit ac04853f8c
8 changed files with 114 additions and 117 deletions

View file

@ -292,7 +292,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep; fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y; fixed_t yfracstep, scale_y;
const column_t *patchcol; const column_t *patchcol;
UINT8 *block = mipmap->grInfo.data; UINT8 *block = mipmap->data;
INT32 bpp; INT32 bpp;
INT32 blockmodulo; INT32 blockmodulo;
@ -307,7 +307,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
yfracstep = FRACUNIT; yfracstep = FRACUNIT;
scale_y = FRACUNIT; scale_y = FRACUNIT;
bpp = format2bpp[mipmap->grInfo.format]; bpp = format2bpp[mipmap->format];
if (bpp < 1 || bpp > 4) if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -339,7 +339,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep; fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y; fixed_t yfracstep, scale_y;
const column_t *patchcol; const column_t *patchcol;
UINT8 *block = mipmap->grInfo.data; UINT8 *block = mipmap->data;
INT32 bpp; INT32 bpp;
INT32 blockmodulo; INT32 blockmodulo;
INT32 width, height; INT32 width, height;
@ -400,7 +400,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
yfracstep = (texture->height<< FRACBITS) / pblockheight; yfracstep = (texture->height<< FRACBITS) / pblockheight;
scale_y = (pblockheight << FRACBITS) / texture->height; scale_y = (pblockheight << FRACBITS) / texture->height;
bpp = format2bpp[mipmap->grInfo.format]; bpp = format2bpp[mipmap->format];
if (bpp < 1 || bpp > 4) if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -431,8 +431,8 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX); UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX);
INT32 blocksize = (grMipmap->width * grMipmap->height); INT32 blocksize = (grMipmap->width * grMipmap->height);
bpp = format2bpp[grMipmap->grInfo.format]; bpp = format2bpp[grMipmap->format];
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data)); block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
switch (bpp) switch (bpp)
{ {
@ -483,7 +483,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
grtex->mipmap.width = (UINT16)texture->width; grtex->mipmap.width = (UINT16)texture->width;
grtex->mipmap.height = (UINT16)texture->height; grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.grInfo.format = textureformat; grtex->mipmap.format = textureformat;
blockwidth = texture->width; blockwidth = texture->width;
blockheight = texture->height; blockheight = texture->height;
@ -537,7 +537,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
Z_Unlock(realpatch); Z_Unlock(realpatch);
} }
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp[grtex->mipmap.grInfo.format]==4) if (format2bpp[grtex->mipmap.format]==4)
{ {
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
{ {
@ -581,15 +581,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
// no wrap around, no chroma key // no wrap around, no chroma key
grMipmap->flags = 0; grMipmap->flags = 0;
// setup the texture info // setup the texture info
grMipmap->grInfo.format = patchformat; grMipmap->format = patchformat;
//grPatch->max_s = grPatch->max_t = 1.0f; //grPatch->max_s = grPatch->max_t = 1.0f;
grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; grPatch->max_s = (float)grPatch->width / (float)grMipmap->width;
grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; grPatch->max_t = (float)grPatch->height / (float)grMipmap->height;
} }
Z_Free(grMipmap->grInfo.data); Z_Free(grMipmap->data);
grMipmap->grInfo.data = NULL; grMipmap->data = NULL;
if (makebitmap) if (makebitmap)
{ {
@ -648,9 +648,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
pat->mipmap->nextcolormap = next->nextcolormap; pat->mipmap->nextcolormap = next->nextcolormap;
// Free image data from memory. // Free image data from memory.
if (next->grInfo.data) if (next->data)
Z_Free(next->grInfo.data); Z_Free(next->data);
next->grInfo.data = NULL; next->data = NULL;
// Free the old colormap mipmap from memory. // Free the old colormap mipmap from memory.
free(next); free(next);
@ -736,17 +736,17 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
grtex = &gr_textures[tex]; grtex = &gr_textures[tex];
// Generate texture if missing from the cache // Generate texture if missing from the cache
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_GenerateTexture(tex, grtex); HWR_GenerateTexture(tex, grtex);
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded) if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap); HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap); HWR_SetCurrentTexture(&grtex->mipmap);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
return grtex; return grtex;
} }
@ -756,7 +756,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
size_t size, pflatsize; size_t size, pflatsize;
// setup the texture info // setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_P_8; grMipmap->format = GR_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
size = W_LumpLength(flatlumpnum); size = W_LumpLength(flatlumpnum);
@ -791,7 +791,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
// the flat raw data needn't be converted with palettized textures // the flat raw data needn't be converted with palettized textures
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->grInfo.data)); PU_HWRCACHE, &grMipmap->data));
} }
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
@ -799,13 +799,13 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
UINT8 *flat; UINT8 *flat;
// setup the texture info // setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_P_8; grMipmap->format = GR_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
grMipmap->width = (UINT16)textures[texturenum]->width; grMipmap->width = (UINT16)textures[texturenum]->width;
grMipmap->height = (UINT16)textures[texturenum]->height; grMipmap->height = (UINT16)textures[texturenum]->height;
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data); flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->data);
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height); memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
R_TextureToFlat(texturenum, flat); R_TextureToFlat(texturenum, flat);
@ -819,17 +819,17 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
return; return;
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->data)
HWR_CacheFlat(grmip, flatlumpnum); HWR_CacheFlat(grmip, flatlumpnum);
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded) if (!grmip->downloaded)
HWD.pfnSetTexture(grmip); HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip); HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
} }
void HWR_GetLevelFlat(levelflat_t *levelflat) void HWR_GetLevelFlat(levelflat_t *levelflat)
@ -857,17 +857,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
grtex = &gr_flats[texturenum]; grtex = &gr_flats[texturenum];
// Generate flat if missing from the cache // Generate flat if missing from the cache
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum); HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded) if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap); HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap); HWR_SetCurrentTexture(&grtex->mipmap);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
} }
else // set no texture else // set no texture
HWR_SetCurrentTexture(NULL); HWR_SetCurrentTexture(NULL);
@ -879,7 +879,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
// //
static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
{ {
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->data)
{ {
patch_t *patch = gpatch->rawpatch; patch_t *patch = gpatch->rawpatch;
if (!patch) if (!patch)
@ -895,11 +895,11 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded) if (!grmip->downloaded)
HWD.pfnSetTexture(grmip); HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip); HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
} }
// -----------------+ // -----------------+
@ -908,7 +908,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
void HWR_GetPatch(GLPatch_t *gpatch) void HWR_GetPatch(GLPatch_t *gpatch)
{ {
// is it in hardware cache // is it in hardware cache
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->grInfo.data) if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data)
{ {
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will // load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
// flush the software patch before the conversion! oh yeah I suffered // flush the software patch before the conversion! oh yeah I suffered
@ -930,7 +930,7 @@ void HWR_GetPatch(GLPatch_t *gpatch)
HWR_SetCurrentTexture(gpatch->mipmap); HWR_SetCurrentTexture(gpatch->mipmap);
// The system-memory patch data can be purged now. // The system-memory patch data can be purged now.
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
} }
@ -980,7 +980,7 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
if (!gpatch) if (!gpatch)
return; return;
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED); Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED);
} }
@ -1065,7 +1065,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig
GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
{ {
GLPatch_t *grpatch = HWR_GetCachedGLPatch(lumpnum); GLPatch_t *grpatch = HWR_GetCachedGLPatch(lumpnum);
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{ {
pic_t *pic; pic_t *pic;
UINT8 *block; UINT8 *block;
@ -1083,27 +1083,27 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
grpatch->mipmap->height = (UINT16)grpatch->height; grpatch->mipmap->height = (UINT16)grpatch->height;
if (pic->mode == PALETTE) if (pic->mode == PALETTE)
grpatch->mipmap->grInfo.format = textureformat; // can be set by driver grpatch->mipmap->format = textureformat; // can be set by driver
else else
grpatch->mipmap->grInfo.format = picmode2GR[pic->mode]; grpatch->mipmap->format = picmode2GR[pic->mode];
Z_Free(grpatch->mipmap->grInfo.data); Z_Free(grpatch->mipmap->data);
// allocate block // allocate block
block = MakeBlock(grpatch->mipmap); block = MakeBlock(grpatch->mipmap);
if (grpatch->width == SHORT(pic->width) && if (grpatch->width == SHORT(pic->width) &&
grpatch->height == SHORT(pic->height) && grpatch->height == SHORT(pic->height) &&
format2bpp[grpatch->mipmap->grInfo.format] == format2bpp[picmode2GR[pic->mode]]) format2bpp[grpatch->mipmap->format] == format2bpp[picmode2GR[pic->mode]])
{ {
// no conversion needed // no conversion needed
M_Memcpy(grpatch->mipmap->grInfo.data, pic->data,len); M_Memcpy(grpatch->mipmap->data, pic->data,len);
} }
else else
HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height), HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height),
SHORT(pic->width)*format2bpp[grpatch->mipmap->grInfo.format], SHORT(pic->width)*format2bpp[grpatch->mipmap->format],
pic, pic,
format2bpp[grpatch->mipmap->grInfo.format]); format2bpp[grpatch->mipmap->format]);
Z_Unlock(pic); Z_Unlock(pic);
Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED);
@ -1112,7 +1112,7 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
grpatch->max_s = grpatch->max_t = 1.0f; grpatch->max_s = grpatch->max_t = 1.0f;
} }
HWD.pfnSetTexture(grpatch->mipmap); HWD.pfnSetTexture(grpatch->mipmap);
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.grInfo.data, grpatch->mipmap.downloaded); //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.data, grpatch->mipmap.downloaded);
return grpatch; return grpatch;
} }
@ -1145,7 +1145,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
{ {
INT32 i,j; INT32 i,j;
fixed_t posx, posy, stepx, stepy; fixed_t posx, posy, stepx, stepy;
UINT8 *block = mipmap->grInfo.data; // places the data directly into here UINT8 *block = mipmap->data; // places the data directly into here
UINT8 *flat; UINT8 *flat;
UINT8 *dest, *src, texel; UINT8 *dest, *src, texel;
RGBA_t col; RGBA_t col;
@ -1184,7 +1184,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
UINT16 fmheight = 0, fmwidth = 0; UINT16 fmheight = 0, fmwidth = 0;
// setup the texture info // setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later grMipmap->format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
grMipmap->flags = 0; grMipmap->flags = 0;
size = W_LumpLength(fademasklumpnum); size = W_LumpLength(fademasklumpnum);
@ -1228,13 +1228,13 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
void HWR_GetFadeMask(lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{ {
GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->data)
HWR_CacheFadeMask(grmip, fademasklumpnum); HWR_CacheFadeMask(grmip, fademasklumpnum);
HWD.pfnSetTexture(grmip); HWD.pfnSetTexture(grmip);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
} }
#endif //HWRENDER #endif //HWRENDER

View file

@ -42,17 +42,14 @@ typedef FxI32 GrTextureFormat_t;
#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ #define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */
#define GR_RGBA 0x6 // 32 bit RGBA ! #define GR_RGBA 0x6 // 32 bit RGBA !
typedef struct // data holds the address of the graphics data cached in heap memory
{
GrTextureFormat_t format;
void *data;
} GrTexInfo;
// grInfo.data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache. // NULL if the texture is not in Doom heap cache.
struct GLMipmap_s struct GLMipmap_s
{ {
GrTexInfo grInfo; //for TexDownloadMipMap //for TexDownloadMipMap
GrTextureFormat_t format;
void *data;
FxU32 flags; FxU32 flags;
UINT16 height; UINT16 height;
UINT16 width; UINT16 width;

View file

@ -1229,10 +1229,10 @@ static void HWR_SetLight(void)
{ {
int i, j; int i, j;
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->grInfo.data) if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
{ {
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->grInfo.data); UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
{ {
@ -1245,7 +1245,7 @@ static void HWR_SetLight(void)
Data[i*128+j] = 0; Data[i*128+j] = 0;
} }
} }
lightmappatch.mipmap->grInfo.format = GR_TEXFMT_ALPHA_INTENSITY_88; lightmappatch.mipmap->format = GR_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.width = 128; lightmappatch.width = 128;
lightmappatch.height = 128; lightmappatch.height = 128;
@ -1256,7 +1256,7 @@ static void HWR_SetLight(void)
HWD.pfnSetTexture(lightmappatch.mipmap); HWD.pfnSetTexture(lightmappatch.mipmap);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(lightmappatch.mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(lightmappatch.mipmap->data, PU_HWRCACHE_UNLOCKED);
} }
//********************************************************** //**********************************************************

View file

@ -3327,7 +3327,7 @@ static void HWR_RenderBSPNode(INT32 bspnum)
// Decide which side the view point is on // Decide which side the view point is on
INT32 side; INT32 side;
rs_numbspcalls++; rs_numbspcalls++;
// Found a subsector? // Found a subsector?
@ -3570,7 +3570,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
alpha = 255 - alpha; alpha = 255 - alpha;
gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE); gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE);
if (!(gpatch && gpatch->mipmap->grInfo.format)) return; if (!(gpatch && gpatch->mipmap->format)) return;
HWR_GetPatch(gpatch); HWR_GetPatch(gpatch);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale); scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
@ -4189,7 +4189,7 @@ static int CompareVisSprites(const void *p1, const void *p2)
gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2; gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2;
int idiff; int idiff;
float fdiff; float fdiff;
// Make transparent sprites last. Comment from the previous sort implementation: // Make transparent sprites last. Comment from the previous sort implementation:
// Sryder: Oh boy, while it's nice having ALL the sprites sorted properly, it fails when we bring MD2's into the // Sryder: Oh boy, while it's nice having ALL the sprites sorted properly, it fails when we bring MD2's into the
// mix and they want to be translucent. So let's place all the translucent sprites and MD2's AFTER // mix and they want to be translucent. So let's place all the translucent sprites and MD2's AFTER
@ -4411,7 +4411,7 @@ static void HWR_CreateDrawNodes(void)
// However, in reality we shouldn't be re-copying and shifting all this information // However, in reality we shouldn't be re-copying and shifting all this information
// that is already lying around. This should all be in some sort of linked list or lists. // that is already lying around. This should all be in some sort of linked list or lists.
sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL); sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL);
rs_hw_nodesorttime = I_GetTimeMicros(); rs_hw_nodesorttime = I_GetTimeMicros();
for (i = 0; i < numplanes; i++, p++) for (i = 0; i < numplanes; i++, p++)
@ -4431,7 +4431,7 @@ static void HWR_CreateDrawNodes(void)
sortnode[p].wall = &wallinfo[i]; sortnode[p].wall = &wallinfo[i];
sortindex[p] = p; sortindex[p] = p;
} }
rs_numdrawnodes = p; rs_numdrawnodes = p;
// p is the number of stuff to sort // p is the number of stuff to sort
@ -4468,7 +4468,7 @@ static void HWR_CreateDrawNodes(void)
} }
rs_hw_nodesorttime = I_GetTimeMicros() - rs_hw_nodesorttime; rs_hw_nodesorttime = I_GetTimeMicros() - rs_hw_nodesorttime;
rs_hw_nodedrawtime = I_GetTimeMicros(); rs_hw_nodedrawtime = I_GetTimeMicros();
// Okay! Let's draw it all! Woo! // Okay! Let's draw it all! Woo!
@ -4505,7 +4505,7 @@ static void HWR_CreateDrawNodes(void)
sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap); sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap);
} }
} }
rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime; rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime;
numwalls = 0; numwalls = 0;
@ -5763,7 +5763,7 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_grfiltermode);
CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grcorrecttricks);
CV_RegisterVar(&cv_grsolvetjoin); CV_RegisterVar(&cv_grsolvetjoin);
CV_RegisterVar(&cv_renderstats); CV_RegisterVar(&cv_renderstats);
CV_RegisterVar(&cv_grbatching); CV_RegisterVar(&cv_grbatching);

View file

@ -191,7 +191,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename); //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE); fclose(png_FILE);
Z_Free(grpatch->mipmap->grInfo.data); Z_Free(grpatch->mipmap->data);
return 0; return 0;
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@ -232,7 +232,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
{ {
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr); png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep)); png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch; row_pointers[i] = PNG_image + i*pitch;
@ -306,7 +306,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1; pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 1; ph = *h = header.ymax - header.ymin + 1;
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE) if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{ {
@ -354,7 +354,7 @@ static void md2_loadTexture(md2_t *model)
if (model->grpatch) if (model->grpatch)
{ {
grpatch = model->grpatch; grpatch = model->grpatch;
Z_Free(grpatch->mipmap->grInfo.data); Z_Free(grpatch->mipmap->data);
} }
else else
{ {
@ -363,18 +363,18 @@ static void md2_loadTexture(md2_t *model)
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
} }
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{ {
int w = 0, h = 0; int w = 0, h = 0;
UINT32 size; UINT32 size;
RGBA_t *image; RGBA_t *image;
#ifdef HAVE_PNG #ifdef HAVE_PNG
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0) if (grpatch->mipmap->format == 0)
#endif #endif
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0) if (grpatch->mipmap->format == 0)
{ {
model->notexturefile = true; // mark it so its not searched for again repeatedly model->notexturefile = true; // mark it so its not searched for again repeatedly
return; return;
@ -389,7 +389,7 @@ static void md2_loadTexture(md2_t *model)
grpatch->mipmap->height = (UINT16)h; grpatch->mipmap->height = (UINT16)h;
// Lactozilla: Apply colour cube // Lactozilla: Apply colour cube
image = grpatch->mipmap->grInfo.data; image = grpatch->mipmap->data;
size = w*h; size = w*h;
while (size--) while (size--)
{ {
@ -414,7 +414,7 @@ static void md2_loadBlendTexture(md2_t *model)
if (model->blendgrpatch) if (model->blendgrpatch)
{ {
grpatch = model->blendgrpatch; grpatch = model->blendgrpatch;
Z_Free(grpatch->mipmap->grInfo.data); Z_Free(grpatch->mipmap->data);
} }
else else
{ {
@ -423,15 +423,15 @@ static void md2_loadBlendTexture(md2_t *model)
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
} }
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{ {
int w = 0, h = 0; int w = 0, h = 0;
#ifdef HAVE_PNG #ifdef HAVE_PNG
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0) if (grpatch->mipmap->format == 0)
#endif #endif
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0) if (grpatch->mipmap->format == 0)
{ {
model->noblendfile = true; // mark it so its not searched for again repeatedly model->noblendfile = true; // mark it so its not searched for again repeatedly
Z_Free(filename); Z_Free(filename);
@ -686,20 +686,20 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
// no wrap around, no chroma key // no wrap around, no chroma key
grmip->flags = 0; grmip->flags = 0;
// setup the texture info // setup the texture info
grmip->grInfo.format = GR_RGBA; grmip->format = GR_RGBA;
} }
if (grmip->grInfo.data) if (grmip->data)
{ {
Z_Free(grmip->grInfo.data); Z_Free(grmip->data);
grmip->grInfo.data = NULL; grmip->data = NULL;
} }
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->grInfo.data); cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->data);
memset(cur, 0x00, size*4); memset(cur, 0x00, size*4);
image = gpatch->mipmap->grInfo.data; image = gpatch->mipmap->data;
blendimage = blendgpatch->mipmap->grInfo.data; blendimage = blendgpatch->mipmap->data;
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing. // TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
if (skinnum == TC_METALSONIC) if (skinnum == TC_METALSONIC)
@ -1050,7 +1050,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
return; return;
} }
if ((blendgpatch && blendgpatch->mipmap->grInfo.format) if ((blendgpatch && blendgpatch->mipmap->format)
&& (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height))
{ {
// Blend image exists, but it's bad. // Blend image exists, but it's bad.
@ -1065,10 +1065,10 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
grmip = grmip->nextcolormap; grmip = grmip->nextcolormap;
if (grmip->colormap == colormap) if (grmip->colormap == colormap)
{ {
if (grmip->downloaded && grmip->grInfo.data) if (grmip->downloaded && grmip->data)
{ {
HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture
Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); Z_ChangeTag(grmip->data, PU_HWRMODELTEXTURE_UNLOCKED);
return; return;
} }
} }
@ -1090,7 +1090,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color); HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
HWD.pfnSetTexture(newmip); HWD.pfnSetTexture(newmip);
Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); Z_ChangeTag(newmip->data, PU_HWRMODELTEXTURE_UNLOCKED);
} }
#define NORMALFOG 0x00000000 #define NORMALFOG 0x00000000
@ -1307,17 +1307,17 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
finalscale = md2->scale; finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy //Hurdler: arf, I don't like that implementation at all... too much crappy
gpatch = md2->grpatch; gpatch = md2->grpatch;
if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !md2->notexturefile))
md2_loadTexture(md2); md2_loadTexture(md2);
gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available
&& (!md2->blendgrpatch && (!md2->blendgrpatch
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)
&& !md2->noblendfile))) && !md2->noblendfile)))
md2_loadBlendTexture(md2); md2_loadBlendTexture(md2);
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
{ {
INT32 skinnum = TC_DEFAULT; INT32 skinnum = TC_DEFAULT;

View file

@ -1657,15 +1657,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
else else
texnum = pTexInfo->downloaded; texnum = pTexInfo->downloaded;
//GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data); //GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->data);
w = pTexInfo->width; w = pTexInfo->width;
h = pTexInfo->height; h = pTexInfo->height;
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || if ((pTexInfo->format == GR_TEXFMT_P_8) ||
(pTexInfo->grInfo.format == GR_TEXFMT_AP_88)) (pTexInfo->format == GR_TEXFMT_AP_88))
{ {
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j; INT32 i, j;
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
@ -1691,7 +1691,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pImgData++; pImgData++;
if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88) if (pTexInfo->format == GR_TEXFMT_AP_88)
{ {
if (!(pTexInfo->flags & TF_CHROMAKEYED)) if (!(pTexInfo->flags & TF_CHROMAKEYED))
tex[w*j+i].s.alpha = *pImgData; tex[w*j+i].s.alpha = *pImgData;
@ -1701,15 +1701,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
} }
} }
} }
else if (pTexInfo->grInfo.format == GR_RGBA) else if (pTexInfo->format == GR_RGBA)
{ {
// corona test : passed as ARGB 8888, which is not in glide formats // corona test : passed as ARGB 8888, which is not in glide formats
// Hurdler: not used for coronas anymore, just for dynamic lighting // Hurdler: not used for coronas anymore, just for dynamic lighting
ptex = pTexInfo->grInfo.data; ptex = pTexInfo->data;
} }
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) else if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88)
{ {
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j; INT32 i, j;
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
@ -1725,9 +1725,9 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
} }
} }
} }
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks else if (pTexInfo->format == GR_TEXFMT_ALPHA_8) // Used for fade masks
{ {
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j; INT32 i, j;
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
@ -1743,7 +1743,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
} }
} }
else else
GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format); GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->format);
// the texture number was already generated by pglGenTextures // the texture number was already generated by pglGenTextures
pglBindTexture(GL_TEXTURE_2D, texnum); pglBindTexture(GL_TEXTURE_2D, texnum);
@ -1761,7 +1761,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
} }
if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88)
{ {
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap) if (MipMap)
@ -1782,7 +1782,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
} }
} }
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) else if (pTexInfo->format == GR_TEXFMT_ALPHA_8)
{ {
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap) if (MipMap)
@ -2968,7 +2968,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void)
// I don't know which one the game actually _uses_ but this // I don't know which one the game actually _uses_ but this
// follows format2bpp in hw_cache.c // follows format2bpp in hw_cache.c
int bpp = 1; int bpp = 1;
int format = tmp->grInfo.format; int format = tmp->format;
if (format == GR_RGBA) if (format == GR_RGBA)
bpp = 4; bpp = 4;
else if (format == GR_TEXFMT_RGB_565 else if (format == GR_TEXFMT_RGB_565

View file

@ -1426,10 +1426,10 @@ void R_FreeSingleRotSprite(spritedef_t *spritedef)
} }
if (grPatch->mipmap) if (grPatch->mipmap)
{ {
if (grPatch->mipmap->grInfo.data) if (grPatch->mipmap->data)
{ {
Z_Free(grPatch->mipmap->grInfo.data); Z_Free(grPatch->mipmap->data);
grPatch->mipmap->grInfo.data = NULL; grPatch->mipmap->data = NULL;
} }
Z_Free(grPatch->mipmap); Z_Free(grPatch->mipmap);
grPatch->mipmap = NULL; grPatch->mipmap = NULL;

View file

@ -1732,11 +1732,11 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
grPatch = HWR_GetCachedGLPatchPwad(wad, lump); grPatch = HWR_GetCachedGLPatchPwad(wad, lump);
if (grPatch->mipmap->grInfo.data) if (grPatch->mipmap->data)
{ {
if (tag == PU_CACHE) if (tag == PU_CACHE)
tag = PU_HWRCACHE; tag = PU_HWRCACHE;
Z_ChangeTag(grPatch->mipmap->grInfo.data, tag); Z_ChangeTag(grPatch->mipmap->data, tag);
} }
else else
{ {