[Mesa-dev] [PATCH 05/12] anv/image: Add support for the VkImageViewUsageCreateInfoKHR struct
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Tue Sep 19 14:40:57 UTC 2017
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
On 15/09/17 17:01, Jason Ekstrand wrote:
> ---
> src/intel/vulkan/anv_image.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index 63e507a..202becc 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -30,6 +30,7 @@
>
> #include "anv_private.h"
> #include "util/debug.h"
> +#include "vk_util.h"
>
> #include "vk_format_info.h"
>
> @@ -674,11 +675,17 @@ anv_CreateImageView(VkDevice _device,
>
> assert(range->layerCount > 0);
> assert(range->baseMipLevel < image->levels);
> - assert(image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
> - VK_IMAGE_USAGE_STORAGE_BIT |
> - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
> - VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
> - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT));
> +
> + const VkImageViewUsageCreateInfoKHR *usage_info =
> + vk_find_struct_const(pCreateInfo, IMAGE_VIEW_USAGE_CREATE_INFO_KHR);
> + VkImageUsageFlags view_usage = usage_info ? usage_info->usage : image->usage;
> + /* View usage should be a subset of image usage */
> + assert((view_usage & ~image->usage) == 0);
> + assert(view_usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
> + VK_IMAGE_USAGE_STORAGE_BIT |
> + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
> + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
> + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT));
>
> switch (image->type) {
> default:
> @@ -748,8 +755,8 @@ anv_CreateImageView(VkDevice _device,
> * allow compression so we can just use the texture surface state from the
> * view.
> */
> - if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
> - (image->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
> + if (view_usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
> + (view_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
> !(iview->aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT))) {
> iview->optimal_sampler_surface_state = alloc_surface_state(device);
> iview->general_sampler_surface_state = alloc_surface_state(device);
> @@ -795,7 +802,7 @@ anv_CreateImageView(VkDevice _device,
> }
>
> /* NOTE: This one needs to go last since it may stomp isl_view.format */
> - if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
> + if (view_usage & VK_IMAGE_USAGE_STORAGE_BIT) {
> iview->storage_surface_state = alloc_surface_state(device);
> iview->writeonly_storage_surface_state = alloc_surface_state(device);
>
More information about the mesa-dev
mailing list