gallivm: add lp_build_emit_fetch_src() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 30 Mar 2017 17:57:43 +0000 (19:57 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sat, 1 Apr 2017 16:07:49 +0000 (18:07 +0200)
lp_build_emit_fetch() is useful when the source type can be
infered from the instruction opcode.

However, for bindless samplers/images we can't do that easily
because tgsi_opcode_infer_src_type() returns TGSI_TYPE_FLOAT for
TEX instructions, while we need TGSI_TYPE_UNSIGNED64 if the
resource register is bindless.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h

index d368f38d0987b3d621179efdab96356067facad8..69863ab93c9f3c5f81cb9dd0a74f0e7e66382951 100644 (file)
@@ -323,16 +323,14 @@ lp_build_tgsi_inst_llvm(
 
 
 LLVMValueRef
-lp_build_emit_fetch(
+lp_build_emit_fetch_src(
    struct lp_build_tgsi_context *bld_base,
-   const struct tgsi_full_instruction *inst,
-   unsigned src_op,
+   const struct tgsi_full_src_register *reg,
+   enum tgsi_opcode_type stype,
    const unsigned chan_index)
 {
-   const struct tgsi_full_src_register *reg = &inst->Src[src_op];
    unsigned swizzle;
    LLVMValueRef res;
-   enum tgsi_opcode_type stype = tgsi_opcode_infer_src_type(inst->Instruction.Opcode);
 
    if (chan_index == LP_CHAN_ALL) {
       swizzle = ~0u;
@@ -413,7 +411,21 @@ lp_build_emit_fetch(
    }
 
    return res;
+}
+
+
+LLVMValueRef
+lp_build_emit_fetch(
+   struct lp_build_tgsi_context *bld_base,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op,
+   const unsigned chan_index)
+{
+   const struct tgsi_full_src_register *reg = &inst->Src[src_op];
+   enum tgsi_opcode_type stype =
+      tgsi_opcode_infer_src_type(inst->Instruction.Opcode);
 
+   return lp_build_emit_fetch_src(bld_base, reg, stype, chan_index);
 }
 
 
index a9f3d449e74ecc57142345357f0b7959a0940507..eb632b700ab1d5ee479604284ef9b1431fbcd647 100644 (file)
@@ -642,6 +642,13 @@ lp_build_tgsi_inst_llvm(
    struct lp_build_tgsi_context * bld_base,
    const struct tgsi_full_instruction *inst);
 
+LLVMValueRef
+lp_build_emit_fetch_src(
+   struct lp_build_tgsi_context *bld_base,
+   const struct tgsi_full_src_register *reg,
+   enum tgsi_opcode_type stype,
+   const unsigned chan_index);
+
 LLVMValueRef
 lp_build_emit_fetch(
    struct lp_build_tgsi_context *bld_base,