summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-04-03 13:54:17 +1000
committerDave Airlie <[email protected]>2020-04-04 12:33:49 +1000
commit03204dadbc1829128f3e0a5e74f4f85851f6e708 (patch)
treeccc8630e30a7a42312704815e6eef9c1cd18c04e
parent0b06adb75054842294e4dbbe2e5af294470862fb (diff)
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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4425>
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c16
1 files changed, 10 insertions, 6 deletions
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) */