Bug 88907

Summary: [PNV Bisected]Ogles2conform ES2-CTS.gtf.GL2ExtensionTests.texture_float.texture_float segfault
Product: Mesa Reporter: lu hua <huax.lu>
Component: Drivers/DRI/i915Assignee: Tapani Pälli <lemody>
Status: VERIFIED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: kondapallykalyancontribute, lemody
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: patch to fix the issue
patch to fix the issue

Description lu hua 2015-02-02 05:26:42 UTC
System Environment:
--------------------------
Platform: PNV
Libdrm:		(master)libdrm-2.4.59-6-g28ee135a37e10b9a6cd62d67df0332e38ee0b85c
Mesa:		(master)6094619c0297180db218e5b4e45fc07aff116413
Xserver:	(master)xorg-server-1.16.99.902-4-g697b696e5e24d0679f133183a3bb0852025377c2
Xf86_video_intel:(master)2.99.917-75-g6d2754b1902e8bce37818c854fb890400b27343e
Libva:		(master)f9741725839ea144e9a6a1827f74503ee39946c3
Libva_intel_driver:(master)bf324e3440246a487997a1624ac862e3e4027f9e
Kernel:   (drm-intel-nightly)8b4216f91c7bf8d3459cadf9480116220bd6545e

Bug detailed description:
---------------------------
It segfault on PNV with mesa master branch, works well on 10.4 branch.

Bisect shows: a63c8a524b01e802cf2505099f930c0cb97df0b2 is the first bad commit
commit a63c8a524b01e802cf2505099f930c0cb97df0b2
Author:     Kalyan Kondapally <kondapallykalyancontribute@gmail.com>
AuthorDate: Wed Jan 7 20:30:25 2015 -0800
Commit:     Tapani Pälli <tapani.palli@intel.com>
CommitDate: Thu Jan 29 08:16:47 2015 +0200

    Mesa: Add support for GL_OES_texture_*float* extensions.

    This patch series adds support for following GLES2 Texture Float extensions:
    1)GL_OES_texture_float,
    2)GL_OES_texture_half_float,
    3)GL_OES_texture_float_linear,
    4)GL_OES_texture_half_float_linear.

    This patch adds basic infrastructure and needed boolean flags to advertise
    support for these extensions, by default the support is disabled. Next patch
    in the series introduces support for HALF_FLOAT_OES token.

    v4: take assert away and make valid_filter_for_float conditional (Tapani),
        fix the alphabetical order (Emil)

    Signed-off-by: Kevin Rogovin <kevin.rogovin@intel.com>
    Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
    Reviewed-by: Tapani Pälli <tapani.palli@intel.com>

output:
dEQP Core GL-CTS-2.0 (0x0052484b) starting..
  target implementation = 'X11'

Test case 'ES2-CTS.gtf.GL2ExtensionTests.texture_float.texture_float'..
GL_OES_texture_float is not supported.
Mesa 10.5.0-devel implementation error: unexpected format GL_RGB32F in _mesa_choose_tex_format()
Please report at https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa
glcts: main/teximage.c:3263: teximage: Assertion `texFormat != MESA_FORMAT_NONE' failed.
Aborted (core dumped)

(gdb) bt
#0  0xb7fffab0 in __kernel_vsyscall ()
#1  0x48190776 in raise () from /lib/libc.so.6
#2  0x48191fb3 in abort () from /lib/libc.so.6
#3  0x48189847 in __assert_fail_base () from /lib/libc.so.6
#4  0x481898f7 in __assert_fail () from /lib/libc.so.6
#5  0xb79ee5df in teximage (ctx=0xb785d01c, compressed=compressed@entry=0 '\000', dims=dims@entry=2, target=target@entry=3553, level=level@entry=0, internalFormat=34837,
    internalFormat@entry=6407, width=width@entry=4, height=height@entry=4, depth=depth@entry=1, border=border@entry=0, format=format@entry=6407, type=type@entry=5126,
    imageSize=imageSize@entry=0, pixels=pixels@entry=0x0) at main/teximage.c:3263
#6  0xb79ef57e in _mesa_TexImage2D (target=3553, level=0, internalFormat=6407, width=4, height=4, border=0, format=6407, type=5126, pixels=0x0) at main/teximage.c:3382
#7  0x08a90abe in glwTexImage2D ()
#8  0x0888149b in GTFExtensionTestTextureFloatApply ()
#9  0x08817776 in GTFTestExtensionApply ()
#10 0x0844fa12 in GTFTestEncapsulateApply ()
#11 0x08408b6d in GTFRunTest ()
#12 0x0840227e in gtf::TestCase::iterate() ()
#13 0x08a36d27 in tcu::TestCaseWrapper::iterateTestCase(tcu::TestCase*) ()
#14 0x083d7e8a in glcts::TestCaseWrapper::iterateTestCase(tcu::TestCase*) ()
#15 0x08a381c9 in tcu::TestExecutor::iterate() ()
#16 0x08a2c2ee in tcu::App::iterate() ()
#17 0x08169c02 in main ()

Reproduce steps:
-------------------------
1. xinit
2. ./glcts --deqp-case=ES2-CTS.gtf.GL2ExtensionTests.texture_float.texture_float
Comment 1 Ian Romanick 2015-02-11 22:33:30 UTC
It sounds like floating-point formats are some how being allowed when the extension is not enabled.
Comment 2 Tapani Pälli 2015-02-12 07:30:46 UTC
Created attachment 113390 [details] [review]
patch to fix the issue

It looks like internal format adjustment is made always, even when extension is not enabled. Does this patch help/fix the issue?
Comment 3 Ian Romanick 2015-02-12 19:46:44 UTC
Comment on attachment 113390 [details] [review]
patch to fix the issue

Review of attachment 113390 [details] [review]:
-----------------------------------------------------------------

I think the problem is that adjust_for_oes_float_texture is called even when internalFormat is not GL_FLOAT, GL_HALF_FLOAT_OES, or GL_HALF_FLOAT.

It seems like this would be better:

      if (_mesa_is_gles(ctx) && format == internalFormat) {
         if (type == GL_FLOAT) {
            texObj->_IsFloat = GL_TRUE;
            internalFormat = adjust_for_oes_float_texture(format, type);
         } else if (type == GL_HALF_FLOAT_OES || type == GL_HALF_FLOAT) {
            texObj->_IsHalfFloat = GL_TRUE;
            internalFormat = adjust_for_oes_float_texture(format, type);
         }
      }
Comment 4 Ian Romanick 2015-02-12 19:48:45 UTC
(In reply to Ian Romanick from comment #3)
> Comment on attachment 113390 [details] [review] [review]
> patch to fix the issue
> 
> Review of attachment 113390 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> I think the problem is that adjust_for_oes_float_texture is called even when
> internalFormat is not GL_FLOAT, GL_HALF_FLOAT_OES, or GL_HALF_FLOAT.
> 
> It seems like this would be better:
> 
>       if (_mesa_is_gles(ctx) && format == internalFormat) {

Also, I think the check here should be ctx->API == API_OPENGLES2.  We don't want to do this in GLES 1.1.

>          if (type == GL_FLOAT) {
>             texObj->_IsFloat = GL_TRUE;
>             internalFormat = adjust_for_oes_float_texture(format, type);
>          } else if (type == GL_HALF_FLOAT_OES || type == GL_HALF_FLOAT) {
>             texObj->_IsHalfFloat = GL_TRUE;
>             internalFormat = adjust_for_oes_float_texture(format, type);
>          }
>       }
Comment 5 Tapani Pälli 2015-02-13 04:25:55 UTC
(In reply to Ian Romanick from comment #3)
> Comment on attachment 113390 [details] [review] [review]
> patch to fix the issue
> 
> Review of attachment 113390 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> I think the problem is that adjust_for_oes_float_texture is called even when
> internalFormat is not GL_FLOAT, GL_HALF_FLOAT_OES, or GL_HALF_FLOAT.

Nothing happens in the function if format was not one of these formats so not calling it does not seem to change existing functionality. I think extension check seems very relevant here because these things should happen only because of the extension is enabled, not because you are running ES2. i965 should be only driver currently supporting this extension on ES2.
Comment 6 Tapani Pälli 2015-02-16 12:35:31 UTC
I've sent updated patch to the list for review.
Comment 7 Tapani Pälli 2015-02-27 10:23:11 UTC
Created attachment 113864 [details] [review]
patch to fix the issue

Updated patch. QA, please test with this patch.
Comment 8 lu hua 2015-03-02 06:33:12 UTC
Test on the latest Mesa master branch, the core dumped issue goes away.

output:
dEQP Core GL-CTS-2.0 (0x0052484b) starting..
  target implementation = 'X11'

Test case 'ES2-CTS.gtf.GL2ExtensionTests.texture_float.texture_float'..
GL_OES_texture_float is not supported.
Mesa 10.6.0-devel implementation error: unexpected format GL_RGB32F in _mesa_choose_tex_format()
Please report at https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa
#+ glTexImage2D: Got GL_NO_ERROR with internalformat=GL_RGB & type=GL_FLOAT. Expected GL_INVALID_ENUM
  Fail (Fail)

DONE!

Test run totals:
  Passed:        0/1 (0.00%)
  Failed:        1/1 (100.00%)
  Not supported: 0/1 (0.00%)
  Warnings:      0/1 (0.00%)
Comment 9 lu hua 2015-03-02 06:33:32 UTC
Verified.Fixed.
Comment 10 Tapani Pälli 2015-03-02 06:35:56 UTC
The test still fails though, will you open a separate bug for that or will we handle it in the same one?
Comment 11 lu hua 2015-03-02 07:13:17 UTC
(In reply to Tapani Pälli from comment #10)
> The test still fails though, will you open a separate bug for that or will
> we handle it in the same one?

It always fail, So closed this bug. Reported bug 89389 to track the fail.

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.