Bugzilla – Bug 66850
glGenerateMipmap crashes when using GL_TEXTURE_2D_ARRAY with compressed internal format
Last modified: 2013-08-01 02:18:06 UTC
Created attachment 82363 [details]
Test program, using GLUT, to reproduce the crash
At least happens on Mesa commit id 1681bd7f2b392d0b379cb0ff43a4fac33da74762 and also on Mesa 9.1.4 that is in Debian testing repositories at the moment.
I have attached a short test program to reproduce the crash.
The crash occurs if you create and put data to a GL_TEXTURE_2D_ARRAY, using a compressed texture format, while the number of textures in the array is greater than 1 and then call glGenerateMipmap.
I'm not entirely sure if you are supposed to be able to generate mipmaps with glGenerateMipmap if the zero layer texture is in compressed format but I'd think it should at least fail gracefully, if this is the case.
This is what I could get out of GDB:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff452bd38 in do_row (datatype=5121, comps=3, srcWidth=128, srcRowA=0x7fffffffee90, srcRowB=0x7ffffffff010, dstWidth=64, dstRow=0x90ffc0) at ../../../src/mesa/main/mipmap.c:183
183 dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
#0 0x00007ffff452bd38 in do_row (datatype=5121, comps=3, srcWidth=128, srcRowA=0x7fffffffee90, srcRowB=0x7ffffffff010, dstWidth=64, dstRow=0x90ffc0) at ../../../src/mesa/main/mipmap.c:183
#1 0x00007ffff453992b in make_2d_mipmap (datatype=5121, comps=3, border=0, srcWidth=128, srcHeight=128, srcPtr=0x7fffffffe590 "", srcRowStride=384, dstWidth=64, dstHeight=64,
dstPtr=0x90fd80 "Sz_\002\023\225_37#", dstRowStride=192) at ../../../src/mesa/main/mipmap.c:1475
#2 0x00007ffff453a7f2 in _mesa_generate_mipmap_level (target=35866, datatype=5121, comps=3, border=0, srcWidth=128, srcHeight=128, srcDepth=2, srcData=0x7fffffffe570, srcRowStride=384,
dstWidth=64, dstHeight=64, dstDepth=2, dstData=0x7fffffffe568, dstRowStride=192) at ../../../src/mesa/main/mipmap.c:1750
#3 0x00007ffff453b39f in generate_mipmap_compressed (ctx=0x621170, target=35866, texObj=0x8c1780, srcImage=0x8ede50, maxLevel=13) at ../../../src/mesa/main/mipmap.c:2121
#4 0x00007ffff453b55b in _mesa_generate_mipmap (ctx=0x621170, target=35866, texObj=0x8c1780) at ../../../src/mesa/main/mipmap.c:2180
#5 0x00007ffff46aa33c in _mesa_meta_GenerateMipmap (ctx=0x621170, target=35866, texObj=0x8c1780) at ../../../src/mesa/drivers/common/meta.c:3527
#6 0x00007ffff44f08e2 in _mesa_GenerateMipmap (target=35866) at ../../../src/mesa/main/fbobject.c:2889
#7 0x00007ffff796c527 in glGenerateMipmap (target=35866) at ../../../src/mapi/glapi/glapi_mapi_tmp.h:8178
#8 0x0000000000400954 in main (argc=1, argv=0x7fffffffe8b8) at test_program.c:31
Created attachment 82480 [details] [review]
Created attachment 82481 [details] [review]
Created attachment 82482 [details] [review]
Here's a patch series to try. Let me know if this helps.
Created attachment 82505 [details]
Test program showing problem with glGetTexImage
After patching in these patches, it no longer crashes. However, I seem to be unable to get back, with glGetTexImage, texture images in mipmap layers beyond the first texture in the texture array. All base level images for all layers can be fetched back just fine. Those aformentioned mipmap images, however, are all completely black.
I modified and attached another test program to show the problem this time around.
Created attachment 82506 [details] [review]
fix a few more bugs
OK, here's a patch to apply on top of the previous 3. Retest?
As far as I can tell, it now works perfectly.
OK, great. I'll post the patches for review and push them.
Patches pushed a few days ago.