Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
---
 src/amd/common/ac_llvm_build.c           | 20 ++++++++++++++++++
 src/amd/common/ac_llvm_build.h           |  3 +++
 src/amd/common/ac_nir_to_llvm.c          | 23 +-------------------
 src/gallium/drivers/radeonsi/si_shader.c | 27 +-----------------------
 4 files changed, 25 insertions(+), 48 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 6a1ba5de0e0..d305af280d5 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -4037,3 +4037,23 @@ ac_build_frexp_mant(struct ac_llvm_context *ctx, 
LLVMValueRef src0,
        return ac_build_intrinsic(ctx, intr, type, params, 1,
                                  AC_FUNC_ATTR_READNONE);
 }
+
+/*
+ * this takes an I,J coordinate pair,
+ * and works out the X and Y derivatives.
+ * it returns DDX(I), DDX(J), DDY(I), DDY(J).
+ */
+LLVMValueRef
+ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij)
+{
+       LLVMValueRef result[4], a;
+       unsigned i;
+
+       for (i = 0; i < 2; i++) {
+               a = LLVMBuildExtractElement(ctx->builder, interp_ij,
+                                           LLVMConstInt(ctx->i32, i, false), 
"");
+               result[i] = ac_build_ddxy(ctx, AC_TID_MASK_TOP_LEFT, 1, a);
+               result[2+i] = ac_build_ddxy(ctx, AC_TID_MASK_TOP_LEFT, 2, a);
+       }
+       return ac_build_gather_values(ctx, result, 4);
+}
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 61689f6a07e..64b6894538e 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -686,6 +686,9 @@ LLVMValueRef
 ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
                    unsigned bitsize);
 
+LLVMValueRef
+ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 1287507628a..733c535c378 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -540,27 +540,6 @@ static LLVMValueRef emit_ddxy(struct ac_nir_context *ctx,
        return result;
 }
 
-/*
- * this takes an I,J coordinate pair,
- * and works out the X and Y derivatives.
- * it returns DDX(I), DDX(J), DDY(I), DDY(J).
- */
-static LLVMValueRef emit_ddxy_interp(
-       struct ac_nir_context *ctx,
-       LLVMValueRef interp_ij)
-{
-       LLVMValueRef result[4], a;
-       unsigned i;
-
-       for (i = 0; i < 2; i++) {
-               a = LLVMBuildExtractElement(ctx->ac.builder, interp_ij,
-                                           LLVMConstInt(ctx->ac.i32, i, 
false), "");
-               result[i] = emit_ddxy(ctx, nir_op_fddx, a);
-               result[2+i] = emit_ddxy(ctx, nir_op_fddy, a);
-       }
-       return ac_build_gather_values(&ctx->ac, result, 4);
-}
-
 static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
 {
        LLVMValueRef src[4], result = NULL;
@@ -3038,7 +3017,7 @@ static LLVMValueRef visit_interp(struct ac_nir_context 
*ctx,
 
        if (location == INTERP_CENTER) {
                LLVMValueRef ij_out[2];
-               LLVMValueRef ddxy_out = emit_ddxy_interp(ctx, interp_param);
+               LLVMValueRef ddxy_out = ac_build_ddxy_interp(&ctx->ac, 
interp_param);
 
                /*
                 * take the I then J parameters, and the DDX/Y for it, and
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index efae02ee91c..8ebc8d39e99 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3924,31 +3924,6 @@ static void si_llvm_emit_ddxy(
        emit_data->output[emit_data->chan] = val;
 }
 
-/*
- * this takes an I,J coordinate pair,
- * and works out the X and Y derivatives.
- * it returns DDX(I), DDX(J), DDY(I), DDY(J).
- */
-static LLVMValueRef si_llvm_emit_ddxy_interp(
-       struct lp_build_tgsi_context *bld_base,
-       LLVMValueRef interp_ij)
-{
-       struct si_shader_context *ctx = si_shader_context(bld_base);
-       LLVMValueRef result[4], a;
-       unsigned i;
-
-       for (i = 0; i < 2; i++) {
-               a = LLVMBuildExtractElement(ctx->ac.builder, interp_ij,
-                                           LLVMConstInt(ctx->i32, i, 0), "");
-               result[i] = ac_build_ddxy(&ctx->ac, AC_TID_MASK_TOP_LEFT, 1,
-                                         ac_to_integer(&ctx->ac, a)); /* DDX */
-               result[2+i] = ac_build_ddxy(&ctx->ac, AC_TID_MASK_TOP_LEFT, 2,
-                                           ac_to_integer(&ctx->ac, a)); /* DDY 
*/
-       }
-
-       return ac_build_gather_values(&ctx->ac, result, 4);
-}
-
 static void build_interp_intrinsic(const struct lp_build_tgsi_action *action,
                                struct lp_build_tgsi_context *bld_base,
                                struct lp_build_emit_data *emit_data)
@@ -4062,7 +4037,7 @@ static void build_interp_intrinsic(const struct 
lp_build_tgsi_action *action,
        if (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
            inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE) {
                LLVMValueRef ij_out[2];
-               LLVMValueRef ddxy_out = si_llvm_emit_ddxy_interp(bld_base, 
interp_param);
+               LLVMValueRef ddxy_out = ac_build_ddxy_interp(&ctx->ac, 
interp_param);
 
                /*
                 * take the I then J parameters, and the DDX/Y for it, and
-- 
2.21.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to