i965: perf: factorize code for availability
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 25 Jul 2017 16:19:08 +0000 (17:19 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 3 Nov 2017 14:23:39 +0000 (14:23 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_oa.py

index 91f7ecb5731e867a34eb979acddc8e4913579099..8c35923462fda7e89b62895442e458a9d928abf0 100644 (file)
@@ -325,6 +325,21 @@ semantic_type_map = {
     "ratio": "event"
     }
 
+def output_availability(set, availability, counter_name):
+    expression = splice_rpn_expression(set, counter_name, availability)
+    lines = expression.split(' && ')
+    n_lines = len(lines)
+    if n_lines == 1:
+        c("if (" + lines[0] + ") {")
+    else:
+        c("if (" + lines[0] + " &&")
+        c_indent(4)
+        for i in range(1, (n_lines - 1)):
+            c(lines[i] + " &&")
+        c(lines[(n_lines - 1)] + ") {")
+        c_outdent(4)
+
+
 def output_counter_report(set, counter, current_offset):
     data_type = counter.get('data_type')
     data_type_uc = data_type.upper()
@@ -343,18 +358,7 @@ def output_counter_report(set, counter, current_offset):
 
     availability = counter.get('availability')
     if availability:
-        expression = splice_rpn_expression(set, counter, availability)
-        lines = expression.split(' && ')
-        n_lines = len(lines)
-        if n_lines == 1:
-            c("if (" + lines[0] + ") {")
-        else:
-            c("if (" + lines[0] + " &&")
-            c_indent(4)
-            for i in range(1, (n_lines - 1)):
-                c(lines[i] + " &&")
-            c(lines[(n_lines - 1)] + ") {")
-            c_outdent(4)
+        output_availability(set, availability, counter.get('name'))
         c_indent(3)
 
     c("counter = &query->counters[query->n_counters++];\n")