OSDN Git Service

mesa: fix mipmap generation for immutable, compressed textures
authorRoland Scheidegger <sroland@vmware.com>
Sat, 19 Sep 2015 23:33:17 +0000 (01:33 +0200)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 7 Oct 2015 13:42:27 +0000 (14:42 +0100)
commit46dc4946a24337796e2e22f72d08a87d415b04e6
tree70a2c2b54074a7c2b6ab6f52e4589d5f926d659d
parent01e197c21a3adc3934bde7b0248a067602270caa
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>
(cherry picked from commit 19604d30e1351868f7f54847c91ffec7b3fcd27e)
src/mesa/main/mipmap.c