r600/sfn: emit texture instructions in one block
[mesa.git] / 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;
 }