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 <lionel.g.landwerlin@intel.com>
This commit is contained in:
Jason Ekstrand
2019-06-17 09:39:08 -05:00
parent f3ea0cf828
commit 1be38f9178
4 changed files with 16 additions and 2 deletions

View File

@@ -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),

View File

@@ -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;

View File

@@ -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.
*/

View File

@@ -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 */