r600/sfn: Add support for texture_samples
authorGert Wollny <gert.wollny@collabora.com>
Sat, 9 May 2020 13:21:01 +0000 (15:21 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 19 May 2020 07:52:13 +0000 (07:52 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5085>

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

index 1495714fab076ab54e2afaa977b9056776955797..a063f6c424e498af2dbd4ef10b94b4a70c073e08 100644 (file)
@@ -97,7 +97,10 @@ bool EmitTexInstruction::do_emit(nir_instr* instr)
          return emit_tex_txf_ms(ir, src);
       case nir_texop_query_levels:
          return emit_tex_txs(ir, src, {3,7,7,7});
+      case nir_texop_texture_samples:
+         return emit_tex_texture_samples(ir, src, {3,7,7,7});
       default:
+
          return false;
       }
    }
@@ -630,6 +633,22 @@ bool EmitTexInstruction::emit_tex_txs(nir_tex_instr* instr, TexInputs& tex_src,
 
 }
 
+bool EmitTexInstruction::emit_tex_texture_samples(nir_tex_instr* instr, TexInputs& src,
+                                                  const std::array<int, 4> &dest_swz)
+{
+   GPRVector dest = vec_from_nir(instr->dest, nir_dest_num_components(instr->dest));
+   GPRVector help{0,{4,4,4,4}};
+
+   auto dyn_offset = PValue();
+   int res_id = R600_MAX_CONST_BUFFERS + instr->sampler_index;
+
+   auto ir = new TexInstruction(TexInstruction::get_nsampled, dest, help,
+                                0, res_id, src.sampler_offset);
+   ir->set_dest_swizzle(dest_swz);
+   emit_instruction(ir);
+   return true;
+}
+
 bool EmitTexInstruction::emit_tex_tg4(nir_tex_instr* instr, TexInputs& src)
 {
    r600::sfn_log << SfnLog::instr << "emit '"
index 5c998b99b45838789afef3ab6268bd8ccd628bf1..e63a6f9cc7128501bc71261bcf2996006008ca96 100644 (file)
@@ -73,6 +73,8 @@ private:
    bool emit_tex_txl(nir_tex_instr* instr, TexInputs& src);
    bool emit_tex_txs(nir_tex_instr* instr, TexInputs& src,
                      const std::array<int, 4> &dest_swz);
+   bool emit_tex_texture_samples(nir_tex_instr* instr, TexInputs& src,
+                                 const std::array<int, 4> &dest_swz);
    bool emit_tex_lod(nir_tex_instr* instr, TexInputs& src);
    bool emit_tex_tg4(nir_tex_instr* instr, TexInputs& src);
    bool emit_tex_txf_ms(nir_tex_instr* instr, TexInputs& src);