<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 11, 2017 at 5:55 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is a better mapping to the Vulkan API and improves performance in<br>
all tested workloads.<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 | 48 ++----------------------------<wbr>---<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 54 ++++++++++++++++++++++++++++++<wbr>+-------<br>
2 files changed, 46 insertions(+), 56 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
index 9919ac7ea0..5d410f7d86 100644<br>
--- a/src/intel/vulkan/anv_blorp.c<br>
+++ b/src/intel/vulkan/anv_blorp.c<br>
@@ -1579,52 +1579,8 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer *cmd_buffer,<br>
image->aux_usage != ISL_AUX_USAGE_HIZ)<br>
return;<br>
<br>
- const struct anv_cmd_state *cmd_state = &cmd_buffer->state;<br>
- const uint32_t ds = cmd_state->subpass->depth_<wbr>stencil_attachment;<br>
-<br>
- /* Section 7.4. of the Vulkan 1.0.27 spec states:<br>
- *<br>
- * "The render area must be contained within the framebuffer dimensions."<br>
- *<br>
- * Therefore, the only way the extent of the render area can match that of<br>
- * the image view is if the render area offset equals (0, 0).<br>
- */<br>
- const bool full_surface_op =<br>
- cmd_state->render_area.extent.<wbr>width == image->extent.width &&<br>
- cmd_state->render_area.extent.<wbr>height == image->extent.height;<br>
- if (full_surface_op)<br>
- assert(cmd_state->render_area.<wbr>offset.x == 0 &&<br>
- cmd_state->render_area.offset.<wbr>y == 0);<br>
-<br>
- /* Check the subpass index to determine if skipping a resolve is allowed */<br>
- const uint32_t subpass_idx = cmd_state->subpass - cmd_state->pass->subpasses;<br>
- switch (op) {<br>
- case BLORP_HIZ_OP_DEPTH_RESOLVE:<br>
- if (cmd_buffer->state.pass-><wbr>attachments[ds].store_op !=<br>
- VK_ATTACHMENT_STORE_OP_STORE &&<br>
- subpass_idx == cmd_state->pass->subpass_count - 1)<br>
- return;<br>
- break;<br>
- case BLORP_HIZ_OP_HIZ_RESOLVE:<br>
- /* If the render area covers the entire surface *and* load_op is either<br>
- * CLEAR or DONT_CARE then the previous contents of the depth buffer<br>
- * will be entirely discarded. In this case, we can skip the HiZ<br>
- * resolve.<br>
- *<br>
- * If the render area is not the full surface, we need to do<br>
- * the resolve because otherwise data outside the render area may get<br>
- * garbled by the resolve at the end of the render pass.<br>
- */<br>
- if (full_surface_op &&<br>
- cmd_buffer->state.pass-><wbr>attachments[ds].load_op !=<br>
- VK_ATTACHMENT_LOAD_OP_LOAD && subpass_idx == 0)<br>
- return;<br>
- break;<br>
- case BLORP_HIZ_OP_DEPTH_CLEAR:<br>
- case BLORP_HIZ_OP_NONE:<br>
- unreachable("Invalid HiZ OP");<br>
- }<br>
-<br>
+ assert(op == BLORP_HIZ_OP_HIZ_RESOLVE ||<br>
+ op == BLORP_HIZ_OP_DEPTH_RESOLVE);<br>
<br>
struct blorp_batch batch;<br>
blorp_batch_init(&cmd_buffer-><wbr>device->blorp, &batch, cmd_buffer, 0);<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 1793c4df26..447baa08b2 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -510,7 +510,13 @@ genX(cmd_buffer_setup_<wbr>attachments)(struct anv_cmd_buffer *cmd_buffer,<br>
state->attachments[i].aux_<wbr>usage,<br>
state->attachments[i].color_<wbr>rt_state);<br>
} else {<br>
- state->attachments[i].aux_<wbr>usage = iview->image->aux_usage;<br>
+ if (iview->image->aux_usage == ISL_AUX_USAGE_HIZ &&<br>
+ iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) {<br>
+ state->attachments[i].aux_<wbr>usage =<br>
+ layout_to_hiz_usage(att-><wbr>initial_layout);<br>
+ } else {<br>
+ state->attachments[i].aux_<wbr>usage = ISL_AUX_USAGE_NONE;<br>
+ }<br>
state->attachments[i].input_<wbr>aux_usage = ISL_AUX_USAGE_NONE;<br>
}<br>
<br>
@@ -915,6 +921,13 @@ void genX(CmdPipelineBarrier)(<br>
for (uint32_t i = 0; i < imageMemoryBarrierCount; i++) {<br>
src_flags |= pImageMemoryBarriers[i].<wbr>srcAccessMask;<br>
dst_flags |= pImageMemoryBarriers[i].<wbr>dstAccessMask;<br>
+ ANV_FROM_HANDLE(anv_image, image, pImageMemoryBarriers[i].image)<wbr>;<br>
+ if (pImageMemoryBarriers[i].<wbr>subresourceRange.aspectMask &<br>
+ VK_IMAGE_ASPECT_DEPTH_BIT) {<br>
+ transition_depth_buffer(cmd_<wbr>buffer, image,<br>
+ pImageMemoryBarriers[i].<wbr>oldLayout,<br>
+ pImageMemoryBarriers[i].<wbr>newLayout);<br>
+ }<br>
}<br>
<br>
enum anv_pipe_bits pipe_bits = 0;<br>
@@ -2297,9 +2310,16 @@ genX(cmd_buffer_set_subpass)(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
const struct anv_image_view *iview =<br>
anv_cmd_buffer_get_depth_<wbr>stencil_view(cmd_buffer);<br>
<br>
- if (iview) {<br>
- anv_gen8_hiz_op_resolve(cmd_<wbr>buffer, iview->image,<br>
- BLORP_HIZ_OP_HIZ_RESOLVE);<br>
+ if (iview && iview->image->aux_usage == ISL_AUX_USAGE_HIZ &&<br>
+ iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) {<br></blockquote><div><br></div><div>I don't think you want the "iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT" part. The image view aspect doesn't affect depth stencil attachments, only input attachments and textures.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ const uint32_t ds = subpass->depth_stencil_<wbr>attachment;<br>
+ transition_depth_buffer(cmd_<wbr>buffer, iview->image,<br>
+ cmd_buffer->state.attachments[<wbr>ds].current_layout,<br>
+ cmd_buffer->state.subpass-><wbr>depth_stencil_layout);<br>
+ cmd_buffer->state.attachments[<wbr>ds].current_layout =<br>
+ cmd_buffer->state.subpass-><wbr>depth_stencil_layout;<br>
+ cmd_buffer->state.attachments[<wbr>ds].aux_usage =<br>
+ layout_to_hiz_usage(cmd_<wbr>buffer->state.subpass->depth_<wbr>stencil_layout);<br>
}<br>
<br>
cmd_buffer_emit_depth_stencil(<wbr>cmd_buffer);<br>
@@ -2337,9 +2357,16 @@ void genX(CmdNextSubpass)(<br>
const struct anv_image_view *iview =<br>
anv_cmd_buffer_get_depth_<wbr>stencil_view(cmd_buffer);<br>
<br>
- if (iview) {<br>
- anv_gen8_hiz_op_resolve(cmd_<wbr>buffer, iview->image,<br>
- BLORP_HIZ_OP_DEPTH_RESOLVE);<br>
+ if (iview && iview->image->aux_usage == ISL_AUX_USAGE_HIZ &&<br>
+ iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) {<br></blockquote><div><br></div><div>Same comment here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ const uint32_t ds = cmd_buffer->state.subpass-><wbr>depth_stencil_attachment;<br>
+<br>
+ if (cmd_buffer->state.subpass - cmd_buffer->state.pass-><wbr>subpasses ==<br>
+ cmd_buffer->state.pass-><wbr>attachments[ds].last_subpass_<wbr>idx) {<br>
+ transition_depth_buffer(cmd_<wbr>buffer, iview->image,<br>
+ cmd_buffer->state.attachments[<wbr>ds].current_layout,<br>
+ cmd_buffer->state.pass-><wbr>attachments[ds].final_layout);<br>
+ }<br>
}<br>
<br>
anv_cmd_buffer_resolve_<wbr>subpass(cmd_buffer);<br>
@@ -2354,9 +2381,16 @@ void genX(CmdEndRenderPass)(<br>
const struct anv_image_view *iview =<br>
anv_cmd_buffer_get_depth_<wbr>stencil_view(cmd_buffer);<br>
<br>
- if (iview) {<br>
- anv_gen8_hiz_op_resolve(cmd_<wbr>buffer, iview->image,<br>
- BLORP_HIZ_OP_DEPTH_RESOLVE);<br>
+ if (iview && iview->image->aux_usage == ISL_AUX_USAGE_HIZ &&<br>
+ iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) {<br></blockquote><div><br></div><div>And here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ const uint32_t ds = cmd_buffer->state.subpass-><wbr>depth_stencil_attachment;<br>
+<br>
+ if (cmd_buffer->state.subpass - cmd_buffer->state.pass-><wbr>subpasses ==<br>
+ cmd_buffer->state.pass-><wbr>attachments[ds].last_subpass_<wbr>idx) {<br>
+ transition_depth_buffer(cmd_<wbr>buffer, iview->image,<br>
+ cmd_buffer->state.attachments[<wbr>ds].current_layout,<br>
+ cmd_buffer->state.pass-><wbr>attachments[ds].final_layout);<br>
+ }<br>
}<br>
<br>
anv_cmd_buffer_resolve_<wbr>subpass(cmd_buffer);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<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>