Mesa (main): gallivm/format: clamp SINT conversion rather than truncate.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 5 23:31:31 UTC 2021


Module: Mesa
Branch: main
Commit: 1d48022dabc0ea8c51804a2c596f6fec9f632aa1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d48022dabc0ea8c51804a2c596f6fec9f632aa1

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Oct  5 11:33:49 2021 +1000

gallivm/format: clamp SINT conversion rather than truncate.

KHR-GL32.packed_pixels.pbo_rectangle.r16i on zink on lavapipe
ends up using a pbo that does an SINT image write. This was producing
truncated rather than clamped values.

Fix the calculations for 8/16-bit signed ints to clamp not truncate.

Fixes: 13e5f331db77 ("gallivm/nir: fix image store conversions")

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13187>

---

 src/gallium/auxiliary/gallivm/lp_bld_format_soa.c   | 10 +++++++++-
 src/gallium/drivers/zink/ci/deqp-zink-lvp-fails.txt | 16 ----------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
index f9ee308101e..bedc8f87b7c 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
@@ -919,7 +919,15 @@ lp_build_insert_soa_chan(struct lp_build_context *bld,
     case UTIL_FORMAT_TYPE_SIGNED:
        if (chan_desc.pure_integer) {
           chan = LLVMBuildBitCast(builder, rgba, bld->int_vec_type, "");
-          chan = LLVMBuildAnd(builder, chan, lp_build_const_int_vec(gallivm, type, chan_mask), "");
+          /* clamp to SINT range for < 32-bit values */
+          if (width < 32) {
+             struct lp_build_context int_bld;
+             lp_build_context_init(&int_bld, gallivm, lp_int_type(bld->type));
+             chan = lp_build_clamp(&int_bld, chan,
+                                   lp_build_const_int_vec(gallivm, type, -(1ULL << (width - 1))),
+                                   lp_build_const_int_vec(gallivm, type, (1ULL << (width - 1)) - 1));
+             chan = LLVMBuildAnd(builder, chan, lp_build_const_int_vec(gallivm, type, chan_mask), "");
+          }
        } else if (type.floating) {
           if (chan_desc.normalized) {
              char intrin[32];
diff --git a/src/gallium/drivers/zink/ci/deqp-zink-lvp-fails.txt b/src/gallium/drivers/zink/ci/deqp-zink-lvp-fails.txt
index 60c8b845e2e..13aeb75e87e 100644
--- a/src/gallium/drivers/zink/ci/deqp-zink-lvp-fails.txt
+++ b/src/gallium/drivers/zink/ci/deqp-zink-lvp-fails.txt
@@ -31,19 +31,3 @@ KHR-GL32.transform_feedback.query_vertex_interleaved_test,Fail
 KHR-GL32.transform_feedback.query_vertex_separate_test,Fail
 dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_center,Fail
 dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.r16i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.r16ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.r32i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.r32ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.r8ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rg16i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rg16ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rg32i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rg32ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rg8ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgb10_a2ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgba16i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgba16ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgba32i,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgba32ui,Fail
-KHR-GL32.packed_pixels.pbo_rectangle.rgba8ui,Fail



More information about the mesa-commit mailing list