Bug 79903

Summary: [HSW Bisected]Some Piglit and Ogles2conform cases fail
Product: Mesa Reporter: lu hua <huax.lu>
Component: Drivers/DRI/i965Assignee: Kenneth Graunke <kenneth>
Status: VERIFIED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: major    
Priority: high CC: itoral, kenneth
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description lu hua 2014-06-11 02:44:18 UTC
System Environment:
--------------------------
Platform: Haswell
Libdrm:		(master)libdrm-2.4.54-9-g8fc62ca8ac010659023bb63c4759eb683de4f9af
Mesa:		(master)5cb1cad0aef8d1c426207c955996278290e19e60
Xserver:	(master)xorg-server-1.15.99.903-1-ge27a839bf0488d5b1cc2e2a887f2ea0e3d790790
Xf86_video_intel:(master)2.99.911-294-g68ac3039e4170b318952213311534cd213cbaff7
Libva:		(staging)35e70cb9b9c77dfb99fb370e319ed501f0c31b17
Libva_intel_driver:(staging)20bee4c3cb478702155df1779f24ec483aeab059
Kernel:	(drm-intel-nightly)969b3c5a312e849fa7a3dc0937a6acf34cdd7e25

Bug detailed description:
-------------------------
Some Piglit and Ogles2conform cases fail on Haswell with Mesa master branch, they works well on 10.1 branch.
Piglit cases:
glean_glsl1-discard_statement_(1)
glean_glsl1-discard_statement_in_for_loop
shaders_glsl-fs-discard-01
shaders_glsl-fs-discard-02
shaders_glsl-fs-discard-03
shaders_glsl-fs-if-texture2d-discard
spec_ARB_fragment_program_fp-kil
spec_ARB_fragment_program_kil-swizzle
spec_glsl-1.30_execution_fs-discard-exit-1
spec_glsl-1.30_execution_fs-discard-exit-2
spec_OpenGL_2.0_occlusion-query-discard
Ogles2conform cases:
GL2FixedTests_user_clip_planes_user_clip_planes.test
GL_discard_discard_cond_frag.test
GL_discard_discard_frag.test

Bisect shows:dc2d3a7f5c217a7cee92380fbf503924a9591bea is the first bad commit.
commit dc2d3a7f5c217a7cee92380fbf503924a9591bea
Author:     Iago Toral Quiroga <itoral@igalia.com>
AuthorDate: Thu Jun 5 15:03:08 2014 +0200
Commit:     Iago Toral Quiroga <itoral@igalia.com>
CommitDate: Mon Jun 9 11:48:49 2014 +0200

    i965/fs: Add Gen < 6 runtime checks for line antialiasing.

    In Gen < 6 the hardware generates a runtime bit that indicates whether AA da
    has to be sent as part of the framebuffer write SEND message. This affects t
    specific case where we have setup antialiased line rendering and we render
    polygons which have one face setup in GL_LINE mode (line antialiasing
    will be used) and the other one in GL_FILL mode (no line antialiasing needed

    Currently we are not doing this runtime test and instead we always send AA
    data, which produces incorrect rendering of the GL_FILL face of the polygon
    in the aforementioned scenario (verified in ironlake and gm45).

    In Gen4 this is, likely, a regression introduced with commit 098acf6c843. In
    Gen5 this has never worked properly. Gen > 5 are not affected by this.

    The patch fixes the problem by adding the appropriate runtime check and
    adjusting the framebuffer write message accordingly in the conflictive
    scenario.

    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78679

    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

run  bin/fp-kil -auto
output:
GL_RENDERER = Mesa DRI Intel(R) Haswell Desktop
Probe color at (20,20)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (80,20)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (20,80)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (37,112)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (62,112)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (87,112)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (12,137)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (37,137)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (62,137)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (87,137)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (12,162)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (37,162)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (62,162)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (87,162)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (12,187)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (37,187)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (62,187)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
Probe color at (87,187)
  Expected: 0.000000 0.000000 0.000000 1.000000
  Observed: 0.000000 1.000000 0.000000 1.000000
PIGLIT: {'result': 'fail' }

Reproduce steps:
-------------------------
1. xinit
2. bin/fp-kil -auto
Comment 1 Kenneth Graunke 2014-06-11 03:12:50 UTC
Fix on the mailing list:
http://lists.freedesktop.org/archives/mesa-dev/2014-June/061201.html
Comment 2 Kenneth Graunke 2014-06-12 09:30:21 UTC
Fixed.

commit a2ad771671d94feae16b35c26ed4d1907f74f50e
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Tue Jun 10 18:50:03 2014 -0700

    i965: Fix Haswell discard regressions since Gen4-5 line AA fix.
    
    In commit dc2d3a7f5c217a7cee92380fbf503924a9591bea, Iago accidentally
    moved fire_fb_write() above the brw_pop_insn_state(), which caused the
    SEND to lose its predication and change from WE_normal to WE_all.
    Haswell uses predicated SENDs for discards, so this broke Piglit's
    tests for discards.
    
    We want the Gen4-5 MOV to be uncompressed, unpredicated, and unmasked,
    but the actual FB write itself should respect those.  So, pop state
    first, and force it again around the single MOV.
    
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Matt Turner <mattst88@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79903
Comment 3 lu hua 2014-06-16 02:43:49 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.