From: Dave Airlie Date: Fri, 3 Apr 2020 03:54:17 +0000 (+1000) Subject: gallivm/rgtc: fix the truncation to 8-bit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=03204dadbc1829128f3e0a5e74f4f85851f6e708;p=mesa.git gallivm/rgtc: fix the truncation to 8-bit The 8 bit type wasn't 8-bit so when doing signed work we lost the sign bit. This fixes it to use a proper vector type, even if we just end up in here with the 1-wide path for now. Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c index d799a5d45a9..174857e06d9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c @@ -898,19 +898,23 @@ s3tc_dxt5_alpha_channel(struct gallivm_state *gallivm, LLVMValueRef i, LLVMValueRef j) { LLVMBuilderRef builder = gallivm->builder; - struct lp_type type; + struct lp_type type, type8; LLVMValueRef tmp, alpha0, alpha1, alphac, alphac0, bit_pos, shift; LLVMValueRef sel_mask, tmp_mask, alpha, alpha64, code_s; LLVMValueRef mask6, mask7, ainterp; LLVMTypeRef i64t = LLVMInt64TypeInContext(gallivm->context); LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context); - LLVMTypeRef i8t = LLVMInt32TypeInContext(gallivm->context); struct lp_build_context bld32; memset(&type, 0, sizeof type); type.width = 32; type.length = n; + memset(&type8, 0, sizeof type8); + type8.width = 8; + type8.length = n; + type8.sign = is_signed; + lp_build_context_init(&bld32, gallivm, type); /* this looks pretty complex for vectorization: * extract a0/a1 values @@ -924,8 +928,8 @@ s3tc_dxt5_alpha_channel(struct gallivm_state *gallivm, alpha0 = LLVMBuildAnd(builder, alpha_lo, lp_build_const_int_vec(gallivm, type, 0xff), ""); if (is_signed) { - alpha0 = LLVMBuildTrunc(builder, alpha0, i8t, ""); - alpha0 = LLVMBuildSExt(builder, alpha0, i32t, ""); + alpha0 = LLVMBuildTrunc(builder, alpha0, lp_build_vec_type(gallivm, type8), ""); + alpha0 = LLVMBuildSExt(builder, alpha0, lp_build_vec_type(gallivm, type), ""); } alpha1 = LLVMBuildLShr(builder, alpha_lo, @@ -933,8 +937,8 @@ s3tc_dxt5_alpha_channel(struct gallivm_state *gallivm, alpha1 = LLVMBuildAnd(builder, alpha1, lp_build_const_int_vec(gallivm, type, 0xff), ""); if (is_signed) { - alpha1 = LLVMBuildTrunc(builder, alpha1, i8t, ""); - alpha1 = LLVMBuildSExt(builder, alpha1, i32t, ""); + alpha1 = LLVMBuildTrunc(builder, alpha1, lp_build_vec_type(gallivm, type8), ""); + alpha1 = LLVMBuildSExt(builder, alpha1, lp_build_vec_type(gallivm, type), ""); } /* pos = 3*(4j+i) */