From ebb5b88a02637908b9f4bfd0644964d6347b23af Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 2 Apr 2020 02:51:03 +0200 Subject: [PATCH] gallivm: fix rgtc2 format In some cases, there can be garbage in the upper bits after the channel decode - for dxt5 this didn't matter (as the upper bits are shifted out anyway) but for rgtc2 formats it does. Reviewed-by: Dave Airlie Reviewed-by: Brian Paul Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c index c5ecaf6ff9a..50addad486a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c @@ -1023,6 +1023,8 @@ s3tc_dxt5_alpha_channel(struct gallivm_state *gallivm, alpha = LLVMBuildAnd(builder, alpha, LLVMBuildNot(builder, mask6, ""), ""); alpha = LLVMBuildOr(builder, alpha, mask7, ""); } + /* There can be garbage in upper bits, mask them off for rgtc formats */ + alpha = LLVMBuildAnd(builder, alpha, lp_build_const_int_vec(gallivm, type, 0xff), ""); return alpha; } -- 2.30.2