mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
gl3: preserve cache on free slots in image and models list(aa6032f0
)
This commit is contained in:
parent
330830fc38
commit
423c3fa299
3 changed files with 99 additions and 7 deletions
|
@ -46,7 +46,8 @@ int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
||||||
int gl_filter_max = GL_LINEAR;
|
int gl_filter_max = GL_LINEAR;
|
||||||
|
|
||||||
gl3image_t gl3textures[MAX_GL3TEXTURES];
|
gl3image_t gl3textures[MAX_GL3TEXTURES];
|
||||||
int numgl3textures;
|
int numgl3textures = 0;
|
||||||
|
static int image_max = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
GL3_TextureMode(char *string)
|
GL3_TextureMode(char *string)
|
||||||
|
@ -948,6 +949,33 @@ GL3_FreeUnusedImages(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean
|
||||||
|
GL3_ImageHasFreeSpace(void)
|
||||||
|
{
|
||||||
|
int i, used;
|
||||||
|
gl3image_t *image;
|
||||||
|
|
||||||
|
used = 0;
|
||||||
|
|
||||||
|
for (i = 0, image = gl3textures; i < numgl3textures; i++, image++)
|
||||||
|
{
|
||||||
|
if (!image->name[0])
|
||||||
|
continue;
|
||||||
|
if (image->registration_sequence == registration_sequence)
|
||||||
|
{
|
||||||
|
used ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image_max < used)
|
||||||
|
{
|
||||||
|
image_max = used;
|
||||||
|
}
|
||||||
|
|
||||||
|
// should same size of free slots as currently used
|
||||||
|
return (numgl3textures + used) < MAX_GL3TEXTURES;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GL3_ShutdownImages(void)
|
GL3_ShutdownImages(void)
|
||||||
{
|
{
|
||||||
|
@ -986,7 +1014,8 @@ static qboolean IsNPOT(int v)
|
||||||
void
|
void
|
||||||
GL3_ImageList_f(void)
|
GL3_ImageList_f(void)
|
||||||
{
|
{
|
||||||
int i, texels=0;
|
int i, used, texels;
|
||||||
|
qboolean freeup;
|
||||||
gl3image_t *image;
|
gl3image_t *image;
|
||||||
const char *formatstrings[2] = {
|
const char *formatstrings[2] = {
|
||||||
"RGB ",
|
"RGB ",
|
||||||
|
@ -998,15 +1027,25 @@ GL3_ImageList_f(void)
|
||||||
};
|
};
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, "------------------\n");
|
R_Printf(PRINT_ALL, "------------------\n");
|
||||||
|
texels = 0;
|
||||||
|
used = 0;
|
||||||
|
|
||||||
for (i = 0, image = gl3textures; i < numgl3textures; i++, image++)
|
for (i = 0, image = gl3textures; i < numgl3textures; i++, image++)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
char *in_use = "";
|
||||||
qboolean isNPOT = false;
|
qboolean isNPOT = false;
|
||||||
if (image->texnum == 0)
|
if (image->texnum == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image->registration_sequence == registration_sequence)
|
||||||
|
{
|
||||||
|
in_use = "*";
|
||||||
|
used++;
|
||||||
|
}
|
||||||
|
|
||||||
w = image->width;
|
w = image->width;
|
||||||
h = image->height;
|
h = image->height;
|
||||||
|
|
||||||
|
@ -1036,9 +1075,11 @@ GL3_ImageList_f(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, " %3i %3i %s %s: %s\n", w, h,
|
R_Printf(PRINT_ALL, " %3i %3i %s %s: %s %s\n", w, h,
|
||||||
formatstrings[image->has_alpha], potstrings[isNPOT], image->name);
|
formatstrings[image->has_alpha], potstrings[isNPOT], image->name, in_use);
|
||||||
}
|
}
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, "Total texel count (not counting mipmaps): %i\n", texels);
|
R_Printf(PRINT_ALL, "Total texel count (not counting mipmaps): %i\n", texels);
|
||||||
|
freeup = GL3_ImageHasFreeSpace();
|
||||||
|
R_Printf(PRINT_ALL, "Used %d of %d images%s.\n", used, image_max, freeup ? ", has free space" : "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,42 @@ static gl3model_t *loadmodel;
|
||||||
YQ2_ALIGNAS_TYPE(int) static byte mod_novis[MAX_MAP_LEAFS / 8];
|
YQ2_ALIGNAS_TYPE(int) static byte mod_novis[MAX_MAP_LEAFS / 8];
|
||||||
gl3model_t mod_known[MAX_MOD_KNOWN];
|
gl3model_t mod_known[MAX_MOD_KNOWN];
|
||||||
static int mod_numknown;
|
static int mod_numknown;
|
||||||
|
static int mod_max = 0;
|
||||||
int registration_sequence;
|
int registration_sequence;
|
||||||
static byte *mod_base;
|
static byte *mod_base;
|
||||||
|
|
||||||
/* the inline * models from the current map are kept seperate */
|
/* the inline * models from the current map are kept seperate */
|
||||||
gl3model_t mod_inline[MAX_MOD_KNOWN];
|
gl3model_t mod_inline[MAX_MOD_KNOWN];
|
||||||
|
|
||||||
|
//===============================================================================
|
||||||
|
|
||||||
|
static qboolean
|
||||||
|
Mod_HasFreeSpace(void)
|
||||||
|
{
|
||||||
|
int i, used;
|
||||||
|
gl3model_t *mod;
|
||||||
|
|
||||||
|
used = 0;
|
||||||
|
|
||||||
|
for (i=0, mod=mod_known ; i < mod_numknown ; i++, mod++)
|
||||||
|
{
|
||||||
|
if (!mod->name[0])
|
||||||
|
continue;
|
||||||
|
if (mod->registration_sequence == registration_sequence)
|
||||||
|
{
|
||||||
|
used ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mod_max < used)
|
||||||
|
{
|
||||||
|
mod_max = used;
|
||||||
|
}
|
||||||
|
|
||||||
|
// should same size of free slots as currently used
|
||||||
|
return (mod_numknown + mod_max) < MAX_MOD_KNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
mleaf_t *
|
mleaf_t *
|
||||||
GL3_Mod_PointInLeaf(vec3_t p, gl3model_t *model)
|
GL3_Mod_PointInLeaf(vec3_t p, gl3model_t *model)
|
||||||
{
|
{
|
||||||
|
@ -92,30 +122,44 @@ GL3_Mod_ClusterPVS(int cluster, const gl3model_t *model)
|
||||||
void
|
void
|
||||||
GL3_Mod_Modellist_f(void)
|
GL3_Mod_Modellist_f(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, total, used;
|
||||||
gl3model_t *mod;
|
gl3model_t *mod;
|
||||||
int total;
|
qboolean freeup;
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
|
used = 0;
|
||||||
R_Printf(PRINT_ALL, "Loaded models:\n");
|
R_Printf(PRINT_ALL, "Loaded models:\n");
|
||||||
|
|
||||||
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
|
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
|
||||||
{
|
{
|
||||||
|
char *in_use = "";
|
||||||
|
|
||||||
|
if (mod->registration_sequence == registration_sequence)
|
||||||
|
{
|
||||||
|
in_use = "*";
|
||||||
|
used ++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mod->name[0])
|
if (!mod->name[0])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, "%8i : %s\n", mod->extradatasize, mod->name);
|
R_Printf(PRINT_ALL, "%8i : %s %s\n",
|
||||||
|
mod->extradatasize, mod->name, in_use);
|
||||||
total += mod->extradatasize;
|
total += mod->extradatasize;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, "Total resident: %i\n", total);
|
R_Printf(PRINT_ALL, "Total resident: %i\n", total);
|
||||||
|
// update statistics
|
||||||
|
freeup = Mod_HasFreeSpace();
|
||||||
|
R_Printf(PRINT_ALL, "Used %d of %d models%s.\n", used, mod_max, freeup ? ", has free space" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GL3_Mod_Init(void)
|
GL3_Mod_Init(void)
|
||||||
{
|
{
|
||||||
|
mod_max = 0;
|
||||||
memset(mod_novis, 0xff, sizeof(mod_novis));
|
memset(mod_novis, 0xff, sizeof(mod_novis));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,6 +1177,12 @@ GL3_EndRegistration(void)
|
||||||
int i;
|
int i;
|
||||||
gl3model_t *mod;
|
gl3model_t *mod;
|
||||||
|
|
||||||
|
if (Mod_HasFreeSpace() && GL3_ImageHasFreeSpace())
|
||||||
|
{
|
||||||
|
// should be enough space for load next maps
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
|
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
|
||||||
{
|
{
|
||||||
if (!mod->name[0])
|
if (!mod->name[0])
|
||||||
|
|
|
@ -421,6 +421,7 @@ extern gl3image_t *GL3_FindImage(char *name, imagetype_t type);
|
||||||
extern gl3image_t *GL3_RegisterSkin(char *name);
|
extern gl3image_t *GL3_RegisterSkin(char *name);
|
||||||
extern void GL3_ShutdownImages(void);
|
extern void GL3_ShutdownImages(void);
|
||||||
extern void GL3_FreeUnusedImages(void);
|
extern void GL3_FreeUnusedImages(void);
|
||||||
|
extern qboolean GL3_ImageHasFreeSpace(void);
|
||||||
extern void GL3_ImageList_f(void);
|
extern void GL3_ImageList_f(void);
|
||||||
|
|
||||||
// gl3_light.c
|
// gl3_light.c
|
||||||
|
|
Loading…
Reference in a new issue