swr/rast: Add string handling to AR event framework
authorAlok Hota <alok.hota@intel.com>
Fri, 7 Sep 2018 20:17:53 +0000 (15:17 -0500)
committerAlok Hota <alok.hota@intel.com>
Wed, 1 May 2019 15:11:30 +0000 (15:11 +0000)
For use by an internal tool

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/archrast/events.proto
src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py
src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp
src/gallium/drivers/swr/rasterizer/common/simdlib_512_emu.inl

index fd80383..aedc37b 100644 (file)
@@ -129,7 +129,7 @@ event EarlyZSingleSample
     uint32_t drawId;
     uint64_t passCount;
     uint64_t failCount;
-};     
+};
 
 event LateZSingleSample
 {
@@ -157,7 +157,7 @@ event EarlyZSampleRate
     uint32_t drawId;
     uint64_t passCount;
     uint64_t failCount;
-};     
+};
 
 event LateZSampleRate
 {
@@ -186,7 +186,7 @@ event EarlyZ
     uint32_t drawId;
     uint64_t passCount;
     uint64_t failCount;
-};     
+};
 
 // Total LateZ counts, SingleSample and SampleRate
 event LateZ
@@ -445,5 +445,6 @@ event SWTagDispatchEvent
 event SWTagFlushEvent
 {
     uint32_t drawId;
-       uint32_t flushType;
+    char flushReason[256];
+    uint32_t flushType;
 };
\ No newline at end of file
index 87c68fc..6182504 100644 (file)
@@ -27,30 +27,29 @@ import re
 from gen_common import *
 
 def parse_event_fields(lines, idx, event_dict):
-    field_names = []
-    field_types = []
+    fields = []
     end_of_event = False
 
-    num_fields = 0
-
     # record all fields in event definition.
     # note: we don't check if there's a leading brace.
     while not end_of_event and idx < len(lines):
         line = lines[idx].rstrip()
         idx += 1
 
-        field = re.match(r'(\s*)(\w+)(\s*)(\w+)', line)
+        match = re.match(r'(\s*)([\w\*]+)(\s*)([\w]+)(\[\d+\])*', line)
 
-        if field:
-            field_types.append(field.group(2))
-            field_names.append(field.group(4))
-            num_fields += 1
+        if match:
+            field = {
+                "type": match.group(2),
+                "name": match.group(4),
+                "size": int(match.group(5)[1:-1]) if match.group(5) else 1
+            }
+            fields.append(field)
 
         end_of_event = re.match(r'(\s*)};', line)
 
-    event_dict['field_types'] = field_types
-    event_dict['field_names'] = field_names
-    event_dict['num_fields'] = num_fields
+    event_dict['fields'] = fields
+    event_dict['num_fields'] = len(fields)
 
     return idx
 
index 685365c..ac685ad 100644 (file)
@@ -165,7 +165,7 @@ def parse_ir_builder(input_file):
                         func_name == 'CreateGEP' or
                         func_name == 'CreateLoad' or
                         func_name == 'CreateMaskedLoad' or
-                                               func_name == 'CreateStore' or
+                        func_name == 'CreateStore' or
                         func_name == 'CreateMaskedStore' or
                         func_name == 'CreateElementUnorderedAtomicMemCpy'):
                         ignore = True
index fe3f261..884a321 100644 (file)
@@ -68,11 +68,14 @@ namespace ArchRast
 #pragma pack(push, 1)
     struct ${name}Data
     {<%
-        field_names = protos['events'][name]['field_names']
-        field_types = protos['events'][name]['field_types'] %>
+        fields = protos['events'][name]['fields'] %>
         // Fields
-        % for i in range(len(field_names)):
-        ${field_types[i]} ${field_names[i]};
+        % for i in range(len(fields)):
+            % if fields[i]['size'] > 1:
+        ${fields[i]['type']} ${fields[i]['name']}[${fields[i]['size']}];
+            % else:
+        ${fields[i]['type']} ${fields[i]['name']};
+            % endif
         % endfor
     };
 #pragma pack(pop)
@@ -82,24 +85,44 @@ namespace ArchRast
     //////////////////////////////////////////////////////////////////////////
     struct ${name} : Event
     {<%
-        field_names = protos['events'][name]['field_names']
-        field_types = protos['events'][name]['field_types'] %>
+        fields = protos['events'][name]['fields'] %>
         ${name}Data data;
 
         // Constructor
         ${name}(
-        % for i in range(len(field_names)):
-            % if i < len(field_names)-1:
-            ${field_types[i]} ${field_names[i]},
+        % for i in range(len(fields)):
+            % if i < len(fields)-1:
+                % if fields[i]['size'] > 1:
+            ${fields[i]['type']}* ${fields[i]['name']},
+            uint32_t ${fields[i]['name']}_size,
+                % else:
+            ${fields[i]['type']} ${fields[i]['name']},
+                % endif
             % endif
-            % if i == len(field_names)-1:
-            ${field_types[i]} ${field_names[i]}
+            % if i == len(fields)-1:
+                % if fields[i]['size'] > 1:
+            ${fields[i]['type']}* ${fields[i]['name']},
+            uint32_t ${fields[i]['name']}_size
+                % else:
+            ${fields[i]['type']} ${fields[i]['name']}
+                % endif
             % endif
         % endfor
         )
         {
-        % for i in range(len(field_names)):
-            data.${field_names[i]} = ${field_names[i]};
+        % for i in range(len(fields)):
+            % if fields[i]['size'] > 1:
+                % if fields[i]['type'] == 'char':
+            // Copy size of string (null-terminated) followed by string buffer info entire buffer
+            SWR_ASSERT(${fields[i]['name']}_size + 1 < ${fields[i]['size']} - sizeof(uint32_t), "String length must be less than size of char buffer - size(uint32_t)!");
+            memcpy(data.${fields[i]['name']}, &${fields[i]['name']}_size, sizeof(uint32_t));
+            strcpy_s(data.${fields[i]['name']} + sizeof(uint32_t), ${fields[i]['name']}_size + 1, ${fields[i]['name']});
+                % else:
+            memcpy(data.${fields[i]['name']}, ${fields[i]['name']}, ${fields[i]['name']}_size);
+                % endif
+            % else:
+            data.${fields[i]['name']} = ${fields[i]['name']};
+            % endif
         % endfor
         }
 
index f25d834..ec90550 100644 (file)
@@ -559,7 +559,7 @@ static SIMDINLINE Float SIMDCALL
 //
 //      SELECT4(src, control) {
 //          CASE(control[1:0])
-//              0:     tmp[127:0] : = src[127:0]
+//              0 : tmp[127:0] : = src[127:0]
 //              1 : tmp[127:0] : = src[255:128]
 //              2 : tmp[127:0] : = src[383:256]
 //              3 : tmp[127:0] : = src[511:384]