Mesa (master): llvmpipe: clamp color storage for integer types.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 27 02:54:59 UTC 2020


Module: Mesa
Branch: master
Commit: 565df656513acec8c2d5fe915c51b4b901265fa7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=565df656513acec8c2d5fe915c51b4b901265fa7

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Apr 21 15:28:38 2020 +1000

llvmpipe: clamp color storage for integer types.

If storing to an integer for lower bit size (i.e. 16-bit uint to
10-bit uint), we need to clamp to the maximum value not truncate.

Fixes:
dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.r16_uint.a2b10g10r10_uint_pack32.optimal_optimal_nearest

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4574>

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index f55cfa9a85d..8826d499b47 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1590,6 +1590,7 @@ convert_from_blend_type(struct gallivm_state *gallivm,
       for (j = 0; j < src_fmt->nr_channels; ++j) {
          unsigned mask = 0;
          unsigned sa = src_fmt->channel[j].shift;
+         unsigned sz_a = src_fmt->channel[j].size;
 #if UTIL_ARCH_LITTLE_ENDIAN
          unsigned from_lsb = j;
 #else
@@ -1618,6 +1619,10 @@ convert_from_blend_type(struct gallivm_state *gallivm,
          if (src_type.norm) {
             chans[j] = scale_bits(gallivm, blend_type.width,
                                   src_fmt->channel[j].size, chans[j], src_type);
+         } else if (!src_type.floating && sz_a < blend_type.width) {
+            LLVMValueRef mask_val = lp_build_const_int_vec(gallivm, src_type, (1UL << sz_a) - 1);
+            LLVMValueRef mask = LLVMBuildICmp(builder, LLVMIntUGT, chans[j], mask_val, "");
+            chans[j] = LLVMBuildSelect(builder, mask, mask_val, chans[j], "");
          }
 
          /* Insert bits */



More information about the mesa-commit mailing list