swr: [rasterizer archrast] Add thread tags to event files.
authorGeorge Kyriazis <george.kyriazis@intel.com>
Sat, 15 Oct 2016 22:35:26 +0000 (17:35 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 31 Oct 2016 14:05:25 +0000 (09:05 -0500)
This allows the post-processor to easily detect the API thread and to
process frame information. The frame information is needed to
optimized how data is processed from worker threads.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/archrast/events.proto
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py
src/gallium/drivers/swr/rasterizer/scripts/templates/ar_event_h.template
src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template

index 4ddb7c988c046ff00b90c421c9a9aacb07c30ccb..107d7a3b31d99701ce832e74d3ca9db09f7155f9 100644 (file)
@@ -97,6 +97,14 @@ event End
     uint32_t count;
 };
 
+event ThreadStartApiEvent
+{
+};
+
+event ThreadStartWorkerEvent
+{
+};
+
 event DrawInstancedEvent
 {
     uint32_t drawId;
index 226924039d1362aa9e312deaffd083d30672d0db..e67ede2610f12d3f3a2b4bb2a2de6548f331bc12 100644 (file)
@@ -112,10 +112,11 @@ HANDLE SwrCreateContext(
     pContext->ppScratch = new uint8_t*[pContext->NumWorkerThreads];
     pContext->pStats = new SWR_STATS[pContext->NumWorkerThreads];
 
-#if KNOB_ENABLE_AR
+#if defined(KNOB_ENABLE_AR)
     // Setup ArchRast thread contexts which includes +1 for API thread.
     pContext->pArContext = new HANDLE[pContext->NumWorkerThreads+1];
     pContext->pArContext[pContext->NumWorkerThreads] = ArchRast::CreateThreadContext();
+    _AR_EVENT(pContext->pArContext[pContext->NumWorkerThreads], ThreadStartApiEvent());
 #endif
 
     // Allocate scratch space for workers.
@@ -133,9 +134,10 @@ HANDLE SwrCreateContext(
         pContext->ppScratch[i] = (uint8_t*)AlignedMalloc(32 * sizeof(KILOBYTE), KNOB_SIMD_WIDTH * 4);
 #endif
 
-#if KNOB_ENABLE_AR
+#if defined(KNOB_ENABLE_AR)
         // Initialize worker thread context for ArchRast.
         pContext->pArContext[i] = ArchRast::CreateThreadContext();
+        _AR_EVENT(pContext->pArContext[i], ThreadStartWorkerEvent());
 #endif
     }
 
@@ -383,7 +385,7 @@ void SwrDestroyContext(HANDLE hContext)
         AlignedFree(pContext->ppScratch[i]);
 #endif
 
-#if KNOB_ENABLE_AR
+#if defined(KNOB_ENABLE_AR)
         ArchRast::DestroyThreadContext(pContext->pArContext[i]);
 #endif
     }
index 1b89a91b8fd69da20014bfabbf0e7de089ec4a00..901d6d8d05b8770bd3ed3c256cacbd1ebe443673 100644 (file)
@@ -49,6 +49,8 @@ def parse_event_fields(lines, idx, event_dict):
     field_types = []
     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):
@@ -60,11 +62,14 @@ def parse_event_fields(lines, idx, event_dict):
         if field:
             field_types.append(field.group(2))
             field_names.append(field.group(4))
+            num_fields += 1
 
         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
+
     return idx
 
 def parse_enums(lines, idx, event_dict):
index e5c94c7a8d6bb0427a92dd94b551426e9259d3e3..b0e679613043f8cf57b0034c75ce4ef0fc15ab58 100644 (file)
@@ -86,9 +86,10 @@ namespace ArchRast
             ${field_types[i]} ${field_names[i]},
             % endif
             % if i == len(field_names)-1:
-            ${field_types[i]} ${field_names[i]})
+            ${field_types[i]} ${field_names[i]}
             % endif
         % endfor
+        )
         {
         % for i in range(len(field_names)):
             data.${field_names[i]} = ${field_names[i]};
index 1924b15ca325527ea3beb24c172d68311c7325ef..6a62f170a839233603468700d40ef816f6fdfa8e 100644 (file)
@@ -83,7 +83,11 @@ namespace ArchRast
 % for name in protos['event_names']:
         virtual void handle(${name}& event)
         {
+% if protos['events'][name]['num_fields'] == 0:
+            write(${protos['events'][name]['event_id']}, (char*)&event.data, 0);
+% else:
             write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data));
+%endif
         }
 % endfor