lavapipe: Use vk_image_subresource_layer/level_count
authorJason Ekstrand <jason.ekstrand@collabora.com>
Thu, 17 Mar 2022 18:10:06 +0000 (13:10 -0500)
committerMarge Bot <emma+marge@anholt.net>
Thu, 24 Mar 2022 21:21:10 +0000 (21:21 +0000)
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15535>

src/gallium/frontends/lavapipe/lvp_execute.c
src/gallium/frontends/lavapipe/lvp_private.h

index 339e6ce..8ac5870 100644 (file)
@@ -3193,7 +3193,7 @@ static void handle_clear_color_image(struct vk_cmd_queue_entry *cmd,
       box.y = 0;
       box.z = 0;
 
-      uint32_t level_count = lvp_get_levelCount(image, range);
+      uint32_t level_count = vk_image_subresource_level_count(&image->vk, range);
       for (unsigned j = range->baseMipLevel; j < range->baseMipLevel + level_count; j++) {
          box.width = u_minify(image->bo->width0, j);
          box.height = u_minify(image->bo->height0, j);
@@ -3202,11 +3202,11 @@ static void handle_clear_color_image(struct vk_cmd_queue_entry *cmd,
             box.depth = u_minify(image->bo->depth0, j);
          else if (image->bo->target == PIPE_TEXTURE_1D_ARRAY) {
             box.y = range->baseArrayLayer;
-            box.height = lvp_get_layerCount(image, range);
+            box.height = vk_image_subresource_layer_count(&image->vk, range);
             box.depth = 1;
          } else {
             box.z = range->baseArrayLayer;
-            box.depth = lvp_get_layerCount(image, range);
+            box.depth = vk_image_subresource_layer_count(&image->vk, range);
          }
 
          state->pctx->clear_texture(state->pctx, image->bo,
@@ -3227,7 +3227,7 @@ static void handle_clear_ds_image(struct vk_cmd_queue_entry *cmd,
       if (range->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
          ds_clear_flags |= PIPE_CLEAR_STENCIL;
 
-      uint32_t level_count = lvp_get_levelCount(image, range);
+      uint32_t level_count = vk_image_subresource_level_count(&image->vk, range);
       for (unsigned j = 0; j < level_count; j++) {
          struct pipe_surface *surf;
          unsigned width, height;
@@ -3238,7 +3238,7 @@ static void handle_clear_ds_image(struct vk_cmd_queue_entry *cmd,
          surf = create_img_surface_bo(state, range,
                                       image->bo, image->bo->format,
                                       width, height,
-                                      0, lvp_get_layerCount(image, range) - 1, j);
+                                      0, vk_image_subresource_layer_count(&image->vk, range) - 1, j);
 
          state->pctx->clear_depth_stencil(state->pctx,
                                           surf,
index 2420298..ba0e4a6 100644 (file)
@@ -240,22 +240,6 @@ struct lvp_image {
    struct pipe_resource *bo;
 };
 
-static inline uint32_t
-lvp_get_layerCount(const struct lvp_image *image,
-                   const VkImageSubresourceRange *range)
-{
-   return range->layerCount == VK_REMAINING_ARRAY_LAYERS ?
-      image->bo->array_size - range->baseArrayLayer : range->layerCount;
-}
-
-static inline uint32_t
-lvp_get_levelCount(const struct lvp_image *image,
-                   const VkImageSubresourceRange *range)
-{
-   return range->levelCount == VK_REMAINING_MIP_LEVELS ?
-      (image->bo->last_level + 1) - range->baseMipLevel : range->levelCount;
-}
-
 struct lvp_image_view {
    struct vk_image_view vk;
    const struct lvp_image *image; /**< VkImageViewCreateInfo::image */