Bug 66850 - glGenerateMipmap crashes when using GL_TEXTURE_2D_ARRAY with compressed internal format
Summary: glGenerateMipmap crashes when using GL_TEXTURE_2D_ARRAY with compressed inter...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-12 10:59 UTC by Mikko Juola
Modified: 2013-08-01 02:18 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Test program, using GLUT, to reproduce the crash (803 bytes, text/plain)
2013-07-12 10:59 UTC, Mikko Juola
Details
patch 1/3 (3.96 KB, patch)
2013-07-16 13:15 UTC, Brian Paul
Details | Splinter Review
patch 2/3 (2.07 KB, patch)
2013-07-16 13:15 UTC, Brian Paul
Details | Splinter Review
patch 3/3 (5.80 KB, patch)
2013-07-16 13:16 UTC, Brian Paul
Details | Splinter Review
Test program showing problem with glGetTexImage (2.17 KB, text/plain)
2013-07-16 20:55 UTC, Mikko Juola
Details
fix a few more bugs (1.32 KB, patch)
2013-07-16 21:36 UTC, Brian Paul
Details | Splinter Review

Description Mikko Juola 2013-07-12 10:59:54 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][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4;
(gdb) bt
#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
Comment 1 Brian Paul 2013-07-16 13:15:38 UTC
Created attachment 82480 [details] [review]
patch 1/3
Comment 2 Brian Paul 2013-07-16 13:15:55 UTC
Created attachment 82481 [details] [review]
patch 2/3
Comment 3 Brian Paul 2013-07-16 13:16:32 UTC
Created attachment 82482 [details] [review]
patch 3/3

Here's a patch series to try.  Let me know if this helps.
Comment 4 Mikko Juola 2013-07-16 20:55:06 UTC
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.
Comment 5 Brian Paul 2013-07-16 21:36:35 UTC
Created attachment 82506 [details] [review]
fix a few more bugs

OK, here's a patch to apply on top of the previous 3.  Retest?
Comment 6 Mikko Juola 2013-07-16 21:47:37 UTC
As far as I can tell, it now works perfectly.
Comment 7 Brian Paul 2013-07-17 15:00:55 UTC
OK, great.  I'll post the patches for review and push them.
Comment 8 Brian Paul 2013-08-01 02:18:06 UTC
Patches pushed a few days ago.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.