Mesa (staging/22.0): zink: stop leaking shader image surfaces
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon May 16 19:33:38 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: d40d80e3872efb25e8187e10c16dce80842c2d4c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d40d80e3872efb25e8187e10c16dce80842c2d4c
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri May 13 11:28:37 2022 -0400
zink: stop leaking shader image surfaces
the code here was fine for checking the base resource unbinds and whatever,
but it never actually destroyed the surfaces/bufferviews created,
which meant they were always being leaked
cc: mesa-stable
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16508>
(cherry picked from commit 1526df283c3659d510066f58b152597ea15913a0)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_context.c | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index c68f3aa4b91..92b7d90bd73 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -476,7 +476,7 @@
"description": "zink: stop leaking shader image surfaces",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"because_sha": null
},
{
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 753024e53eb..e3264d1cc0b 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1377,19 +1377,10 @@ zink_set_shader_images(struct pipe_context *pctx,
struct zink_image_view *image_view = &ctx->image_views[p_stage][start_slot + i];
if (images && images[i].resource) {
struct zink_resource *res = zink_resource(images[i].resource);
- struct zink_resource *old_res = zink_resource(image_view->base.resource);
if (!zink_resource_object_init_storage(ctx, res)) {
debug_printf("couldn't create storage image!");
continue;
}
- if (res != old_res) {
- if (old_res) {
- unbind_shader_image_counts(ctx, old_res, p_stage == PIPE_SHADER_COMPUTE, image_view->base.access & PIPE_IMAGE_ACCESS_WRITE);
- if (!old_res->obj->is_buffer && !old_res->image_bind_count[p_stage == PIPE_SHADER_COMPUTE])
- check_for_layout_update(ctx, old_res, p_stage == PIPE_SHADER_COMPUTE);
- }
- update_res_bind_count(ctx, res, p_stage == PIPE_SHADER_COMPUTE, false);
- }
/* no refs */
VkAccessFlags access = 0;
if (images[i].access & PIPE_IMAGE_ACCESS_WRITE) {
@@ -1401,14 +1392,24 @@ zink_set_shader_images(struct pipe_context *pctx,
}
res->image_bind_count[p_stage == PIPE_SHADER_COMPUTE]++;
if (images[i].resource->target == PIPE_BUFFER) {
- image_view->buffer_view = create_image_bufferview(ctx, &images[i]);
- assert(image_view->buffer_view);
+ struct zink_buffer_view *bv = create_image_bufferview(ctx, &images[i]);
+ assert(bv);
+ if (image_view->buffer_view != bv) {
+ update_res_bind_count(ctx, res, p_stage == PIPE_SHADER_COMPUTE, false);
+ unbind_shader_image(ctx, p_stage, start_slot + i);
+ }
+ image_view->buffer_view = bv;
zink_batch_usage_set(&image_view->buffer_view->batch_uses, ctx->batch.state);
zink_resource_buffer_barrier(ctx, res, access,
zink_pipeline_flags_from_pipe_stage(p_stage));
} else {
- image_view->surface = create_image_surface(ctx, &images[i], p_stage == PIPE_SHADER_COMPUTE);
- assert(image_view->surface);
+ struct zink_surface *surface = create_image_surface(ctx, &images[i], p_stage == PIPE_SHADER_COMPUTE);
+ assert(surface);
+ if (image_view->surface != surface) {
+ update_res_bind_count(ctx, res, p_stage == PIPE_SHADER_COMPUTE, false);
+ unbind_shader_image(ctx, p_stage, start_slot + i);
+ }
+ image_view->surface = surface;
finalize_image_bind(ctx, res, p_stage == PIPE_SHADER_COMPUTE);
zink_batch_usage_set(&image_view->surface->batch_uses, ctx->batch.state);
}
More information about the mesa-commit
mailing list