mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 17:22:12 +00:00
Make some things clearer here.
This commit is contained in:
parent
40b862967d
commit
bc60a0a887
1 changed files with 28 additions and 15 deletions
|
@ -760,15 +760,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||||
// CACHING HANDLING
|
// CACHING HANDLING
|
||||||
// =================================================
|
// =================================================
|
||||||
|
|
||||||
static size_t gr_numtextures;
|
static size_t gr_numtextures; // Texture count
|
||||||
static GLTexture_t *gr_textures; // for ALL Doom textures
|
static GLTexture_t *gr_textures; // For all textures
|
||||||
static GLTexture_t *gr_textures2;
|
static GLTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached
|
||||||
|
|
||||||
void HWR_InitTextureCache(void)
|
void HWR_InitTextureCache(void)
|
||||||
{
|
{
|
||||||
gr_numtextures = 0;
|
gr_numtextures = 0;
|
||||||
gr_textures = NULL;
|
gr_textures = NULL;
|
||||||
gr_textures2 = NULL;
|
gr_flats = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback function for HWR_FreeTextureCache.
|
// Callback function for HWR_FreeTextureCache.
|
||||||
|
@ -831,10 +831,10 @@ void HWR_FreeTextureCache(void)
|
||||||
// texturecache info, we can free it
|
// texturecache info, we can free it
|
||||||
if (gr_textures)
|
if (gr_textures)
|
||||||
free(gr_textures);
|
free(gr_textures);
|
||||||
if (gr_textures2)
|
if (gr_flats)
|
||||||
free(gr_textures2);
|
free(gr_flats);
|
||||||
gr_textures = NULL;
|
gr_textures = NULL;
|
||||||
gr_textures2 = NULL;
|
gr_flats = NULL;
|
||||||
gr_numtextures = 0;
|
gr_numtextures = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,13 +848,15 @@ void HWR_PrepLevelCache(size_t pnumtextures)
|
||||||
// we must free it since numtextures changed
|
// we must free it since numtextures changed
|
||||||
HWR_FreeTextureCache();
|
HWR_FreeTextureCache();
|
||||||
|
|
||||||
|
// Why not Z_Malloc?
|
||||||
gr_numtextures = pnumtextures;
|
gr_numtextures = pnumtextures;
|
||||||
gr_textures = calloc(pnumtextures, sizeof (*gr_textures));
|
gr_textures = calloc(gr_numtextures, sizeof(*gr_textures));
|
||||||
if (gr_textures == NULL)
|
gr_flats = calloc(gr_numtextures, sizeof(*gr_flats));
|
||||||
I_Error("3D can't alloc gr_textures");
|
|
||||||
gr_textures2 = calloc(pnumtextures, sizeof (*gr_textures2));
|
// Doesn't tell you which it _is_, but hopefully
|
||||||
if (gr_textures2 == NULL)
|
// should never ever happen (right?!)
|
||||||
I_Error("3D can't alloc gr_textures2");
|
if ((gr_textures == NULL) || (gr_flats == NULL))
|
||||||
|
I_Error("HWR_PrepLevelCache: ran out of memory for OpenGL textures. Sad!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HWR_SetPalette(RGBA_t *palette)
|
void HWR_SetPalette(RGBA_t *palette)
|
||||||
|
@ -887,11 +889,16 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
||||||
if ((unsigned)tex >= gr_numtextures)
|
if ((unsigned)tex >= gr_numtextures)
|
||||||
I_Error("HWR_GetTexture: tex >= numtextures\n");
|
I_Error("HWR_GetTexture: tex >= numtextures\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Every texture in memory, stored in the
|
||||||
|
// hardware renderer's bit depth format. Wow!
|
||||||
grtex = &gr_textures[tex];
|
grtex = &gr_textures[tex];
|
||||||
|
|
||||||
|
// Generate texture if missing from the cache
|
||||||
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
|
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
|
||||||
HWR_GenerateTexture(tex, grtex);
|
HWR_GenerateTexture(tex, grtex);
|
||||||
|
|
||||||
|
// Tell the hardware driver to bind the current texture to the flat's mipmap
|
||||||
HWD.pfnSetTexture(&grtex->mipmap);
|
HWD.pfnSetTexture(&grtex->mipmap);
|
||||||
|
|
||||||
// The system-memory data can be purged now.
|
// The system-memory data can be purged now.
|
||||||
|
@ -1003,13 +1010,19 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
if ((unsigned)texturenum >= gr_numtextures)
|
if ((unsigned)texturenum >= gr_numtextures)
|
||||||
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
|
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Who knows?
|
||||||
if (texturenum == 0 || texturenum == -1)
|
if (texturenum == 0 || texturenum == -1)
|
||||||
return;
|
return;
|
||||||
grtex = &gr_textures2[texturenum];
|
|
||||||
|
|
||||||
|
// Every texture in memory, stored as a 8-bit flat. Wow!
|
||||||
|
grtex = &gr_flats[texturenum];
|
||||||
|
|
||||||
|
// Generate flat if missing from the cache
|
||||||
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
|
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
|
||||||
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
|
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
|
||||||
|
|
||||||
|
// Tell the hardware driver to bind the current texture to the flat's mipmap
|
||||||
HWD.pfnSetTexture(&grtex->mipmap);
|
HWD.pfnSetTexture(&grtex->mipmap);
|
||||||
|
|
||||||
// The system-memory data can be purged now.
|
// The system-memory data can be purged now.
|
||||||
|
@ -1033,6 +1046,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
|
||||||
HWR_MakePatch(patch, gpatch, grmip, true);
|
HWR_MakePatch(patch, gpatch, grmip, true);
|
||||||
|
|
||||||
// You can't free rawpatch for some reason?
|
// You can't free rawpatch for some reason?
|
||||||
|
// (Obviously I can't, sprite rotation needs that...)
|
||||||
if (!gpatch->rawpatch)
|
if (!gpatch->rawpatch)
|
||||||
Z_Free(patch);
|
Z_Free(patch);
|
||||||
}
|
}
|
||||||
|
@ -1060,7 +1074,6 @@ void HWR_GetPatch(GLPatch_t *gpatch)
|
||||||
|
|
||||||
// this is inefficient.. but the hardware patch in heap is purgeable so it should
|
// this is inefficient.. but the hardware patch in heap is purgeable so it should
|
||||||
// not fragment memory, and besides the REAL cache here is the hardware memory
|
// not fragment memory, and besides the REAL cache here is the hardware memory
|
||||||
// You can't free rawpatch for some reason?
|
|
||||||
if (!gpatch->rawpatch)
|
if (!gpatch->rawpatch)
|
||||||
Z_Free(ptr);
|
Z_Free(ptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue