From c768c5297a89841d80f65f6a4e8de50509baed7c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 10 Aug 2020 14:42:19 -0400 Subject: [PATCH] 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 Part-of: --- 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;