Bug 92588

Summary: [HSW,BDW,BSW,SKL-Y][GLES 3.1 CTS] ES31-CTS.arrays_of_arrays.InteractionFunctionCalls2 - assert
Product: Mesa Reporter: Marta Löfstedt <marta.lofstedt>
Component: Drivers/DRI/i965Assignee: Timothy Arceri <t_arceri>
Status: VERIFIED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: major    
Priority: high CC: marta.lofstedt
Version: 11.0   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 92778    
Attachments: Patch that avoid the problem

Description Marta Löfstedt 2015-10-22 08:19:55 UTC
Created attachment 119059 [details]
Patch that avoid the problem

Software versions:
    4.2.0-1-generic
    OpenGL version string: 3.0 Mesa 11.1.0-devel (git-13a5805)

GPU hardware:
    OpenGL renderer string: Mesa DRI Intel(R) Haswell Desktop 
    00:02.0 VGA compatible controller [0300]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06)

CPU hardware:
    x86_64
    Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz

CTS version:
git@67ae88f31295

command: 
./glcts --deqp-case=ES31-CTS.arrays_of_arrays.InteractionFunctionCalls2

Environment:
Mesa built with: --enable-debug
export MESA_GLES_VERSION_OVERRIDE=3.1
export MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader

------------------------------------------------------
When running the InteractionFunctionCalls2 OpenGL ES 3.1 CTS test, I hit below assert:
glcts: nir/nir_lower_vars_to_ssa.c:462: lower_copies_to_load_store: Assertion `arg_entry' failed.
Aborted (core dumped)
With attached patch the issue is avoided and all the Arrays of arrays tests pass. The problem is that we get duplicated set and keys, which are then deleted from the table, so on the second time in the loop we hit the assert. The patch just removes the duplication, but the real fix would avoid the duplication in the first place.
Comment 1 Timothy Arceri 2015-10-31 03:20:54 UTC
It looks like the problem is with the get_deref_node() function, arrays of arrays support looks to be missing here and so its returning the same deref_node for two different AoA vars.
Comment 2 Timothy Arceri 2015-10-31 04:16:21 UTC
Ignore my last comment the AoA support in that function looks fine. There is an issue well before getting to this code.

In assignment visitor in the glsl to nir pass nir_visitor::visit(ir_assignment *ir) the rhs and lhs side reference the same variable.
Comment 3 Timothy Arceri 2015-10-31 10:33:07 UTC
Ok so this isn't a problem just with arrays of arrays its a problem with 1D arrays too. 

I've send a minimal piglit test [1] that triggers the assert, the problem I believe is a missed opportunity to optimise out a redundant assignment and so nir ends up with a scenario it wasn't expecting.

It shouldn't be to hard to fix once I figure out where in the code we would normally optimise this out.

[1] https://patchwork.freedesktop.org/patch/63355/
Comment 4 Timothy Arceri 2015-11-01 08:35:52 UTC
Mesa patch : https://patchwork.freedesktop.org/patch/63372/
Comment 5 Marta Löfstedt 2015-11-02 08:13:28 UTC
I confirm that the patch fixes the problem.
Comment 6 Jason Ekstrand 2015-11-13 06:12:06 UTC
Just pushed a fix.  Turns out it was a bug in nir_lower_vars_to_ssa where it couldn't handle a copy_var from a deref to the same deref.  It's a silly thing to have in a shader but certainly not illegal.

Thanks, Timothy, for pointing me at it!

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.