Mesa (main): anv: Generalize border color swizzles
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 4 22:14:56 UTC 2022
Module: Mesa
Branch: main
Commit: e32b9e5c3fbabce07dd154b99dc05f7213e9de1e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e32b9e5c3fbabce07dd154b99dc05f7213e9de1e
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Tue Mar 29 10:55:00 2022 -0500
anv: Generalize border color swizzles
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15624>
---
src/intel/vulkan/genX_state.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index a551206b0e2..c3d8592e515 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -937,21 +937,30 @@ VkResult genX(CreateSampler)(
(VkSamplerCustomBorderColorCreateInfoEXT *) ext;
if (sampler->custom_border_color.map == NULL)
break;
- struct gfx8_border_color *cbc = sampler->custom_border_color.map;
- if (custom_border_color->format == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
- /* B4G4R4A4_UNORM_PACK16 is treated as R4G4B4A4_UNORM_PACK16 with
- * a swizzle, but this does not carry over to the sampler for
- * border colors, so we need to do the swizzle ourselves here.
- */
- cbc->uint32[0] = custom_border_color->customBorderColor.uint32[2];
- cbc->uint32[1] = custom_border_color->customBorderColor.uint32[1];
- cbc->uint32[2] = custom_border_color->customBorderColor.uint32[0];
- cbc->uint32[3] = custom_border_color->customBorderColor.uint32[3];
- } else {
- /* Both structs share the same layout, so just copy them over. */
- memcpy(cbc, &custom_border_color->customBorderColor,
- sizeof(VkClearColorValue));
+
+ union isl_color_value color = { .u32 = {
+ custom_border_color->customBorderColor.uint32[0],
+ custom_border_color->customBorderColor.uint32[1],
+ custom_border_color->customBorderColor.uint32[2],
+ custom_border_color->customBorderColor.uint32[3],
+ } };
+
+ const struct anv_format *format_desc =
+ custom_border_color->format != VK_FORMAT_UNDEFINED ?
+ anv_get_format(custom_border_color->format) : NULL;
+
+ /* For formats with a swizzle, it does not carry over to the sampler
+ * for border colors, so we need to do the swizzle ourselves here.
+ */
+ if (format_desc && format_desc->n_planes == 1 &&
+ !isl_swizzle_is_identity(format_desc->planes[0].swizzle)) {
+ const struct anv_format_plane *fmt_plane = &format_desc->planes[0];
+
+ assert(!isl_format_has_int_channel(fmt_plane->isl_format));
+ color = isl_color_value_swizzle(color, fmt_plane->swizzle, true);
}
+
+ memcpy(sampler->custom_border_color.map, color.u32, sizeof(color));
has_custom_color = true;
break;
}
More information about the mesa-commit
mailing list