anv: Rework depth_stencil_attachment_compute_aux_usage

Instead of making it a function that pretends to choose aux usage (which
isn't what it does at all), make it a function which returns whether or
not we want to do a fast clear.  This is far more accurate to the
purpose of the function.

Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4393>
This commit is contained in:
Jason Ekstrand 2020-03-25 15:31:55 -05:00 committed by Marge Bot
parent 26e6da90ab
commit 3fe45a9b6c

View file

@ -462,47 +462,34 @@ color_attachment_compute_aux_usage(struct anv_device * device,
}
}
static void
depth_stencil_attachment_compute_aux_usage(struct anv_device *device,
struct anv_cmd_state *cmd_state,
uint32_t att, VkRect2D render_area)
static bool
anv_can_hiz_clear_ds_view(struct anv_device *device,
struct anv_image_view *iview,
VkImageLayout layout,
VkImageAspectFlags clear_aspects,
float depth_clear_value,
VkRect2D render_area)
{
struct anv_render_pass_attachment *pass_att =
&cmd_state->pass->attachments[att];
struct anv_attachment_state *att_state = &cmd_state->attachments[att];
struct anv_image_view *iview = cmd_state->attachments[att].image_view;
/* We don't do any HiZ or depth fast-clears on gen7 yet */
if (GEN_GEN == 7)
return false;
/* These will be initialized after the first subpass transition. */
att_state->aux_usage = ISL_AUX_USAGE_NONE;
att_state->input_aux_usage = ISL_AUX_USAGE_NONE;
if (GEN_GEN == 7) {
/* We don't do any HiZ or depth fast-clears on gen7 yet */
att_state->fast_clear = false;
return;
}
if (!(att_state->pending_clear_aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) {
/* If we're just clearing stencil, we can always HiZ clear */
att_state->fast_clear = true;
return;
}
/* Default to false for now */
att_state->fast_clear = false;
/* If we're just clearing stencil, we can always HiZ clear */
if (!(clear_aspects & VK_IMAGE_ASPECT_DEPTH_BIT))
return true;
/* We must have depth in order to have HiZ */
if (!(iview->image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT))
return;
return false;
const enum isl_aux_usage first_subpass_aux_usage =
const enum isl_aux_usage clear_aux_usage =
anv_layout_to_aux_usage(&device->info, iview->image,
VK_IMAGE_ASPECT_DEPTH_BIT,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
pass_att->first_subpass_layout);
layout);
if (!blorp_can_hiz_clear_depth(&device->info,
&iview->image->planes[0].surface.isl,
first_subpass_aux_usage,
clear_aux_usage,
iview->planes[0].isl.base_level,
iview->planes[0].isl.base_array_layer,
render_area.offset.x,
@ -511,22 +498,20 @@ depth_stencil_attachment_compute_aux_usage(struct anv_device *device,
render_area.extent.width,
render_area.offset.y +
render_area.extent.height))
return;
return false;
if (att_state->clear_value.depthStencil.depth != ANV_HZ_FC_VAL)
return;
if (depth_clear_value != ANV_HZ_FC_VAL)
return false;
if (GEN_GEN == 8 && anv_can_sample_with_hiz(&device->info, iview->image)) {
/* Only gen9+ supports returning ANV_HZ_FC_VAL when sampling a
* fast-cleared portion of a HiZ buffer. Testing has revealed that Gen8
* only supports returning 0.0f. Gens prior to gen8 do not support this
* feature at all.
*/
return;
}
/* Only gen9+ supports returning ANV_HZ_FC_VAL when sampling a fast-cleared
* portion of a HiZ buffer. Testing has revealed that Gen8 only supports
* returning 0.0f. Gens prior to gen8 do not support this feature at all.
*/
if (GEN_GEN == 8 && anv_can_sample_with_hiz(&device->info, iview->image))
return false;
/* If we got here, then we can fast clear */
att_state->fast_clear = true;
return true;
}
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
@ -1475,9 +1460,15 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
color_attachment_compute_aux_usage(cmd_buffer->device,
state, i, begin->renderArea);
} else {
depth_stencil_attachment_compute_aux_usage(cmd_buffer->device,
state, i,
begin->renderArea);
/* These will be initialized after the first subpass transition. */
att_state->aux_usage = ISL_AUX_USAGE_NONE;
att_state->input_aux_usage = ISL_AUX_USAGE_NONE;
att_state->fast_clear =
anv_can_hiz_clear_ds_view(cmd_buffer->device, iview,
pass_att->first_subpass_layout,
clear_aspects,
att_state->clear_value.depthStencil.depth,
begin->renderArea);
}
}
}