[Mesa-dev] [PATCH 04/23] anv/image: Add an aspects field
Nanley Chery
nanleychery at gmail.com
Tue May 17 00:34:59 UTC 2016
On Mon, May 16, 2016 at 12:08:09PM -0700, Jason Ekstrand wrote:
> This makes several checks easier and allows us to avoid calling
> anv_format_for_vk_format in a number of cases.
> ---
> src/intel/vulkan/anv_image.c | 3 +++
> src/intel/vulkan/anv_private.h | 3 ++-
> src/intel/vulkan/gen7_cmd_buffer.c | 5 ++---
> src/intel/vulkan/genX_cmd_buffer.c | 7 +++----
> 4 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index fb28389..6316a2a 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -233,12 +233,14 @@ anv_image_create(VkDevice _device,
> image->tiling = pCreateInfo->tiling;
>
> if (likely(anv_format_is_color(format))) {
> + image->aspects |= VK_IMAGE_ASPECT_COLOR_BIT;
> r = make_surface(device, image, create_info,
> VK_IMAGE_ASPECT_COLOR_BIT);
> if (r != VK_SUCCESS)
> goto fail;
> } else {
> if (image->format->has_depth) {
> + image->aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;
> r = make_surface(device, image, create_info,
> VK_IMAGE_ASPECT_DEPTH_BIT);
> if (r != VK_SUCCESS)
> @@ -246,6 +248,7 @@ anv_image_create(VkDevice _device,
> }
>
> if (image->format->has_stencil) {
> + image->aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;
> r = make_surface(device, image, create_info,
> VK_IMAGE_ASPECT_STENCIL_BIT);
> if (r != VK_SUCCESS)
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index a5888d6..c3b31e6 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -1561,6 +1561,7 @@ struct anv_image {
> */
> VkFormat vk_format;
> const struct anv_format *format;
> + VkImageAspectFlags aspects;
In Vulkan, the bitfield is a property of the image, so it is good to
have this alignment.
Reviewed-by: Nanley Chery <nanley.g.chery at intel.com>
- Nanley
> VkExtent3D extent;
> uint32_t levels;
> uint32_t array_size;
> @@ -1579,7 +1580,7 @@ struct anv_image {
> * Image subsurfaces
> *
> * For each foo, anv_image::foo_surface is valid if and only if
> - * anv_image::format has a foo aspect.
> + * anv_image::aspects has a foo aspect.
> *
> * The hardware requires that the depth buffer and stencil buffer be
> * separate surfaces. From Vulkan's perspective, though, depth and stencil
> diff --git a/src/intel/vulkan/gen7_cmd_buffer.c b/src/intel/vulkan/gen7_cmd_buffer.c
> index 03ce889..62d9f46 100644
> --- a/src/intel/vulkan/gen7_cmd_buffer.c
> +++ b/src/intel/vulkan/gen7_cmd_buffer.c
> @@ -415,9 +415,8 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
> const struct anv_image_view *iview =
> anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
> const struct anv_image *image = iview ? iview->image : NULL;
> - const struct anv_format *anv_format =
> - iview ? anv_format_for_vk_format(iview->vk_format) : NULL;
> - const bool has_depth = iview && anv_format->has_depth;
> + const bool has_depth =
> + image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT);
> const uint32_t depth_format = has_depth ?
> isl_surf_get_depth_format(&cmd_buffer->device->isl_dev,
> &image->depth_surface.isl) : D16_UNORM;
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
> index 0a5c404..a7e20da 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -927,10 +927,9 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
> const struct anv_image_view *iview =
> anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
> const struct anv_image *image = iview ? iview->image : NULL;
> - const struct anv_format *anv_format =
> - iview ? anv_format_for_vk_format(iview->vk_format) : NULL;
> - const bool has_depth = iview && anv_format->has_depth;
> - const bool has_stencil = iview && anv_format->has_stencil;
> + const bool has_depth = image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT);
> + const bool has_stencil =
> + image && (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT);
>
> /* FIXME: Implement the PMA stall W/A */
> /* FIXME: Width and Height are wrong */
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list