Bug 75661

Summary: st_glsl_to_tgsi.cpp:637:get_opcode: Assertion `src0.type != GLSL_TYPE_STRUCT' failed.
Product: Mesa Reporter: Vinson Lee <vlee>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: medium CC: bryancain3+fdo
Version: gitKeywords: bisected, have-backtrace, regression
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Vinson Lee 2014-03-02 04:45:20 UTC
mesa: fc25956badb8e1932cc19d8c97b4be16e92dfc65 (master 10.2.0-devel)

piglit fs-deref-literal-array-of-structs triggers an assert on softpipe and llvmpipe.

$ ./bin/shader_runner tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs.shader_test -auto
state_tracker/st_glsl_to_tgsi.cpp:637:get_opcode: Assertion `src0.type != GLSL_TYPE_STRUCT' failed.
Trace/breakpoint trap (core dumped)

(gdb) bt
#0  0x00007f527f2d9a1b in _debug_assert_fail (expr=0x7f527f41c182 "src0.type != GLSL_TYPE_STRUCT", 
    file=0x7f527f41c0d0 "state_tracker/st_glsl_to_tgsi.cpp", line=637, 
    function=0x7f527f41d508 <glsl_to_tgsi_visitor::get_opcode(ir_instruction*, unsigned int, st_dst_reg, st_src_reg, st_src_reg)::__FUNCTION__> "get_opcode") at util/u_debug.c:278
#1  0x00007f527f141e2a in glsl_to_tgsi_visitor::get_opcode (this=0x10cc050, ir=0x10e4460, op=1, dst=..., 
    src0=..., src1=...) at state_tracker/st_glsl_to_tgsi.cpp:637
#2  0x00007f527f14162e in glsl_to_tgsi_visitor::emit (this=0x10cc050, ir=0x10e4460, op=1, dst=..., src0=..., 
    src1=..., src2=...) at state_tracker/st_glsl_to_tgsi.cpp:533
#3  0x00007f527f141c77 in glsl_to_tgsi_visitor::emit (this=0x10cc050, ir=0x10e4460, op=1, dst=..., src0=...)
    at state_tracker/st_glsl_to_tgsi.cpp:616
#4  0x00007f527f14c9d1 in glsl_to_tgsi_visitor::visit (this=0x10cc050, ir=0x10e4460)
    at state_tracker/st_glsl_to_tgsi.cpp:2492
#5  0x00007f527f21b69c in ir_constant::accept (this=0x10e4460, v=0x10cc050) at ../../src/glsl/ir.h:2134
#6  0x00007f527f14acdc in glsl_to_tgsi_visitor::visit (this=0x10cc050, ir=0x10e48e0)
    at state_tracker/st_glsl_to_tgsi.cpp:2085
#7  0x00007f527f21b5f0 in ir_dereference_array::accept (this=0x10e48e0, v=0x10cc050)
    at ../../src/glsl/ir.h:2024
#8  0x00007f527f14b3a3 in glsl_to_tgsi_visitor::visit (this=0x10cc050, ir=0x10e4950)
    at state_tracker/st_glsl_to_tgsi.cpp:2163
#9  0x00007f527f21b65e in ir_dereference_record::accept (this=0x10e4950, v=0x10cc050)
    at ../../src/glsl/ir.h:2072
#10 0x00007f527f14b9f5 in glsl_to_tgsi_visitor::visit (this=0x10cc050, ir=0x10e4a00)
    at state_tracker/st_glsl_to_tgsi.cpp:2338
#11 0x00007f527f21b318 in ir_assignment::accept (this=0x10e4a00, v=0x10cc050) at ../../src/glsl/ir.h:1053
#12 0x00007f527f143954 in glsl_to_tgsi_visitor::visit (this=0x10cc050, ir=0x10e4130)
    at state_tracker/st_glsl_to_tgsi.cpp:1187
#13 0x00007f527f21b268 in ir_function::accept (this=0x10e4130, v=0x10cc050) at ../../src/glsl/ir.h:920
#14 0x00007f527f2183dd in visit_exec_list (list=0x10d8fe0, visitor=0x10cc050) at ../../src/glsl/ir.cpp:1725
#15 0x00007f527f156f98 in get_mesa_program (ctx=0x7f52843d2010, shader_program=0x10cb510, shader=0x10d8e10)
    at state_tracker/st_glsl_to_tgsi.cpp:5144
#16 0x00007f527f1577eb in st_link_shader (ctx=0x7f52843d2010, prog=0x10cb510)
    at state_tracker/st_glsl_to_tgsi.cpp:5376
#17 0x00007f527f16d3ec in _mesa_glsl_link_shader (ctx=0x7f52843d2010, prog=0x10cb510)
    at program/ir_to_mesa.cpp:3093
#18 0x00007f527f068b97 in link_program (ctx=0x7f52843d2010, program=3) at main/shaderapi.c:913
#19 0x00007f527f069cd1 in _mesa_LinkProgram (programObj=3) at main/shaderapi.c:1377
#20 0x00007f5283f0d469 in stub_glLinkProgram (program=3)
    at piglit/tests/util/generated_dispatch.c:17573
#21 0x000000000040586e in link_and_use_shaders () at piglit/tests/shaders/shader_runner.c:814
#22 0x00000000004094f0 in piglit_init (argc=2, argv=0x7fff9e9bf9c8)
    at piglit/tests/shaders/shader_runner.c:2055
#23 0x00007f5283ee7a1a in run_test (gl_fw=0x7f52841d6360 <glut_fw>, argc=2, argv=0x7fff9e9bf9c8)
    at piglit/tests/util/piglit-framework-gl/piglit_glut_framework.c:140
#24 0x00007f5283ee57e9 in piglit_gl_test_run (argc=2, argv=0x7fff9e9bf9c8, config=0x7fff9e9bf890)
    at piglit/tests/util/piglit-framework-gl.c:191
#25 0x000000000040415e in main (argc=2, argv=0x7fff9e9bf9c8)
    at piglit/tests/shaders/shader_runner.c:60
(gdb) frame 1
#1  0x00007f527f141e2a in glsl_to_tgsi_visitor::get_opcode (this=0x10cc050, ir=0x10e4460, op=1, dst=..., 
    src0=..., src1=...) at state_tracker/st_glsl_to_tgsi.cpp:637
637	   assert(src0.type != GLSL_TYPE_STRUCT);
(gdb) print src0.type
$1 = 7
(gdb) print /d GLSL_TYPE_STRUCT
$2 = 7
Comment 1 Vinson Lee 2014-03-03 22:59:49 UTC
ebd8df7a3152e34805e2863c8471ee1a2de38fe1 is the first bad commit
commit ebd8df7a3152e34805e2863c8471ee1a2de38fe1
Author: Bryan Cain <bryancain3@gmail.com>
Date:   Tue Oct 23 11:58:40 2012 -0500

    glsl_to_tgsi: set correct register type for array and structure elements
    
    This fixes an issue where glsl_to_tgsi_visior::get_opcode() would emit the
    wrong opcode because the register type was GLSL_TYPE_ARRAY/STRUCT instead of
    GLSL_TYPE_FLOAT/INT/UINT/BOOL, so the function would use the float opcodes for
    operations on integer or boolean values dereferenced from an array or
    structure.  Assertions have been added to get_opcode() to prevent this bug
    from reappearing in the future.

:040000 040000 a1514a0bff8facb9462bd47ae879ae6cee1813f4 78f7de501607623cc59255860ca8583d9da2cd07 M	src
bisect run success
Comment 2 Vinson Lee 2016-07-08 23:40:05 UTC
mesa: 83a782cd5ed6d0c3265b4bd817160fc4de6a19c1 (master 12.1.0-devel)

piglit fs-deref-literal-array-of-structs passes on both llvmpipe and softpipe.

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.