summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-07-15 15:33:34 +0200
committerErik Faye-Lund <[email protected]>2019-10-28 08:51:46 +0000
commit499bf4148738d32fd84bb82660f78b24e76f6923 (patch)
treec66a0646f2b719627667476a2b822b2cd8425339 /src/gallium
parent5f14168edf577fcaaf389a225a5648a2e725bcf1 (diff)
zink: do not use both depth and stencil aspects for sampler-views
Acked-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/zink/zink_context.c16
-rw-r--r--src/gallium/drivers/zink/zink_resource.c6
-rw-r--r--src/gallium/drivers/zink/zink_resource.h3
3 files changed, 18 insertions, 7 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index b78e2c36348..77b57c1397c 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -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;
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 781e865cbf8..8726427b66c 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -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))))
diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h
index 1862c0f09e3..65e5e19dc73 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -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);