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>
Mon, 25 Feb 2019 19:05:31 +0000 (13:05 -0600)
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 fd803830101bcaa55f0e0d2f08977fa3d0571a0a..aedc37b74401b5985a96a8a11d6f2c08dbb066c4 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 87c68fcf3648af7f0bcbd34337181a28ae73fc2e..6182504567a489ab8b3310dcf358aa08a5a48fbf 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 97a08d21f35635154c77dfad523b82dac52f9f50..c24e19982b79daa11cfdd13f873b9ab33bc9d70d 100644 (file)
@@ -162,7 +162,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 fe3f261f68093150cd7b7eef89f5b615d145b2fb..884a321003922222875d4620e8da8fc60a50bbf8 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 f25d834725c05955088a238d82fdac02e3f6944b..ec905505dc413cd70182dd3aa46e33d4047d4051 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]