From 5fb9b85f6043f985de3397b724553a830f0393e4 Mon Sep 17 00:00:00 2001
From: Don Pellegrino <don@drexel.edu>
Date: Tue, 07 Jul 2009 20:26:59 +0000
Subject: Code to test the use of the AMD Performance Monitor OpenGL

Extensions.  This test failed as it seems that the non-free Linux
driver from AMD does not include an implementation of the extension
functions.
---
diff --git a/src/util/amd_performance_monitor/ati_counter_info.h b/src/util/amd_performance_monitor/ati_counter_info.h
new file mode 100644
index 0000000..36fdfdc
--- a/dev/null
+++ b/src/util/amd_performance_monitor/ati_counter_info.h
@@ -0,0 +1,13 @@
+#ifndef ATI_COUNTER_INFO_H
+#define ATI_COUNTER_INFO_H
+
+#include <GL/glut.h>
+
+typedef struct
+{
+  GLuint *counterList;
+  int numCounters;
+  int maxActiveCounters;
+} ATI_Counter_Info;
+
+#endif // ATI_COUNTER_INFO_H
diff --git a/src/util/amd_performance_monitor/ati_get_group_and_counter_list.c b/src/util/amd_performance_monitor/ati_get_group_and_counter_list.c
new file mode 100644
index 0000000..cb6419b
--- a/dev/null
+++ b/src/util/amd_performance_monitor/ati_get_group_and_counter_list.c
@@ -0,0 +1,36 @@
+#include "ati_get_group_and_counter_list.h"
+#include <stdlib.h>
+
+extern void glGetPerfMonitorGroupsAMD (int* numGroups, int groupsSize,
+				       void *groups);
+
+void
+ati_get_group_and_counter_list (GLuint ** groupsList, int *numGroups,
+				ATI_Counter_Info ** counterInfo)
+{
+  GLint n;
+  GLuint *groups;
+  ATI_Counter_Info *counters;
+
+  glGetPerfMonitorGroupsAMD (&n, 0, NULL);
+  groups = (GLuint *) malloc (n * sizeof (GLuint));
+  glGetPerfMonitorGroupsAMD (NULL, n, groups);
+  *numGroups = n;
+
+  *groupsList = groups;
+  counters = (ATI_Counter_Info *) malloc (sizeof (ATI_Counter_Info) * n);
+  for (int i = 0; i < n; i++)
+    {
+      glGetPerfMonitorCountersAMD (groups[i], &counters[i].numCounters,
+				   &counters[i].maxActiveCounters, 0, NULL);
+      counters[i].counterList = (GLuint *) malloc (counters[i].numCounters *
+						   sizeof (int));
+      glGetPerfMonitorCountersAMD (groups[i], NULL, NULL,
+				   counters[i].numCounters,
+				   counters[i].counterList);
+    }
+
+  *counterInfo = counters;
+
+  return;
+}
diff --git a/src/util/amd_performance_monitor/ati_get_group_and_counter_list.h b/src/util/amd_performance_monitor/ati_get_group_and_counter_list.h
new file mode 100644
index 0000000..e30096e
--- a/dev/null
+++ b/src/util/amd_performance_monitor/ati_get_group_and_counter_list.h
@@ -0,0 +1,13 @@
+#ifndef ATI_GET_GROUP_AND_COUNTER_LIST_H
+#define ATI_GET_GROUP_AND_COUNTER_LIST_H
+
+#include "ati_counter_info.h"
+
+/*
+ * Code from
+ * http://www.opengl.org/registry/specs/AMD/performance_monitor.txt
+ */
+void ati_get_group_and_counter_list (GLuint ** groupsList, int *numGroups,
+				     ATI_Counter_Info ** counterInfo);
+
+#endif // ATI_GET_GROUP_AND_COUNTER_LIST_H
--
cgit v0.8.3.1-22-g547a