[Mesa-dev] [RFC PATCH v1 05/30] anv: Fix get_image_format_properties() - depthstencil (v2)
Jason Ekstrand
jason at jlekstrand.net
Tue Nov 7 16:20:56 UTC 2017
I think I'd prefer we not make "Fix" the first word in the title unless it
fixes an actual bug. How about "Refactor"? Same for the ASTC patch.
On Tue, Nov 7, 2017 at 6:47 AM, Chad Versace <chadversary at chromium.org>
wrote:
> 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 <jason at jlekstrand.net> (v1)
> ---
> src/intel/vulkan/anv_formats.c | 47 ++++++++++++++++++++++++++++--
> ------------
> 1 file 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
> --
> 2.13.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171107/317c3f2e/attachment.html>
More information about the mesa-dev
mailing list