From 6ac2146a9865f0ccb31dfbd167d1620072d2fb45 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 17 Jul 2019 18:54:42 -0400 Subject: [PATCH] ac/nir: implement nir_op_pack_{us}norm_2x16 Reviewed-by: Pierre-Eric Pelloux-Prayer --- src/amd/common/ac_nir_to_llvm.c | 19 ++++++++++++++----- src/gallium/drivers/radeonsi/si_get.c | 2 -- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index ec79e5f1ce7..91865bd95ee 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -455,8 +455,10 @@ static LLVMValueRef emit_bitfield_select(struct ac_llvm_context *ctx, LLVMBuildXor(ctx->builder, insert, base, ""), ""), ""); } -static LLVMValueRef emit_pack_half_2x16(struct ac_llvm_context *ctx, - LLVMValueRef src0) +static LLVMValueRef emit_pack_2x16(struct ac_llvm_context *ctx, + LLVMValueRef src0, + LLVMValueRef (*pack)(struct ac_llvm_context *ctx, + LLVMValueRef args[2])) { LLVMValueRef comp[2]; @@ -464,8 +466,7 @@ static LLVMValueRef emit_pack_half_2x16(struct ac_llvm_context *ctx, comp[0] = LLVMBuildExtractElement(ctx->builder, src0, ctx->i32_0, ""); comp[1] = LLVMBuildExtractElement(ctx->builder, src0, ctx->i32_1, ""); - return LLVMBuildBitCast(ctx->builder, ac_build_cvt_pkrtz_f16(ctx, comp), - ctx->i32, ""); + return LLVMBuildBitCast(ctx->builder, pack(ctx, comp), ctx->i32, ""); } static LLVMValueRef emit_unpack_half_2x16(struct ac_llvm_context *ctx, @@ -526,6 +527,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) src_components = 1; break; case nir_op_pack_half_2x16: + case nir_op_pack_snorm_2x16: + case nir_op_pack_unorm_2x16: src_components = 2; break; case nir_op_unpack_half_2x16: @@ -935,7 +938,13 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) result = emit_imul_high(&ctx->ac, src[0], src[1]); break; case nir_op_pack_half_2x16: - result = emit_pack_half_2x16(&ctx->ac, src[0]); + result = emit_pack_2x16(&ctx->ac, src[0], ac_build_cvt_pkrtz_f16); + break; + case nir_op_pack_snorm_2x16: + result = emit_pack_2x16(&ctx->ac, src[0], ac_build_cvt_pknorm_i16); + break; + case nir_op_pack_unorm_2x16: + result = emit_pack_2x16(&ctx->ac, src[0], ac_build_cvt_pknorm_u16); break; case nir_op_unpack_half_2x16: result = emit_unpack_half_2x16(&ctx->ac, src[0]); diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 6beca2e0744..882bbbbae06 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -503,9 +503,7 @@ static const struct nir_shader_compiler_options nir_options = { .lower_sub = true, .lower_ffma = true, .lower_fmod = true, - .lower_pack_snorm_2x16 = true, .lower_pack_snorm_4x8 = true, - .lower_pack_unorm_2x16 = true, .lower_pack_unorm_4x8 = true, .lower_unpack_snorm_2x16 = true, .lower_unpack_snorm_4x8 = true, -- 2.30.2