]> git.cworth.org Git - fips/blobdiff - metrics.c
Print reports every 15 frames rather than every 60
[fips] / metrics.c
index c24ae3f27d298cfb7c5a692ef855ebd168534c78..eede09b3729886fcdff33780b416b832130e0c51 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -303,7 +303,8 @@ metrics_info_init (void)
 void
 metrics_info_fini (void)
 {
-       metrics_info_t *info = &current_context.metrics_info;
+       context_t *ctx = &current_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]);
@@ -532,6 +533,7 @@ accumulate_program_metrics (metrics_op_t op, GLuint *result, GLuint size)
 
        context_t *ctx = &current_context;
        metrics_info_t *info = &ctx->metrics_info;
+       op_metrics_t *metrics = ctx_get_op_metrics (ctx, op);
        unsigned char *p = (unsigned char *) result;
 
        while (p < ((unsigned char *) result) + size)
@@ -585,7 +587,7 @@ accumulate_program_metrics (metrics_op_t op, GLuint *result, GLuint size)
                        break;
                }
 
-               ctx->op_metrics[op].counters[group_index][counter_index] += value;
+               metrics->counters[group_index][counter_index] += value;
        }
 }
 
@@ -660,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,
@@ -772,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;
+                       }
                }
        }
 
@@ -807,6 +828,7 @@ metrics_exit (void)
 void
 metrics_end_frame (void)
 {
+       context_t *ctx = &current_context;
        static int initialized = 0;
        static struct timeval tv_start, tv_now;
 
@@ -822,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;
@@ -837,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;
@@ -877,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 +