<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">The lifespan of the fast-clear data will surpass the render pass scope.<br>
We need CCS_D to be enabled in order to invalidate blocks previously<br>
marked as cleared and to sample cleared data correctly.<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 | 15 ++----<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 94 +++++++++++++++++++-----------<wbr>--------<br>
2 files changed, 52 insertions(+), 57 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
index d17b73dcc7..5e7d4b06b8 100644<br>
--- a/src/intel/vulkan/anv_blorp.c<br>
+++ b/src/intel/vulkan/anv_blorp.c<br>
@@ -1383,7 +1383,8 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,<br>
&cmd_buffer->state.<wbr>attachments[att];<br>
<br>
if (att_state->aux_usage == ISL_AUX_USAGE_NONE ||<br>
- att_state->aux_usage == ISL_AUX_USAGE_MCS)<br>
+ att_state->aux_usage == ISL_AUX_USAGE_MCS ||<br>
+ att_state->fast_clear == false)<br>
return; /* Nothing to resolve */<br>
<br>
assert(att_state->aux_usage == ISL_AUX_USAGE_CCS_E ||<br>
@@ -1432,7 +1433,7 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,<br>
* the render pass. We need a full resolve.<br>
*/<br>
resolve_op = BLORP_FAST_CLEAR_OP_RESOLVE_<wbr>FULL;<br>
- } else if (att_state->fast_clear) {<br>
+ } else {<br>
/* We don't know what to do with clear colors outside the render<br>
* pass. We need a partial resolve. Only transparent black is<br>
* built into the surface state object and thus no resolve is<br>
@@ -1443,11 +1444,6 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,<br>
att_state->clear_value.color.<wbr>uint32[2] ||<br>
att_state->clear_value.color.<wbr>uint32[3])<br>
resolve_op = BLORP_FAST_CLEAR_OP_RESOLVE_<wbr>PARTIAL;<br>
- } else {<br>
- /* The image "natively" supports all the compression we care about<br>
- * and we don't need to resolve at all. If this is the case, we also<br>
- * don't need to resolve for any of the input attachment cases below.<br>
- */<br>
}<br>
} else if (usage & ANV_SUBPASS_USAGE_INPUT) {<br>
/* Input attachments are clear-color aware so, at least on Sky Lake, we<br>
@@ -1474,8 +1470,7 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,<br>
struct blorp_surf surf;<br>
get_blorp_surf_for_anv_image(<wbr>image, VK_IMAGE_ASPECT_COLOR_BIT,<br>
att_state->aux_usage, &surf);<br>
- if (att_state->fast_clear)<br>
- surf.clear_color = vk_to_isl_color(att_state-><wbr>clear_value.color);<br>
+ surf.clear_color = vk_to_isl_color(att_state-><wbr>clear_value.color);<br>
<br>
/* From the Sky Lake PRM Vol. 7, "Render Target Resolve":<br>
*<br>
@@ -1504,8 +1499,6 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,<br>
<br>
/* Once we've done any sort of resolve, we're no longer fast-cleared */<br>
att_state->fast_clear = false;<br>
- if (att_state->aux_usage == ISL_AUX_USAGE_CCS_D)<br>
- att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
}<br>
<br>
void<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index ddb22c4539..0ea378fde2 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -232,6 +232,50 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device *device,<br>
att_state->input_aux_usage = ISL_AUX_USAGE_MCS;<br>
att_state->fast_clear = false;<br>
return;<br>
+ } else if (GEN_GEN == 7 &&<br>
+ (iview->isl.base_level > 0 ||<br>
+ iview->isl.base_array_layer > 0 ||<br>
+ iview->isl.array_len > 1)) {<br>
+ /* On gen7, we can't do multi-LOD or multi-layer CCS. We technically<br>
+ * can, but it comes with crazy restrictions that we don't want to deal<br>
+ * with now.<br>
+ */<br>
+ att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
+ att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
+ att_state->fast_clear = false;<br>
+ return;<br>
+ } else if (iview->image->aux_usage == ISL_AUX_USAGE_CCS_E) {<br>
+ att_state->aux_usage = ISL_AUX_USAGE_CCS_E;<br>
+ att_state->input_aux_usage = ISL_AUX_USAGE_CCS_E;<br>
+ } else {<br>
+ att_state->aux_usage = ISL_AUX_USAGE_CCS_D;<br>
+ if (isl_format_supports_ccs_e(&<wbr>device->info, iview->isl.format)) {<br>
+ /* SKL can sample from CCS with one restriction.<br>
+ *<br>
+ * From the Sky Lake PRM, RENDER_SURFACE_STATE::<wbr>AuxiliarySurfaceMode:<br>
+ *<br>
+ * "If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_D<br>
+ * setting is only allowed if Surface Format supported for Fast<br>
+ * Clear. In addition, if the surface is bound to the sampling<br>
+ * engine, Surface Format must be supported for Render Target<br>
+ * Compression for surfaces bound to the sampling engine."<br>
+ *<br>
+ * In other words, we can only sample from a fast-cleared image if it<br>
+ * also supports color compression.<br>
+ *<br>
+ * TODO: Consider using a heuristic to determine if temporarily enabling<br>
+ * CCS_E for this image view would be beneficial.<br>
+ *<br>
+ * While fast-clear resolves and partial resolves are fairly cheap in the<br>
+ * case where you render to most of the pixels, full resolves are not<br>
+ * because they potentially involve reading and writing the entire<br>
+ * framebuffer. If we can't texture with CCS_E, we should leave it off and<br>
+ * limit ourselves to fast clears.<br>
+ */<br>
+ att_state->input_aux_usage = ISL_AUX_USAGE_CCS_D;<br>
+ } else {<br>
+ att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
+ }<br></blockquote><div><br></div><div>Is this refactor needed? I don't see how this code does anything different from what we had before.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
assert(iview->image->aux_<wbr>surface.isl.usage & ISL_SURF_USAGE_CCS_BIT);<br>
@@ -240,6 +284,10 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device *device,<br>
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>
+<br>
+ /* We should have returned early if the aux buffer will not be used. */<br>
+ assert(att_state->aux_usage != ISL_AUX_USAGE_NONE);<br>
+<br>
/* Start off assuming fast clears are possible */<br>
att_state->fast_clear = true;<br>
<br>
@@ -253,17 +301,6 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device *device,<br>
render_area.extent.height != iview->extent.height)<br>
att_state->fast_clear = false;<br>
<br>
- if (GEN_GEN <= 7) {<br>
- /* On gen7, we can't do multi-LOD or multi-layer fast-clears. We<br>
- * technically can, but it comes with crazy restrictions that we<br>
- * don't want to deal with now.<br>
- */<br>
- if (iview->isl.base_level > 0 ||<br>
- iview->isl.base_array_layer > 0 ||<br>
- iview->isl.array_len > 1)<br>
- att_state->fast_clear = false;<br>
- }<br>
-<br>
/* On Broadwell and earlier, we can only handle 0/1 clear colors */<br>
if (GEN_GEN <= 8 && !att_state->clear_color_is_<wbr>zero_one)<br>
att_state->fast_clear = false;<br>
@@ -275,41 +312,6 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device *device,<br>
} else {<br>
att_state->fast_clear = false;<br>
}<br>
-<br>
- /**<br>
- * TODO: Consider using a heuristic to determine if temporarily enabling<br>
- * CCS_E for this image view would be beneficial.<br>
- *<br>
- * While fast-clear resolves and partial resolves are fairly cheap in the<br>
- * case where you render to most of the pixels, full resolves are not<br>
- * because they potentially involve reading and writing the entire<br>
- * framebuffer. If we can't texture with CCS_E, we should leave it off and<br>
- * limit ourselves to fast clears.<br>
- */<br>
- if (iview->image->aux_usage == ISL_AUX_USAGE_CCS_E) {<br>
- att_state->aux_usage = ISL_AUX_USAGE_CCS_E;<br>
- att_state->input_aux_usage = ISL_AUX_USAGE_CCS_E;<br>
- } else if (att_state->fast_clear) {<br>
- att_state->aux_usage = ISL_AUX_USAGE_CCS_D;<br>
- /* From the Sky Lake PRM, RENDER_SURFACE_STATE::<wbr>AuxiliarySurfaceMode:<br>
- *<br>
- * "If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_D<br>
- * setting is only allowed if Surface Format supported for Fast<br>
- * Clear. In addition, if the surface is bound to the sampling<br>
- * engine, Surface Format must be supported for Render Target<br>
- * Compression for surfaces bound to the sampling engine."<br>
- *<br>
- * In other words, we can only sample from a fast-cleared image if it<br>
- * also supports color compression.<br>
- */<br>
- if (isl_format_supports_ccs_e(&<wbr>device->info, iview->isl.format))<br>
- att_state->input_aux_usage = ISL_AUX_USAGE_CCS_D;<br>
- else<br>
- att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
- } else {<br>
- att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
- att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
- }<br>
}<br>
<br>
static bool<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>