From 95d4faea490338a2f96d32828870d8abdb1ed553 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 14 Sep 2022 09:05:08 -0400 Subject: [PATCH] zink: add srgb border color clamping fixes (tu): dEQP-GLES31.functional.texture.border_clamp.range_clamp.linear_srgb_color dEQP-GLES31.functional.texture.border_clamp.range_clamp.nearest_srgb_color Reviewed-by: Emma Anholt Part-of: --- .../drivers/zink/ci/zink-tu-a630-fails.txt | 2 -- src/gallium/drivers/zink/zink_context.c | 4 +++- src/gallium/drivers/zink/zink_format.c | 15 +++++++++++++++ src/gallium/drivers/zink/zink_format.h | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt b/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt index 7e0d984e138..2d29a159fd1 100644 --- a/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt @@ -4,8 +4,6 @@ GTF-GL46.gtf32.GL3Tests.draw_elements_base_vertex.draw_elements_base_vertex_inva KHR-Single-GL46.arrays_of_arrays_gl.AtomicUsage,Fail KHR-Single-GL46.arrays_of_arrays_gl.SubroutineFunctionCalls2,Crash -dEQP-GLES31.functional.texture.border_clamp.range_clamp.linear_srgb_color,Fail -dEQP-GLES31.functional.texture.border_clamp.range_clamp.nearest_srgb_color,Fail # Turnip has maxFragmentInputComponents = 124, while GL requires # gl_MaxFragmentInputComponents >= 128 diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index e8aeef7e266..ea9ab4b6ebb 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -431,8 +431,10 @@ zink_create_sampler_state(struct pipe_context *pctx, memcpy(&cbci.customBorderColor, &state->border_color, sizeof(union pipe_color_union)); } else { cbci.format = zink_get_format(screen, state->border_color_format); - for (unsigned i = 0; i < 4; i++) + for (unsigned i = 0; i < 4; i++) { zink_format_clamp_channel_color(util_format_description(state->border_color_format), (void*)&cbci.customBorderColor, &state->border_color, i); + zink_format_clamp_channel_srgb(util_format_description(state->border_color_format), (void*)&cbci.customBorderColor, (void*)&cbci.customBorderColor, i); + } } } cbci.pNext = sci.pNext; diff --git a/src/gallium/drivers/zink/zink_format.c b/src/gallium/drivers/zink/zink_format.c index 85755957a23..a340dee0238 100644 --- a/src/gallium/drivers/zink/zink_format.c +++ b/src/gallium/drivers/zink/zink_format.c @@ -370,3 +370,18 @@ zink_format_clamp_channel_color(const struct util_format_description *desc, unio break; } } + +void +zink_format_clamp_channel_srgb(const struct util_format_description *desc, union pipe_color_union *dst, const union pipe_color_union *src, unsigned i) +{ + if (desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB) + return; + switch (desc->channel[i].type) { + case UTIL_FORMAT_TYPE_SIGNED: + case UTIL_FORMAT_TYPE_UNSIGNED: + dst->f[i] = CLAMP(src->f[i], 0.0, 1.0); + break; + default: + break; + } +} diff --git a/src/gallium/drivers/zink/zink_format.h b/src/gallium/drivers/zink/zink_format.h index 281ebe3eacf..53ddd06d9aa 100644 --- a/src/gallium/drivers/zink/zink_format.h +++ b/src/gallium/drivers/zink/zink_format.h @@ -48,4 +48,6 @@ enum pipe_format zink_format_get_emulated_alpha(enum pipe_format format); void zink_format_clamp_channel_color(const struct util_format_description *desc, union pipe_color_union *dst, const union pipe_color_union *src, unsigned i); +void +zink_format_clamp_channel_srgb(const struct util_format_description *desc, union pipe_color_union *dst, const union pipe_color_union *src, unsigned i); #endif