metrics->timer_head = NULL;
metrics->timer_tail = NULL;
- if (metrics->monitor_begun_id) {
- glEndPerfMonitorAMD (metrics->monitor_begun_id);
- glDeletePerfMonitorsAMD (1, &metrics->monitor_begun_id);
- metrics->monitor_begun_id = 0;
- }
+ if (metrics->info->have_perfmon) {
+
+ if (metrics->monitor_begun_id) {
+ glEndPerfMonitorAMD (metrics->monitor_begun_id);
+ glDeletePerfMonitorsAMD (1, &metrics->monitor_begun_id);
+ metrics->monitor_begun_id = 0;
+ }
+
+ for (monitor = metrics->monitor_head;
+ monitor;
+ monitor = monitor_next)
+ {
+ glDeletePerfMonitorsAMD (1, &monitor->id);
+ monitor_next = monitor->next;
+ free (monitor);
+ }
+ metrics->monitor_head = NULL;
+ metrics->monitor_tail = NULL;
- for (monitor = metrics->monitor_head;
- monitor;
- monitor = monitor_next)
- {
- glDeletePerfMonitorsAMD (1, &monitor->id);
- monitor_next = monitor->next;
- free (monitor);
}
- metrics->monitor_head = NULL;
- metrics->monitor_tail = NULL;
metrics->monitors_in_flight = 0;
}
{
unsigned i;
- /* Initialize the timer_query and monitor objects */
+ /* Initialize the timer_query object. */
glGenQueries (1, &metrics->timer_begun_id);
+ /* Most everything else in this function is
+ * performance-monitor related. If we don't have that
+ * extension, just start the timer query and be done. */
+ if (! metrics->info->have_perfmon) {
+ glBeginQuery (GL_TIME_ELAPSED, metrics->timer_begun_id);
+ return;
+ }
+
+ /* Initialize the performance-monitor object */
glGenPerfMonitorsAMD (1, &metrics->monitor_begun_id);
for (i = 0; i < metrics->info->num_groups; i++)
/* Stop the current timer and monitor. */
glEndQuery (GL_TIME_ELAPSED);
- glEndPerfMonitorAMD (metrics->monitor_begun_id);
+
+ if (metrics->info->have_perfmon)
+ glEndPerfMonitorAMD (metrics->monitor_begun_id);
/* Add these IDs to our lists of outstanding queries and
* monitors so the results can be collected later. */
metrics->timer_head = timer;
}
- /* Create a new performance-monitor query */
- monitor = xmalloc (sizeof (monitor_t));
+ if (metrics->info->have_perfmon) {
+ /* Create a new performance-monitor query */
+ monitor = xmalloc (sizeof (monitor_t));
- monitor->op = metrics->op;
- monitor->id = metrics->monitor_begun_id;
- monitor->next = NULL;
+ monitor->op = metrics->op;
+ monitor->id = metrics->monitor_begun_id;
+ monitor->next = NULL;
- if (metrics->monitor_tail) {
- metrics->monitor_tail->next = monitor;
- metrics->monitor_tail = monitor;
- } else {
- metrics->monitor_tail = monitor;
- metrics->monitor_head = monitor;
+ if (metrics->monitor_tail) {
+ metrics->monitor_tail->next = monitor;
+ metrics->monitor_tail = monitor;
+ } else {
+ metrics->monitor_tail = monitor;
+ metrics->monitor_head = monitor;
+ }
}
metrics->monitors_in_flight++;
/* Make a sorted list of the per-stage operations by time
* used, and figure out the total so we can print percentages.
*/
- num_sorted = metrics->num_op_metrics * num_shader_stages;
+ if (num_shader_stages)
+ num_sorted = metrics->num_op_metrics * num_shader_stages;
+ else
+ num_sorted = metrics->num_op_metrics;
sorted = xmalloc (sizeof (*sorted) * num_sorted);
/* Also, find total cycles in all stages of this op. */
op_cycles = 0.0;
+ if (num_shader_stages == 0) {
+ per_stage = &sorted[i];
+ per_stage->metrics = op;
+ per_stage->stage = NULL;
+ per_stage->time_ns = op->time_ns;
+ per_stage->active = 0.0;
+ }
+
for (j = 0; j < num_shader_stages; j++) {
/* Active cycles */
group_index = info->stages[j].active_group_index;
timer = metrics->timer_head;
}
+ if (! metrics->info->have_perfmon)
+ return;
+
/* And similarly for all performance monitors that are ready. */
monitor_t *monitor = metrics->monitor_head;