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: 13e5f331db ("gallivm/nir: fix image store conversions")

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13187>
This commit is contained in:
Dave Airlie 2021-10-05 11:33:49 +10:00 committed by Marge Bot
parent 60f464bbce
commit 1d48022dab
2 changed files with 9 additions and 17 deletions

View file

@ -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];

View file

@ -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