zink: do not use both depth and stencil aspects for sampler-views
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 15 Jul 2019 13:33:34 +0000 (15:33 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:46 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_resource.c
src/gallium/drivers/zink/zink_resource.h

index b78e2c36348386b7e2b81f3fce69971d84b8758d..77b57c1397c2a233c6db8cbedf24d1521c4eea05 100644 (file)
@@ -226,6 +226,19 @@ component_mapping(enum pipe_swizzle swizzle)
    }
 }
 
+static VkImageAspectFlags
+sampler_aspect_from_format(enum pipe_format fmt)
+{
+   if (util_format_is_depth_or_stencil(fmt)) {
+      const struct util_format_description *desc = util_format_description(fmt);
+      if (util_format_has_depth(desc))
+         return VK_IMAGE_ASPECT_DEPTH_BIT;
+      assert(util_format_has_stencil(desc));
+      return VK_IMAGE_ASPECT_STENCIL_BIT;
+   } else
+     return VK_IMAGE_ASPECT_COLOR_BIT;
+}
+
 static struct pipe_sampler_view *
 zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
                          const struct pipe_sampler_view *state)
@@ -249,7 +262,8 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
    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 = zink_aspect_from_format(state->format);
+
+   ivci.subresourceRange.aspectMask = sampler_aspect_from_format(state->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;
index 781e865cbf86cde950d16f5a58d6d9806a63b768..8726427b66cb76e067d73067075c86daad0065da 100644 (file)
@@ -68,8 +68,8 @@ get_memory_type_index(struct zink_screen *screen,
    return 0;
 }
 
-VkImageAspectFlags
-zink_aspect_from_format(enum pipe_format fmt)
+static VkImageAspectFlags
+aspect_from_format(enum pipe_format fmt)
 {
    if (util_format_is_depth_or_stencil(fmt)) {
       VkImageAspectFlags aspect = 0;
@@ -224,7 +224,7 @@ zink_resource_create(struct pipe_screen *pscreen,
       }
 
       res->optimial_tiling = ici.tiling != VK_IMAGE_TILING_LINEAR;
-      res->aspect = zink_aspect_from_format(templ->format);
+      res->aspect = aspect_from_format(templ->format);
 
       vkGetImageMemoryRequirements(screen->dev, res->image, &reqs);
       if (templ->usage == PIPE_USAGE_STAGING || (screen->winsys && (templ->bind & (PIPE_BIND_SCANOUT|PIPE_BIND_DISPLAY_TARGET|PIPE_BIND_SHARED))))
index 1862c0f09e3393f05fb1051a3ec8b96cf5d2ea1a..65e5e19dc73e4cc6fe0b8719c0b780b7dc212645 100644 (file)
@@ -62,9 +62,6 @@ zink_resource(struct pipe_resource *r)
    return (struct zink_resource *)r;
 }
 
-VkImageAspectFlags
-zink_aspect_from_format(enum pipe_format fmt);
-
 void
 zink_screen_resource_init(struct pipe_screen *pscreen);