[Mesa-dev] [PATCH 21/38] ac/nir: implement 16-bit ac_build_ddxy
Rhys Perry
pendingchaos02 at gmail.com
Fri Dec 7 17:22:14 UTC 2018
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
src/amd/common/ac_llvm_build.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index e85c178f78..f394d16bc9 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1519,6 +1519,11 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
LLVMValueRef tl, trbl, args[2];
LLVMValueRef result;
+ int size = ac_get_type_size(LLVMTypeOf(val));
+
+ if (size == 2)
+ val = LLVMBuildZExt(ctx->builder, val, ctx->i32, "");
+
if (HAVE_LLVM >= 0x0700) {
unsigned tl_lanes[4], trbl_lanes[4];
@@ -1600,13 +1605,19 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
AC_FUNC_ATTR_CONVERGENT);
}
- tl = LLVMBuildBitCast(ctx->builder, tl, ctx->f32, "");
- trbl = LLVMBuildBitCast(ctx->builder, trbl, ctx->f32, "");
+ if (size == 2) {
+ tl = LLVMBuildTrunc(ctx->builder, tl, ctx->i16, "");
+ trbl = LLVMBuildTrunc(ctx->builder, trbl, ctx->i16, "");
+ }
+
+ LLVMTypeRef type = ac_float_of_size(ctx, size * 8);
+ tl = LLVMBuildBitCast(ctx->builder, tl, type, "");
+ trbl = LLVMBuildBitCast(ctx->builder, trbl, type, "");
result = LLVMBuildFSub(ctx->builder, trbl, tl, "");
if (HAVE_LLVM >= 0x0700) {
result = ac_build_intrinsic(ctx,
- "llvm.amdgcn.wqm.f32", ctx->f32,
+ LLVMTypeOf(val) == ctx->f32 ? "llvm.amdgcn.wqm.f32" : "llvm.amdgcn.wqm.f16", type,
&result, 1, 0);
}
--
2.19.2
More information about the mesa-dev
mailing list