X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=metrics.c;h=eede09b3729886fcdff33780b416b832130e0c51;hb=40729d306204edbc29675e78b5641efe19566dd7;hp=9f66ded156bc997e8572fce88c258aa60f3f7313;hpb=3b579d69622d53b95c6259daf0ecb4f5d2b1798b;p=fips diff --git a/metrics.c b/metrics.c index 9f66ded..eede09b 100644 --- a/metrics.c +++ b/metrics.c @@ -303,7 +303,8 @@ metrics_info_init (void) void metrics_info_fini (void) { - metrics_info_t *info = ¤t_context.metrics_info; + 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; @@ -311,25 +312,25 @@ metrics_info_fini (void) if (! info->initialized) return; - for (timer = current_context.timer_head; + for (timer = ctx->timer_head; timer; timer = timer_next) { timer_next = timer->next; free (timer); } - current_context.timer_head = NULL; - current_context.timer_tail = NULL; + ctx->timer_head = NULL; + ctx->timer_tail = NULL; - for (monitor = current_context.monitor_head; + for (monitor = ctx->monitor_head; monitor; monitor = monitor_next) { monitor_next = monitor->next; free (monitor); } - current_context.monitor_head = NULL; - current_context.monitor_tail = NULL; + ctx->monitor_head = NULL; + ctx->monitor_tail = NULL; for (i = 0; i < info->num_groups; i++) metrics_group_info_fini (&info->groups[i]); @@ -661,7 +662,11 @@ print_per_stage_metrics (context_t *ctx, printf (" "); } - printf (" %cS:", per_stage->stage->name[0]); + + if (per_stage->stage) + printf (" %cS:", per_stage->stage->name[0]); + else + printf (" :"); printf ("\t%7.2f ms (%4.1f%%)", per_stage->time_ns / 1e6, @@ -773,15 +778,30 @@ print_program_metrics (void) per_stage = &sorted[i * num_shader_stages + j]; per_stage->metrics = op; - per_stage->stage = &info->stages[j]; - if (op_cycles) + + if (op_cycles) { + per_stage->stage = &info->stages[j]; per_stage->time_ns = op->time_ns * (stage_cycles / op_cycles); - else - per_stage->time_ns = 0.0; - if (stage_cycles) + } else { + /* If we don't have any per-stage cycle counts + * for this operation, then use the first + * stage as a placeholder for all the time, + * but NULL-ify the stage info so that the + * report doesn't lie about this time being + * from any particular stage. */ + per_stage->stage = NULL; + if (j == 0) { + per_stage->time_ns = op->time_ns; + } else { + per_stage->time_ns = 0.0; + } + } + + if (stage_cycles) { per_stage->active = active_cycles / stage_cycles; - else + } else { per_stage->active = 0.0; + } } } @@ -808,6 +828,7 @@ metrics_exit (void) void metrics_end_frame (void) { + context_t *ctx = ¤t_context; static int initialized = 0; static struct timeval tv_start, tv_now; @@ -823,7 +844,7 @@ metrics_end_frame (void) gettimeofday (&tv_now, NULL); /* Consume all timer queries that are ready. */ - timer_query_t *timer = current_context.timer_head; + timer_query_t *timer = ctx->timer_head; while (timer) { GLuint available, elapsed; @@ -838,18 +859,18 @@ metrics_end_frame (void) accumulate_program_time (timer->op, elapsed); - current_context.timer_head = timer->next; - if (current_context.timer_head == NULL) - current_context.timer_tail = NULL; + ctx->timer_head = timer->next; + if (ctx->timer_head == NULL) + ctx->timer_tail = NULL; glDeleteQueries (1, &timer->id); free (timer); - timer = current_context.timer_head; + timer = ctx->timer_head; } /* And similarly for all performance monitors that are ready. */ - monitor_t *monitor = current_context.monitor_head; + monitor_t *monitor = ctx->monitor_head; while (monitor) { GLuint available, result_size, *result; @@ -878,17 +899,17 @@ metrics_end_frame (void) free (result); - current_context.monitor_head = monitor->next; - if (current_context.monitor_head == NULL) - current_context.monitor_tail = NULL; + ctx->monitor_head = monitor->next; + if (ctx->monitor_head == NULL) + ctx->monitor_tail = NULL; glDeletePerfMonitorsAMD (1, &monitor->id); free (monitor); - monitor = current_context.monitor_head; + monitor = ctx->monitor_head; } - if (frames % 60 == 0) { + if (frames % 15 == 0) { double fps; fps = (double) frames / (tv_now.tv_sec - tv_start.tv_sec +