diff --git a/.pick_status.json b/.pick_status.json index a7626759e41..76493ec6a51 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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" }, diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index 90deaca5762..5dda2b74814 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -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,