lavapipe: take layers into account around render surface creation.

This makes the code more consistent with handling layers, but also
makes sure a new surface is created when the w/h/layers changes.

Fixes: 8a6160a354 ("lavapipe: VK_KHR_dynamic_rendering")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18811>
(cherry picked from commit 21d39dd1de)
This commit is contained in:
Dave Airlie
2022-09-26 09:13:37 +10:00
committed by Dylan Baker
parent 4295192f35
commit 8f9fc8e186
2 changed files with 18 additions and 8 deletions

View File

@@ -517,7 +517,7 @@
"description": "lavapipe: take layers into account around render surface creation.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "8a6160a35428264fa3b4722d8c72b9c8aa4b8256"
},

View File

@@ -1528,7 +1528,7 @@ static struct pipe_surface *create_img_surface_bo(struct rendering_state *state,
template.width = width;
template.height = height;
template.u.tex.first_layer = range->baseArrayLayer + base_layer;
template.u.tex.last_layer = range->baseArrayLayer + layer_count;
template.u.tex.last_layer = range->baseArrayLayer + base_layer + layer_count - 1;
template.u.tex.level = range->baseMipLevel + level;
if (template.format == PIPE_FORMAT_NONE)
@@ -1552,12 +1552,20 @@ static struct pipe_surface *create_img_surface(struct rendering_state *state,
}
static void add_img_view_surface(struct rendering_state *state,
struct lvp_image_view *imgv, int width, int height)
struct lvp_image_view *imgv, int width, int height,
int layer_count)
{
if (imgv->surface) {
if (imgv->surface->width != width ||
imgv->surface->height != height ||
(imgv->surface->u.tex.last_layer - imgv->surface->u.tex.first_layer) != (layer_count - 1))
pipe_surface_reference(&imgv->surface, NULL);
}
if (!imgv->surface) {
imgv->surface = create_img_surface(state, imgv, imgv->vk.format,
width, height,
0, imgv->vk.layer_count - 1);
0, layer_count);
}
}
@@ -1589,7 +1597,7 @@ static void clear_attachment_layers(struct rendering_state *state,
state->framebuffer.width,
state->framebuffer.height,
base_layer,
base_layer + layer_count - 1);
layer_count);
if (ds_clear_flags) {
state->pctx->clear_depth_stencil(state->pctx,
@@ -1978,7 +1986,8 @@ static void handle_begin_rendering(struct vk_cmd_queue_entry *cmd,
if (state->color_att[i].imgv) {
struct lvp_image_view *imgv = state->color_att[i].imgv;
add_img_view_surface(state, imgv,
state->framebuffer.width, state->framebuffer.height);
state->framebuffer.width, state->framebuffer.height,
state->framebuffer.layers);
if (state->forced_sample_count && imgv->image->vk.samples == 1)
state->color_att[i].imgv = create_multisample_surface(state, imgv, state->forced_sample_count,
att_needs_replicate(state, imgv, state->color_att[i].load_op));
@@ -1998,7 +2007,8 @@ static void handle_begin_rendering(struct vk_cmd_queue_entry *cmd,
state->stencil_att.imgv;
struct lvp_image_view *imgv = state->ds_imgv;
add_img_view_surface(state, imgv,
state->framebuffer.width, state->framebuffer.height);
state->framebuffer.width, state->framebuffer.height,
state->framebuffer.layers);
if (state->forced_sample_count && imgv->image->vk.samples == 1) {
VkAttachmentLoadOp load_op;
if (state->depth_att.load_op == VK_ATTACHMENT_LOAD_OP_CLEAR ||
@@ -3108,7 +3118,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, depth - 1, j);
0, depth, j);
state->pctx->clear_depth_stencil(state->pctx,
surf,