Bug 80880

Summary: Unreal Engine 4 demos fail GLSL compiler assertion
Product: Mesa Reporter: Michel Dänzer <michel>
Component: glsl-compilerAssignee: Tapani Pälli <lemody>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: mzdunek
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: TappyChicken output with MESA_GLSL=dump
patch to fix ir_loop generation

Description Michel Dänzer 2014-07-04 01:15:27 UTC
Trying to run any of the Unreal Engine 4 demos from https://wiki.unrealengine.com/Linux_Demos fails like this:

TappyChicken: ../../../src/glsl/ir_constant_expression.cpp:519: virtual ir_constant* ir_expression::constant_expression_value(hash_table*): Assertion `op[0]->type->base_type == op[1]->type->base_type' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffed703700 (LWP 3105)]
0x00007ffff69c6407 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff69c6407 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff69c77e8 in __GI_abort () at abort.c:89
#2  0x00007ffff69bf516 in __assert_fail_base (fmt=0x7ffff6af5d38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7ffff2299bc8 "op[0]->type->base_type == op[1]->type->base_type", file=file@entry=0x7ffff2299b98 "../../../src/glsl/ir_constant_expression.cpp", 
    line=line@entry=519, 
    function=function@entry=0x7ffff229a340 <ir_expression::constant_expression_value(hash_table*)::__PRETTY_FUNCTION__> "virtual ir_constant* ir_expression::constant_expression_value(hash_table*)") at assert.c:92
#3  0x00007ffff69bf5c2 in __GI___assert_fail (assertion=0x7ffff2299bc8 "op[0]->type->base_type == op[1]->type->base_type", file=0x7ffff2299b98 "../../../src/glsl/ir_constant_expression.cpp", 
    line=519, function=0x7ffff229a340 <ir_expression::constant_expression_value(hash_table*)::__PRETTY_FUNCTION__> "virtual ir_constant* ir_expression::constant_expression_value(hash_table*)")
    at assert.c:101
#4  0x00007ffff1fa8798 in ir_expression::constant_expression_value (this=0x7fffe95c8530, variable_context=<optimized out>) at ../../../src/glsl/ir_constant_expression.cpp:519
#5  0x00007ffff1fa50c4 in ir_expression::constant_expression_value (this=0x7fffe95c85c0, variable_context=0x0) at ../../../src/glsl/ir_constant_expression.cpp:503
#6  0x00007ffff1fa50c4 in ir_expression::constant_expression_value (this=0x7fffe95c8650, variable_context=0x0) at ../../../src/glsl/ir_constant_expression.cpp:503
#7  0x00007ffff1fbc082 in calculate_iterations (from=from@entry=0x7fffe9191910, to=to@entry=0x7fffe93fa640, increment=0x7fffe920a380, op=op@entry=ir_binop_gequal)
    at ../../../src/glsl/loop_controls.cpp:140
#8  0x00007ffff1fbb4ef in (anonymous namespace)::loop_analysis::visit_leave (this=<optimized out>, ir=0x7fffe971a3a0) at ../../../src/glsl/loop_analysis.cpp:442
#9  0x00007ffff1faa7df in visit_list_elements (v=v@entry=0x7fffed701bf0, l=l@entry=0x7fffe944e758, statement_list=statement_list@entry=true) at ../../../src/glsl/ir_hv_accept.cpp:55
#10 0x00007ffff1faa939 in ir_function_signature::accept (this=0x7fffe944e710, v=0x7fffed701bf0) at ../../../src/glsl/ir_hv_accept.cpp:115
#11 0x00007ffff1faa7df in visit_list_elements (v=v@entry=0x7fffed701bf0, l=l@entry=0x7fffe97740a8, statement_list=statement_list@entry=false) at ../../../src/glsl/ir_hv_accept.cpp:55
#12 0x00007ffff1faa9a7 in ir_function::accept (this=0x7fffe9774080, v=0x7fffed701bf0) at ../../../src/glsl/ir_hv_accept.cpp:127
#13 0x00007ffff1faa7df in visit_list_elements (v=v@entry=0x7fffed701bf0, l=l@entry=0x7fffe917e130, statement_list=statement_list@entry=true) at ../../../src/glsl/ir_hv_accept.cpp:55
#14 0x00007ffff1faa67f in ir_hierarchical_visitor::run (this=this@entry=0x7fffed701bf0, instructions=instructions@entry=0x7fffe917e130) at ../../../src/glsl/ir_hierarchical_visitor.cpp:323
#15 0x00007ffff1fbbae2 in analyze_loop_variables (instructions=instructions@entry=0x7fffe917e130) at ../../../src/glsl/loop_analysis.cpp:638
#16 0x00007ffff1f9bcf4 in do_common_optimization (ir=0x7fffe917e130, linked=linked@entry=true, uniform_locations_assigned=uniform_locations_assigned@entry=false, 
    options=options@entry=0x49d8758, native_integers=<optimized out>) at ../../../src/glsl/glsl_parser_extras.cpp:1574
#17 0x00007ffff1fb9480 in link_shaders (ctx=ctx@entry=0x49b7330, prog=prog@entry=0x7fffe9511560) at ../../../src/glsl/linker.cpp:2666
#18 0x00007ffff1f33d83 in _mesa_glsl_link_shader (ctx=0x49b7330, prog=0x7fffe9511560) at ../../../src/mesa/program/ir_to_mesa.cpp:3075
#19 0x00007ffff1e752eb in link_program (ctx=0x49b7330, program=<optimized out>) at ../../../src/mesa/main/shaderapi.c:915

P.S. Since I'm using a Gallium driver, I have to revert commit f4b0ab7afd83c811329211eae8167c9bf238870c, or I run into another assertion failure first. This is being discussed on the mesa-dev mailing list.
Comment 1 Kenneth Graunke 2014-07-09 07:27:42 UTC
Pretty sure this is Matt's tree rebalancer not coping with vector * scalar stuff correctly, which is a recent regression.
Comment 2 Matt Turner 2014-07-10 18:27:37 UTC
Two patches on the list

[PATCH 1/2] glsl: Add callback_leave to ir_hierarchical_visitor.
[PATCH 2/2] glsl: Update expression types after rebalancing the tree.
Comment 3 Matt Turner 2014-07-15 17:15:54 UTC
Should be fixed by

http://cgit.freedesktop.org/mesa/mesa/commit/?id=103716a8629858f6af32a3a6b195a4dc78c356d2

Let me know if there are still problems.
Comment 4 Tim Writer 2014-07-15 17:31:24 UTC
I'm out of the office until Tuesday, July 22.

For urgent issues pertaining to Open Source Graphics, please contact Alex Deucher.

For urgent issues pertaining to Embedded Linux Graphics, please contact Samuel Li.

For urgent issues pertaining to CMM/QS, please contact Serguei Sagalovitch.
Comment 5 Michel Dänzer 2014-07-28 10:04:49 UTC
Created attachment 103582 [details]
TappyChicken output with MESA_GLSL=dump
Comment 6 Michel Dänzer 2014-07-28 10:05:38 UTC
I'm still hitting this after working around bug 81834. I attached the MESA_GLSL=dump output.
Comment 7 Tapani Pälli 2014-07-29 06:11:46 UTC
This looks like a case where we would need implicit conversion between unsigned and signed types, adding implicit conversion where the expression gets generated should fix this but requires client to use GLSL 4.0. I will try to see if this helps.
Comment 8 Christoph Haag 2014-07-29 07:22:19 UTC
In case other people look at this bug, there is another backtrace where it runs into a failed assertion: https://bugs.freedesktop.org/show_bug.cgi?id=75276#c32

You are right, after reverting f4b0ab7afd83c811329211eae8167c9bf238870c this does not happen anymore.

With the TappyChicken demo, I then get bug 80880 too.
Comment 9 Christoph Haag 2014-07-29 07:26:11 UTC
(In reply to comment #8)
Sorry, posted in the wrong tab.
Comment 10 Tapani Pälli 2014-07-30 10:07:55 UTC
Created attachment 103679 [details] [review]
patch to fix ir_loop generation

Here's a fix. Alternatively we could add a ir_unop_i2u cast for the iter. I'm not sure which solution is preferable.
Comment 11 Michel Dänzer 2014-07-30 14:46:05 UTC
(In reply to comment #10)
> Here's a fix.

Works for me, thanks.
Comment 12 Tapani Pälli 2014-08-07 04:34:10 UTC
fix pushed in

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.