summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNanley Chery <[email protected]>2017-02-16 17:35:39 -0800
committerNanley Chery <[email protected]>2017-03-02 13:17:54 -0800
commit172747a963f92f7d9a1a4eb5ef6683f53426af0b (patch)
tree27696999cd650acf9c1ba2a426bc23c039f6956f /src
parent425e33bcdb273911ca28efebbe15e66dffaac0d3 (diff)
anv/cmd_buffer: Replace layout_to_hiz_usage()
Signed-off-by: Nanley Chery <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 2b070355d26..60ee55b0719 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -326,27 +326,6 @@ need_input_attachment_state(const struct anv_render_pass_attachment *att)
return vk_format_is_color(att->format);
}
-static enum isl_aux_usage
-layout_to_hiz_usage(VkImageLayout layout, uint8_t samples)
-{
- switch (layout) {
- case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
- return ISL_AUX_USAGE_HIZ;
- case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
- case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
- if (anv_can_sample_with_hiz(GEN_GEN, samples))
- return ISL_AUX_USAGE_HIZ;
- /* Fall-through */
- case VK_IMAGE_LAYOUT_GENERAL:
- /* This buffer could be used as a source or destination in a transfer
- * operation. Transfer operations current don't perform HiZ-enabled reads
- * and writes.
- */
- default:
- return ISL_AUX_USAGE_NONE;
- }
-}
-
/* Transitions a HiZ-enabled depth buffer from one layout to another. Unless
* the initial layout is undefined, the HiZ buffer and depth buffer will
* represent the same data at the end of this operation.
@@ -362,13 +341,9 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
if (image->aux_usage != ISL_AUX_USAGE_HIZ || final_layout == initial_layout)
return;
- const bool hiz_enabled = layout_to_hiz_usage(initial_layout, image->samples) ==
- ISL_AUX_USAGE_HIZ;
- const bool enable_hiz = layout_to_hiz_usage(final_layout, image->samples) ==
- ISL_AUX_USAGE_HIZ;
-
enum blorp_hiz_op hiz_op;
- if (initial_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
+ if (initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
+ initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
/* We've already initialized the aux HiZ buffer at BindImageMemory time,
* so there's no need to perform a HIZ resolve or clear to avoid GPU hangs.
* This initial layout indicates that the user doesn't care about the data
@@ -376,16 +351,25 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
* for the special case noted below.
*/
hiz_op = BLORP_HIZ_OP_NONE;
- } else if (hiz_enabled && !enable_hiz) {
- hiz_op = BLORP_HIZ_OP_DEPTH_RESOLVE;
- } else if (!hiz_enabled && enable_hiz) {
- hiz_op = BLORP_HIZ_OP_HIZ_RESOLVE;
} else {
- assert(hiz_enabled == enable_hiz);
- /* If the same buffer will be used, no resolves are necessary except for
- * the special case noted below.
- */
- hiz_op = BLORP_HIZ_OP_NONE;
+ const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
+ image->aspects, initial_layout);
+ const bool enable_hiz = ISL_AUX_USAGE_HIZ ==
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
+ image->aspects, final_layout);
+
+ if (hiz_enabled && !enable_hiz) {
+ hiz_op = BLORP_HIZ_OP_DEPTH_RESOLVE;
+ } else if (!hiz_enabled && enable_hiz) {
+ hiz_op = BLORP_HIZ_OP_HIZ_RESOLVE;
+ } else {
+ assert(hiz_enabled == enable_hiz);
+ /* If the same buffer will be used, no resolves are necessary except for
+ * the special case noted below.
+ */
+ hiz_op = BLORP_HIZ_OP_NONE;
+ }
}
if (hiz_op != BLORP_HIZ_OP_NONE)
@@ -557,12 +541,11 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
state->attachments[i].aux_usage,
state->attachments[i].color_rt_state);
} else {
- if (iview->image->aux_usage == ISL_AUX_USAGE_HIZ) {
- state->attachments[i].aux_usage =
- layout_to_hiz_usage(att->initial_layout, iview->image->samples);
- } else {
- state->attachments[i].aux_usage = ISL_AUX_USAGE_NONE;
- }
+ /* This field will be initialized after the first subpass
+ * transition.
+ */
+ state->attachments[i].aux_usage = ISL_AUX_USAGE_NONE;
+
state->attachments[i].input_aux_usage = ISL_AUX_USAGE_NONE;
}
@@ -2399,8 +2382,9 @@ genX(cmd_buffer_set_subpass)(struct anv_cmd_buffer *cmd_buffer,
cmd_buffer->state.attachments[ds].current_layout =
cmd_buffer->state.subpass->depth_stencil_layout;
cmd_buffer->state.attachments[ds].aux_usage =
- layout_to_hiz_usage(cmd_buffer->state.subpass->depth_stencil_layout,
- iview->image->samples);
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, iview->image,
+ iview->aspect_mask,
+ cmd_buffer->state.subpass->depth_stencil_layout);
}
cmd_buffer_emit_depth_stencil(cmd_buffer);