X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=metrics.c;h=6e81fae4714753608b454f6968d6ef56c147cecb;hb=158a5862aeea9224fcd60c28b0bb19cb6b9f9381;hp=9b94eb650ce9a48ee2ad4b9590eef28d07852f7a;hpb=9e6a41d89661ce7e983bac1b747755380604e447;p=fips diff --git a/metrics.c b/metrics.c index 9b94eb6..6e81fae 100644 --- a/metrics.c +++ b/metrics.c @@ -331,7 +331,11 @@ metrics_info_fini (void) if (! info->initialized) return; + metrics_collect_available (); + if (ctx->timer_begun_id) { + glEndQuery (GL_TIME_ELAPSED); + glDeleteQueries (1, &ctx->timer_begun_id); ctx->timer_begun_id = 0; } @@ -339,6 +343,7 @@ metrics_info_fini (void) timer; timer = timer_next) { + glDeleteQueries (1, &timer->id); timer_next = timer->next; free (timer); } @@ -346,6 +351,8 @@ metrics_info_fini (void) ctx->timer_tail = NULL; if (ctx->monitor_begun_id) { + glEndPerfMonitorAMD (ctx->monitor_begun_id); + glDeletePerfMonitorsAMD (1, &ctx->monitor_begun_id); ctx->monitor_begun_id = 0; } @@ -353,6 +360,7 @@ metrics_info_fini (void) monitor; monitor = monitor_next) { + glDeletePerfMonitorsAMD (1, &monitor->id); monitor_next = monitor->next; free (monitor); } @@ -859,14 +867,52 @@ print_program_metrics (void) free (sorted); } -/* Called at program exit */ +/* Called at program exit. + * + * This is similar to metrics_info_fini, but only frees any used + * memory. Notably, it does not call any OpenGL functions, (since the + * OpenGL context no longer exists at program exit). + */ static void metrics_exit (void) { + context_t *ctx = ¤t_context; + metrics_info_t *info = &ctx->metrics_info; + unsigned i; + timer_query_t *timer, *timer_next; + monitor_t *monitor, *monitor_next; + if (verbose) printf ("fips: terminating\n"); - metrics_info_fini (); + if (! info->initialized) + return; + + for (timer = ctx->timer_head; + timer; + timer = timer_next) + { + timer_next = timer->next; + free (timer); + } + + for (monitor = ctx->monitor_head; + monitor; + monitor = monitor_next) + { + monitor_next = monitor->next; + free (monitor); + } + + for (i = 0; i < info->num_groups; i++) + metrics_group_info_fini (&info->groups[i]); + + free (info->groups); + + for (i = 0; i < info->num_shader_stages; i++) + free (info->stages[i].name); + + free (info->stages); } void