intel/compiler: Fix illegal mutation in get_nir_image_intrinsic_image
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 15 Jan 2020 08:31:49 +0000 (00:31 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Jan 2020 19:25:35 +0000 (19:25 +0000)
commit0a1c47074b9edbb52c4783b34397d24fe98ad96f
treed235394b42abab9cd36b1745465afb6e212ac7f3
parentb706a157c5b3b07425a16bebe3f8ebc5afac8bd3
intel/compiler: Fix illegal mutation in get_nir_image_intrinsic_image

get_nir_image_intrinsic_image() was incorrectly mutating the value held
by the register which holds the intrinsic's first source (image index).

If this happened to be the register for an SSA def which is also used
elsewhere in the program, this meant that we would clobber that value
in subsequent uses.

Note that this only affects i965, because neither anv nor iris use the
binding table start sections, so nothing is ever added here.

Fixes KHR-GL46.compute_shader.resources-max on i965 with Eric Anholt's
MR !3240 applied.  That MR reorders SSBOs and ABOs, so that test uses
image 0 and SSBO 0, causing this code to brilliantly add binding table
index 45 to both the image (correct) and the SSBO (bzzt, wrong!).

Fixes: 09f1de97a76 ("anv,i965: Lower away image derefs in the driver")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3404>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3404>
src/intel/compiler/brw_fs_nir.cpp