r600/sfn: save some instructions when doing multisample on sample 0
authorGert Wollny <gert.wollny@collabora.com>
Thu, 24 Sep 2020 18:04:30 +0000 (20:04 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 28 Sep 2020 18:16:28 +0000 (18:16 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6879>

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

index 09ba7ba..1df96f6 100644 (file)
@@ -820,16 +820,20 @@ bool EmitTexInstruction::emit_tex_txf_ms(nir_tex_instr* instr, TexInputs& src)
 
    emit_instruction(tex_sample_id_ir);
 
-   emit_instruction(new AluInstruction(op2_mullo_int, help,
-                                       {src.ms_index, PValue(new LiteralValue(4))},
-                                       {alu_write, alu_last_instr}));
 
-   emit_instruction(new AluInstruction(op2_lshr_int, src.coord.reg_i(3),
-                                       {sample_id_dest.reg_i(0), help},
-                                       {alu_write, alu_last_instr}));
+   if (src.ms_index->type() != Value::literal ||
+       static_cast<const LiteralValue&>(*src.ms_index).value() != 0) {
+      emit_instruction(new AluInstruction(op2_lshl_int, help,
+                                          src.ms_index, literal(2),
+      {alu_write, alu_last_instr}));
+
+      emit_instruction(new AluInstruction(op2_lshr_int, sample_id_dest.reg_i(0),
+                                          {sample_id_dest.reg_i(0), help},
+                                          {alu_write, alu_last_instr}));
+   }
 
    emit_instruction(new AluInstruction(op2_and_int, src.coord.reg_i(3),
-                                       {src.coord.reg_i(3), PValue(new LiteralValue(15))},
+                                       {sample_id_dest.reg_i(0), PValue(new LiteralValue(15))},
                                        {alu_write, alu_last_instr}));
 
    auto dst = make_dest(*instr);