summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-11-21 11:39:12 -0800
committerJason Ekstrand <[email protected]>2015-11-21 11:39:12 -0800
commite14b2c76b40398a61f45f5d058079641661a66cb (patch)
tree2bea802ce615c3df5eb9a4257131d2f1f1b2b042
parent83c305f8efc019151f8cabaca0114bfcace096ef (diff)
anv/meta_clear: Don't trash state if no clears are needed
-rw-r--r--src/vulkan/anv_meta_clear.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c
index 16e15c67cc9..6645e37d124 100644
--- a/src/vulkan/anv_meta_clear.c
+++ b/src/vulkan/anv_meta_clear.c
@@ -619,6 +619,32 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
{
struct anv_meta_saved_state saved_state;
+ /* Figure out whether or not we actually need to clear anything to avoid
+ * trashing state when clearing is a no-op.
+ */
+ bool needs_clear = false;
+ for (uint32_t a = 0; a < pass->attachment_count; ++a) {
+ struct anv_render_pass_attachment *att = &pass->attachments[a];
+
+ if (anv_format_is_color(att->format)) {
+ if (att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
+ needs_clear = true;
+ break;
+ }
+ } else {
+ if ((att->format->depth_format &&
+ att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) ||
+ (att->format->has_stencil &&
+ att->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR)) {
+ needs_clear = true;
+ break;
+ }
+ }
+ }
+
+ if (!needs_clear)
+ return;
+
meta_clear_begin(&saved_state, cmd_buffer);
for (uint32_t a = 0; a < pass->attachment_count; ++a) {