free (group->name);
}
-static void
-metrics_info_fini (metrics_info_t *info);
-
/* A helper function, part of metrics_info_init below. */
typedef enum {
GLuint *group_ids;
metrics_info_t *info = ¤t_context.metrics_info;
- if (info->initialized)
- metrics_info_fini (info);
-
glGetPerfMonitorGroupsAMD ((int *) &info->num_groups, 0, NULL);
group_ids = xmalloc (info->num_groups * sizeof (GLuint));
info->initialized = 1;
}
-static void
-metrics_info_fini (metrics_info_t *info)
+void
+metrics_info_fini (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 (! info->initialized)
+ return;
+
+ for (timer = ctx->timer_head;
+ timer;
+ timer = timer_next)
+ {
+ timer_next = timer->next;
+ free (timer);
+ }
+ ctx->timer_head = NULL;
+ ctx->timer_tail = NULL;
+
+ for (monitor = ctx->monitor_head;
+ monitor;
+ monitor = monitor_next)
+ {
+ monitor_next = monitor->next;
+ free (monitor);
+ }
+ ctx->monitor_head = NULL;
+ ctx->monitor_tail = NULL;
for (i = 0; i < info->num_groups; i++)
metrics_group_info_fini (&info->groups[i]);
free (info->groups);
+ info->groups = NULL;
for (i = 0; i < info->num_shader_stages; i++)
free (info->stages[i].name);
free (info->stages);
+ info->stages = NULL;
+
+ info->initialized = 0;
}
static const char *
context_t *ctx = ¤t_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)
break;
}
- ctx->op_metrics[op].counters[group_index][counter_index] += value;
+ metrics->counters[group_index][counter_index] += value;
}
}
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,
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;
+ }
}
}
if (verbose)
printf ("fips: terminating\n");
- metrics_info_fini (¤t_context.metrics_info);
+ metrics_info_fini ();
}
void
metrics_end_frame (void)
{
+ context_t *ctx = ¤t_context;
static int initialized = 0;
static struct timeval tv_start, tv_now;
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;
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;
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 +