X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=metrics.c;h=ad73fe6e26202ae2d1785548fbe8ea1fe730997d;hb=refs%2Fheads%2Freset-metrics;hp=9b94eb650ce9a48ee2ad4b9590eef28d07852f7a;hpb=9e6a41d89661ce7e983bac1b747755380604e447;p=fips diff --git a/metrics.c b/metrics.c index 9b94eb6..ad73fe6 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); } @@ -763,6 +771,38 @@ time_compare(const void *in_a, const void *in_b, void *arg unused) return 0; } +static void +op_metrics_reset (op_metrics_t *op) +{ + context_t *ctx = ¤t_context; + metrics_info_t *info = &ctx->metrics_info; + unsigned group_index, counter; + metrics_group_info_t *group; + + op->time_ns = 0.0; + + for (group_index = 0; group_index < info->num_groups; group_index++) { + group = &info->groups[group_index]; + for (counter = 0; counter < group->num_counters; counter++) + { + op->counters[group_index][counter] = 0.0; + } + } +} + +static void +reset_metrics (void) +{ + context_t *ctx = ¤t_context; + unsigned i; + + for (i = 0; i < ctx->num_op_metrics; i++) { + + op_metrics_reset (&ctx->op_metrics[i]); + + } +} + static void print_program_metrics (void) { @@ -859,14 +899,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 @@ -975,4 +1053,7 @@ metrics_end_frame (void) print_program_metrics (); } + + if (frames == 208) + reset_metrics (); }