static void swr_destroy(struct pipe_context *pipe) { struct swr_context *ctx = swr_context(pipe); struct swr_screen *screen = swr_screen(pipe->screen); if (ctx->blitter) util_blitter_destroy(ctx->blitter); for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { if (ctx->framebuffer.cbufs[i]) { struct swr_resource *res = swr_resource(ctx->framebuffer.cbufs[i]->texture); /* NULL curr_pipe, so we don't have a reference to a deleted pipe */ res->curr_pipe = NULL; pipe_surface_reference(&ctx->framebuffer.cbufs[i], NULL); } } if (ctx->framebuffer.zsbuf) { struct swr_resource *res = swr_resource(ctx->framebuffer.zsbuf->texture); /* NULL curr_pipe, so we don't have a reference to a deleted pipe */ res->curr_pipe = NULL; pipe_surface_reference(&ctx->framebuffer.zsbuf, NULL); } for (unsigned i = 0; i < ARRAY_SIZE(ctx->sampler_views[0]); i++) { pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL); } for (unsigned i = 0; i < ARRAY_SIZE(ctx->sampler_views[0]); i++) { pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_VERTEX][i], NULL); } if (ctx->pipe.stream_uploader) u_upload_destroy(ctx->pipe.stream_uploader); /* Idle core after destroying buffer resources, but before deleting * context. Destroying resources has potentially called StoreTiles.*/ ctx->api.pfnSwrWaitForIdle(ctx->swrContext); if (ctx->swrContext) ctx->api.pfnSwrDestroyContext(ctx->swrContext); delete ctx->blendJIT; swr_destroy_scratch_buffers(ctx); /* Only update screen->pipe if current context is being destroyed */ assert(screen); if (screen->pipe == pipe) screen->pipe = NULL; AlignedFree(ctx); }
static void swr_destroy(struct pipe_context *pipe) { struct swr_context *ctx = swr_context(pipe); struct swr_screen *screen = swr_screen(pipe->screen); if (ctx->blitter) util_blitter_destroy(ctx->blitter); /* Idle core before deleting context */ SwrWaitForIdle(ctx->swrContext); for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { pipe_surface_reference(&ctx->framebuffer.cbufs[i], NULL); } pipe_surface_reference(&ctx->framebuffer.zsbuf, NULL); for (unsigned i = 0; i < ARRAY_SIZE(ctx->sampler_views[0]); i++) { pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL); } for (unsigned i = 0; i < ARRAY_SIZE(ctx->sampler_views[0]); i++) { pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_VERTEX][i], NULL); } if (ctx->swrContext) SwrDestroyContext(ctx->swrContext); delete ctx->blendJIT; swr_destroy_scratch_buffers(ctx); /* Only update screen->pipe if current context is being destroyed */ assert(screen); if (screen->pipe == pipe) screen->pipe = NULL; FREE(ctx); }