gallivm: fix rgtc2 format
authorRoland Scheidegger <sroland@vmware.com>
Thu, 2 Apr 2020 00:51:03 +0000 (02:51 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 2 Apr 2020 15:53:23 +0000 (15:53 +0000)
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 <airlied@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4416>

src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c

index c5ecaf6ff9a67c50c3a5ff89b6187d19dee6aa8a..50addad486a61d7300cb33f99d7103d66465a97e 100644 (file)
@@ -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;
 }