r600/sfn: emit texture instructions in one block
authorGert Wollny <gert.wollny@collabora.com>
Sun, 5 Jul 2020 14:39:09 +0000 (16:39 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 20 Jul 2020 09:32:51 +0000 (09:32 +0000)
Setting the offset must happen in the same CF like using it, so don't
emit ALU instruction between the tex instructions.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5963>

src/gallium/drivers/r600/sfn/sfn_emittexinstruction.cpp

index a063f6c424e498af2dbd4ef10b94b4a70c073e08..8764d8adeacd6af143dc34b652582af9be252168 100644 (file)
@@ -655,6 +655,8 @@ bool EmitTexInstruction::emit_tex_tg4(nir_tex_instr* instr, TexInputs& src)
                  << *reinterpret_cast<nir_instr*>(instr)
                  << "' (" << __func__ << ")\n";
 
+   TexInstruction *set_ofs = nullptr;
+
    auto tex_op = TexInstruction::gather4;
 
    if (instr->is_shadow)  {
@@ -689,11 +691,10 @@ bool EmitTexInstruction::emit_tex_tg4(nir_tex_instr* instr, TexInputs& src)
          tex_op = (tex_op == TexInstruction::gather4_c) ?
                      TexInstruction::gather4_c_o : TexInstruction::gather4_o;
 
-         auto set_ofs = new TexInstruction(TexInstruction::set_offsets, dummy,
+         set_ofs = new TexInstruction(TexInstruction::set_offsets, dummy,
                                            ofs, sampler.id,
-                                           sampler.id + R600_MAX_CONST_BUFFERS, src.sampler_offset);
+                                      sampler.id + R600_MAX_CONST_BUFFERS, src.sampler_offset);
          set_ofs->set_dest_swizzle({7,7,7,7});
-         emit_instruction(set_ofs);
       }
    }
 
@@ -716,6 +717,9 @@ bool EmitTexInstruction::emit_tex_tg4(nir_tex_instr* instr, TexInputs& src)
 
    set_rect_coordinate_flags(instr, irt);
 
+   if (set_ofs)
+      emit_instruction(set_ofs);
+
    emit_instruction(irt);
    return true;
 }