From: Timothy Arceri Date: Thu, 2 Nov 2017 02:24:27 +0000 (+1100) Subject: ac: add v2f32 to the common code and make use of it X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7f4966731fe1b6f928702596360f1fb5ec982557;p=mesa.git ac: add v2f32 to the common code and make use of it Reviewed-by: Marek Olšák --- diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 1519262b3dd..5640a23b8aa 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -69,6 +69,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context, ctx->v2i32 = LLVMVectorType(ctx->i32, 2); ctx->v3i32 = LLVMVectorType(ctx->i32, 3); ctx->v4i32 = LLVMVectorType(ctx->i32, 4); + ctx->v2f32 = LLVMVectorType(ctx->f32, 2); ctx->v4f32 = LLVMVectorType(ctx->f32, 4); ctx->v8i32 = LLVMVectorType(ctx->i32, 8); diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index f662cc4dd89..1f51937c9e1 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -55,6 +55,7 @@ struct ac_llvm_context { LLVMTypeRef v2i32; LLVMTypeRef v3i32; LLVMTypeRef v4i32; + LLVMTypeRef v2f32; LLVMTypeRef v4f32; LLVMTypeRef v8i32; diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 1e1a1c0276a..ac50debdde6 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -134,7 +134,6 @@ struct nir_to_llvm_context { LLVMValueRef persp_sample, persp_center, persp_centroid; LLVMValueRef linear_sample, linear_center, linear_centroid; - LLVMTypeRef v2f32; LLVMTypeRef v4f32; unsigned uniform_md_kind; @@ -985,7 +984,6 @@ static void create_function(struct nir_to_llvm_context *ctx, static void setup_types(struct nir_to_llvm_context *ctx) { - ctx->v2f32 = LLVMVectorType(ctx->ac.f32, 2); ctx->v4f32 = LLVMVectorType(ctx->ac.f32, 4); ctx->uniform_md_kind = @@ -1450,8 +1448,7 @@ static LLVMValueRef emit_unpack_half_2x16(struct ac_llvm_context *ctx, temps[i] = LLVMBuildFPExt(ctx->builder, val, ctx->f32, ""); } - LLVMTypeRef v2f32 = LLVMVectorType(ctx->f32, 2); - result = LLVMBuildInsertElement(ctx->builder, LLVMGetUndef(v2f32), temps[0], + result = LLVMBuildInsertElement(ctx->builder, LLVMGetUndef(ctx->v2f32), temps[0], ctx->i32_0, ""); result = LLVMBuildInsertElement(ctx->builder, result, temps[1], ctx->i32_1, ""); @@ -2305,11 +2302,9 @@ static void visit_store_ssbo(struct ac_nir_context *ctx, store_name = "llvm.amdgcn.buffer.store.v4f32"; data = base_data; } else if (count == 2) { - LLVMTypeRef v2f32 = LLVMVectorType(ctx->ac.f32, 2); - tmp = LLVMBuildExtractElement(ctx->ac.builder, base_data, LLVMConstInt(ctx->ac.i32, start, false), ""); - data = LLVMBuildInsertElement(ctx->ac.builder, LLVMGetUndef(v2f32), tmp, + data = LLVMBuildInsertElement(ctx->ac.builder, LLVMGetUndef(ctx->ac.v2f32), tmp, ctx->ac.i32_0, ""); tmp = LLVMBuildExtractElement(ctx->ac.builder, @@ -3803,7 +3798,7 @@ static LLVMValueRef load_sample_position(struct nir_to_llvm_context *ctx, LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_PS_SAMPLE_POSITIONS, false)); ptr = LLVMBuildBitCast(ctx->builder, ptr, - const_array(ctx->v2f32, 64), ""); + const_array(ctx->ac.v2f32, 64), ""); sample_id = LLVMBuildAdd(ctx->builder, sample_id, ctx->sample_pos_offset, ""); result = ac_build_load_invariant(&ctx->ac, ptr, sample_id); @@ -3906,7 +3901,7 @@ static LLVMValueRef visit_interp(struct nir_to_llvm_context *ctx, if (interp_param) { interp_param = LLVMBuildBitCast(ctx->builder, - interp_param, LLVMVectorType(ctx->ac.f32, 2), ""); + interp_param, ctx->ac.v2f32, ""); LLVMValueRef i = LLVMBuildExtractElement( ctx->builder, interp_param, ctx->ac.i32_0, ""); LLVMValueRef j = LLVMBuildExtractElement( @@ -5045,7 +5040,7 @@ static void interp_fs_input(struct nir_to_llvm_context *ctx, */ if (interp) { interp_param = LLVMBuildBitCast(ctx->builder, interp_param, - LLVMVectorType(ctx->ac.f32, 2), ""); + ctx->ac.v2f32, ""); i = LLVMBuildExtractElement(ctx->builder, interp_param, ctx->ac.i32_0, "");