[Mesa-dev] [PATCH 2/2] ac: add 16-bit support to ac_build_ddxy()
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Tue Apr 9 21:23:11 UTC 2019
r-b for both.
On Mon, Apr 8, 2019 at 9:22 AM Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
>
> From: Rhys Perry <pendingchaos02 at gmail.com>
>
> Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
> ---
> src/amd/common/ac_llvm_build.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index 54e90288bda..3e3ca5c7fdb 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -1862,9 +1862,16 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
> LLVMValueRef val)
> {
> unsigned tl_lanes[4], trbl_lanes[4];
> + char name[32], type[8];
> LLVMValueRef tl, trbl;
> + LLVMTypeRef result_type;
> LLVMValueRef result;
>
> + result_type = ac_to_float_type(ctx, LLVMTypeOf(val));
> +
> + if (result_type == ctx->f16)
> + val = LLVMBuildZExt(ctx->builder, val, ctx->i32, "");
> +
> for (unsigned i = 0; i < 4; ++i) {
> tl_lanes[i] = i & mask;
> trbl_lanes[i] = (i & mask) + idx;
> @@ -1877,14 +1884,19 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
> trbl_lanes[0], trbl_lanes[1],
> trbl_lanes[2], trbl_lanes[3]);
>
> - tl = LLVMBuildBitCast(ctx->builder, tl, ctx->f32, "");
> - trbl = LLVMBuildBitCast(ctx->builder, trbl, ctx->f32, "");
> + if (result_type == ctx->f16) {
> + tl = LLVMBuildTrunc(ctx->builder, tl, ctx->i16, "");
> + trbl = LLVMBuildTrunc(ctx->builder, trbl, ctx->i16, "");
> + }
> +
> + tl = LLVMBuildBitCast(ctx->builder, tl, result_type, "");
> + trbl = LLVMBuildBitCast(ctx->builder, trbl, result_type, "");
> result = LLVMBuildFSub(ctx->builder, trbl, tl, "");
>
> - result = ac_build_intrinsic(ctx, "llvm.amdgcn.wqm.f32", ctx->f32,
> - &result, 1, 0);
> + ac_build_type_name_for_intr(result_type, type, sizeof(type));
> + snprintf(name, sizeof(name), "llvm.amdgcn.wqm.%s", type);
>
> - return result;
> + return ac_build_intrinsic(ctx, name, result_type, &result, 1, 0);
> }
>
> void
> --
> 2.21.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list