aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intel/perf/gen_perf.h21
-rw-r--r--src/intel/perf/gen_perf.py3
-rw-r--r--src/mesa/drivers/dri/i965/brw_performance_query.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c4
4 files changed, 26 insertions, 9 deletions
diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h
index 24fbd15cac1..6e7a6d36c15 100644
--- a/src/intel/perf/gen_perf.h
+++ b/src/intel/perf/gen_perf.h
@@ -106,7 +106,6 @@ struct gen_perf_query_counter {
enum gen_perf_counter_data_type data_type;
uint64_t raw_max;
size_t offset;
- size_t size;
union {
uint64_t (*oa_counter_read_uint64)(struct gen_perf *perf,
@@ -193,6 +192,25 @@ struct gen_perf {
int (*ioctl)(int, unsigned long, void *);
};
+static inline size_t
+gen_perf_query_counter_get_size(const struct gen_perf_query_counter *counter)
+{
+ switch (counter->data_type) {
+ case GEN_PERF_COUNTER_DATA_TYPE_BOOL32:
+ return sizeof(uint32_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_UINT32:
+ return sizeof(uint32_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_UINT64:
+ return sizeof(uint64_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_FLOAT:
+ return sizeof(float);
+ case GEN_PERF_COUNTER_DATA_TYPE_DOUBLE:
+ return sizeof(double);
+ default:
+ unreachable("invalid counter data type");
+ }
+}
+
static inline struct gen_perf_query_info *
gen_perf_query_append_query_info(struct gen_perf *perf, int max_counters)
{
@@ -230,7 +248,6 @@ gen_perf_query_info_add_stat_reg(struct gen_perf_query_info *query,
counter->desc = description;
counter->type = GEN_PERF_COUNTER_TYPE_RAW;
counter->data_type = GEN_PERF_COUNTER_DATA_TYPE_UINT64;
- counter->size = sizeof(uint64_t);
counter->offset = sizeof(uint64_t) * query->n_counters;
counter->pipeline_stat.reg = reg;
counter->pipeline_stat.numerator = numerator;
diff --git a/src/intel/perf/gen_perf.py b/src/intel/perf/gen_perf.py
index c41e8f3eb11..f7d0b86b2cf 100644
--- a/src/intel/perf/gen_perf.py
+++ b/src/intel/perf/gen_perf.py
@@ -381,7 +381,6 @@ def output_counter_report(set, counter, current_offset):
current_offset = pot_align(current_offset, sizeof(c_type))
c("counter->offset = " + str(current_offset) + ";\n")
- c("counter->size = sizeof(" + c_type + ");\n")
if availability:
c_outdent(3);
@@ -722,7 +721,7 @@ def main():
offset = output_counter_report(set, counter, offset)
- c("\nquery->data_size = counter->offset + counter->size;\n")
+ c("\nquery->data_size = counter->offset + gen_perf_query_counter_get_size(counter);\n")
c_outdent(3)
c("}");
diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c b/src/mesa/drivers/dri/i965/brw_performance_query.c
index 831ad97a675..cd7961905bd 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_query.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_query.c
@@ -447,7 +447,7 @@ brw_get_perf_counter_info(struct gl_context *ctx,
*name = counter->name;
*desc = counter->desc;
*offset = counter->offset;
- *data_size = counter->size;
+ *data_size = gen_perf_query_counter_get_size(counter);
*type_enum = gen_counter_type_enum_to_gl_type(counter->type);
*data_type_enum = gen_counter_data_type_to_gl_type(counter->data_type);
*raw_max = counter->raw_max;
@@ -1392,8 +1392,9 @@ get_oa_counter_data(struct brw_context *brw,
const struct gen_perf_query_counter *counter = &query->counters[i];
uint64_t *out_uint64;
float *out_float;
+ size_t counter_size = gen_perf_query_counter_get_size(counter);
- if (counter->size) {
+ if (counter_size) {
switch (counter->data_type) {
case GEN_PERF_COUNTER_DATA_TYPE_UINT64:
out_uint64 = (uint64_t *)(data + counter->offset);
@@ -1411,7 +1412,7 @@ get_oa_counter_data(struct brw_context *brw,
/* So far we aren't using uint32, double or bool32... */
unreachable("unexpected counter data type");
}
- written = counter->offset + counter->size;
+ written = counter->offset + counter_size;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c b/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c
index f77560390d7..379515d328f 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c
@@ -43,10 +43,10 @@ fill_mdapi_perf_query_counter(struct gen_perf_query_info *query,
counter->type = GEN_PERF_COUNTER_TYPE_RAW;
counter->data_type = data_type;
counter->offset = data_offset;
- counter->size = data_size;
- assert(counter->offset + counter->size <= query->data_size);
query->n_counters++;
+
+ assert(counter->offset + gen_perf_query_counter_get_size(counter) <= query->data_size);
}
#define MDAPI_QUERY_ADD_COUNTER(query, struct_name, field_name, type_name) \