<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 28, 2017 at 2:14 PM, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">v2: Rewrite functions.<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/genX_cmd_<wbr>buffer.c | 93 ++++++++++++++++++++++++++++++<wbr>++++----<br>
1 file changed, 84 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 53c58ca5b3..8601d706d1 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -384,6 +384,70 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
anv_gen8_hiz_op_resolve(cmd_<wbr>buffer, image, hiz_op);<br>
}<br>
<br>
+static inline uint32_t<br>
+get_fast_clear_state_entry_<wbr>offset(const struct anv_device *device,<br>
+ const struct anv_image *image,<br>
+ unsigned level)<br>
+{<br>
+ assert(device && image);<br>
+ assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
+ assert(level < anv_image_aux_levels(image));<br>
+ const uint32_t offset = image->offset + image->aux_surface.offset +<br>
+ image->aux_surface.isl.size +<br>
+ anv_fast_clear_state_entry_<wbr>size(device) * level;<br>
+ assert(offset < image->offset + image->size);<br>
+ return offset;<br>
+}<br>
+<br>
+static void<br>
+init_fast_clear_state_entry(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
+ const struct anv_image *image,<br>
+ unsigned level)<br>
+{<br>
+ assert(cmd_buffer && image);<br>
+ assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
+ assert(level < anv_image_aux_levels(image));<br>
+<br>
+ /* The fast clear value dword(s) will be copied into a surface state object.<br>
+ * Ensure that the restrictions of the fields in the dword(s) are followed.<br>
+ *<br>
+ * CCS buffers on SKL+ can have any value set for the clear colors.<br>
+ */<br>
+ if (image->samples == 1 && GEN_GEN >= 9)<br>
+ return;<br>
+<br>
+ /* Other combinations of auxiliary buffers and platforms require specific<br>
+ * values in the clear value dword(s).<br>
+ */<br>
+ unsigned i = 0;<br>
+ for (; i < cmd_buffer->device->isl_dev.<wbr>ss.clear_value_size; i += 4) {<br>
+ anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(MI_STORE_DATA_IMM), sdi) {<br>
+ const uint32_t entry_offset =<br>
+ get_fast_clear_state_entry_<wbr>offset(cmd_buffer->device, image, level);<br>
+ sdi.Address = (struct anv_address) { image->bo, entry_offset + i };<br>
+<br>
+ if (GEN_GEN >= 9) {<br>
+ /* MCS buffers on SKL+ can only have 1/0 clear colors. */<br>
+ assert(image->aux_usage == ISL_AUX_USAGE_MCS);<br>
+ sdi.ImmediateData = 0;<br>
+ } else {<br>
+ /* Pre-SKL, the dword containing the clear values also contains<br>
+ * other fields, so we need to initialize those fields to match the<br>
+ * values that would be in a color attachment.<br>
+ */<br>
+ assert(i == 0);<br>
+ sdi.ImmediateData = level << 8;<br></blockquote><div><br></div><div>From the Broadwell PRM, RENDER_SURFACE_STATE::Resource Min LOD:<br><br>For Sampling Engine Surfaces:<br>This field indicates the most detailed LOD that is present in the resource underlying the surface.<br>Refer to the "LOD Computation Pseudocode" section for the use of this field.<br><br>For Other Surfaces:<br>This field is ignored.<br><br></div><div>I think we can safely leave this field zero since this will only ever be ORed into render target surfaces. Grepping through isl_surface_state.c also indicates that we never set this field in either GL or Vulkan so it's always zero.<br> <br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ if (GEN_VERSIONx10 >= 75) {<br>
+ sdi.ImmediateData |= ISL_CHANNEL_SELECT_RED << 25 |<br>
+ ISL_CHANNEL_SELECT_GREEN << 22 |<br>
+ ISL_CHANNEL_SELECT_BLUE << 19 |<br>
+ ISL_CHANNEL_SELECT_ALPHA << 16;<br></blockquote><div><br></div><div>These, however, are needed. :-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ }<br>
+ }<br>
+ }<br>
+ }<br>
+}<br>
+<br>
static void<br>
transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
const struct anv_image *image,<br>
@@ -392,7 +456,9 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
VkImageLayout initial_layout,<br>
VkImageLayout final_layout)<br>
{<br>
- if (image->aux_usage != ISL_AUX_USAGE_CCS_E)<br>
+ assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
+<br>
+ if (image->aux_surface.isl.size == 0)<br>
return;<br>
<br>
if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&<br>
@@ -405,15 +471,24 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
layer_count = anv_minify(image->extent.<wbr>depth, base_level);<br>
}<br>
<br>
-#if GEN_GEN >= 9<br>
- /* We're transitioning from an undefined layout so it doesn't really matter<br>
- * what data ends up in the color buffer. We do, however, need to ensure<br>
- * that the CCS has valid data in it. One easy way to do that is to<br>
- * fast-clear the specified range.<br>
+ /* We're interested in the subresource range subset that has aux data. */<br>
+ level_count = MIN2(level_count, anv_image_aux_levels(image));<br>
+<br>
+ /* We're transitioning from an undefined layout. We must ensure that the<br>
+ * clear values buffer is filled with valid data.<br>
*/<br>
- anv_image_ccs_clear(cmd_<wbr>buffer, image, base_level, level_count,<br>
- base_layer, layer_count);<br>
-#endif<br>
+ for (unsigned l = 0; l < level_count; l++)<br>
+ init_fast_clear_state_entry(<wbr>cmd_buffer, image, base_level + l);<br>
+<br>
+ if (image->aux_usage == ISL_AUX_USAGE_CCS_E) {<br>
+ /* We're transitioning from an undefined layout so it doesn't really<br>
+ * matter what data ends up in the color buffer. We do, however, need to<br>
+ * ensure that the CCS has valid data in it. One easy way to do that is<br>
+ * to fast-clear the specified range.<br>
+ */<br>
+ anv_image_ccs_clear(cmd_<wbr>buffer, image, base_level, level_count,<br>
+ base_layer, layer_count);<br>
+ }<br>
}<br>
<br>
/**<br>
<span class="gmail-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>