intel: Avoid no-op calls to anv_image_clear_color
Whenever we execute a fast-clear due to LOAD_OP_CLEAR, we decrease the number of layers to clear by one. We then enter the slow clear function and possibly exit without clearing if the layer count is zero. Unfortunately, we've already compiled the shader for slow clears by the time we exit. Skip the slow clear function if there are no layers to clear. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31167>
This commit is contained in:
@@ -608,6 +608,7 @@ blorp_clear(struct blorp_batch *batch,
|
||||
if (!compute && !blorp_ensure_sf_program(batch, ¶ms))
|
||||
return;
|
||||
|
||||
assert(num_layers > 0);
|
||||
while (num_layers > 0) {
|
||||
blorp_surface_info_init(batch, ¶ms.dst, surf, level,
|
||||
start_layer, format, true);
|
||||
@@ -834,6 +835,7 @@ blorp_clear_depth_stencil(struct blorp_batch *batch,
|
||||
uint8_t stencil_mask, uint8_t stencil_value)
|
||||
{
|
||||
assert((batch->flags & BLORP_BATCH_USE_COMPUTE) == 0);
|
||||
assert(num_layers > 0);
|
||||
|
||||
if (!clear_depth && blorp_clear_stencil_as_rgba(batch, stencil, level,
|
||||
start_layer, num_layers,
|
||||
|
||||
@@ -2310,6 +2310,7 @@ anv_image_clear_depth_stencil(struct anv_cmd_buffer *cmd_buffer,
|
||||
{
|
||||
assert(image->vk.aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT));
|
||||
assert(layer_count > 0);
|
||||
|
||||
struct blorp_batch batch;
|
||||
anv_blorp_batch_init(cmd_buffer, &batch, 0);
|
||||
|
||||
@@ -5309,7 +5309,7 @@ void genX(CmdBeginRendering)(
|
||||
iview->vk.base_array_layer + view, 1,
|
||||
render_area, clear_color);
|
||||
}
|
||||
} else {
|
||||
} else if (clear_rect.layerCount > 0) {
|
||||
anv_image_clear_color(cmd_buffer, iview->image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
aux_usage,
|
||||
|
||||
@@ -5227,7 +5227,7 @@ void genX(CmdBeginRendering)(
|
||||
iview->vk.base_array_layer + view, 1,
|
||||
render_area, clear_color);
|
||||
}
|
||||
} else {
|
||||
} else if (clear_layer_count > 0) {
|
||||
anv_image_clear_color(cmd_buffer, iview->image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
aux_usage,
|
||||
|
||||
Reference in New Issue
Block a user