intel/fs: Fix unused texture coordinate zeroing on Gen4-5
authorJason Ekstrand <jason@jlekstrand.net>
Sun, 26 Apr 2020 14:48:16 +0000 (09:48 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Sat, 30 May 2020 06:08:50 +0000 (01:08 -0500)
We were inserting the right number of MOVs but, thanks to the way we
advanced msg_end earlier in the function, were often writing the zeros
past the end of where we actually read in the register file.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5243>

src/intel/compiler/brw_fs.cpp

index ab97a07d0d1c117cf5d48ddd06358460ec85f6d8..3894217c04557c800775ddaf46489bb1aa2dbbe6 100644 (file)
@@ -4754,7 +4754,8 @@ lower_sampler_logical_send_gen4(const fs_builder &bld, fs_inst *inst, opcode op,
    if (coord_components > 0 &&
        (has_lod || shadow_c.file != BAD_FILE ||
         (op == SHADER_OPCODE_TEX && bld.dispatch_width() == 8))) {
-      for (unsigned i = coord_components; i < 3; i++)
+      assert(coord_components <= 3);
+      for (unsigned i = 0; i < 3 - coord_components; i++)
          bld.MOV(offset(msg_end, bld, i), brw_imm_f(0.0f));
 
       msg_end = offset(msg_end, bld, 3 - coord_components);