Mesa (master): zink: force stencil format for stencil-only samplers and swizzle the right component

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 18 16:33:36 UTC 2020


Module: Mesa
Branch: master
Commit: c768c5297a89841d80f65f6a4e8de50509baed7c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c768c5297a89841d80f65f6a4e8de50509baed7c

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Aug 10 14:42:19 2020 -0400

zink: force stencil format for stencil-only samplers and swizzle the right component

packed buffers will still return the full format when we're using only the
stencil aspect, so we need to explicitly set the format here

also due to 7ca72f172678116d29d254b786a9422b864aef3d we can't use the provided
swizzle for this case and have to force y -> x component swizzle

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7491>

---

 src/gallium/drivers/zink/zink_context.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index baaf1652394..f83cdcc8e65 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -330,14 +330,20 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
       ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
       ivci.image = res->image;
       ivci.viewType = image_view_type(state->target);
-      ivci.format = zink_get_format(screen, state->format);
-      assert(ivci.format);
+
       ivci.components.r = component_mapping(state->swizzle_r);
       ivci.components.g = component_mapping(state->swizzle_g);
       ivci.components.b = component_mapping(state->swizzle_b);
       ivci.components.a = component_mapping(state->swizzle_a);
-
       ivci.subresourceRange.aspectMask = sampler_aspect_from_format(state->format);
+      /* samplers for stencil aspects of packed formats need to always use stencil type */
+      if (ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) {
+         ivci.format = VK_FORMAT_S8_UINT;
+         ivci.components.g = VK_COMPONENT_SWIZZLE_R;
+      } else
+         ivci.format = zink_get_format(screen, state->format);
+      assert(ivci.format);
+
       ivci.subresourceRange.baseMipLevel = state->u.tex.first_level;
       ivci.subresourceRange.baseArrayLayer = state->u.tex.first_layer;
       ivci.subresourceRange.levelCount = state->u.tex.last_level - state->u.tex.first_level + 1;



More information about the mesa-commit mailing list