[Mesa-dev] [PATCH 11/22] anv/cmd_buffer: Ensure the fast clear values are correct
Nanley Chery
nanleychery at gmail.com
Thu Apr 27 18:32:10 UTC 2017
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
src/intel/vulkan/genX_cmd_buffer.c | 76 ++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index e3b1687121..4698270abb 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -400,6 +400,57 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
}
+/* Copies clear value dwords between a surface state object and an image's
+ * clear value buffer.
+ */
+static void
+genX(transfer_clear_value)(struct anv_cmd_buffer * const cmd_buffer,
+ const struct anv_state surface_state,
+ const struct anv_image * const image,
+ const uint8_t level,
+ const bool copy_to_buffer)
+{
+ assert(cmd_buffer && image);
+
+ /* The image and its subresource must have a color auxiliary buffer. */
+ assert(anv_image_has_color_aux(image));
+ assert(level < anv_color_aux_levels(image));
+
+ const uint32_t img_clear_offset =
+ image->offset + image->aux_surface.offset +
+ image->aux_surface.isl.size +
+ cmd_buffer->device->isl_dev.ss.size * level +
+ cmd_buffer->device->isl_dev.ss.clear_value_offset;
+
+ struct anv_bo * const ss_bo =
+ &cmd_buffer->device->surface_state_block_pool.bo;
+ const uint32_t ss_clear_offset = surface_state.offset +
+ cmd_buffer->device->isl_dev.ss.clear_value_offset;
+
+ const uint8_t clear_value_size =
+ cmd_buffer->device->isl_dev.ss.clear_value_size;
+
+ if (copy_to_buffer) {
+ genX(cmd_buffer_gpu_memcpy)(cmd_buffer, image->bo, img_clear_offset,
+ ss_bo, ss_clear_offset, clear_value_size);
+ } else {
+ genX(cmd_buffer_gpu_memcpy)(cmd_buffer, ss_bo, ss_clear_offset,
+ image->bo, img_clear_offset, clear_value_size);
+
+ /* From the SKL PRM, Shared Functions -> State -> State Caching:
+ *
+ * Whenever the RENDER_SURFACE_STATE object in memory pointed to by
+ * the Binding Table Pointer (BTP) and Binding Table Index (BTI) is
+ * modified [...], the L1 state cache must be invalidated to ensure
+ * the new surface or sampler state is fetched from system memory.
+ *
+ * SKL actually doesn't seem to need this, but HSW does.
+ */
+ cmd_buffer->state.pending_pipe_bits |=
+ ANV_PIPE_STATE_CACHE_INVALIDATE_BIT;
+ }
+}
+
/**
* Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.
*/
@@ -538,6 +589,31 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
add_image_view_relocs(cmd_buffer, iview,
state->attachments[i].aux_usage,
state->attachments[i].color_rt_state);
+
+ /* Update the image subresource's fast-clear value as necessary. */
+ if (state->attachments[i].fast_clear) {
+ /* Update the clear value buffer. */
+ assert(state->attachments[i].aux_usage != ISL_AUX_USAGE_NONE);
+ genX(transfer_clear_value)(cmd_buffer,
+ state->attachments[i].color_rt_state, iview->image,
+ iview->isl.base_level, true /* copy_to_buffer */);
+ } else if (att->load_op == VK_ATTACHMENT_LOAD_OP_LOAD &&
+ state->attachments[i].aux_usage != ISL_AUX_USAGE_NONE) {
+ /* The attachment may have been fast-cleared in a previous
+ * render pass. Update the clear color fields.
+ */
+ genX(transfer_clear_value)(cmd_buffer,
+ state->attachments[i].color_rt_state, iview->image,
+ iview->isl.base_level, false /* copy_to_ss */);
+
+ if (need_input_attachment_state(&pass->attachments[i]) &&
+ state->attachments[i].input_aux_usage !=
+ ISL_AUX_USAGE_NONE) {
+ genX(transfer_clear_value)(cmd_buffer,
+ state->attachments[i].input_att_state, iview->image,
+ iview->isl.base_level, false /* copy_to_ss */);
+ }
+ }
} else {
/* This field will be initialized after the first subpass
* transition.
--
2.12.2
More information about the mesa-dev
mailing list