[Mesa-dev] [PATCH 12/24] anv/cmd_buffer: Disable fast clears in the GENERAL layout
Nanley Chery
nanleychery at gmail.com
Thu May 11 19:05:19 UTC 2017
v2 (Jason Ekstrand):
- Initialize ::first_subpass_layout instead of asserting
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
src/intel/vulkan/anv_pass.c | 22 ++++++++++++++++++++++
src/intel/vulkan/anv_private.h | 1 +
src/intel/vulkan/genX_cmd_buffer.c | 10 ++++++++--
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c
index 93f14830cc..bb7ee45098 100644
--- a/src/intel/vulkan/anv_pass.c
+++ b/src/intel/vulkan/anv_pass.c
@@ -34,6 +34,16 @@ num_subpass_attachments(const VkSubpassDescription *desc)
(desc->pDepthStencilAttachment != NULL);
}
+static void
+init_first_subpass_layout(struct anv_render_pass_attachment * const att,
+ const VkAttachmentReference att_ref)
+{
+ if (att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
+ att->first_subpass_layout = att_ref.layout;
+ assert(att->first_subpass_layout != VK_IMAGE_LAYOUT_UNDEFINED);
+ }
+}
+
VkResult anv_CreateRenderPass(
VkDevice _device,
const VkRenderPassCreateInfo* pCreateInfo,
@@ -91,6 +101,7 @@ VkResult anv_CreateRenderPass(
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
att->initial_layout = pCreateInfo->pAttachments[i].initialLayout;
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
+ att->first_subpass_layout = VK_IMAGE_LAYOUT_UNDEFINED;
att->subpass_usage = subpass_usages;
subpass_usages += pass->subpass_count;
}
@@ -119,6 +130,8 @@ VkResult anv_CreateRenderPass(
pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_INPUT;
pass->attachments[a].last_subpass_idx = i;
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pInputAttachments[j]);
if (desc->pDepthStencilAttachment &&
a == desc->pDepthStencilAttachment->attachment)
subpass->has_ds_self_dep = true;
@@ -138,6 +151,9 @@ VkResult anv_CreateRenderPass(
pass->attachments[a].usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_DRAW;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pColorAttachments[j]);
}
}
}
@@ -162,6 +178,9 @@ VkResult anv_CreateRenderPass(
pass->attachments[a].subpass_usage[i] |=
ANV_SUBPASS_USAGE_RESOLVE_DST;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pResolveAttachments[j]);
}
}
}
@@ -176,6 +195,9 @@ VkResult anv_CreateRenderPass(
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_DRAW;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ *desc->pDepthStencilAttachment);
}
} else {
subpass->depth_stencil_attachment.attachment = VK_ATTACHMENT_UNUSED;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index b0752d286d..30147801a6 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2301,6 +2301,7 @@ struct anv_render_pass_attachment {
VkAttachmentLoadOp stencil_load_op;
VkImageLayout initial_layout;
VkImageLayout final_layout;
+ VkImageLayout first_subpass_layout;
/* An array, indexed by subpass id, of how the attachment will be used. */
enum anv_subpass_usage * subpass_usage;
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 5cc8235e38..466ae1e443 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -330,6 +330,13 @@ color_attachment_compute_aux_usage(struct anv_device * device,
att_state->fast_clear = false;
}
+ /* We only allow fast clears for the COLOR_ATTACHMENT_OPTIMAL layout.
+ * See add_clear_values() for more information.
+ */
+ if (cmd_state->pass->attachments[att].first_subpass_layout !=
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
+ att_state->fast_clear = false;
+
if (att_state->fast_clear) {
memcpy(fast_clear_color->u32, att_state->clear_value.color.uint32,
sizeof(fast_clear_color->u32));
@@ -524,8 +531,7 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
union isl_color_value clear_color = { .u32 = { 0, } };
if (att_aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
color_attachment_compute_aux_usage(cmd_buffer->device,
- state, i,
- begin->renderArea,
+ state, i, begin->renderArea,
&clear_color);
struct isl_view view = iview->isl;
--
2.12.2
More information about the mesa-dev
mailing list