From ac04853f8c1aedde657885cfa9c8f6fb495c6c7e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 00:35:48 -0300 Subject: [PATCH] Remove GrTexInfo --- src/hardware/hw_cache.c | 92 ++++++++++++++++---------------- src/hardware/hw_data.h | 13 ++--- src/hardware/hw_light.c | 8 +-- src/hardware/hw_main.c | 16 +++--- src/hardware/hw_md2.c | 62 ++++++++++----------- src/hardware/r_opengl/r_opengl.c | 30 +++++------ src/r_patch.c | 6 +-- src/w_wad.c | 4 +- 8 files changed, 114 insertions(+), 117 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ab9a50dd5..1e63acf78 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -292,7 +292,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, fixed_t xfrac, xfracstep; fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = mipmap->grInfo.data; + UINT8 *block = mipmap->data; INT32 bpp; INT32 blockmodulo; @@ -307,7 +307,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, yfracstep = FRACUNIT; scale_y = FRACUNIT; - bpp = format2bpp[mipmap->grInfo.format]; + bpp = format2bpp[mipmap->format]; if (bpp < 1 || bpp > 4) 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 yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = mipmap->grInfo.data; + UINT8 *block = mipmap->data; INT32 bpp; INT32 blockmodulo; INT32 width, height; @@ -400,7 +400,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, yfracstep = (texture->height<< FRACBITS) / pblockheight; scale_y = (pblockheight << FRACBITS) / texture->height; - bpp = format2bpp[mipmap->grInfo.format]; + bpp = format2bpp[mipmap->format]; if (bpp < 1 || bpp > 4) 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); INT32 blocksize = (grMipmap->width * grMipmap->height); - bpp = format2bpp[grMipmap->grInfo.format]; - block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data)); + bpp = format2bpp[grMipmap->format]; + block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data)); switch (bpp) { @@ -483,7 +483,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.width = (UINT16)texture->width; grtex->mipmap.height = (UINT16)texture->height; - grtex->mipmap.grInfo.format = textureformat; + grtex->mipmap.format = textureformat; blockwidth = texture->width; blockheight = texture->height; @@ -537,7 +537,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) Z_Unlock(realpatch); } //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 { @@ -581,15 +581,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // no wrap around, no chroma key grMipmap->flags = 0; // setup the texture info - grMipmap->grInfo.format = patchformat; + grMipmap->format = patchformat; //grPatch->max_s = grPatch->max_t = 1.0f; grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; } - Z_Free(grMipmap->grInfo.data); - grMipmap->grInfo.data = NULL; + Z_Free(grMipmap->data); + grMipmap->data = NULL; if (makebitmap) { @@ -648,9 +648,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. - if (next->grInfo.data) - Z_Free(next->grInfo.data); - next->grInfo.data = NULL; + if (next->data) + Z_Free(next->data); + next->data = NULL; // Free the old colormap mipmap from memory. free(next); @@ -736,17 +736,17 @@ GLTexture_t *HWR_GetTexture(INT32 tex) grtex = &gr_textures[tex]; // 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); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // 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; } @@ -756,7 +756,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) size_t size, pflatsize; // setup the texture info - grMipmap->grInfo.format = GR_TEXFMT_P_8; + grMipmap->format = GR_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; 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 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) @@ -799,13 +799,13 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) UINT8 *flat; // setup the texture info - grMipmap->grInfo.format = GR_TEXFMT_P_8; + grMipmap->format = GR_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; grMipmap->width = (UINT16)textures[texturenum]->width; 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); R_TextureToFlat(texturenum, flat); @@ -819,17 +819,17 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) return; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; - if (!grmip->downloaded && !grmip->grInfo.data) + if (!grmip->downloaded && !grmip->data) HWR_CacheFlat(grmip, flatlumpnum); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - + HWR_SetCurrentTexture(grmip); // 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) @@ -857,17 +857,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) grtex = &gr_flats[texturenum]; // 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); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // 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 HWR_SetCurrentTexture(NULL); @@ -879,7 +879,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) // 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; 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 (!grmip->downloaded) HWD.pfnSetTexture(grmip); - + HWR_SetCurrentTexture(grmip); // 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) { // 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 // 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); // 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) return; - Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_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 *grpatch = HWR_GetCachedGLPatch(lumpnum); - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) { pic_t *pic; UINT8 *block; @@ -1083,27 +1083,27 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) grpatch->mipmap->height = (UINT16)grpatch->height; if (pic->mode == PALETTE) - grpatch->mipmap->grInfo.format = textureformat; // can be set by driver + grpatch->mipmap->format = textureformat; // can be set by driver 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 block = MakeBlock(grpatch->mipmap); if (grpatch->width == SHORT(pic->width) && 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 - M_Memcpy(grpatch->mipmap->grInfo.data, pic->data,len); + M_Memcpy(grpatch->mipmap->data, pic->data,len); } else 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, - format2bpp[grpatch->mipmap->grInfo.format]); + format2bpp[grpatch->mipmap->format]); Z_Unlock(pic); 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; } 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; } @@ -1145,7 +1145,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 { INT32 i,j; 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 *dest, *src, texel; RGBA_t col; @@ -1184,7 +1184,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) UINT16 fmheight = 0, fmwidth = 0; // 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; size = W_LumpLength(fademasklumpnum); @@ -1228,13 +1228,13 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; - if (!grmip->downloaded && !grmip->grInfo.data) + if (!grmip->downloaded && !grmip->data) HWR_CacheFadeMask(grmip, fademasklumpnum); HWD.pfnSetTexture(grmip); // 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 diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 6dc26948f..9cd929e1e 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -42,17 +42,14 @@ typedef FxI32 GrTextureFormat_t; #define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ #define GR_RGBA 0x6 // 32 bit RGBA ! -typedef struct -{ - GrTextureFormat_t format; - void *data; -} GrTexInfo; - -// grInfo.data holds the address of the graphics data cached in heap memory +// data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s { - GrTexInfo grInfo; //for TexDownloadMipMap + //for TexDownloadMipMap + GrTextureFormat_t format; + void *data; + FxU32 flags; UINT16 height; UINT16 width; diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index a685994cc..a7e815730 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -1229,10 +1229,10 @@ static void HWR_SetLight(void) { 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++) { @@ -1245,7 +1245,7 @@ static void HWR_SetLight(void) 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.height = 128; @@ -1256,7 +1256,7 @@ static void HWR_SetLight(void) HWD.pfnSetTexture(lightmappatch.mipmap); // 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); } //********************************************************** diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f07cb24d8..98a92768c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3327,7 +3327,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on INT32 side; - + rs_numbspcalls++; // Found a subsector? @@ -3570,7 +3570,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) alpha = 255 - alpha; gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE); - if (!(gpatch && gpatch->mipmap->grInfo.format)) return; + if (!(gpatch && gpatch->mipmap->format)) return; HWR_GetPatch(gpatch); 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; int idiff; float fdiff; - + // 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 // 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 // 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); - + rs_hw_nodesorttime = I_GetTimeMicros(); for (i = 0; i < numplanes; i++, p++) @@ -4431,7 +4431,7 @@ static void HWR_CreateDrawNodes(void) sortnode[p].wall = &wallinfo[i]; sortindex[p] = p; } - + rs_numdrawnodes = p; // 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_nodedrawtime = I_GetTimeMicros(); // 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); } } - + rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime; numwalls = 0; @@ -5763,7 +5763,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grsolvetjoin); - + CV_RegisterVar(&cv_renderstats); CV_RegisterVar(&cv_grbatching); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f5df49bcd..b5a00a785 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -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); png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); fclose(png_FILE); - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); return 0; } #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_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)); for (i = 0; i < height; i++) 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; 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) { @@ -354,7 +354,7 @@ static void md2_loadTexture(md2_t *model) if (model->grpatch) { grpatch = model->grpatch; - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); } else { @@ -363,18 +363,18 @@ static void md2_loadTexture(md2_t *model) 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; UINT32 size; RGBA_t *image; #ifdef HAVE_PNG - grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) #endif - grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) { model->notexturefile = true; // mark it so its not searched for again repeatedly return; @@ -389,7 +389,7 @@ static void md2_loadTexture(md2_t *model) grpatch->mipmap->height = (UINT16)h; // Lactozilla: Apply colour cube - image = grpatch->mipmap->grInfo.data; + image = grpatch->mipmap->data; size = w*h; while (size--) { @@ -414,7 +414,7 @@ static void md2_loadBlendTexture(md2_t *model) if (model->blendgrpatch) { grpatch = model->blendgrpatch; - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); } else { @@ -423,15 +423,15 @@ static void md2_loadBlendTexture(md2_t *model) 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; #ifdef HAVE_PNG - grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) #endif - grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) { model->noblendfile = true; // mark it so its not searched for again repeatedly Z_Free(filename); @@ -686,20 +686,20 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // no wrap around, no chroma key grmip->flags = 0; // 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); - grmip->grInfo.data = NULL; + Z_Free(grmip->data); + 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); - image = gpatch->mipmap->grInfo.data; - blendimage = blendgpatch->mipmap->grInfo.data; + image = gpatch->mipmap->data; + blendimage = blendgpatch->mipmap->data; // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. if (skinnum == TC_METALSONIC) @@ -1050,7 +1050,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT return; } - if ((blendgpatch && blendgpatch->mipmap->grInfo.format) + if ((blendgpatch && blendgpatch->mipmap->format) && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) { // 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; 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 - Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); + Z_ChangeTag(grmip->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } } @@ -1090,7 +1090,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color); HWD.pfnSetTexture(newmip); - Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); + Z_ChangeTag(newmip->data, PU_HWRMODELTEXTURE_UNLOCKED); } #define NORMALFOG 0x00000000 @@ -1307,17 +1307,17 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) finalscale = md2->scale; //Hurdler: arf, I don't like that implementation at all... too much crappy 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); 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 - || ((!((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_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; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e5f6ff3cf..7abd98fba 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1657,15 +1657,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) else 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; h = pTexInfo->height; - if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || - (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)) + if ((pTexInfo->format == GR_TEXFMT_P_8) || + (pTexInfo->format == GR_TEXFMT_AP_88)) { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; + const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; for (j = 0; j < h; j++) @@ -1691,7 +1691,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pImgData++; - if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88) + if (pTexInfo->format == GR_TEXFMT_AP_88) { if (!(pTexInfo->flags & TF_CHROMAKEYED)) 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 // 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; 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; for (j = 0; j < h; j++) @@ -1743,7 +1743,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } 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 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); } - 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); 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); } } - 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); if (MipMap) @@ -2968,7 +2968,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) // I don't know which one the game actually _uses_ but this // follows format2bpp in hw_cache.c int bpp = 1; - int format = tmp->grInfo.format; + int format = tmp->format; if (format == GR_RGBA) bpp = 4; else if (format == GR_TEXFMT_RGB_565 diff --git a/src/r_patch.c b/src/r_patch.c index ad4b3329a..8980eda58 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1426,10 +1426,10 @@ void R_FreeSingleRotSprite(spritedef_t *spritedef) } if (grPatch->mipmap) { - if (grPatch->mipmap->grInfo.data) + if (grPatch->mipmap->data) { - Z_Free(grPatch->mipmap->grInfo.data); - grPatch->mipmap->grInfo.data = NULL; + Z_Free(grPatch->mipmap->data); + grPatch->mipmap->data = NULL; } Z_Free(grPatch->mipmap); grPatch->mipmap = NULL; diff --git a/src/w_wad.c b/src/w_wad.c index 9af661b57..e6dedba22 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1732,11 +1732,11 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) grPatch = HWR_GetCachedGLPatchPwad(wad, lump); - if (grPatch->mipmap->grInfo.data) + if (grPatch->mipmap->data) { if (tag == PU_CACHE) tag = PU_HWRCACHE; - Z_ChangeTag(grPatch->mipmap->grInfo.data, tag); + Z_ChangeTag(grPatch->mipmap->data, tag); } else {