Revert "Merge remote-tracking branch 'origin/moreopengl' into lugstuff"
This reverts commita6015e4647, reversing changes made tofcbe95447a.
This commit is contained in:
1 parent
23c84a9e96
commit
5a17430747
10 files changed
+46
-126
No files matched your search
+9
-12
@@ -504,23 +504,19 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||
|
||||
// Set the first colormap to the one that comes after it.
|
||||
next = pat->mipmap->nextcolormap;
|
||||
if (!next)
|
||||
break;
|
||||
|
||||
pat->mipmap->nextcolormap = next->nextcolormap;
|
||||
|
||||
// Free image data from memory.
|
||||
if (next->grInfo.data)
|
||||
Z_Free(next->grInfo.data);
|
||||
next->grInfo.data = NULL;
|
||||
HWD.pfnDeleteTexture(next);
|
||||
|
||||
// Free the old colormap from memory.
|
||||
free(next);
|
||||
}
|
||||
}
|
||||
|
||||
void HWR_FreeMipmapCache(void)
|
||||
void HWR_FreeTextureCache(void)
|
||||
{
|
||||
INT32 i;
|
||||
// free references to the textures
|
||||
@@ -532,15 +528,11 @@ void HWR_FreeMipmapCache(void)
|
||||
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
|
||||
|
||||
// Alam: free the Z_Blocks before freeing it's users
|
||||
|
||||
// free all patch colormaps after each level: must be done after ClearMipMapCache!
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
|
||||
}
|
||||
|
||||
void HWR_FreeTextureCache(void)
|
||||
{
|
||||
// free references to the textures
|
||||
HWR_FreeMipmapCache();
|
||||
// now the heap don't have any 'user' pointing to our
|
||||
// texturecache info, we can free it
|
||||
if (gr_textures)
|
||||
@@ -549,15 +541,20 @@ void HWR_FreeTextureCache(void)
|
||||
gr_numtextures = 0;
|
||||
}
|
||||
|
||||
void HWR_LoadTextures(size_t pnumtextures)
|
||||
void HWR_PrepLevelCache(size_t pnumtextures)
|
||||
{
|
||||
// problem: the mipmap cache management hold a list of mipmaps.. but they are
|
||||
// reallocated on each level..
|
||||
//sub-optimal, but 1) just need re-download stuff in hardware cache VERY fast
|
||||
// 2) sprite/menu stuff mixed with level textures so can't do anything else
|
||||
|
||||
// we must free it since numtextures changed
|
||||
HWR_FreeTextureCache();
|
||||
|
||||
gr_numtextures = pnumtextures;
|
||||
gr_textures = calloc(pnumtextures, sizeof (*gr_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
|
||||
if (gr_textures == NULL)
|
||||
I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!");
|
||||
I_Error("HWR_PrepLevelCache: can't alloc gr_textures");
|
||||
}
|
||||
|
||||
void HWR_SetPalette(RGBA_t *palette)
|
||||
|
||||
+1
-10
@@ -207,16 +207,7 @@ enum ETextureFlags
|
||||
TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0
|
||||
};
|
||||
|
||||
struct FTextureInfo
|
||||
{
|
||||
UINT32 width, height;
|
||||
UINT32 downloaded;
|
||||
UINT32 format;
|
||||
|
||||
struct GLMipmap_s *texture;
|
||||
struct FTextureInfo *prev, *next;
|
||||
};
|
||||
typedef struct FTextureInfo FTextureInfo;
|
||||
typedef struct GLMipmap_s FTextureInfo;
|
||||
|
||||
struct FLightInfo
|
||||
{
|
||||
|
||||
@@ -39,9 +39,8 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
|
||||
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, boolean horizonSpecial);
|
||||
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
|
||||
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
|
||||
EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo);
|
||||
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo);
|
||||
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo);
|
||||
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
|
||||
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo);
|
||||
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
|
||||
EXPORT void HWRAPI(ClearMipMapCache) (void);
|
||||
@@ -107,7 +106,6 @@ struct hwdriver_s
|
||||
ClearBuffer pfnClearBuffer;
|
||||
SetTexture pfnSetTexture;
|
||||
UpdateTexture pfnUpdateTexture;
|
||||
DeleteTexture pfnDeleteTexture;
|
||||
ReadRect pfnReadRect;
|
||||
GClipRect pfnGClipRect;
|
||||
ClearMipMapCache pfnClearMipMapCache;
|
||||
|
||||
@@ -57,7 +57,6 @@ extern size_t addsubsector;
|
||||
// --------
|
||||
void HWR_InitTextureCache(void);
|
||||
void HWR_FreeTextureCache(void);
|
||||
void HWR_FreeMipmapCache(void);
|
||||
void HWR_FreeExtraSubsectors(void);
|
||||
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap);
|
||||
|
||||
@@ -161,7 +161,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum);
|
||||
extern boolean gr_maphasportals;
|
||||
|
||||
// hw_cache.c
|
||||
void HWR_LoadTextures(size_t pnumtextures);
|
||||
void HWR_PrepLevelCache(size_t pnumtextures);
|
||||
|
||||
// hw_trick.c
|
||||
void HWR_CorrectSWTricks(void);
|
||||
|
||||
@@ -79,9 +79,8 @@ static GLuint tex_downloaded = 0;
|
||||
static GLfloat fov = 90.0f;
|
||||
static FBITFIELD CurrentPolyFlags;
|
||||
|
||||
// Linked list of all textures.
|
||||
static FTextureInfo *TexCacheTail = NULL;
|
||||
static FTextureInfo *TexCacheHead = NULL;
|
||||
static FTextureInfo *gr_cachetail = NULL;
|
||||
static FTextureInfo *gr_cachehead = NULL;
|
||||
|
||||
typedef struct LightTableCacheEntry_s
|
||||
{
|
||||
@@ -251,6 +250,7 @@ static void GL_MSG_Error(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef STATIC_OPENGL
|
||||
/* 1.0 functions */
|
||||
/* Miscellaneous */
|
||||
@@ -1548,39 +1548,6 @@ void SetStates(void)
|
||||
pglEnable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
|
||||
// -----------------+
|
||||
// DeleteTexture : Deletes a texture from the GPU and frees its data
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo)
|
||||
{
|
||||
FTextureInfo *head = TexCacheHead;
|
||||
|
||||
if (!pTexInfo)
|
||||
return;
|
||||
else if (pTexInfo->downloaded)
|
||||
pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded);
|
||||
|
||||
while (head)
|
||||
{
|
||||
if (head->downloaded == pTexInfo->downloaded)
|
||||
{
|
||||
if (head->next)
|
||||
head->next->prev = head->prev;
|
||||
if (head->prev)
|
||||
head->prev->next = head->next;
|
||||
free(head);
|
||||
break;
|
||||
}
|
||||
|
||||
head = head->next;
|
||||
}
|
||||
|
||||
pTexInfo->downloaded = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------+
|
||||
// Flush : flush OpenGL textures
|
||||
// : Clear list of downloaded mipmaps
|
||||
@@ -1589,30 +1556,21 @@ void Flush(void)
|
||||
{
|
||||
//GL_DBG_Printf("HWR_Flush()\n");
|
||||
|
||||
while (TexCacheHead)
|
||||
while (gr_cachehead)
|
||||
{
|
||||
FTextureInfo *pTexInfo = TexCacheHead;
|
||||
GLMipmap_t *texture = pTexInfo->texture;
|
||||
|
||||
if (pTexInfo->downloaded)
|
||||
{
|
||||
pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded);
|
||||
pTexInfo->downloaded = 0;
|
||||
}
|
||||
|
||||
if (texture)
|
||||
texture->downloaded = 0;
|
||||
|
||||
TexCacheHead = pTexInfo->next;
|
||||
free(pTexInfo);
|
||||
// this is not necessary at all, because you have loaded them normally,
|
||||
// and so they already are in your list!
|
||||
if (gr_cachehead->downloaded)
|
||||
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
|
||||
gr_cachehead->downloaded = 0;
|
||||
gr_cachehead = gr_cachehead->nextmipmap;
|
||||
}
|
||||
gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL
|
||||
|
||||
TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL
|
||||
tex_downloaded = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------+
|
||||
// isExtAvailable : Look if an OpenGL extension is available
|
||||
// Returns : true if extension available
|
||||
@@ -2030,10 +1988,11 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
|
||||
CurrentPolyFlags = PolyFlags;
|
||||
}
|
||||
|
||||
|
||||
// -----------------+
|
||||
// UpdateTexture : Updates texture data.
|
||||
// UpdateTexture : Updates the texture data.
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
|
||||
{
|
||||
// Download a mipmap
|
||||
boolean updatemipmap = true;
|
||||
@@ -2246,7 +2205,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||
// -----------------+
|
||||
// SetTexture : The mipmap becomes the current texture source
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo)
|
||||
EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
|
||||
{
|
||||
if (!pTexInfo)
|
||||
{
|
||||
@@ -2263,25 +2222,15 @@ EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo)
|
||||
}
|
||||
else
|
||||
{
|
||||
FTextureInfo *newTex = calloc(1, sizeof (*newTex));
|
||||
|
||||
UpdateTexture(pTexInfo);
|
||||
newTex->texture = pTexInfo;
|
||||
newTex->downloaded = (UINT32)pTexInfo->downloaded;
|
||||
newTex->width = (UINT32)pTexInfo->width;
|
||||
newTex->height = (UINT32)pTexInfo->height;
|
||||
newTex->format = (UINT32)pTexInfo->grInfo.format;;
|
||||
|
||||
// insertion at the tail
|
||||
if (TexCacheTail)
|
||||
{
|
||||
newTex->prev = TexCacheTail;
|
||||
TexCacheTail->next = newTex;
|
||||
TexCacheTail = newTex;
|
||||
|
||||
pTexInfo->nextmipmap = NULL;
|
||||
if (gr_cachetail)
|
||||
{ // insertion at the tail
|
||||
gr_cachetail->nextmipmap = pTexInfo;
|
||||
gr_cachetail = pTexInfo;
|
||||
}
|
||||
else // initialization of the linked list
|
||||
TexCacheTail = TexCacheHead = newTex;
|
||||
gr_cachetail = gr_cachehead = pTexInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3947,7 +3896,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
||||
|
||||
EXPORT INT32 HWRAPI(GetTextureUsed) (void)
|
||||
{
|
||||
FTextureInfo *tmp = TexCacheHead;
|
||||
FTextureInfo *tmp = gr_cachehead;
|
||||
INT32 res = 0;
|
||||
|
||||
while (tmp)
|
||||
@@ -3956,7 +3905,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->format;
|
||||
int format = tmp->grInfo.format;
|
||||
if (format == GR_RGBA)
|
||||
bpp = 4;
|
||||
else if (format == GR_TEXFMT_RGB_565
|
||||
@@ -3968,7 +3917,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void)
|
||||
|
||||
// Add it up!
|
||||
res += tmp->height*tmp->width*bpp;
|
||||
tmp = tmp->next;
|
||||
tmp = tmp->nextmipmap;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
+9
-12
@@ -3143,19 +3143,8 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
P_SpawnPrecipitation();
|
||||
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
if (rendermode == render_opengl)
|
||||
if (rendermode != render_soft && rendermode != render_none)
|
||||
{
|
||||
// Lactozilla (December 8, 2019)
|
||||
// Level setup used to free EVERY mipmap from memory.
|
||||
// Even mipmaps that aren't related to level textures.
|
||||
// Presumably, the hardware render code used to store textures as level data.
|
||||
// Meaning, they had memory allocated and marked with the PU_LEVEL tag.
|
||||
// Level textures are only reloaded after R_LoadTextures, which is
|
||||
// when the texture list is loaded.
|
||||
|
||||
// Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug.
|
||||
HWR_FreeMipmapCache();
|
||||
|
||||
// Correct missing sidedefs & deep water trick
|
||||
HWR_CorrectSWTricks();
|
||||
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
||||
@@ -3366,6 +3355,14 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
// clear special respawning que
|
||||
iquehead = iquetail = 0;
|
||||
|
||||
// preload graphics
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
if (rendermode != render_soft && rendermode != render_none)
|
||||
{
|
||||
HWR_PrepLevelCache(numtextures);
|
||||
}
|
||||
#endif
|
||||
|
||||
P_MapEnd();
|
||||
|
||||
// Remove the loading shit from the screen
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
#include <malloc.h> // alloca(sizeof)
|
||||
#endif
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h" // HWR_LoadTextures
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -536,11 +532,6 @@ void R_LoadTextures(void)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
HWR_LoadTextures(numtextures);
|
||||
#endif
|
||||
}
|
||||
|
||||
static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||
|
||||
@@ -85,7 +85,6 @@ void *hwSym(const char *funcName,void *handle)
|
||||
GETFUNC(ClearBuffer);
|
||||
GETFUNC(SetTexture);
|
||||
GETFUNC(UpdateTexture);
|
||||
GETFUNC(DeleteTexture);
|
||||
GETFUNC(ReadRect);
|
||||
GETFUNC(GClipRect);
|
||||
GETFUNC(ClearMipMapCache);
|
||||
|
||||
@@ -2117,7 +2117,6 @@ void I_StartupGraphics(void)
|
||||
HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL);
|
||||
HWD.pfnSetTexture = hwSym("SetTexture",NULL);
|
||||
HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL);
|
||||
HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL);
|
||||
HWD.pfnReadRect = hwSym("ReadRect",NULL);
|
||||
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
|
||||
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
|
||||
|
||||
Reference in new issue
Block a user