Bug 83468 - [UBO] Using bool from UBO as if-statement condition asserts
Summary: [UBO] Using bool from UBO as if-statement condition asserts
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Kenneth Graunke
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-04 01:33 UTC by Ian Romanick
Modified: 2014-09-11 01:04 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Use bool from UBO as if-statement condition (533 bytes, text/plain)
2014-09-04 01:33 UTC, Ian Romanick
Details
Use bool from UBO as if-statement condition (in FS) (401 bytes, text/plain)
2014-09-04 04:34 UTC, Kenneth Graunke
Details
Use bool for UBO as if-statement condition (in FS, v2) (423 bytes, text/plain)
2014-09-04 04:45 UTC, Kenneth Graunke
Details

Note You need to log in before you can comment on or make changes to this bug.
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)

to

    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:
http://lists.freedesktop.org/archives/mesa-dev/2014-September/067204.html
http://lists.freedesktop.org/archives/mesa-dev/2014-September/067206.html
http://lists.freedesktop.org/archives/mesa-dev/2014-September/067205.html

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.