+
+ 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. */
+ timer = xmalloc (sizeof (timer_query_t));
+
+ timer->op = metrics->op;
+ timer->id = metrics->timer_begun_id;
+ timer->next = NULL;
+
+ if (metrics->timer_tail) {
+ metrics->timer_tail->next = timer;
+ metrics->timer_tail = timer;
+ } else {
+ metrics->timer_tail = timer;
+ metrics->timer_head = timer;
+ }
+
+ 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;
+
+ 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++;
+
+ /* Avoid being a resource hog and collect outstanding results
+ * once we have sent off a large number of
+ * queries. (Presumably, many of the outstanding queries are
+ * available by now.)
+ */
+ if (metrics->monitors_in_flight > MAX_MONITORS_IN_FLIGHT)
+ metrics_collect_available (metrics);