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/vulkan/anv_meta.c | |
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/vulkan/anv_meta.c')
-rw-r--r-- | src/vulkan/anv_meta.c | 26 |
1 files changed, 11 insertions, 15 deletions
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); |