]> git.cworth.org Git - fips/commitdiff
Add support for performance counters of types other than uint32_t
authorCarl Worth <cworth@cworth.org>
Wed, 23 Oct 2013 16:23:44 +0000 (09:23 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 23 Oct 2013 23:17:48 +0000 (16:17 -0700)
The AMD_performance_monitor extension also allows counters of type
uin64_t, float, and percentage (which is the same data-type as float).

Fips was already storing the expected type in the group's
counter_types array, so it's a simple matter to look at that and read
a value of the expected type.

metrics.c

index d9dd3a0b3faef6ff600f6a6a487c9f639def47ec..71fe82da1b3d5ff06cf6dd94aa541f14f0b38a33 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -163,15 +163,6 @@ metrics_group_info_init (metrics_group_info_t *group, GLuint id)
                                                GL_COUNTER_TYPE_AMD,
                                                &group->counter_types[i]);
 
-               /* We assume that all peformance counters are made
-                * available as uint32 values. The code calling
-                * CONSUME in accumulate_program_metrics will need to
-                * be extended to accomodate other counter values. */
-               if (group->counter_types[i] != GL_UNSIGNED_INT) {
-                       fprintf (stderr, "fips: Internal error: No support for non-uint counter values\n");
-                       exit (1);
-               }
-
                glGetPerfMonitorCounterStringAMD (group->id,
                                                  group->counter_ids[i],
                                                  0, &length, NULL);
@@ -524,12 +515,11 @@ accumulate_program_metrics (metrics_op_t op, GLuint *result, GLuint size)
                GLuint group_id, group_index;
                GLuint counter_id, counter_index;
                metrics_group_info_t *group;
-               uint32_t value;
+               double value;
                unsigned i;
 
                CONSUME (group_id);
                CONSUME (counter_id);
-               CONSUME (value);
 
                for (i = 0; i < info->num_groups; i++) {
                        if (info->groups[i].id == group_id)
@@ -546,6 +536,31 @@ accumulate_program_metrics (metrics_op_t op, GLuint *result, GLuint size)
                counter_index = i;
                assert (counter_index < group->num_counters);
 
+               switch (group->counter_types[counter_index])
+               {
+                       uint uint_value;
+                       uint64_t uint64_value;
+                       float float_value;
+               case GL_UNSIGNED_INT:
+                       CONSUME (uint_value);
+                       value = uint_value;
+                       break;
+               case GL_UNSIGNED_INT64_AMD:
+                       CONSUME (uint64_value);
+                       value = uint64_value;
+                       break;
+               case GL_PERCENTAGE_AMD:
+               case GL_FLOAT:
+                       CONSUME (float_value);
+                       value = float_value;
+                       break;
+               default:
+                       fprintf (stderr, "fips: Warning: Unknown counter value type (%d)\n",
+                                group->counter_types[counter_index]);
+                       value = 0.0;
+                       break;
+               }
+
                ctx->op_metrics[op].counters[group_index][counter_index] += value;
        }
 }