zink: explicitly unref old fb object when setting new one
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 27 Apr 2020 17:44:08 +0000 (13:44 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Apr 2020 21:55:51 +0000 (21:55 +0000)
this object has a ref from being created, and its lifetime is expected to
be a single frame, so remove that initial ref when we expect to stop
using it

Closes: #2648
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4768>

src/gallium/drivers/zink/zink_context.c

index 32a0a1f82e6e1f41b33a69e9b438bfa5a389c75d..4c2fe44da5396c8a007f8a182b86c51756687085 100644 (file)
@@ -638,7 +638,11 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
 
    util_copy_framebuffer_state(&ctx->fb_state, state);
 
-   struct zink_framebuffer *fb = create_framebuffer(ctx);
+   struct zink_framebuffer *fb = ctx->framebuffer;
+   /* explicitly unref previous fb to ensure it gets destroyed */
+   if (fb)
+      zink_framebuffer_reference(screen, &fb, NULL);
+   fb = create_framebuffer(ctx);
    zink_framebuffer_reference(screen, &ctx->framebuffer, fb);
    zink_render_pass_reference(screen, &ctx->gfx_pipeline_state.render_pass, fb->rp);