i965: perf: list registers to program for queries
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 25 Jul 2017 16:21:22 +0000 (17:21 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 3 Nov 2017 14:25:36 +0000 (14:25 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_oa.py

index 0960d635beb7de282c2ea88203ee2ee6e85794e3..766b5bc0731104fc6952193a25d945c64af21152 100644 (file)
@@ -615,6 +615,11 @@ enum brw_query_kind {
    PIPELINE_STATS
 };
 
+struct brw_perf_query_register_prog {
+   uint32_t reg;
+   uint32_t val;
+};
+
 struct brw_perf_query_info
 {
    enum brw_query_kind kind;
@@ -634,6 +639,16 @@ struct brw_perf_query_info
    int a_offset;
    int b_offset;
    int c_offset;
+
+   /* Register programming for a given query */
+   struct brw_perf_query_register_prog *flex_regs;
+   uint32_t n_flex_regs;
+
+   struct brw_perf_query_register_prog *mux_regs;
+   uint32_t n_mux_regs;
+
+   struct brw_perf_query_register_prog *b_counter_regs;
+   uint32_t n_b_counter_regs;
 };
 
 /**
index 8c35923462fda7e89b62895442e458a9d928abf0..576ea6687fc8cb30f3fa384c069252c15f9ab928 100644 (file)
@@ -380,6 +380,45 @@ def output_counter_report(set, counter, current_offset):
     return current_offset + sizeof(c_type)
 
 
+register_types = {
+    'FLEX': 'flex_regs',
+    'NOA': 'mux_regs',
+    'OA': 'b_counter_regs',
+}
+
+def compute_register_lengths(set):
+    register_lengths = {}
+    register_configs = set.findall('register_config')
+    for register_config in register_configs:
+        t = register_types[register_config.get('type')]
+        if t not in register_lengths:
+            register_lengths[t] = len(register_config.findall('register'))
+        else:
+            register_lengths[t] += len(register_config.findall('register'))
+
+    return register_lengths
+
+
+def generate_register_configs(set):
+    register_configs = set.findall('register_config')
+    for register_config in register_configs:
+        t = register_types[register_config.get('type')]
+
+        availability = register_config.get('availability')
+        if availability:
+            output_availability(set, availability, register_config.get('type') + ' register config')
+            c_indent(3)
+
+        for register in register_config.findall('register'):
+            c("query->%s[query->n_%s++] = (struct brw_perf_query_register_prog) { .reg = %s, .val = %s };" %
+              (t, t, register.get('address'), register.get('value')))
+
+        if availability:
+            c_outdent(3)
+            c("}")
+        c("\n")
+
+
 def main():
     global c_file
     global header_file
@@ -475,6 +514,12 @@ def main():
             max_values[counter.get('symbol_name')] = output_counter_max(set, counter, empty_vars)
             counter_vars["$" + counter.get('symbol_name')] = counter
 
+        c("\n")
+        register_lengths = compute_register_lengths(set);
+        for reg_type, reg_length in register_lengths.iteritems():
+            c("static struct brw_perf_query_register_prog {0}_{1}_{2}[{3}];".format(chipset,
+                                                                                    set.get('underscore_name'),
+                                                                                    reg_type, reg_length))
 
         c("\nstatic struct brw_perf_query_counter {0}_{1}_query_counters[{2}];\n".format(chipset, set.get('underscore_name'), len(counters)))
         c("static struct brw_perf_query_info " + chipset + "_" + set.get('underscore_name') + "_query = {\n")
@@ -510,6 +555,10 @@ def main():
                 .c_offset = 46,
                 """))
 
+        for reg_type, reg_length in register_lengths.iteritems():
+            c(".{0} = {1}_{2}_{3},".format(reg_type, chipset, set.get('underscore_name'), reg_type))
+            c(".n_{0} = 0, /* Determined at runtime */".format(reg_type))
+
         c_outdent(3)
         c("};\n")
 
@@ -528,6 +577,8 @@ def main():
         c("\nif (!query->data_size) {")
         c_indent(3)
 
+        generate_register_configs(set)
+
         offset = 0
         for counter in counters:
             offset = output_counter_report(set, counter, offset)