glsl: fix array assignments of a swizzled vector
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 5 Oct 2018 06:18:20 +0000 (02:18 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 8 Oct 2018 18:29:14 +0000 (14:29 -0400)
commit1bb1c03d618a9636563cf4dcf067876e50ba0d81
treee629e3377b628c65608f3fbad7c1d2adb821da15
parentd3682766f66b69ab636a2b9ca74db48fab68e024
glsl: fix array assignments of a swizzled vector

This happens in situations where we might do

  vec.wzyx[i] = ...

The swizzle would get effectively ignored because of the interaction
between how ir_assignment->set_lhs works and overwriting the write_mask.
There are two cases, one where i is a constant, and another where i is
variable. We have to be extra-careful in both cases.

Fixes the following WebGL test:

  https://www.khronos.org/registry/webgl/sdk/tests/conformance2/glsl3/vector-dynamic-indexing-swizzled-lvalue.html

And the new piglit tests:

  swizzled-writemask-indexing-nonconst.shader_test
  swizzled-writemask-indexing.shader_test

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Cc: mesa-stable@lists.freedesktop.org
src/compiler/glsl/lower_vector_derefs.cpp