mesa: don't leak performance monitors on context destroy
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 29 Nov 2013 10:52:27 +0000 (05:52 -0500)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 4 Dec 2013 14:20:36 +0000 (06:20 -0800)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
src/mesa/main/context.c
src/mesa/main/performance_monitor.c
src/mesa/main/performance_monitor.h

index 87a4a35451de3023d2880872cc99b5a42dc2f961..658499fa4e37441e762591578ad87422292f0ba0 100644 (file)
@@ -1194,6 +1194,7 @@ _mesa_free_context_data( struct gl_context *ctx )
    _mesa_free_sync_data(ctx);
    _mesa_free_varray_data(ctx);
    _mesa_free_transform_feedback(ctx);
+   _mesa_free_performance_monitors(ctx);
 
    _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
    _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
index 4981e6fb27c6213cee688c298a85b8a656610493..e62f7701217b1e8903a7c6d07e9e2939b73240b5 100644 (file)
@@ -93,6 +93,25 @@ fail:
    return NULL;
 }
 
+static void
+free_performance_monitor(GLuint key, void *data, void *user)
+{
+   struct gl_perf_monitor_object *m = data;
+   struct gl_context *ctx = user;
+
+   ralloc_free(m->ActiveGroups);
+   ralloc_free(m->ActiveCounters);
+   ctx->Driver.DeletePerfMonitor(ctx, m);
+}
+
+void
+_mesa_free_performance_monitors(struct gl_context *ctx)
+{
+   _mesa_HashDeleteAll(ctx->PerfMonitor.Monitors,
+                       free_performance_monitor, ctx);
+   _mesa_DeleteHashTable(ctx->PerfMonitor.Monitors);
+}
+
 static inline struct gl_perf_monitor_object *
 lookup_monitor(struct gl_context *ctx, GLuint id)
 {
index a852a4184c2e4a28d3a9078041c2bda677b9491e..76234e5c1bc670cdb079d41937e6088810129ff7 100644 (file)
@@ -35,6 +35,9 @@
 extern void
 _mesa_init_performance_monitors(struct gl_context *ctx);
 
+extern void
+_mesa_free_performance_monitors(struct gl_context *ctx);
+
 extern void GLAPIENTRY
 _mesa_GetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize,
                               GLuint *groups);