Bug 38624 - program/ir_to_mesa.cpp:1440: virtual void ir_to_mesa_visitor::visit(ir_dereference_variable*): Assertion `var->location != -1' failed.
program/ir_to_mesa.cpp:1440: virtual void ir_to_mesa_visitor::visit(ir_derefe...
Status: CLOSED FIXED
Product: Mesa
Classification: Unclassified
Component: glsl-compiler
git
x86 (IA32) Linux (All)
: medium critical
Assigned To: Ian Romanick
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-23 16:26 UTC by Vinson Lee
Modified: 2011-08-18 19:32 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vinson Lee 2011-06-23 16:26:00 UTC
mesa: 9c5d15e929f47f517f90977f5420e11dfbd3db67 (master)

Run piglit "ARB_explicit_attrib_location 1.10 compiler out-01" test on swrast or softpipe.

$ ./bin/glslparsertest tests/spec/arb_explicit_attrib_location/1.10/compiler/out-01.frag pass 1.10
Successfully compiled fragment shader tests/spec/arb_explicit_attrib_location/1.10/compiler/out-01.frag: 
glslparsertest: program/ir_to_mesa.cpp:1440: virtual void ir_to_mesa_visitor::visit(ir_dereference_variable*): Assertion `var->location != -1' failed.

(gdb) bt
#0  0x00133416 in __kernel_vsyscall ()
#1  0x002bd941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x002c0e42 in abort () at abort.c:92
#3  0x002b68e8 in __assert_fail (assertion=0x84cda6 "var->location != -1", file=0x84c88d "program/ir_to_mesa.cpp", line=1440, 
    function=0x84d900 "virtual void ir_to_mesa_visitor::visit(ir_dereference_variable*)") at assert.c:81
#4  0x00659965 in ir_to_mesa_visitor::visit (this=0xbff6ff70, ir=0x8a42628) at program/ir_to_mesa.cpp:1440
#5  0x00687cb3 in ir_dereference_variable::accept (this=0x8a42628, v=0xbff6ff70) at ir.h:1428
#6  0x00659f86 in get_assignment_lhs (ir=0x8a42628, v=0xbff6ff70) at program/ir_to_mesa.cpp:1559
#7  0x0065a1a1 in ir_to_mesa_visitor::visit (this=0xbff6ff70, ir=0x8af9a20) at program/ir_to_mesa.cpp:1660
#8  0x006879bf in ir_assignment::accept (this=0x8af9a20, v=0xbff6ff70) at ir.h:703
#9  0x00656600 in ir_to_mesa_visitor::visit (this=0xbff6ff70, ir=0x8af9828) at program/ir_to_mesa.cpp:891
#10 0x00687949 in ir_function::accept (this=0x8af9828, v=0xbff6ff70) at ir.h:536
#11 0x00694315 in visit_exec_list (list=0x89cc350, visitor=0xbff6ff70) at ir.cpp:1477
#12 0x0065e386 in get_mesa_program (ctx=0x89978e0, shader_program=0x89eaa10, shader=0x8c21a58) at program/ir_to_mesa.cpp:2899
#13 0x0065eeaa in _mesa_ir_link_shader (ctx=0x89978e0, prog=0x89eaa10) at program/ir_to_mesa.cpp:3116
#14 0x0065f4a5 in _mesa_glsl_link_shader (ctx=0x89978e0, prog=0x89eaa10) at program/ir_to_mesa.cpp:3266
#15 0x005fcee8 in link_program (ctx=0x89978e0, program=2) at main/shaderapi.c:877
#16 0x005fe3bd in _mesa_LinkProgramARB (programObj=2) at main/shaderapi.c:1461
#17 0x080695d1 in test ()
#18 0x0806988e in main ()
(gdb) frame 4
#4  0x00659965 in ir_to_mesa_visitor::visit (this=0xbff6ff70, ir=0x8a42628) at program/ir_to_mesa.cpp:1440
1440		 assert(var->location != -1);
Comment 1 Ian Romanick 2011-06-29 10:36:37 UTC
I posted a patch to the mesa-dev mailing list that should fix this issue.

http://marc.info/?l=mesa3d-dev&m=130929376131870&w=2
Comment 2 Ian Romanick 2011-07-07 14:45:35 UTC
Fixed on master by the commits below.  These commits have been cherry picked to 7.11 (127bd9d and 98af042) and 7.10 (c286f78 and 4e2a5d0).

commit d32d4f780f9dad122adb63086da266aec6e88850
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Mon Jun 27 17:59:58 2011 -0700

    linker: Assign locations for fragment shader output
    
    Fixes an assertion failure in the piglib out-01.frag
    ARB_explicit_attrib_location test.  The locations set via the layout
    qualifier in fragment shader were not being applied to the shader
    outputs.  As a result all of these variables still had a location of
    -1 set.
    
    This may need some more work for pre-3.0 contexts.  The problem is
    dealing with generic outputs that lack a layout qualifier.  There is
    no way for the application to specify a location
    (glBindFragDataLocation is not supported) or query the location
    assigned by the linker (glGetFragDataLocation is not supported).
    
    NOTE: This is a candidate for the 7.10 and 7.11 branches.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Cc: Kenneth Graunke <kenneth@whitecape.org>
    Cc: Vinson Lee <vlee@vmware.com>

commit b078aad8ab22d840456688480a8c27d4664297ce
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Jun 28 09:42:24 2011 -0700

    glsl: permit explicit locations on fragment shader outputs, not inputs
    
    From the OpenGL docs for GL_ARB_explicit_attrib_location:
    
        This extension provides a method to pre-assign attribute locations to
        named vertex shader inputs and color numbers to named fragment shader
        outputs.
    
    This was accidentally implemented for fragment shader inputs.  This
    patch fixes it to apply to fragment shader outputs.
    
    Fixes piglit tests
    spec/ARB_explicit_attrib_location/1.{10,20}/compiler/layout-{01,03,06,07,08,09,10}.frag
    
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    
    NOTE: This is a candidate for the 7.10 and 7.11 branches.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624
Comment 3 Vinson Lee 2011-08-18 19:32:51 UTC
mesa: ccecc08f79afc020c8c0acface04a8e53e3a7c32 (master)

Verified fixed.