Bug 32069

Summary: [GLSL] matrix member assignment with a complex subscript fails
Product: Mesa Reporter: Gordon Jin <gordon.jin>
Component: glsl-compilerAssignee: Ian Romanick <idr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: medium CC: chadversary, kenneth
Version: git   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: new test case for piglit shader_runner

Description Gordon Jin 2010-12-02 23:28:06 UTC
Created attachment 40758 [details]
new test case for piglit shader_runner

This fails on Piketon (i965) with mesa master:
	mat2 a;
	a[0][0] = 0;
	a[int(a[0][0])][1] = 1;

Changing a[int(a[0][0])] into a[int(0)] passes.

The subscript is not necessarily for matrix. It also fails for array subscript if it's array of matrix.
Comment 1 Vinson Lee 2010-12-03 23:14:18 UTC
Test case attachment id=40758 committed to piglit.

commit 3e61a4df2e1ffc636b65ff491b6493b2427a3c2d
Author: Gordon Jin <gordon.jin@intel.com>
Date:   Fri Dec 3 23:13:25 2010 -0800

    glsl-complex-subscript: Add test case from FDO bug 32069.
Comment 2 Ian Romanick 2010-12-09 17:15:31 UTC
The output of MESA_GLSL=dump tells the whole story.  a[i].y is never assigned.  I'm having a bit of trouble grokking the generated IR at all.

(
(declare (out ) vec4 gl_FragColor@0x94f4c40)
(function main
  (signature void
    (parameters
    )
    (
      (declare () mat2 a@0x943ce48)
      (assign (constant bool (1)) (x) (array_ref (var_ref a@0x943ce48) (constant int (0)) )  (constant float (0.000000)) ) 
      (declare (temporary ) vec2 dereference_array_value@0x9793278)
      (assign (constant bool (1)) (x) (var_ref dereference_array_value@0x9793278)  (constant float (1.000000)) ) 
      (declare (temporary ) bvec2 dereference_array_condition@0x97a9420)
      (assign (constant bool (1)) (xy) (var_ref dereference_array_condition@0x97a9420)  (expression bvec2 == (swiz xx (expression int f2i (swiz x (array_ref (var_ref a@0x943ce48) (constant int (0)) ) )) )(constant ivec2 (0 1)) ) ) 
      (assign (swiz x (var_ref dereference_array_condition@0x97a9420) ) (xy) (array_ref (var_ref a@0x943ce48) (constant uint (0)) )  (var_ref dereference_array_value@0x9793278) ) 
      (assign (swiz y (var_ref dereference_array_condition@0x97a9420) ) (xy) (array_ref (var_ref a@0x943ce48) (constant uint (1)) )  (var_ref dereference_array_value@0x9793278) ) 
      (declare (temporary ) bool and_tmp@0x943d5b0)
      (if (expression bool all_equal (swiz x (array_ref (var_ref a@0x943ce48) (constant int (0)) ) )(constant float (0.000000)) ) (
        (assign (constant bool (1)) (x) (var_ref and_tmp@0x943d5b0)  (expression bool all_equal (swiz y (array_ref (var_ref a@0x943ce48) (constant int (0)) ) )(constant float (1.000000)) ) ) 
      )
      (
        (assign (constant bool (1)) (x) (var_ref and_tmp@0x943d5b0)  (constant bool (0)) ) 
      ))

      (if (var_ref and_tmp@0x943d5b0) (
        (assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x94f4c40)  (constant vec4 (0.000000 1.000000 0.000000 1.000000)) ) 
      )
      (
        (assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x94f4c40)  (constant vec4 (1.000000 0.000000 0.000000 1.000000)) ) 
      ))

    ))

)


)
Comment 3 Ian Romanick 2011-01-27 12:46:49 UTC
Fixed in master by:

commit c00bc13564e432c496aa685d7b3ca7c60165be02
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Jan 11 14:50:19 2011 -0800

    glsl: Fix the lowering of variable array indexing to not lose write_masks.
    
    Fixes glsl-complex-subscript on 965.

Fixed in 7.10 by:

commit a7028581394975520f249b2f31f7a6bab8199187
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Jan 11 14:50:19 2011 -0800

    glsl: Fix the lowering of variable array indexing to not lose write_masks.
    
    Fixes glsl-complex-subscript on 965.
    (cherry picked from commit c00bc13564e432c496aa685d7b3ca7c60165be02)

The bug did not occur in 7.9 because write masks were handled differently.
Comment 4 Gordon Jin 2011-02-11 21:55:26 UTC
verified.

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.