diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 887eba84d52..864d13878aa 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -2481,6 +2481,47 @@ anv_image_aspect_get_planes(VkImageAspectFlags aspect_mask) return util_bitcount(aspect_mask); } +bool +anv_can_hiz_clear_ds_view(struct anv_device *device, + const struct anv_image_view *iview, + VkImageLayout layout, + VkImageAspectFlags clear_aspects, + float depth_clear_value, + VkRect2D render_area) +{ + /* 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->vk.aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) + return false; + + 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, + layout); + if (!blorp_can_hiz_clear_depth(device->info, + &iview->image->planes[0].primary_surface.isl, + clear_aux_usage, + iview->planes[0].isl.base_level, + iview->planes[0].isl.base_array_layer, + render_area.offset.x, + render_area.offset.y, + render_area.offset.x + + render_area.extent.width, + render_area.offset.y + + render_area.extent.height)) + return false; + + if (depth_clear_value != ANV_HZ_FC_VAL) + return false; + + /* If we got here, then we can fast clear */ + return true; +} + VkResult anv_CreateImageView(VkDevice _device, const VkImageViewCreateInfo *pCreateInfo, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 04db528e1b0..cd1cab742a6 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -4063,6 +4063,14 @@ anv_cmd_buffer_fill_area(struct anv_cmd_buffer *cmd_buffer, VkDeviceSize size, uint32_t data); +bool +anv_can_hiz_clear_ds_view(struct anv_device *device, + const struct anv_image_view *iview, + VkImageLayout layout, + VkImageAspectFlags clear_aspects, + float depth_clear_value, + VkRect2D render_area); + enum isl_aux_state ATTRIBUTE_PURE anv_layout_to_aux_state(const struct intel_device_info * const devinfo, const struct anv_image *image, diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 62db88302e1..fa9688448e8 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -414,47 +414,6 @@ anv_can_fast_clear_color_view(struct anv_device * device, return true; } -static bool -anv_can_hiz_clear_ds_view(struct anv_device *device, - const struct anv_image_view *iview, - VkImageLayout layout, - VkImageAspectFlags clear_aspects, - float depth_clear_value, - VkRect2D render_area) -{ - /* 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->vk.aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) - return false; - - 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, - layout); - if (!blorp_can_hiz_clear_depth(device->info, - &iview->image->planes[0].primary_surface.isl, - clear_aux_usage, - iview->planes[0].isl.base_level, - iview->planes[0].isl.base_array_layer, - render_area.offset.x, - render_area.offset.y, - render_area.offset.x + - render_area.extent.width, - render_area.offset.y + - render_area.extent.height)) - return false; - - if (depth_clear_value != ANV_HZ_FC_VAL) - return false; - - /* If we got here, then we can fast clear */ - return true; -} - #define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x)) #if GFX_VER == 12