From 05629bb4700b87b4942b7461d4be803fa43a40ec Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 17 Nov 2020 18:26:01 -0500 Subject: [PATCH] zink: verify format caps and add storage image usage when possible in creation this is a huge perf hog that will be improved on later, but it's necessary for now in order to correctly determine whether we can use resources as shader images since gallium gives us no info about usage Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/zink/zink_resource.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 8ce09755c30..15b16f1788a 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -229,8 +229,18 @@ resource_create(struct pipe_screen *pscreen, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; - if (templ->bind & PIPE_BIND_SHADER_IMAGE) - ici.usage |= VK_IMAGE_USAGE_STORAGE_BIT; + if ((templ->nr_samples <= 1 || screen->info.feats.features.shaderStorageImageMultisample) && + (templ->bind & PIPE_BIND_SHADER_IMAGE || + (templ->bind & PIPE_BIND_SAMPLER_VIEW && templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY))) { + VkFormatProperties props; + vkGetPhysicalDeviceFormatProperties(screen->pdev, res->format, &props); + /* gallium doesn't provide any way to actually know whether this will be used as a shader image, + * so we have to just assume and set the bit if it's available + */ + if ((ici.tiling == VK_IMAGE_TILING_LINEAR && props.linearTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) || + (ici.tiling == VK_IMAGE_TILING_OPTIMAL && props.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) + ici.usage |= VK_IMAGE_USAGE_STORAGE_BIT; + } if (templ->bind & PIPE_BIND_RENDER_TARGET) ici.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;