swr: dereference cbuf/zbuf/views on context destroy
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 18 Apr 2016 20:09:17 +0000 (15:09 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 18 Apr 2016 20:52:26 +0000 (15:52 -0500)
Fixes resource memory leaks.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/swr/swr_context.cpp

index 46c79a14b2f5c6107cf92fd06b9a0a24831893bc..5d311ddf32ed9ca2a10634c0f65778842e566bb5 100644 (file)
@@ -300,6 +300,21 @@ swr_destroy(struct pipe_context *pipe)
 
    /* 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 < Elements(ctx->sampler_views[0]); i++) {
+      pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL);
+   }
+
+   for (unsigned i = 0; i < Elements(ctx->sampler_views[0]); i++) {
+      pipe_sampler_view_reference(&ctx->sampler_views[PIPE_SHADER_VERTEX][i], NULL);
+   }
+
    if (ctx->swrContext)
       SwrDestroyContext(ctx->swrContext);