diff options
author | Chad Versace <[email protected]> | 2015-08-20 10:03:58 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2015-08-20 10:25:04 -0700 |
commit | 0db3d67a1488089602f787c281b2dff888fb7acd (patch) | |
tree | 93e65da8e0f58619f4947c863633c6c6cda5a0d8 /src | |
parent | 23872191012a0b95a1ef7bcefeb6609ce595fecf (diff) |
vk: Cache each render pass's number of clear ops
During vkCreateRenderPass, count the number of clear ops and store them
in new members of anv_render_pass:
uint32_t num_color_clear_attachments
bool has_depth_clear_attachment
bool has_stencil_clear_attachment
Cacheing these 8 bytes (including padding) reduces the number of times
that anv_cmd_buffer_clear_attachments needs to loop over the pass's
attachments.
Diffstat (limited to 'src')
-rw-r--r-- | src/vulkan/anv_device.c | 11 | ||||
-rw-r--r-- | src/vulkan/anv_meta.c | 26 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 4 |
3 files changed, 26 insertions, 15 deletions
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 5805ffab193..eaeae3b0a4f 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -2238,6 +2238,17 @@ VkResult anv_CreateRenderPass( att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp; // att->store_op = pCreateInfo->pAttachments[i].storeOp; // att->stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp; + + if (att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) { + if (anv_format_is_color(att->format)) { + ++pass->num_color_clear_attachments; + } else if (att->format->depth_format) { + pass->has_depth_clear_attachment = true; + } + } else if (att->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) { + assert(att->format->has_stencil); + pass->has_stencil_clear_attachment = true; + } } for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index add5f7d6d9b..b1f3fe7191b 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -272,22 +272,17 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, { struct anv_saved_state saved_state; - int num_clear_layers = 0; - for (uint32_t i = 0; i < pass->attachment_count; i++) { - if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) { - if (anv_format_is_depth_or_stencil(pass->attachments[i].format)) { - anv_finishme("Can't clear depth-stencil yet"); - continue; - } - num_clear_layers++; - } - } + if (pass->has_depth_clear_attachment) + anv_finishme("depth clear"); + + if (pass->has_stencil_clear_attachment) + anv_finishme("stencil clear"); - if (num_clear_layers == 0) + if (pass->num_color_clear_attachments == 0) return; - struct clear_instance_data instance_data[num_clear_layers]; - uint32_t color_attachments[num_clear_layers]; + struct clear_instance_data instance_data[pass->num_color_clear_attachments]; + uint32_t color_attachments[pass->num_color_clear_attachments]; int layer = 0; for (uint32_t i = 0; i < pass->attachment_count; i++) { @@ -310,14 +305,15 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, struct anv_subpass subpass = { .input_count = 0, - .color_count = num_clear_layers, + .color_count = pass->num_color_clear_attachments, .color_attachments = color_attachments, .depth_stencil_attachment = VK_ATTACHMENT_UNUSED, }; anv_cmd_buffer_begin_subpass(cmd_buffer, &subpass); - meta_emit_clear(cmd_buffer, num_clear_layers, instance_data); + meta_emit_clear(cmd_buffer, pass->num_color_clear_attachments, + instance_data); /* Restore API state */ anv_cmd_buffer_restore(cmd_buffer, &saved_state); diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 73bcd85e411..1de97fda83a 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1063,6 +1063,10 @@ struct anv_render_pass { uint32_t attachment_count; uint32_t subpass_count; + uint32_t num_color_clear_attachments; + bool has_depth_clear_attachment; + bool has_stencil_clear_attachment; + struct anv_render_pass_attachment * attachments; struct anv_subpass subpasses[0]; }; |