iris: plug leaks
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 16 Jun 2018 16:56:59 +0000 (09:56 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_batch.c
src/gallium/drivers/iris/iris_context.c
src/gallium/drivers/iris/iris_program_cache.c
src/gallium/drivers/iris/iris_resource.c
src/gallium/drivers/iris/iris_state.c

index 038a952442e0591ab5b03ac2534de1e7dbce5ea0..d552579782fb5d10511283b2be4c91f6ee7300e1 100644 (file)
@@ -252,6 +252,8 @@ iris_batch_free(struct iris_batch *batch)
    _mesa_hash_table_destroy(batch->cache.render, NULL);
    _mesa_set_destroy(batch->cache.depth, NULL);
 
+   iris_destroy_binder(&batch->binder);
+
    if (batch->state_sizes) {
       _mesa_hash_table_destroy(batch->state_sizes, NULL);
       gen_batch_decode_ctx_finish(&batch->decoder);
index 09eb288bbbcc6ed47ba04f29410709a8e8904e60..4812d7c3af8b6c26a756e6f2af6a91f24f22dbc9 100644 (file)
@@ -79,6 +79,7 @@ iris_destroy_context(struct pipe_context *ctx)
    if (ctx->stream_uploader)
       u_upload_destroy(ctx->stream_uploader);
 
+   ice->vtbl.destroy_state(ice);
    iris_destroy_program_cache(ice);
    u_upload_destroy(ice->state.surface_uploader);
    u_upload_destroy(ice->state.dynamic_uploader);
index 5a09c7f55297af970c00886d353fe2448b8145b7..d80de6e6c4bb6c050408b2e7b6a262e1e55ec899 100644 (file)
@@ -341,6 +341,11 @@ iris_destroy_program_cache(struct iris_context *ice)
       ice->shaders.prog[i] = NULL;
    }
 
+   hash_table_foreach(ice->shaders.cache, entry) {
+      struct iris_compiled_shader *shader = entry->data;
+      pipe_resource_reference(&shader->buffer, NULL);
+   }
+
    u_upload_destroy(ice->shaders.uploader);
 
    ralloc_free(ice->shaders.cache);
index aeed6ce594379372770cd69c1ed35eb6e853af88..5eccd66de59be30c5867e4922b0812f56376ed0d 100644 (file)
@@ -159,6 +159,7 @@ iris_resource_destroy(struct pipe_screen *screen,
    struct iris_resource *res = (struct iris_resource *)resource;
 
    iris_bo_unreference(res->bo);
+   free(res);
 }
 
 static struct iris_resource *
index add3428abd4ff90e2822ada8ed736b254987dabc..f24e59d5a60d70bc62f47acb20dfdb0e843b2315 100644 (file)
@@ -1260,6 +1260,7 @@ iris_set_viewport_states(struct pipe_context *ctx,
       vp_map += GENX(SF_CLIP_VIEWPORT_length);
    }
 
+   free(ice->state.cso_vp);
    ice->state.cso_vp = cso;
    ice->state.num_viewports = num_viewports;
    ice->state.dirty |= IRIS_DIRTY_SF_CL_VIEWPORT;
@@ -1456,8 +1457,6 @@ iris_set_vertex_buffers(struct pipe_context *ctx,
                         const struct pipe_vertex_buffer *buffers)
 {
    struct iris_context *ice = (struct iris_context *) ctx;
-   struct iris_vertex_buffer_state *cso =
-      malloc(sizeof(struct iris_vertex_buffer_state));
 
    /* If there are no buffers, do nothing.  We can leave the stale
     * 3DSTATE_VERTEX_BUFFERS in place - as long as there are no vertex
@@ -1466,6 +1465,9 @@ iris_set_vertex_buffers(struct pipe_context *ctx,
    if (!buffers)
       return;
 
+   struct iris_vertex_buffer_state *cso =
+      malloc(sizeof(struct iris_vertex_buffer_state));
+
    iris_free_vertex_buffers(ice->state.cso_vertex_buffers);
 
    cso->num_buffers = count;
@@ -2746,14 +2748,27 @@ iris_upload_render_state(struct iris_context *ice,
    }
 }
 
+/**
+ * State module teardown.
+ */
 static void
 iris_destroy_state(struct iris_context *ice)
 {
+   iris_free_vertex_buffers(ice->state.cso_vertex_buffers);
+
    // XXX: unreference resources/surfaces.
    for (unsigned i = 0; i < ice->state.framebuffer.nr_cbufs; i++) {
       pipe_surface_reference(&ice->state.framebuffer.cbufs[i], NULL);
    }
    pipe_surface_reference(&ice->state.framebuffer.zsbuf, NULL);
+
+   free(ice->state.cso_depthbuffer);
+
+   pipe_resource_reference(&ice->state.last_res.cc_vp, NULL);
+   pipe_resource_reference(&ice->state.last_res.sf_cl_vp, NULL);
+   pipe_resource_reference(&ice->state.last_res.color_calc, NULL);
+   pipe_resource_reference(&ice->state.last_res.scissor, NULL);
+   pipe_resource_reference(&ice->state.last_res.blend, NULL);
 }
 
 static unsigned