glsl: Replace constant-index vector array accesses with swizzles
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 16 Mar 2013 01:05:55 +0000 (18:05 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 29 Mar 2013 19:01:07 +0000 (12:01 -0700)
commitdbf94d105a48b7aafb2c8cf64d8b4392d87efea1
tree520dd307dce18c892fde014b550d1f3a83d7156d
parentc770faea0a308ffb858c0125c9e680c6e477efee
glsl: Replace constant-index vector array accesses with swizzles

Search and replace:

    ][0] -> ].x
    ][1] -> ].y
    ][2] -> ].z
    ][3] -> ].w

Fixes piglit tests inverse-mat[234].{vert,frag}.  These tests call the
inverse function with constant parameters and expect proper constant
folding to happen.  My suspicion is that this patch papers over some bug
in constant propagation involving array accesses.

Either way, all of these accesses eventually get lowered to swizzles.
This cuts out the middle man (saving a trivial amount of CPU).

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Paul Berry <stereotype441@gmail.com>
src/glsl/builtins/glsl/determinant.glsl
src/glsl/builtins/glsl/inverse.glsl