Bug 83468

Summary: [UBO] Using bool from UBO as if-statement condition asserts
Product: Mesa Reporter: Ian Romanick <idr>
Component: Drivers/DRI/i965Assignee: Kenneth Graunke <kenneth>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
i915 platform: i915 features:
Attachments: Use bool from UBO as if-statement condition
Use bool from UBO as if-statement condition (in FS)
Use bool for UBO as if-statement condition (in FS, v2)

Description Ian Romanick 2014-09-04 01:33:15 UTC
Created attachment 105711 [details]
Use bool from UBO as if-statement condition

The attached shader causes the following assertion failure:

shader_runner: brw_vec4_visitor.cpp:856: void brw::vec4_visitor::emit_bool_to_cond_code(ir_rvalue*, brw_predicate*): Assertion `!"not reached"' failed.

I have only tested on a fairly stale version of my gles3conform-v5 branch, so this issue may not exist in 10.3 or master branches.  If I don't submit a bug, I'll forget about it...
Comment 1 Ian Romanick 2014-09-04 01:34:20 UTC
Changing the line

    if (b1)


    if (b1 == true)

causes it to not assert.
Comment 2 Kenneth Graunke 2014-09-04 04:34:39 UTC
Created attachment 105714 [details]
Use bool from UBO as if-statement condition (in FS)

Yeah, we need to handle ir_unop_ubo_load in that switch statement.  In both backends.
Comment 3 Kenneth Graunke 2014-09-04 04:45:08 UTC
Created attachment 105715 [details]
Use bool for UBO as if-statement condition (in FS, v2)

Whoops, that FS test had the wrong result.  Here's a better one.
Comment 4 Kenneth Graunke 2014-09-04 07:46:52 UTC
Patches on the mailing list:

The last one should fix it.  It may or may not depend on the second.  The first is just a bug fix while I was in the area :)
Comment 5 Ian Romanick 2014-09-11 01:04:14 UTC
Fixed by:

commit a20cc2796f5d55e49956ac0bc5d61ca027eec7f9
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Thu Sep 4 00:18:45 2014 -0700

    i965: Handle ir_binop_ubo_load in boolean expression code.
    UBO loads can be boolean-valued expressions, too, so we need to handle
    them in emit_bool_to_cond_code() and emit_if_gen6().
    However, unlike most expressions, it doesn't make sense to evaluate
    their operands, then do something with the results.  We just want to
    evaluate the UBO load as a whole---which performs the read from
    memory---then load the boolean result into the flag register.
    Instead of adding code to handle it, we can simply bypass the
    ir_expression handling, and fall through to the default code, which will
    do exactly that.
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83468
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Matt Turner <mattst88@gmail.com>
    Cc: mesa-stable@lists.freedesktop.org

Commit a318e2f3 on 10.3 branch.

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.