From 8ce831b4994e445482eeaeaea868def8a847f34c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Oct 2013 09:23:44 -0700 Subject: [PATCH] Add support for performance counters of types other than uint32_t 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 | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/metrics.c b/metrics.c index d9dd3a0..71fe82d 100644 --- 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; } } -- 2.43.0