[Mesa-dev] [PATCH 04/22] anv: Add color auxiliary buffer helpers

Nanley Chery nanleychery at gmail.com
Thu Apr 27 18:32:03 UTC 2017


Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/intel/vulkan/anv_private.h | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index dbe1e0475e..ac71537e88 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1977,6 +1977,48 @@ struct anv_image {
    struct anv_surface aux_surface;
 };
 
+static inline bool
+anv_image_has_color_aux(const struct anv_image * const image)
+{
+   assert(image);
+
+   return image->aspects == VK_IMAGE_ASPECT_COLOR_BIT &&
+          image->aux_surface.isl.size > 0;
+}
+
+/* Returns the number of levels present in the auxiliary buffer of a color
+ * image.
+ */
+static inline uint8_t
+anv_color_aux_levels(const struct anv_image * const image)
+{
+   assert(image);
+
+   /* We expect the image to have a color aux buffer. */
+   assert(anv_image_has_color_aux(image));
+
+   return image->aux_surface.isl.levels;
+}
+
+/* Returns the number of layers present in the auxiliary buffer of a color
+ * image.
+ */
+static inline uint32_t
+anv_color_aux_layers(const struct anv_image * const image,
+                     const uint8_t miplevel)
+{
+   assert(image);
+
+   /* We expect the image to have a color aux buffer. */
+   assert(anv_image_has_color_aux(image));
+
+   /* The miplevel must exist in the main buffer. */
+   assert(miplevel < image->levels);
+
+   return MAX2(image->aux_surface.isl.logical_level0_px.array_len,
+               image->aux_surface.isl.logical_level0_px.depth >> miplevel);
+}
+
 /* Returns true if a HiZ-enabled depth buffer can be sampled from. */
 static inline bool
 anv_can_sample_with_hiz(const struct gen_device_info * const devinfo,
-- 
2.12.2



More information about the mesa-dev mailing list