summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorJesse Natalie <jenatali@microsoft.com>2021-03-31 14:12:50 -0700
committerMarge Bot <eric+marge@anholt.net>2021-04-01 16:19:41 +0000
commit1517fb25a43ca5246ed05dba4f900d864e391bc3 (patch)
treefc769d744eb322b56b128ab4459f1a49940dad95 /src/gallium
parentaa1643d141cf97ca004fcc952b7d689725a1afca (diff)
d3d12: Clean up swapchains on framebuffer destruction
Reviewed-By: Bill Kristiansen <billkris@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9959>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp b/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp
index ec4d6f05246..b96dc52517f 100644
--- a/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp
+++ b/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp
@@ -64,7 +64,26 @@ static void
d3d12_wgl_framebuffer_destroy(struct stw_winsys_framebuffer *fb,
pipe_context *ctx)
{
- FREE(fb);
+ struct d3d12_wgl_framebuffer *framebuffer = d3d12_wgl_framebuffer(fb);
+ struct pipe_fence_handle *fence = NULL;
+
+ if (ctx) {
+ /* Ensure all resources are flushed */
+ ctx->flush(ctx, &fence, PIPE_FLUSH_HINT_FINISH);
+ if (fence) {
+ ctx->screen->fence_finish(ctx->screen, ctx, fence, PIPE_TIMEOUT_INFINITE);
+ ctx->screen->fence_reference(ctx->screen, &fence, NULL);
+ }
+ }
+
+ for (int i = 0; i < num_buffers; ++i) {
+ if (framebuffer->buffers[i]) {
+ d3d12_resource_release(d3d12_resource(framebuffer->buffers[i]));
+ pipe_resource_reference(&framebuffer->buffers[i], NULL);
+ }
+ }
+
+ delete framebuffer;
}
static void
@@ -208,6 +227,8 @@ d3d12_wgl_create_framebuffer(struct pipe_screen *screen,
if (!fb)
return NULL;
+ new (fb) struct d3d12_wgl_framebuffer();
+
fb->window = WindowFromDC(hDC);
fb->screen = d3d12_screen(screen);
fb->base.destroy = d3d12_wgl_framebuffer_destroy;