mesa: fix mipmap generation for immutable, compressed textures
authorRoland Scheidegger <sroland@vmware.com>
Sat, 19 Sep 2015 23:33:17 +0000 (01:33 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 24 Sep 2015 22:06:10 +0000 (00:06 +0200)
commit19604d30e1351868f7f54847c91ffec7b3fcd27e
treedbc10d4cb3f2bba4ff02682571ad80d8947136a7
parentd6bb46bbe8e4ef90dedc5a04c7434a8113c10a8b
mesa: fix mipmap generation for immutable, compressed textures

If the immutable compressed texture didn't have the full mip pyramid,
this didn't work, because it tried to generate mip levels for non-existing
levels. _mesa_prepare_mipmap_level() would correctly handle this by returning
FALSE if the mip level didn't exist, however we actually created the
non-existing mip level right before that because we used _mesa_get_tex_image()
before calling _mesa_prepare_mipmap_level(). It would then proceed to crash
(we allocated the mip level, which is a bad idea on an immutable texture,
but didn't initialize the values, leading to assertion failures or segfaults).
Fix this by using _mesa_select_tex_image() instead and call it after
_mesa_prepare_mipmap_level(), as that function will allocate missing mip levels
for non-immutable textures already.
This fixes a (2 year old) crash with astromenace which was hack-fixed in ubuntu
packages instead: http://bugs.debian.org/718680 (I guess most apps do full mip
chains - I believe this app not doing it is actually unintentional, always one
level less than full mip chain...).

Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/mipmap.c