diff options
author | Chad Versace <[email protected]> | 2017-11-02 18:24:08 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2017-11-09 16:01:59 -0800 |
commit | 8ae4e97536476b1a6f6e36c7c73e00d09940e5b3 (patch) | |
tree | 6cd3684c16c61c58b11b788441fbd70766506e16 /src/intel | |
parent | 6720abf292e77d44467419a82af40d63572c6e5a (diff) |
anv: Refactor get_image_format_properties() - depthstencil (v2)
Teach it to calculate the features of depthstencil formats.
The goal is to incrementally fix get_image_format_properties() to return
a correct result. Currently, it returns incorrect VkFormatFeatureFlags
which the caller must clean up.
v2: New commit message
Reviewed-by: Jason Ekstrand <[email protected]> (v1)
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/vulkan/anv_formats.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index bd03b248ff9..8c9f5a46d2c 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -468,12 +468,35 @@ anv_get_format_plane(const struct gen_device_info *devinfo, VkFormat vk_format, static VkFormatFeatureFlags get_image_format_properties(const struct gen_device_info *devinfo, - enum isl_format base, struct anv_format_plane format) + VkFormat vk_format, + enum isl_format base, + struct anv_format_plane format, + VkImageTiling vk_tiling) { + VkFormatFeatureFlags flags = 0; + if (format.isl_format == ISL_FORMAT_UNSUPPORTED) return 0; - VkFormatFeatureFlags flags = 0; + const VkImageAspectFlags aspects = vk_format_aspects(vk_format); + + if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { + if (vk_tiling == VK_IMAGE_TILING_LINEAR) + return 0; + + flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + + if (aspects == VK_IMAGE_ASPECT_DEPTH_BIT || devinfo->gen >= 8) + flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; + + flags |= VK_FORMAT_FEATURE_BLIT_SRC_BIT | + VK_FORMAT_FEATURE_BLIT_DST_BIT | + VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | + VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR; + + return flags; + } + if (isl_format_supports_sampling(devinfo, format.isl_format)) { flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT; @@ -563,16 +586,6 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d if (format == NULL) { /* Nothing to do here */ - } else if (vk_format_is_depth_or_stencil(vk_format)) { - tiled |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; - if (vk_format_aspects(vk_format) == VK_IMAGE_ASPECT_DEPTH_BIT || - physical_device->info.gen >= 8) - tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; - - tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT | - VK_FORMAT_FEATURE_BLIT_DST_BIT | - VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | - VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR; } else { struct anv_format_plane linear_fmt, tiled_fmt; linear_fmt = anv_get_format_plane(&physical_device->info, vk_format, @@ -582,10 +595,12 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_TILING_OPTIMAL); - linear = get_image_format_properties(&physical_device->info, - linear_fmt.isl_format, linear_fmt); - tiled = get_image_format_properties(&physical_device->info, - linear_fmt.isl_format, tiled_fmt); + linear = get_image_format_properties(&physical_device->info, vk_format, + linear_fmt.isl_format, linear_fmt, + VK_IMAGE_TILING_LINEAR); + tiled = get_image_format_properties(&physical_device->info, vk_format, + linear_fmt.isl_format, tiled_fmt, + VK_IMAGE_TILING_OPTIMAL); /* XXX: We handle 3-channel formats by switching them out for RGBX or * RGBA formats behind-the-scenes. This works fine for textures |