lavapipe: Use vk_image_subresource_layer/level_count

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15535>
This commit is contained in:
Jason Ekstrand
2022-03-17 13:10:06 -05:00
committed by Marge Bot
parent 8c1bd1f9a2
commit 6646624fb9
2 changed files with 5 additions and 21 deletions
+5 -5
View 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,
@@ -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 */