Bug 107088 - [GEN8+] Hang when discarding a fragment if dual source blending is enabled but shader doesn't support it
Summary: [GEN8+] Hang when discarding a fragment if dual source blending is enabled bu...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 107306
  Show dependency treegraph
 
Reported: 2018-07-02 13:58 UTC by Danylo
Modified: 2018-10-31 23:42 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Danylo 2018-07-02 13:58:53 UTC
The hang is reproducible under the next conditions

- Have blending enabled and use GL_SRC1_COLOR in blend function
- Have depth test enabled
- Have fragment shader which doesn't have second color output and discards fragments
- Draw something with this shader
- Hang will occur 

The hang was found in Unigine Heaven 4.0 running in dx11 mode under wine during the investigation of the bug https://bugs.freedesktop.org/show_bug.cgi?id=103556. I believe this two hangs are separate issues since one in the original bug seems to happened with native Unigine version and doesn't happen anymore.

The situation when dual color blending is enabled but shader doesn't support it is undefined as stated in documentation (vol.7 3D-Media-GPGPU):

"If SRC1 is included in a src/dst blend factor and a DualSource RT Write message is not used, results are UNDEFINED. (This reflects the same restriction in DX APIs, where undefined results are produced if “o1” is not written by a PS – there are no default values defined). If SRC1 is not included in a src/dst blend factor, dual source blending must be disabled."
Comment 1 Danylo 2018-07-02 14:07:02 UTC
Sent a patch to fix it https://patchwork.freedesktop.org/patch/235939/
Comment 2 Eero Tamminen 2018-07-20 11:02:11 UTC
(In reply to Danylo from comment #0)
> The hang was found in Unigine Heaven 4.0 running in dx11 mode under wine
> during the investigation of the bug
> https://bugs.freedesktop.org/show_bug.cgi?id=103556. I believe this two
> hangs are separate issues since one in the original bug seems to happened
> with native Unigine version and doesn't happen anymore.

Does Mesa use this drirc entry also when Heaven is run through Wine:
---------------------------------------------------------------
        <application name="Unigine Heaven (64-bit)" executable="heaven_x64">
            <option name="allow_glsl_extension_directive_midshader" value="true" />
            <!-- remove dual_color_blend_by_location if 4.1 ever comes out -->
            <option name="dual_color_blend_by_location" value="true" />
        </application>
---------------------------------------------------------------
?

(did you try native Heaven with Heaven drirc blend part commented out?)
Comment 3 Danylo 2018-07-20 11:26:54 UTC
(In reply to Eero Tamminen from comment #2)
> (In reply to Danylo from comment #0)
> > The hang was found in Unigine Heaven 4.0 running in dx11 mode under wine
> > during the investigation of the bug
> > https://bugs.freedesktop.org/show_bug.cgi?id=103556. I believe this two
> > hangs are separate issues since one in the original bug seems to happened
> > with native Unigine version and doesn't happen anymore.
> 
> Does Mesa use this drirc entry also when Heaven is run through Wine:
> ---------------------------------------------------------------
>         <application name="Unigine Heaven (64-bit)" executable="heaven_x64">
>             <option name="allow_glsl_extension_directive_midshader"
> value="true" />
>             <!-- remove dual_color_blend_by_location if 4.1 ever comes out
> -->
>             <option name="dual_color_blend_by_location" value="true" />
>         </application>
> ---------------------------------------------------------------
> ?

No, under Wine process is "heaven.exe".

> 
> (did you try native Heaven with Heaven drirc blend part commented out?)

When blend workaround is commented in drirc there is a hang.
Comment 4 Kenneth Graunke 2018-10-30 20:01:12 UTC
Fixed by:

commit eca4a6548d07bbbb02a7768edb397bad7b72cfc2
Author: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Date:   Mon Jul 2 17:04:23 2018 +0300

    i965: Disable dual source blending when shader doesn't support it on gen8+
    
    Dual source blending behaviour is undefined when shader doesn't
    have second color output, dismissing fragment in such situation
    leads to a hang on gen8+ if depth test in enabled.
    
    Since blending cannot be gracefully fixed in such case and the result
    is undefined - blending is simply disabled.
    
    v2 (Kenneth Graunke):
     - Listen to BRW_NEW_FS_PROG_DATA in 3DSTATE_PS_BLEND
     - Also whack BLEND_STATE[] to keep the two in sync, since we're not
       sure exactly which copy of the redundant info the hardware will use.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107088
    Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
    Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Comment 5 Danylo 2018-10-31 08:11:32 UTC
Kenneth, thanks for the review and improvements!
Comment 6 Kenneth Graunke 2018-10-31 15:50:27 UTC
Yeah!  Thanks for reminding me about the patch, I completely forgot that you'd sent that months ago. :(
Comment 7 Dongseong Hwang 2018-10-31 23:42:31 UTC
Thanks for fixing!


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.