<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 27, 2017 at 11:32 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">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 | 76 ++++++++++++++++++++++++++++++<wbr>++++++++<br>
 1 file changed, 76 insertions(+)<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index e3b1687121..4698270abb 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -400,6 +400,57 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
 }<br>
<br>
<br>
+/* Copies clear value dwords between a surface state object and an image's<br>
+ * clear value buffer.<br>
+ */<br>
+static void<br>
+genX(transfer_clear_value)(<wbr>struct anv_cmd_buffer * const cmd_buffer,<br>
+                           const struct anv_state surface_state,<br>
+                           const struct anv_image * const image,<br>
+                           const uint8_t level,<br>
+                           const bool copy_to_buffer)<br>
+{<br>
+   assert(cmd_buffer && image);<br>
+<br>
+   /* The image and its subresource must have a color auxiliary buffer. */<br>
+   assert(anv_image_has_color_<wbr>aux(image));<br>
+   assert(level < anv_color_aux_levels(image));<br>
+<br>
+   const uint32_t img_clear_offset =<br>
+      image->offset + image->aux_surface.offset +<br>
+      image->aux_surface.isl.size +<br>
+      cmd_buffer->device->isl_dev.<wbr>ss.size * level +<br>
+      cmd_buffer->device->isl_dev.<wbr>ss.clear_value_offset;<br></blockquote><div><br></div><div>I think it would be good to add an anv_image_clear_value_offset(anv_image *, unsigned level) helper for this.  This calculation feels very much like anv_image internals which are leaking into cmd_buffer code.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+   struct anv_bo * const ss_bo =<br>
+      &cmd_buffer->device-><a href="http://surface_state_block_pool.bo" rel="noreferrer" target="_blank">surface_<wbr>state_block_pool.bo</a>;<br>
+   const uint32_t ss_clear_offset = surface_state.offset +<br>
+      cmd_buffer->device->isl_dev.<wbr>ss.clear_value_offset;<br>
+<br>
+   const uint8_t clear_value_size =<br>
+      cmd_buffer->device->isl_dev.<wbr>ss.clear_value_size;<br>
+<br>
+   if (copy_to_buffer) {<br>
+      genX(cmd_buffer_gpu_memcpy)(<wbr>cmd_buffer, image->bo, img_clear_offset,<br>
+                                  ss_bo, ss_clear_offset, clear_value_size);<br>
+   } else {<br>
+      genX(cmd_buffer_gpu_memcpy)(<wbr>cmd_buffer, ss_bo, ss_clear_offset,<br>
+                                  image->bo, img_clear_offset, clear_value_size);<br></blockquote><div><br></div><div>The streamout GPU memcpy stuff is a bit heavy-weight for this.  It's great if you have lots of data to copy but setting up a full 3D pipeline per surface state is a bit excessive.  Probably better to just use the command streamer for this instead.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+      /* From the SKL PRM, Shared Functions -> State -> State Caching:<br>
+       *<br>
+       *    Whenever the RENDER_SURFACE_STATE object in memory pointed to by<br>
+       *    the Binding Table Pointer (BTP) and Binding Table Index (BTI) is<br>
+       *    modified [...], the L1 state cache must be invalidated to ensure<br>
+       *    the new surface or sampler state is fetched from system memory.<br>
+       *<br>
+       * SKL actually doesn't seem to need this, but HSW does.<br>
+       */<br>
+      cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
+         ANV_PIPE_STATE_CACHE_<wbr>INVALIDATE_BIT;<br>
+   }<br>
+}<br>
+<br>
 /**<br>
  * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.<br>
  */<br>
@@ -538,6 +589,31 @@ genX(cmd_buffer_setup_<wbr>attachments)(struct anv_cmd_buffer *cmd_buffer,<br>
             add_image_view_relocs(cmd_<wbr>buffer, iview,<br>
                                   state->attachments[i].aux_<wbr>usage,<br>
                                   state->attachments[i].color_<wbr>rt_state);<br>
+<br>
+            /* Update the image subresource's fast-clear value as necessary. */<br>
+            if (state->attachments[i].fast_<wbr>clear) {<br>
+               /* Update the clear value buffer. */<br>
+               assert(state->attachments[i].<wbr>aux_usage != ISL_AUX_USAGE_NONE);<br>
+               genX(transfer_clear_value)(<wbr>cmd_buffer,<br>
+                  state->attachments[i].color_<wbr>rt_state, iview->image,<br>
+                  iview->isl.base_level, true /* copy_to_buffer */);<br>
+            } else if (att->load_op == VK_ATTACHMENT_LOAD_OP_LOAD &&<br>
+                       state->attachments[i].aux_<wbr>usage != ISL_AUX_USAGE_NONE) {<br>
+               /* The attachment may have been fast-cleared in a previous<br>
+                * render pass. Update the clear color fields.<br>
+                */<br>
+               genX(transfer_clear_value)(<wbr>cmd_buffer,<br>
+                  state->attachments[i].color_<wbr>rt_state, iview->image,<br>
+                  iview->isl.base_level, false /* copy_to_ss */);<br>
+<br>
+               if (need_input_attachment_state(&<wbr>pass->attachments[i]) &&<br>
+                   state->attachments[i].input_<wbr>aux_usage !=<br>
+                   ISL_AUX_USAGE_NONE) {<br>
+                  genX(transfer_clear_value)(<wbr>cmd_buffer,<br>
+                     state->attachments[i].input_<wbr>att_state, iview->image,<br>
+                     iview->isl.base_level, false /* copy_to_ss */);<br>
+               }<br>
+            }<br>
          } else {<br>
             /* This field will be initialized after the first subpass<br>
              * transition.<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.12.2<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>