zink: add srgb border color clamping
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 14 Sep 2022 13:05:08 +0000 (09:05 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 22 Sep 2022 03:53:11 +0000 (03:53 +0000)
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 <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18598>

src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_format.c
src/gallium/drivers/zink/zink_format.h

index 7e0d984..2d29a15 100644 (file)
@@ -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
index e8aeef7..ea9ab4b 100644 (file)
@@ -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;
index 8575595..a340dee 100644 (file)
@@ -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;
+   }
+}
index 281ebe3..53ddd06 100644 (file)
@@ -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