r600/sfn: Add support for image_size
authorGert Wollny <gert.wollny@collabora.com>
Sat, 9 May 2020 09:30:19 +0000 (11:30 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Jun 2020 06:58:07 +0000 (06:58 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5206>

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

index f8a843bc61be503dc3ea9398d69813d4cfa2f576..972a0651395e9c6254310a9a9bea50c90aa1a388 100644 (file)
@@ -3,6 +3,7 @@
 #include "sfn_instruction_fetch.h"
 #include "sfn_instruction_gds.h"
 #include "sfn_instruction_misc.h"
+#include "sfn_instruction_tex.h"
 #include "../r600_pipe.h"
 #include "../r600_asm.h"
 
@@ -78,6 +79,8 @@ bool EmitSSBOInstruction::do_emit(nir_instr* instr)
    case nir_intrinsic_image_atomic_imin:
    case nir_intrinsic_image_atomic_imax:
       return emit_image_load(intr);
+   case nir_intrinsic_image_size:
+      return emit_image_size(intr);
    default:
       return false;
    }
@@ -501,6 +504,26 @@ bool EmitSSBOInstruction::fetch_return_value(const nir_intrinsic_instr *intrin)
    return true;
 }
 
+bool EmitSSBOInstruction::emit_image_size(const nir_intrinsic_instr *intrin)
+{
+   GPRVector dest = vec_from_nir(intrin->dest, nir_dest_num_components(intrin->dest));
+   GPRVector src{9,{4,4,4,4}};
+
+   int res_id = R600_IMAGE_REAL_RESOURCE_OFFSET;
+   auto const_offset = nir_src_as_const_value(intrin->src[0]);
+   auto dyn_offset = PValue();
+   if (const_offset)
+      res_id += const_offset[0].u32;
+   else
+      dyn_offset = from_nir(intrin->src[0], 0);
+
+   auto ir = new TexInstruction(TexInstruction::get_resinfo, dest, src,
+                                0/* ?? */,
+                                res_id, dyn_offset);
+   emit_instruction(ir);
+   return true;
+}
+
 GPRVector EmitSSBOInstruction::make_dest(const nir_intrinsic_instr* ir)
 {
    GPRVector::Values v;
index 699075d744bf0c44bb0ddc14a77cb444505dec67..98479da30b2a6cb4875c7bfd1791a83b5dcff7b9 100644 (file)
@@ -26,6 +26,7 @@ private:
    bool emit_load_ssbo(const nir_intrinsic_instr* instr);
    bool emit_store_ssbo(const nir_intrinsic_instr* instr);
 
+   bool emit_image_size(const nir_intrinsic_instr *intrin);
    bool emit_image_load(const nir_intrinsic_instr *intrin);
    bool emit_image_store(const nir_intrinsic_instr *intrin);
    bool emit_ssbo_atomic_op(const nir_intrinsic_instr *intrin);