<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 13, 2017 at 11:41 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v2:<br>
- Check for aux levels in layer helper (Jason Ekstrand)<br>
- Don't assert aux is present, return 0 if it isn't.<br>
- Use the helpers.<br>
<br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
src/intel/vulkan/anv_blorp.c | 4 ++++<br>
src/intel/vulkan/anv_private.h | 39 ++++++++++++++++++++++++++++++<wbr>+++++++++<br>
2 files changed, 43 insertions(+)<br>
<br>
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
index a869eebc24..421f860428 100644<br>
--- a/src/intel/vulkan/anv_blorp.c<br>
+++ b/src/intel/vulkan/anv_blorp.c<br>
@@ -1436,6 +1436,7 @@ anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,<br>
const struct isl_view *view,<br>
const VkImageSubresourceRange *subresourceRange)<br>
{<br>
+ assert(anv_image_has_color_<wbr>aux(image) && image->samples == 1);<br>
assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);<br>
<br>
struct blorp_batch batch;<br>
@@ -1488,6 +1489,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,<br>
blorp_layer_count = anv_get_layerCount(image, subresourceRange);<br>
}<br>
<br>
+ assert(level < anv_color_aux_levels(image));<br>
+ assert(blorp_base_layer + blorp_layer_count <=<br>
+ anv_color_aux_layers(image, level));<br>
blorp_fast_clear(&batch, &surf, surf.surf->format,<br>
level, blorp_base_layer, blorp_layer_count,<br>
0, 0, extent.width, extent.height);<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index fe6ac3bc1b..32aec7782b 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -2071,6 +2071,45 @@ struct anv_image {<br>
struct anv_surface aux_surface;<br>
};<br>
<br>
+/* Return whether or not the image has a color auxiliary buffer. */<br>
+static inline bool<br>
+anv_image_has_color_aux(const struct anv_image * const image)<br>
+{<br>
+ assert(image);<br>
+<br>
+ return image->aspects == VK_IMAGE_ASPECT_COLOR_BIT &&<br>
+ image->aux_surface.isl.size > 0;<br></blockquote><div><br></div><div>I'm not a big fan of conflating CCS and MCS. We do that in i965 today and it's no end of pain. How about anv_image_has_ccs and restrict on sample count as well? Same comment applies to the two below.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
+/* Returns the number of auxiliary buffer levels attached to a color image. */<br>
+static inline uint8_t<br>
+anv_color_aux_levels(const struct anv_image * const image)<br>
+{<br>
+ assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
+ return anv_image_has_color_aux(image) ? image->aux_surface.isl.levels : 0;<br></blockquote><div><br></div><div>Is there some reason why we can't or shouldn't assert anv_image_has_ccs? I haven't read all of the users of these helpers so maybe there's something really useful about having them silently return 0.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
+/* Returns the number of auxiliary buffer layers attached to a color image. */<br>
+static inline uint32_t<br>
+anv_color_aux_layers(const struct anv_image * const image,<br>
+ const uint8_t miplevel)<br>
+{<br>
+ assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
+<br>
+ /* The miplevel must exist in the main buffer. */<br>
+ assert(miplevel < image->levels);<br></blockquote><div><br></div><div>Similarly can we or should we assert that miplevel < anv_color_aux_levels()?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ if (miplevel >= anv_color_aux_levels(image)) {<br>
+ /* There are no layers with auxiliary data because the miplevel has no<br>
+ * auxiliary data.<br>
+ */<br>
+ return 0;<br>
+ } else {<br>
+ return MAX2(image->aux_surface.isl.<wbr>logical_level0_px.array_len,<br>
+ image->aux_surface.isl.<wbr>logical_level0_px.depth >> miplevel);<br>
+ }<br>
+}<br>
+<br>
/* Returns true if a HiZ-enabled depth buffer can be sampled from. */<br>
static inline bool<br>
anv_can_sample_with_hiz(const struct gen_device_info * const devinfo,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>