Bug 88841

Summary: [SNB/IVB/HSW/BDW Bisected]Piglit spec_EGL_NOK_texture_from_pixmap_basic fails
Product: Mesa Reporter: lu hua <huax.lu>
Component: Drivers/DRI/i965Assignee: Jason Ekstrand <jason>
Status: VERIFIED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: high CC: lemody
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: ogles1conform test log

Description lu hua 2015-01-28 02:43:34 UTC
System Environment:
--------------------------
Platform: SNB+
Libdrm:		(master)libdrm-2.4.59-6-g28ee135a37e10b9a6cd62d67df0332e38ee0b85c
Mesa:		(master)f1a9252defb77f3986305c6a1fc9592093b5a4e5
Xserver:	(master)xorg-server-1.16.99.902-3-gdf1b401f57ad4b4925bad66684445b476562f26f
Xf86_video_intel:(master)2.99.917-59-gb8d52b0edd2ad6a2513d37001ee9d8f67c9acaa7
Libva:		(master)f9741725839ea144e9a6a1827f74503ee39946c3
Libva_intel_driver:(master)3d16cf07b6b65b9bd5c2dd855d97558264a12e79
Kernel:   (drm-intel-nightly)2c2cd37eb3b97bb8846ac3bf75dcb8b4948922d0

Bug detailed description:
---------------------------
It fails on SNB+ platforms with mesa master branch, works well on 10.4 branch.
Bisect shows: 90bd943f2abafd5e3ea29ab8397fd4682ef74170 is the first bad commit
commit 90bd943f2abafd5e3ea29ab8397fd4682ef74170
Author:     Sisinty Sasmita Patra <sisinty.patra@intel.com>
AuthorDate: Fri Dec 12 13:03:21 2014 -0800
Commit:     Jason Ekstrand <jason.ekstrand@intel.com>
CommitDate: Mon Jan 26 17:29:35 2015 -0800

    i965: Implemente a tiled fast-path for glReadPixels and glGetTexImage

    Added intel_readpixels_tiled_mempcpy and intel_gettexsubimage_tiled_mempcpy
    functions. These are the fast paths for glReadPixels and glGetTexImage.

    On chrome, using the RoboHornet 2D Canvas toDataURL test, this patch cuts
    amount of time spent in glReadPixels by more than half and reduces the time
    of the entire test by 10%.

    v2: Jason Ekstrand <jason.ekstrand@intel.com>
       - Refactor to make the functions look more like the old
         intel_tex_subimage_tiled_memcpy
       - Don't export the readpixels_tiled_memcpy function
       - Fix some pointer arithmatic bugs in partial image downloads (using
         ReadPixels with a non-zero x or y offset)
       - Fix a bug when ReadPixels is performed on an FBO wrapping a texture
         miplevel other than zero.

    v3: Jason Ekstrand <jason.ekstrand@intel.com>
       - Better documentation fot the *_tiled_memcpy functions
       - Add target restrictions for renderbuffers wrapping textures

    v4: Jason Ekstrand <jason.ekstrand@intel.com>
       - Only check the return value of brw_bo_map for error and not bo->virtual

    v5: Jason Ekstrand <jason.ekstrand@intel.com>
       - Don't unnecessarily repeat a comment

    Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
    Reviewed-by: Chad Versace <chad.versace@intel.com>

output:
EGL_Y_INVERTED_NOK: TRUE
Probe color at (50,50)
  Expected: 0.500000 0.000000 0.500000 1.000000
  Observed: 0.400000 0.000000 0.000000 1.000000
PIGLIT: {"result": "fail" }

Reproduce steps:
-------------------------
1. xinit
2. bin/egl-nok-texture-from-pixmap -auto
Comment 1 lu hua 2015-01-28 03:22:34 UTC
Following cases also fail with the same bisect commit:
Piglit:
spec_EGL_1.4_eglCreatePbufferSurface_and_then_glClear
Webglc:
conformance/textures/texture-attachment-formats.html
Ogles1conform:
apfunc.c
bclear.c
bcolor.c
blend.c
bufobj.c
clip.c
colramp.c
copytex.c
fogexp.c
foglin.c
linerast.c
logicop.c
l_ac.c
l_al.c
l_am.c
l_ap.c
l_as.c
l_dl.c
l_dm.c
l_dmn.c
l_dmp.c
l_em.c
l_se.c
l_sed.c
l_sen.c
l_sep.c
l_sl.c
l_sm.c
l_sn.c
l_sp.c
mask.c
miplin.c
mipsel.c
mstack.c
multitex.c
mustpass.c
packpix.c
pntrast.c
pntsprt.c
polycull.c
scissor.c
spclear.c
spfunc.c
spop.c
texcombine.c
texdecal.c
texedge.c
texpalet.c
trirast.c
userclip.c
vorder.c
xform.c
xformmix.c
xformvp.c
xformw.c
zbclear.c
zbfunc.c
Comment 2 lu hua 2015-01-28 05:16:39 UTC
Following Ogles2conform cases also fail with the same bisect commit.
ES2-CTS.gtf.GL.read_format.read_format
ES2-CTS.gtf.GL2ExtensionTests.compressed_etc1_rgb8_texture.compressed_etc1_rgb8_texture
ES2-CTS.gtf.GL2ExtensionTests.egl_image.egl_image
ES2-CTS.gtf.GL2ExtensionTests.packed_depth_stencil.packed_depth_stencil
ES2-CTS.gtf.GL2FixedTests.blend.blend
ES2-CTS.gtf.GL2FixedTests.buffer_color.buffer_color
ES2-CTS.gtf.GL2FixedTests.buffer_objects.buffer_objects
ES2-CTS.gtf.GL2FixedTests.color_ramp.color_ramp
ES2-CTS.gtf.GL2FixedTests.copy_texture.copy_texture
ES2-CTS.gtf.GL2FixedTests.depth_buffer_functions.depth_buffer_functions
ES2-CTS.gtf.GL2FixedTests.mipmaps_interpolation.mipmaps_interpolation
ES2-CTS.gtf.GL2FixedTests.mipmaps_selection.mipmaps_selection
ES2-CTS.gtf.GL2FixedTests.point_rasterization.point_rasterization
ES2-CTS.gtf.GL2FixedTests.point_sprites.point_sprites
ES2-CTS.gtf.GL2FixedTests.scissor.scissor
ES2-CTS.gtf.GL2FixedTests.texture_edge_clamp.texture_edge_clamp
ES2-CTS.gtf.GL2FixedTests.transform_viewport.transform_viewport
ES2-CTS.gtf.GL2FixedTests.triangle_rasterization.triangle_rasterization
ES2-CTS.gtf.GL2FixedTests.user_clip_planes.user_clip_planes
ES2-CTS.gtf.GL2FixedTests.vertex_order.vertex_order
ES2-CTS.gtf.GL2Tests.framebuffer_objects.framebuffer_objects

1040 Ogles3conform case fail with the same bisect commit. 
This commit impacts 1121 cases. 1040 Ogles3conform, 2 Piglit, 21 Ogles2conform, 1 webglc, 57 Ogles1conform
Comment 3 Jason Ekstrand 2015-01-28 11:35:13 UTC
I believe I found and fixed the bug.  Please try with this branch:

http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=fix/tiled-window-system
Comment 4 lu hua 2015-01-29 06:24:33 UTC
(In reply to Jason Ekstrand from comment #3)
> I believe I found and fixed the bug.  Please try with this branch:
> 
> http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=fix/tiled-window-system

Test this branch, it still fails.
EGL_Y_INVERTED_NOK: TRUE
Probe color at (50,50)
  Expected: 0.500000 0.000000 0.500000 1.000000
  Observed: 0.400000 0.000000 0.000000 1.000000
PIGLIT: {"result": "fail" }
Comment 5 Tapani Pälli 2015-01-29 07:36:47 UTC
(In reply to lu hua from comment #4)
> (In reply to Jason Ekstrand from comment #3)
> > I believe I found and fixed the bug.  Please try with this branch:
> > 
> > http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=fix/tiled-window-system
> 
> Test this branch, it still fails.
> EGL_Y_INVERTED_NOK: TRUE
> Probe color at (50,50)
>   Expected: 0.500000 0.000000 0.500000 1.000000
>   Observed: 0.400000 0.000000 0.000000 1.000000
> PIGLIT: {"result": "fail" }

Could you retry, maybe something went wrong? I just confirmed that this branch fixes the issue for me.
Comment 6 Sergio Perez 2015-01-29 17:23:12 UTC
the mentioned commit (90bd943f2abafd5e3ea29ab8397fd4682ef74170) causes my installation of the game "Europa Universalis 4" to segfault

could this be related? (issue also not fixed with aforementioned branch)

Reproduce steps:
-------------------------
1. start eu4
2. start single player game

backtrace
#0  0xf743f5d6 in ytiled_to_linear_faster () from /usr/lib32/dri/i965_dri.so
#1  0xf74405bb in tiled_to_linear () from /usr/lib32/dri/i965_dri.so
#2  0xf743c161 in intel_gettexsubimage_tiled_memcpy () from /usr/lib32/dri/i965_dri.so
#3  0xf743c2ec in intel_get_tex_image () from /usr/lib32/dri/i965_dri.so
#4  0xf71a16db in _mesa_get_texture_image () from /usr/lib32/dri/i965_dri.so
#5  0xf71a1867 in _mesa_GetnTexImageARB () from /usr/lib32/dri/i965_dri.so
#6  0xf71a18e1 in _mesa_GetTexImage () from /usr/lib32/dri/i965_dri.so
#7  0x09213699 in GfxTransparentAt(TextureGFX*, int, int, unsigned char*, int) ()
#8  0x08f7fdbe in CMaskedSpriteType::TransparenteAt(CVector2<short> const&, unsigned short) const ()
#9  0x0919d213 in C2dVisibleObject::IntersectDistance(CVector2<float>, CMatrix4<float> const&, CVector3<float>, CVector3<float>&, bool) ()
#10 0x09181ccf in CGraphics::Render2dTree(CMatrix4<float> const&, CGraphicalObject*, SScissorRectangle const*) ()
#11 0x09181d6d in CGraphics::Render2dTree(CMatrix4<float> const&, CGraphicalObject*, SScissorRectangle const*) ()
#12 0x09181a11 in CGraphics::Render2dObjectsToScreen(bool) ()
#13 0x08e98630 in CFrontEnd::Render() ()
#14 0x08e963b7 in CFrontEnd::Idle(bool) ()
#15 0x090f5b1e in CApplication::UpdateOneFrame(bool) ()
#16 0x090f5c7c in CApplication::Run() ()
#17 0x089e7fdd in main ()
Comment 7 lu hua 2015-01-30 02:21:23 UTC
This issue happens on SNB/IVB/HSW/BDW. BSW, BYT and ILK don't have this issue.
Comment 8 Jason Ekstrand 2015-01-30 03:22:55 UTC
(In reply to Sergio Perez from comment #6)
> the mentioned commit (90bd943f2abafd5e3ea29ab8397fd4682ef74170) causes my
> installation of the game "Europa Universalis 4" to segfault
> 
> could this be related? (issue also not fixed with aforementioned branch)
> 
> Reproduce steps:
> -------------------------
> 1. start eu4
> 2. start single player game
> 
> backtrace
> #0  0xf743f5d6 in ytiled_to_linear_faster () from /usr/lib32/dri/i965_dri.so
> #1  0xf74405bb in tiled_to_linear () from /usr/lib32/dri/i965_dri.so
> #2  0xf743c161 in intel_gettexsubimage_tiled_memcpy () from
> /usr/lib32/dri/i965_dri.so
> #3  0xf743c2ec in intel_get_tex_image () from /usr/lib32/dri/i965_dri.so
> #4  0xf71a16db in _mesa_get_texture_image () from /usr/lib32/dri/i965_dri.so
> #5  0xf71a1867 in _mesa_GetnTexImageARB () from /usr/lib32/dri/i965_dri.so
> #6  0xf71a18e1 in _mesa_GetTexImage () from /usr/lib32/dri/i965_dri.so
> #7  0x09213699 in GfxTransparentAt(TextureGFX*, int, int, unsigned char*,
> int) ()
> #8  0x08f7fdbe in CMaskedSpriteType::TransparenteAt(CVector2<short> const&,
> unsigned short) const ()
> #9  0x0919d213 in C2dVisibleObject::IntersectDistance(CVector2<float>,
> CMatrix4<float> const&, CVector3<float>, CVector3<float>&, bool) ()
> #10 0x09181ccf in CGraphics::Render2dTree(CMatrix4<float> const&,
> CGraphicalObject*, SScissorRectangle const*) ()
> #11 0x09181d6d in CGraphics::Render2dTree(CMatrix4<float> const&,
> CGraphicalObject*, SScissorRectangle const*) ()
> #12 0x09181a11 in CGraphics::Render2dObjectsToScreen(bool) ()
> #13 0x08e98630 in CFrontEnd::Render() ()
> #14 0x08e963b7 in CFrontEnd::Idle(bool) ()
> #15 0x090f5b1e in CApplication::UpdateOneFrame(bool) ()
> #16 0x090f5c7c in CApplication::Run() ()
> #17 0x089e7fdd in main ()

This is related, but probably a different issue.  Please open another bug.

If you could, it would be helpful if you could take an apitrace (http://apitrace.github.io/) of the game up until it crashes, upload it somewhere, and provide that on the bug.
Comment 9 lu hua 2015-01-30 05:18:06 UTC
(In reply to Tapani Pälli from comment #5)
> (In reply to lu hua from comment #4)
> > (In reply to Jason Ekstrand from comment #3)
> > > I believe I found and fixed the bug.  Please try with this branch:
> > > 
> > > http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=fix/tiled-window-system
> > 
> > Test this branch, it still fails.
> > EGL_Y_INVERTED_NOK: TRUE
> > Probe color at (50,50)
> >   Expected: 0.500000 0.000000 0.500000 1.000000
> >   Observed: 0.400000 0.000000 0.000000 1.000000
> > PIGLIT: {"result": "fail" }
> 
> Could you retry, maybe something went wrong? I just confirmed that this
> branch fixes the issue for me.

I re-build  and test it on HSW, it still fail.
output:
EGL_Y_INVERTED_NOK: TRUE
Probe color at (50,50)
  Expected: 0.500000 0.000000 0.500000 1.000000
  Observed: 0.400000 0.000000 0.000000 1.000000
PIGLIT: {"result": "fail" }

Test commit: 765cfe9a90b6d592b232d1647d65d50c983bea2f
# git branch
* master
# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git://people.freedesktop.org/~jekstrand/mesa
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
Comment 10 Tapani Pälli 2015-01-30 05:34:23 UTC
(In reply to lu hua from comment #9)
> (In reply to Tapani Pälli from comment #5)
> > (In reply to lu hua from comment #4)
> > > (In reply to Jason Ekstrand from comment #3)
> > > > I believe I found and fixed the bug.  Please try with this branch:
> > > > 
> > > > http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=fix/tiled-window-system
> > > 
> > > Test this branch, it still fails.
> > > EGL_Y_INVERTED_NOK: TRUE
> > > Probe color at (50,50)
> > >   Expected: 0.500000 0.000000 0.500000 1.000000
> > >   Observed: 0.400000 0.000000 0.000000 1.000000
> > > PIGLIT: {"result": "fail" }
> > 
> > Could you retry, maybe something went wrong? I just confirmed that this
> > branch fixes the issue for me.
> 
> I re-build  and test it on HSW, it still fail.
> output:
> EGL_Y_INVERTED_NOK: TRUE
> Probe color at (50,50)
>   Expected: 0.500000 0.000000 0.500000 1.000000
>   Observed: 0.400000 0.000000 0.000000 1.000000
> PIGLIT: {"result": "fail" }
> 
> Test commit: 765cfe9a90b6d592b232d1647d65d50c983bea2f
> # git branch
> * master
> # cat .git/config
> [core]
>         repositoryformatversion = 0
>         filemode = true
>         bare = false
>         logallrefupdates = true
> [remote "origin"]
>         url = git://people.freedesktop.org/~jekstrand/mesa
>         fetch = +refs/heads/*:refs/remotes/origin/*
> [branch "master"]
>         remote = origin
>         merge = refs/heads/master

It looks to me like you are in a wrong branch, you should switch to 'fix/tiled-window-system' branch, hash of HEAD there is "725316b5550449e78789b6b2e0b5e6dccb39ac8f".
Comment 11 lu hua 2015-01-30 06:59:41 UTC
Created attachment 112961 [details]
ogles1conform test log


> It looks to me like you are in a wrong branch, you should switch to
> 'fix/tiled-window-system' branch, hash of HEAD there is
> "725316b5550449e78789b6b2e0b5e6dccb39ac8f".

Sorry, incorrect branch.
Test commit 725316b5550449e78789b6b2e0b5e6dccb39ac8f.

bin/egl-nok-texture-from-pixmap -auto is pass
output:
EGL_Y_INVERTED_NOK: TRUE
PIGLIT: {"result": "pass" }

Run full ogles1conform, some cases still fail.
Comment 12 Tapani Pälli 2015-01-30 07:04:47 UTC
> Run full ogles1conform, some cases still fail.

Yep, this was my impression also, there's 'something' in the copy that does not work for some cases, let's have another bug for those so that we get this fix integrated, otherwise people will get vertically flipped screenshots (often taken with glReadPixels) from their apps.
Comment 13 Jason Ekstrand 2015-01-31 02:59:53 UTC
The first two patches I posted to fix this bug are now upstream.  I have one more patch that fixes the rest of the conformance tests.  I force-pushed my fix/tiled-window-system branch with the new patch.  The exact commit is a8178b2f09ed48d084dc91ac5df9923f2eb16712.  Please verify that it fixes it for you.
Comment 14 Jason Ekstrand 2015-01-31 16:56:01 UTC
The fix is now in master, please verify that it fixes both the piglit tests and the conformance issues.
Comment 15 lu hua 2015-02-02 02:24:09 UTC
Most of the fail have been fixed, except one Ogles3conform and one webglc case.
Ogles3conform case ES3-CTS.gtf.GL3Tests.rgb8_rgba8.rgb8_rgba8_rgb  and welglc case conformance/textures/texture-attachment-formats.html.

run ./glcts --deqp-case=ES3-CTS.gtf.GL3Tests.rgb8_rgba8.rgb8_rgba8_rgb
output:
dEQP Core GL-CTS-2.0 (0x0052484b) starting..
  target implementation = 'X11'

Test case 'ES3-CTS.gtf.GL3Tests.rgb8_rgba8.rgb8_rgba8_rgb'..
INFO:rgb8_rgba8_rgb:Alpha is expected to be one (255) for all the pixels. However, different alpha values were found.
ERROR:rgb8_rgba8_rgb:Gradient test detected insufficient framebuffer color precision or faulty alpha values
  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 16 Jason Ekstrand 2015-02-02 17:52:55 UTC
Ok, I just posted one more patch that I think will fix the last of the problems.  It can again be found on the fix/tiled-window-system branc of my freedesktop.org repository.  It's SHA1 f41bc72a432c1949693880259f8528250758f88b.  Please let me know if it fixes the rest of the regressions.
Comment 17 lu hua 2015-02-03 07:45:49 UTC
(In reply to Jason Ekstrand from comment #16)
> Ok, I just posted one more patch that I think will fix the last of the
> problems.  It can again be found on the fix/tiled-window-system branc of my
> freedesktop.org repository.  It's SHA1
> f41bc72a432c1949693880259f8528250758f88b.  Please let me know if it fixes
> the rest of the regressions.

Test on commit f41bc72a432c1949693880259f8528250758f88b, they work well.
Comment 18 Jason Ekstrand 2015-02-03 18:17:51 UTC
(In reply to lu hua from comment #17)
> (In reply to Jason Ekstrand from comment #16)
> > Ok, I just posted one more patch that I think will fix the last of the
> > problems.  It can again be found on the fix/tiled-window-system branc of my
> > freedesktop.org repository.  It's SHA1
> > f41bc72a432c1949693880259f8528250758f88b.  Please let me know if it fixes
> > the rest of the regressions.
> 
> Test on commit f41bc72a432c1949693880259f8528250758f88b, they work well.

Thanks for all your testing!  The commit has been pushed to master, so I'm closing the bug.
Comment 19 lu hua 2015-02-04 01:24:45 UTC
Verified.Fixed.

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.