- GLsizei length;
- unsigned i;
-
- group->id = id;
-
- /* Get name */
- glGetPerfMonitorGroupStringAMD (id, 0, &length, NULL);
-
- group->name = xmalloc (length + 1);
-
- glGetPerfMonitorGroupStringAMD (id, length + 1, NULL, group->name);
-
- /* Get number of counters */
- group->num_counters = 0;
- group->max_active_counters = 0;
- glGetPerfMonitorCountersAMD (group->id,
- (int *) &group->num_counters,
- (int *) &group->max_active_counters,
- 0, NULL);
-
- /* Get counter numbers */
- group->counter_ids = xmalloc (group->num_counters * sizeof (GLuint));
-
- glGetPerfMonitorCountersAMD (group->id, NULL, NULL,
- group->num_counters,
- group->counter_ids);
-
- /* Get counter names */
- group->counter_names = xmalloc (group->num_counters * sizeof (char *));
- group->counter_types = xmalloc (group->num_counters * sizeof (GLuint));
-
- for (i = 0; i < group->num_counters; i++) {
- glGetPerfMonitorCounterInfoAMD (group->id,
- group->counter_ids[i],
- GL_COUNTER_TYPE_AMD,
- &group->counter_types[i]);
-
- glGetPerfMonitorCounterStringAMD (group->id,
- group->counter_ids[i],
- 0, &length, NULL);
-
- group->counter_names[i] = xmalloc (length + 1);
-
- glGetPerfMonitorCounterStringAMD (group->id,
- group->counter_ids[i],
- length + 1, NULL,
- group->counter_names[i]);
- }
-}
-
-static void
-metrics_group_info_fini (metrics_group_info_t *group)
-{
- unsigned i;
-
- for (i = 0; i < group->num_counters; i++)
- free (group->counter_names[i]);
-
- free (group->counter_types);
- free (group->counter_names);
- free (group->counter_ids);
-
- free (group->name);
-}
-
-/* A helper function, part of metrics_info_init below. */
-
-typedef enum {
- SHADER_ACTIVE,
- SHADER_STALL
-} shader_phase_t;
-
-static void
-_add_shader_stage (metrics_info_t *info, const char *name,
- GLuint group_index, GLuint counter_index,
- shader_phase_t phase)
-{
- shader_stage_info_t *stage;
- char *stage_name, *space;
- unsigned i;