From: Erik Faye-Lund Date: Mon, 15 Jul 2019 13:33:34 +0000 (+0200) Subject: zink: do not use both depth and stencil aspects for sampler-views X-Git-Tag: upstream/19.3.0~397 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=499bf4148738d32fd84bb82660f78b24e76f6923;p=platform%2Fupstream%2Fmesa.git zink: do not use both depth and stencil aspects for sampler-views Acked-by: Jordan Justen --- diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index b78e2c3..77b57c1 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 781e865..8726427 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 1862c0f..65e5e19 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);