Module: Mesa Branch: main Commit: 6646624fb9c3808baee2f23bb2907b89616e78a0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6646624fb9c3808baee2f23bb2907b89616e78a0
Author: Jason Ekstrand <[email protected]> Date: Thu Mar 17 13:10:06 2022 -0500 lavapipe: Use vk_image_subresource_layer/level_count Reviewed-By: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15535> --- src/gallium/frontends/lavapipe/lvp_execute.c | 10 +++++----- src/gallium/frontends/lavapipe/lvp_private.h | 16 ---------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index 339e6cefa49..8ac58706814 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -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, diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h index 24202981342..ba0e4a6a844 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -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 */
