Page in textures before caching them

Some custom levels attempt to use texture overrides that reference
textures that are not yet paged in.  It is not legal to access the data
of a paged-out texture, but ogl_loadbmtexture_f attempted to access it
anyway, causing a crash.  Page in the texture before calling
ogl_loadbmtexture_f.  Old versions of the engine would have cached
garbage data when this happened.

Reported-by: kreator <https://github.com/dxx-rebirth/dxx-rebirth/issues/228>
Fixes: 3c20c24ac0 ("Disable piggy_bitmap_page_out_all")
This commit is contained in:
Kp 2016-10-23 20:33:14 +00:00
parent 49ff176e12
commit ffa53eb3c4

View file

@ -513,7 +513,11 @@ void ogl_cache_level_textures(void)
ogl_cache_weapon_textures(ri.weapon_type); ogl_cache_weapon_textures(ri.weapon_type);
} }
if (objp->rtype.pobj_info.tmap_override != -1) if (objp->rtype.pobj_info.tmap_override != -1)
ogl_loadbmtexture(GameBitmaps[Textures[objp->rtype.pobj_info.tmap_override].index], 1); {
auto &t = Textures[objp->rtype.pobj_info.tmap_override];
PIGGY_PAGE_IN(t);
ogl_loadbmtexture(GameBitmaps[t.index], 1);
}
else else
ogl_cache_polymodel_textures(objp->rtype.pobj_info.model_num); ogl_cache_polymodel_textures(objp->rtype.pobj_info.model_num);
} }
@ -1751,7 +1755,8 @@ unsigned char decodebuf[1024*1024];
void ogl_loadbmtexture_f(grs_bitmap &rbm, int texfilt, bool texanis, bool edgepad) void ogl_loadbmtexture_f(grs_bitmap &rbm, int texfilt, bool texanis, bool edgepad)
{ {
assert(!(rbm.bm_flags & BM_FLAG_PAGED_OUT));
assert(rbm.bm_data);
grs_bitmap *bm = &rbm; grs_bitmap *bm = &rbm;
while (bm->bm_parent) while (bm->bm_parent)
bm=bm->bm_parent; bm=bm->bm_parent;