Bug 47220

Summary: [bisected] Oglc pxconv-gettex(basic.allCases) regressed
Product: Mesa Reporter: lu hua <huax.lu>
Component: Drivers/DRI/i915Assignee: Anuj Phogat <anuj.phogat>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: medium CC: anuj.phogat, brianp, xunx.fang
Version: git   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: output

Description lu hua 2012-03-11 23:05:52 UTC
System Environment:
--------------------------
Arch:       i386
Platform:   Sandybridge
Libdrm:	   (master)2.4.31-17-g99c73378a1b440bcf594742445dfe14ab1e89128
Xserver:	   (master)xorg-server-1.12.0
Xf86_video_intel:(master)2.18.0-65-gc25a3f7f46010660f441070ab7b9d5d1bc39ed0d
Libva_intel_driver:(vaapi-ext)304bf4dd752c5d0edd6bcdf87efaaa7db503a1c3
Kernel:	 (drm-intel-next-queued) fa37d39e4c6622d80bd8061d600701bcea1d6870

Bug detailed description:
-----------------------------
It fails on Sandybridge with mesa master branch.It does not happen on mesa 8.0 branch.
Following cases also fail and have same commit.
pxstore-gettex(basic.allCases)
pxtrans-gettex(basic.allCases)
pbo(texImage.1PBOChangeInternalFormat)
pbo(getTexImage.1PBOChangeInternalFormat)

Bisect shows f5d0ced242abc9e4e777bbe374585f44399b75af is the first bad commit.
commit f5d0ced242abc9e4e777bbe374585f44399b75af
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Mar 8 20:16:00 2012 -0700

    mesa: fix GL_LUMINANCE handling in glGetTexImage

    There are several cases in which we need to explicity "rebase" colors
    (ex: set G=B=0) when getting GL_LUMINANCE textures:
    1. If the luminance texture is actually stored as rgba
    2. If getting a luminance texture, but returning rgba
    3. If getting an rgba texture, but returning luminance

    Fixes https://bugs.freedesktop.org/show_bug.cgi?id=46679

    Also fixes the new piglit getteximage-luminance test.

    Reviewed-by: José Fonseca <jfonseca@vmware.com>

Reproduce steps:
----------------------------
1. start X
2. ./oglconform -z -suite all -v 2 -D 117 -test pxconv-gettex basic.allCases
Comment 1 Anuj Phogat 2012-03-12 13:39:29 UTC
This is the issue with the test case not with mesa driver. Test is incorrectly computing the expected result colors when the texture is luminance, luminance alpha or intensity. Similar failures were observed in piglit fbo-alphatest-formats (Bug# 47125).
Comment 2 lu hua 2012-03-15 23:32:37 UTC
It happens on ivybridge sandybridge pineview and ironlake with mesa master branch and mesa 8.0 branch.
Comment 3 Gordon Jin 2012-03-31 18:57:35 UTC
(In reply to comment #1)
> This is the issue with the test case not with mesa driver. Test is incorrectly
> computing the expected result colors when the texture is luminance, luminance
> alpha or intensity. Similar failures were observed in piglit
> fbo-alphatest-formats (Bug# 47125).

47125 looks like unrelated?
Comment 4 Kenneth Graunke 2012-08-13 20:52:28 UTC
I can verify that lu hua's bisect in comment #1 is correct.  Brian's change is when this started failing for LUMINANCE formats.  I can also report that, with newer Mesa, it fails on many more formats (apparently compressed ones).  That bisects down to this:

a36581ccc06693231011c3fe136207e73191b1ce is the first bad commit
commit a36581ccc06693231011c3fe136207e73191b1ce
Author: Brian Paul <brianp@vmware.com>
Date:   Tue May 1 14:46:04 2012 -0600

    mesa: do more teximage error checking for generic compressed formats

    When glTexImage or glCopyTexImage is called with internalFormat being a
    generic compressed format (like GL_COMPRESSED_RGB) we need to do the same
    error checks as for specific compressed formats.  In particular, check if
    the texture target is compatible with the format.  None of the texture
    compression formats we support so far work with GL_TEXTURE_1D, for example.

    See also https://bugs.freedesktop.org/show_bug.cgi?id=49124

    NOTE: This is a candidate for the 8.0 branch.
Comment 5 Anuj Phogat 2012-08-14 22:56:14 UTC
Sorry for the delay in following up on this bug. Gordon, that was a typo and probably i wanted to quote Bug# 46679. There is a related commit in piglit tests which defines the correct behavior for getting the texture in luminance and luminance_alpha formats using glGetTexImage(): 

commit 5beed3c6524f7881791eef7172ad2e6d4118f984
Author: Brian Paul <brianp@vmware.com>
Date:   Thu Mar 8 08:15:58 2012 -0700

    getteximage-luminance: test readback of GL_LUMINANCE textures
    
    Test various combinations of getting a luminance texture.
    
    v2: also test reading back an RGBA texture as GL_LUMINANCE with glReadPixels.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=46679

compute_expected() function in pxconv-gettex computes expected luminace value as follows: L = R + G + B. Which is wrong in case of glGetTexImage().
Brian Paul explained this by a comment in bisected commit:
"If we're reading back an RGB(A) texture as luminance then we need
to return L=tex(R).  Note, that's different from glReadPixels which
returns L=R+G+B."

I guess this explains the cause of failures in LUMINANCE and LUMINANCE_ALPHA formats. pxconv-gettex computes expected luminace values incorrectly.

I will continue investigating the cause of failures in compressed texture formats which are reported by Ken.
Comment 6 lu hua 2012-08-17 07:02:08 UTC
Can't find commit 5beed3c6524f7881791 on the latest mesa master branch(commit 1597176f7090eea73f41b3114ae2a02a50ac7a12).
Issue still exists.
Comment 7 Anuj Phogat 2012-08-17 18:22:23 UTC
This commit (5beed3c) was on piglit (not on mesa master).I quoted this commit to support my investigation of failures in glGetTexImage() with LUMINANCE and LUMINACE_ALPHA formats. It's a bug in pxconv-gettex test case, not in mesa. So, the test case will continue to fail.
Comment 8 Anuj Phogat 2012-08-21 23:43:56 UTC
Following commit fixes the failures in GL_TEXTURE_1D with generic compressed formats:
commit df2c4cbcedb2dcf2aa44adaa6462d9becccbea49
Author: Anuj Phogat <anuj.phogat@gmail.com>
Date:   Tue Aug 21 11:03:48 2012 -0700

    mesa: Fix generic compressed texture formats' handling in glTexImage /  glCopyTexImage
    
    The generic texture formats should be accepted by the <internalformat>
    parameter of TexImage1D, TexImage2D, TexImage3D, CopyTexImage1D, and
    CopyTexImage2D functions. When the application specifies a generic
    format, the driver is free to pick an uncompressed format.
    
    This patch reverts the changes due to following commit:
    commit a36581ccc06693231011c3fe136207e73191b1ce
    mesa: do more teximage error checking for generic compressed formats
    
    This patch fixes compressed texture format failures in intel oglconform
    pxconv-gettex test case:
    https://bugs.freedesktop.org/show_bug.cgi?id=47220
    
    Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
    Reviewed-by: Brian Paul <brianp@vmware.com>

Now, this bug can be marked fixed/resolved.
Comment 9 lu hua 2012-08-28 05:30:39 UTC
It still fails on Mesa master(commit:a3d9d7ec79d6f7205fab2324e47d8ea185431de0).
Comment 10 Anuj Phogat 2012-08-29 19:58:10 UTC
As I explained in my previous comments, this is an issue with the oglconform pxconv-gettex test case not with mesa driver. Test case incorrectly calculates the expected color values. We have to ignore failures related to LUMINANCE and LUMINACE_ALPHA formats in this test case.
Comment 11 Anuj Phogat 2012-09-11 18:40:06 UTC
I noticed a new bug in mesa drivers while fixing the oglconform pxconv-gettex test case. Failures are observed if getting (glGetTexImage) a RGB(A) compressed texture but returning luminance. We need a fix similar to what Brian posted earlier (f5d0ced) for non-compressed formats. I'll soon post a patch on mailing list for review.
Comment 12 Anuj Phogat 2012-12-01 01:54:12 UTC
Fixed by commit 9ab8962 on mesa master:

mesa: Fix GL_LUMINANCE handling for textures in glGetTexImage
We need to rebase colors (ex: set G=B=0) when getting GL_LUMINANCE
textures in following cases:
1. If the luminance texture is actually stored as rgba
2. If getting a luminance texture, but returning rgba
3. If getting an rgba texture, but returning luminance

A similar fix was pushed by Brian Paul for uncompressed textures
in commit: f5d0ced.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=47220

Observed no regressions in piglit and ogles2conform due to this fix.
This patch will cause failures in intel oglconform pxconv-gettex,
pxstore-gettex and pxtrans-gettex test cases. The cause of failures
is a bug in test cases. Expected luminance value is calculted
incorrectly in test cases: L = R+G+B.

V2: Set G = 0 when getting a RG texture but returning luminance.

Note: This is a candidate for stable branches.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <idr@freedesktop.org>

A patch has been sent to fix oglconform test cases.
Comment 13 Ian Romanick 2012-12-05 04:34:46 UTC
Since we believe Mesa is fixed and a fix is on the way to the test suite, let's close this again.
Comment 14 lu hua 2012-12-05 05:18:35 UTC
Case pxconv-gettex(basic.allCases) fixed on master branch. It still fails on 9.0 branch.

Following cases still fail on master and 9.0 branch.
pxstore-gettex(basic.allCases)
pxtrans-gettex(basic.allCases)
pbo(texImage.1PBOChangeInternalFormat)
pbo(getTexImage.1PBOChangeInternalFormat)
Comment 15 lu hua 2012-12-27 02:31:58 UTC
(In reply to comment #14)
> Case pxconv-gettex(basic.allCases) fixed on master branch. It still fails on
> 9.0 branch.
> 
> Following cases still fail on master and 9.0 branch.
> pxstore-gettex(basic.allCases)
> pxtrans-gettex(basic.allCases)
> pbo(texImage.1PBOChangeInternalFormat)
> pbo(getTexImage.1PBOChangeInternalFormat)


pbo(texImage.1PBOChangeInternalFormat) and pbo(getTexImage.1PBOChangeInternalFormat) fixed on master and 9.0 branch.


pxstore-gettex(basic.allCases) and pxtrans-gettex(basic.allCases) fixed on ivybridge, sandybridge and ironlake with mesa master branch, and still fail on mesa 9.0 branch.

pxstore-gettex(basic.allCases) and pxtrans-gettex(basic.allCases) still fail on pineview with mesa master and 9.0 branch.
Comment 16 Andreas Boll 2013-02-21 15:23:24 UTC
Cherry-picked to the 9.0 branch: b086d9ced7d3ab07afa008aea0253c75e827f392

It will be available in Mesa 9.0.3.
Comment 17 lu hua 2013-02-26 03:07:54 UTC
pxstore-gettex(basic.allCases) and pxtrans-gettex(basic.allCases) still fail on pineview with mesa master and 9.1 branch.
Comment 18 Gordon Jin 2013-04-02 01:40:00 UTC
Anuj, do you think the remaining pxstore-gettex(basic.allCases) and pxtrans-gettex(basic.allCases) failures due to test case bug? If so, we can close this.
Comment 19 Anuj Phogat 2013-04-12 17:59:13 UTC
Gordon, I don't have a pineview system to debug the cause of failure. I might be able to comment if lu can post the log of failures on pineview.
Comment 20 lu hua 2013-04-15 06:17:04 UTC
Created attachment 77973 [details]
output

./oglconform -suite all -v 2 -test pxstore-gettex basic.allCases
Comment 21 Anuj Phogat 2013-04-22 18:38:33 UTC
I looked at the error logs in attachment 77973 [details]. All most all of the failures are due to difference in just alpha values. These differences don't look same as I noticed in other oglconform tests which were not handling GL_LUMINANCE properly for textures in glGetTexImage. More investigations are required to find the cause of failure. I've no immediate plan to debug it on pineview. You might want to open a separate bug for pineview.
Comment 22 Gordon Jin 2013-04-23 04:53:53 UTC
I guess oglc on pineview is not so interesting at this point. Let's just stop here.

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.