From 0a0fb85fbe61d3b25bc672d2f578c353f3076253 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 3 Feb 2021 15:32:17 -0500 Subject: [PATCH] zink: incrementally add image usage flags based on device caps these should be provided, but if not... Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index a2119813dd5..4e5dc19a458 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -291,14 +291,18 @@ create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsign if (templ->usage == PIPE_USAGE_STAGING) ici.tiling = VK_IMAGE_TILING_LINEAR; + VkFormatProperties props = screen->format_props[templ->format]; + VkFormatFeatureFlags feats = ici.tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures; /* sadly, gallium doesn't let us know if it'll ever need this, so we have to assume */ - ici.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | - VK_IMAGE_USAGE_TRANSFER_DST_BIT | - VK_IMAGE_USAGE_SAMPLED_BIT; + if (feats & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) + ici.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + if (feats & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) + ici.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if (feats & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) + ici.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; if ((templ->nr_samples <= 1 || screen->info.feats.features.shaderStorageImageMultisample) && (bind & PIPE_BIND_SHADER_IMAGE)) { - VkFormatProperties props = screen->format_props[templ->format]; 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;