[Mesa-dev] [PATCH 06/24] anv: Add color auxiliary buffer helpers

Nanley Chery nanleychery at gmail.com
Thu May 11 19:05:13 UTC 2017


v2 (Jason Ekstrand):
- Check for aux levels in layer helper

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

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 9b0dd678fd..9bbb8f7221 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2047,6 +2047,55 @@ 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);
+
+   if (miplevel >= anv_color_aux_levels(image)) {
+      /* There are no layers with auxiliary data because the miplevel has no
+       * auxiliary data.
+       */
+      return 0;
+   } else {
+      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