From: Jason Ekstrand Date: Mon, 17 Jun 2019 14:39:08 +0000 (-0500) Subject: anv:Use VK_EXT_separate_stencil_usage to avoid stencil shadows on gen7 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1be38f9178a2382aa9f785845456cd8893f10e17;p=mesa.git anv:Use VK_EXT_separate_stencil_usage to avoid stencil shadows on gen7 Whenever stencil texturing is not required (most of the time), we can use VK_EXT_separate_stencil_usage to only create the shadow image when VK_IMAGE_USAGE_SAMPLED_BIT is required for stencil. Of course, this depends on applications to use the extension but hopefully DXVK and similar translators are doing so and that covers most of the apps. Reviewed-by: Lionel Landwerlin --- diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index 8468a72ab8d..c31d2cf870e 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -142,6 +142,7 @@ EXTENSIONS = [ Extension('VK_EXT_queue_family_foreign', 1, 'ANDROID'), Extension('VK_EXT_sampler_filter_minmax', 1, 'device->info.gen >= 9'), Extension('VK_EXT_scalar_block_layout', 1, True), + Extension('VK_EXT_separate_stencil_usage', 1, True), Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen >= 9'), Extension('VK_EXT_shader_viewport_index_layer', 1, True), Extension('VK_EXT_transform_feedback', 1, True), diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index d46da754ba3..3f18553023c 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -1012,6 +1012,9 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO: external_info = (const void *) s; break; + case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT: + /* Ignore but don't warn */ + break; default: anv_debug_ignored_stype(s->sType); break; diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index f405aa8067f..231b0faa60a 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -338,7 +338,7 @@ make_surface(const struct anv_device *dev, if (dev->info.gen <= 7 && aspect == VK_IMAGE_ASPECT_STENCIL_BIT && - (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { + (image->stencil_usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { needs_shadow = true; } @@ -599,6 +599,15 @@ anv_image_create(VkDevice _device, image->drm_format_mod = isl_mod_info ? isl_mod_info->modifier : DRM_FORMAT_MOD_INVALID; + if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { + image->stencil_usage = pCreateInfo->usage; + const VkImageStencilUsageCreateInfoEXT *stencil_usage_info = + vk_find_struct_const(pCreateInfo->pNext, + IMAGE_STENCIL_USAGE_CREATE_INFO_EXT); + if (stencil_usage_info) + image->stencil_usage = stencil_usage_info->stencilUsage; + } + /* In case of external format, We don't know format yet, * so skip the rest for now. */ diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 0cd66e0eadb..9e59d79de7a 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2978,7 +2978,8 @@ struct anv_image { uint32_t array_size; uint32_t samples; /**< VkImageCreateInfo::samples */ uint32_t n_planes; - VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */ + VkImageUsageFlags usage; /**< VkImageCreateInfo::usage. */ + VkImageUsageFlags stencil_usage; VkImageCreateFlags create_flags; /* Flags used when creating image. */ VkImageTiling tiling; /** VkImageCreateInfo::tiling */