<div dir="ltr"><div class="gmail_extra"><br><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: Remove ::first_subpass_layout assertion (Jason Ekstrand).<br>
v3: Allow some fast clears in the GENERAL layout.<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_pass.c | 22 ++++++++++++++++++++++<br>
src/intel/vulkan/anv_private.h | 2 ++<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 17 ++++++++++++++++-<br>
3 files changed, 40 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c<br>
index 1b30c1409d..ab0733fc10 100644<br>
--- a/src/intel/vulkan/anv_pass.c<br>
+++ b/src/intel/vulkan/anv_pass.c<br>
@@ -34,6 +34,16 @@ num_subpass_attachments(const VkSubpassDescription *desc)<br>
(desc->pDepthStencilAttachment != NULL);<br>
}<br>
<br>
+static void<br>
+init_first_subpass_layout(<wbr>struct anv_render_pass_attachment * const att,<br>
+ const VkAttachmentReference att_ref)<br>
+{<br>
+ if (att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {<br>
+ att->first_subpass_layout = att_ref.layout;<br>
+ assert(att->first_subpass_<wbr>layout != VK_IMAGE_LAYOUT_UNDEFINED);<br>
+ }<br>
+}<br>
+<br>
VkResult anv_CreateRenderPass(<br>
VkDevice _device,<br>
const VkRenderPassCreateInfo* pCreateInfo,<br>
@@ -91,6 +101,7 @@ VkResult anv_CreateRenderPass(<br>
att->stencil_load_op = pCreateInfo->pAttachments[i].<wbr>stencilLoadOp;<br>
att->initial_layout = pCreateInfo->pAttachments[i].<wbr>initialLayout;<br>
att->final_layout = pCreateInfo->pAttachments[i].<wbr>finalLayout;<br>
+ att->first_subpass_layout = VK_IMAGE_LAYOUT_UNDEFINED;<br>
att->subpass_usage = subpass_usages;<br>
subpass_usages += pass->subpass_count;<br>
}<br>
@@ -119,6 +130,8 @@ VkResult anv_CreateRenderPass(<br>
pass->attachments[a].subpass_<wbr>usage[i] |= ANV_SUBPASS_USAGE_INPUT;<br>
pass->attachments[a].last_<wbr>subpass_idx = i;<br>
<br>
+ init_first_subpass_layout(&<wbr>pass->attachments[a],<br>
+ desc->pInputAttachments[j]);<br>
if (desc->pDepthStencilAttachment &&<br>
a == desc->pDepthStencilAttachment-<wbr>>attachment)<br>
subpass->has_ds_self_dep = true;<br>
@@ -138,6 +151,9 @@ VkResult anv_CreateRenderPass(<br>
pass->attachments[a].usage |= VK_IMAGE_USAGE_COLOR_<wbr>ATTACHMENT_BIT;<br>
pass->attachments[a].subpass_<wbr>usage[i] |= ANV_SUBPASS_USAGE_DRAW;<br>
pass->attachments[a].last_<wbr>subpass_idx = i;<br>
+<br>
+ init_first_subpass_layout(&<wbr>pass->attachments[a],<br>
+ desc->pColorAttachments[j]);<br>
}<br>
}<br>
}<br>
@@ -162,6 +178,9 @@ VkResult anv_CreateRenderPass(<br>
pass->attachments[a].subpass_<wbr>usage[i] |=<br>
ANV_SUBPASS_USAGE_RESOLVE_DST;<br>
pass->attachments[a].last_<wbr>subpass_idx = i;<br>
+<br>
+ init_first_subpass_layout(&<wbr>pass->attachments[a],<br>
+ desc->pResolveAttachments[j]);<br>
}<br>
}<br>
}<br>
@@ -176,6 +195,9 @@ VkResult anv_CreateRenderPass(<br>
VK_IMAGE_USAGE_DEPTH_STENCIL_<wbr>ATTACHMENT_BIT;<br>
pass->attachments[a].subpass_<wbr>usage[i] |= ANV_SUBPASS_USAGE_DRAW;<br>
pass->attachments[a].last_<wbr>subpass_idx = i;<br>
+<br>
+ init_first_subpass_layout(&<wbr>pass->attachments[a],<br>
+ *desc-><wbr>pDepthStencilAttachment);<br>
}<br>
} else {<br>
subpass->depth_stencil_<wbr>attachment.attachment = VK_ATTACHMENT_UNUSED;<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index a95188ac30..c5a2ba0888 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -1518,6 +1518,7 @@ struct anv_attachment_state {<br>
bool fast_clear;<br>
VkClearValue clear_value;<br>
bool clear_color_is_zero_one;<br>
+ bool clear_color_is_zero;<br>
};<br>
<br>
/** State required while building cmd buffer */<br>
@@ -2336,6 +2337,7 @@ struct anv_render_pass_attachment {<br>
VkAttachmentLoadOp stencil_load_op;<br>
VkImageLayout initial_layout;<br>
VkImageLayout final_layout;<br>
+ VkImageLayout first_subpass_layout;<br>
<br>
/* An array, indexed by subpass id, of how the attachment will be used. */<br>
enum anv_subpass_usage * subpass_usage;<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 15927d32ad..253e68cd1f 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -253,7 +253,12 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device * device,<br>
<br>
assert(iview->image->aux_<wbr>surface.isl.usage & ISL_SURF_USAGE_CCS_BIT);<br>
<br>
- att_state->clear_color_is_<wbr>zero_one =<br>
+ att_state->clear_color_is_zero =<br>
+ att_state->clear_value.color.<wbr>uint32[0] == 0 &&<br>
+ att_state->clear_value.color.<wbr>uint32[1] == 0 &&<br>
+ att_state->clear_value.color.<wbr>uint32[2] == 0 &&<br>
+ att_state->clear_value.color.<wbr>uint32[3] == 0;<br>
+ att_state->clear_color_is_<wbr>zero_one = att_state->clear_color_is_zero ||<br></blockquote><div><br></div><div>I doubt the || actually gains us anything here. function inlining, CSE, and the processor's normal pipelineing will most likely make all of the theoretical performance gain go away.<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">
color_is_zero_one(att_state-><wbr>clear_value.color, iview->isl.format);<br>
<br>
if (att_state->pending_clear_<wbr>aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
@@ -299,6 +304,16 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device * device,<br>
}<br>
}<br>
<br>
+ /* We only allow fast clears in the GENERAL layout if the auxiliary<br>
+ * buffer is always enabled and the fast-clear value is all 0's. See<br>
+ * add_fast_clear_state_buffer() for more information.<br>
+ */<br>
+ if (cmd_state->pass->attachments[<wbr>att].first_subpass_layout ==<br>
+ VK_IMAGE_LAYOUT_GENERAL && (!att_state->clear_color_is_<wbr>zero ||<br>
+ iview->image->aux_usage == ISL_AUX_USAGE_NONE)) {<br></blockquote><div><br></div><div>Mind line-breaking this differently?<br><br>+ if (cmd_state->pass->attachments[<wbr>att].first_subpass_layout ==<br>
+ VK_IMAGE_LAYOUT_GENERAL &&<br>+ (!att_state->clear_color_is_<wbr>zero ||<br>
+ iview->image->aux_usage == ISL_AUX_USAGE_NONE)) {</div><div> <br></div><div>That way it's a bit clearer where the boolean logic is.<br><br></div><div>--Jason<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ att_state->fast_clear = false;<br>
+ }<br>
+<br>
if (att_state->fast_clear) {<br>
memcpy(fast_clear_color->u32, att_state->clear_value.color.<wbr>uint32,<br>
sizeof(fast_clear_color->u32))<wbr>;<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>