[sw] Free alias model cache memory when clearing models

This fixes a Sys_Error when loading the level for the first demo (and
probably many other times). It was mod_numknown getting set to 0 that
triggered the issue, but that seems to be necessary for the other
renderers. I think the whole model loading and caching system needs an
overhaul as this doesn't feel quite right due to removing part of the
advantage of caching the model data.
This commit is contained in:
Bill Currie 2023-03-20 17:45:28 +09:00
parent 654b208641
commit 793525a50a
3 changed files with 16 additions and 1 deletions

View file

@ -73,6 +73,7 @@ void glsl_Mod_IQMFinish (model_t *mod);
void sw_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx, void *_m,
int _s, int extra);
void sw_Mod_LoadAllSkins (mod_alias_ctx_t *alias_ctx);
void sw_Mod_FinalizeAliasModel (mod_alias_ctx_t *alias_ctx);
void sw_Mod_IQMFinish (model_t *mod);
void gl_Mod_LoadLighting (model_t *mod, bsp_t *bsp);

View file

@ -45,6 +45,14 @@
#include "d_iface.h"
#include "mod_internal.h"
static void
sw_alias_clear (model_t *m, void *data)
{
m->needload = true;
Cache_Free (&m->cache);
}
// a pose is a single set of vertexes. a frame may be
// an animating sequence of poses
@ -66,6 +74,12 @@ sw_Mod_LoadAllSkins (mod_alias_ctx_t *alias_ctx)
}
}
void
sw_Mod_FinalizeAliasModel (mod_alias_ctx_t *alias_ctx)
{
alias_ctx->mod->clear = sw_alias_clear;
}
static void
process_frame (mod_alias_ctx_t *alias_ctx, maliasframedesc_t *frame,
int posenum, int extra)

View file

@ -85,7 +85,7 @@ static vid_model_funcs_t model_funcs = {
.Mod_MakeAliasModelDisplayLists = sw_Mod_MakeAliasModelDisplayLists,
.Mod_LoadAllSkins = sw_Mod_LoadAllSkins,
.Mod_FinalizeAliasModel = 0,
.Mod_FinalizeAliasModel = sw_Mod_FinalizeAliasModel,
.Mod_LoadExternalSkins = 0,
.Mod_IQMFinish = sw_Mod_IQMFinish,
.alias_cache = 1,