Mesa (main): gallivm/nir: handle conversion to 16-bit texel fetch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 16 04:47:05 UTC 2021


Module: Mesa
Branch: main
Commit: 0776628d1d3656ccfc4a09c4f20335a627c349b6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0776628d1d3656ccfc4a09c4f20335a627c349b6

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jul 22 13:20:29 2021 +1000

gallivm/nir: handle conversion to 16-bit texel fetch

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11816>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index a5914484a91..8d2cbc0ce48 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -27,6 +27,7 @@
 #include "lp_bld_arit.h"
 #include "lp_bld_bitarit.h"
 #include "lp_bld_const.h"
+#include "lp_bld_conv.h"
 #include "lp_bld_gather.h"
 #include "lp_bld_logic.h"
 #include "lp_bld_quad.h"
@@ -2170,8 +2171,12 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
 
    if (nir_dest_bit_size(instr->dest) != 32) {
       assert(nir_dest_bit_size(instr->dest) == 16);
-      LLVMTypeRef vec_type;
+      LLVMTypeRef vec_type = NULL;
+      bool is_float = false;
       switch (nir_alu_type_get_base_type(instr->dest_type)) {
+      case nir_type_float:
+         is_float = true;
+	 break;
       case nir_type_int:
          vec_type = bld_base->int16_bld.vec_type;
          break;
@@ -2182,12 +2187,17 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
          unreachable("unexpected alu type");
       }
       for (int i = 0; i < nir_dest_num_components(instr->dest); ++i) {
-         texel[i] = LLVMBuildBitCast(builder, texel[i], bld_base->int_bld.vec_type, "");
-         texel[i] = LLVMBuildTrunc(builder, texel[i], vec_type, "");
+         if (is_float) {
+            texel[i] = lp_build_float_to_half(gallivm, texel[i]);
+         } else {
+            texel[i] = LLVMBuildBitCast(builder, texel[i], bld_base->int_bld.vec_type, "");
+            texel[i] = LLVMBuildTrunc(builder, texel[i], vec_type, "");
+         }
       }
    }
 
    assign_dest(bld_base, &instr->dest, texel);
+
 }
 
 static void visit_ssa_undef(struct lp_build_nir_context *bld_base,



More information about the mesa-commit mailing list