swr/rast: Consolidate archrast Draw events
authorGeorge Kyriazis <george.kyriazis@intel.com>
Mon, 12 Feb 2018 23:54:30 +0000 (17:54 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 16 Feb 2018 16:54:02 +0000 (10:54 -0600)
Consolidate archrst draw events into single draw event with an attribute
that represents the type of draw

- Add handlers for new private proto versions of DrawInstancedEvent,
  DrawIndexedInstancedEvent, DrawInstancedSplitEvent, and
  DrawIndexedInstancedSplitEvent
- Convert the draw events to generic DrawInfoEvents
- parse_proto_event_fields() replaces 'AR_DRAW_TYPE' as a field type with
  'uint32_t'. This draw type is actually an enum, but can be represented
  as an unsigned integer.
- is_draw_or_dispatch() recognizes DrawInfoEvent as a draw event

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
src/gallium/drivers/swr/rasterizer/archrast/events.proto
src/gallium/drivers/swr/rasterizer/archrast/events_private.proto
src/gallium/drivers/swr/rasterizer/core/api.cpp

index 49e7764bd55ec1e07be286237fcc54043a969ac7..d7a3b292d627013bee95025243ec254dc5f91af7 100644 (file)
@@ -173,6 +173,34 @@ namespace ArchRast
             mClipper.trivialAcceptCount += _mm_popcnt_u32(event.data.validMask & ~event.data.clipMask);
         }
 
+        virtual void Handle(const DrawInstancedEvent& event)
+        {
+            DrawInfoEvent e(event.data.drawId, event.data.type, event.data.topology, event.data.numVertices, 0, 0, event.data.startVertex, event.data.numInstances, event.data.startInstance);
+
+            EventHandlerFile::Handle(e);
+        }
+
+        virtual void Handle(const DrawIndexedInstancedEvent& event)
+        {
+            DrawInfoEvent e(event.data.drawId, event.data.type, event.data.topology, 0, event.data.numIndices, event.data.indexOffset, event.data.baseVertex, event.data.numInstances, event.data.startInstance);
+
+            EventHandlerFile::Handle(e);
+        }
+
+        virtual void Handle(const DrawInstancedSplitEvent& event)
+        {
+            DrawInfoEvent e(event.data.drawId, event.data.type, 0, 0, 0, 0, 0, 0, 0);
+
+            EventHandlerFile::Handle(e);
+        }
+
+        virtual void Handle(const DrawIndexedInstancedSplitEvent& event)
+        {
+            DrawInfoEvent e(event.data.drawId, event.data.type, 0, 0, 0, 0, 0, 0, 0);
+
+            EventHandlerFile::Handle(e);
+        }
+
         // Flush cached events for this draw
         virtual void FlushDraw(uint32_t drawId)
         {
index c96e7a1bd7ba8191c7dd03363e7788fd03cd5724..638dfd067c655b4220336c8fa1fc1d4674dac613 100644 (file)
 #
 # Provides definitions for events.
 
-event ThreadStartApiEvent
+enum AR_DRAW_TYPE
 {
+    Instanced = 0,
+    IndexedInstanced = 1,
+    InstancedSplit = 2,
+    IndexedInstancedSplit = 3
 };
 
-event ThreadStartWorkerEvent
+event ThreadStartApiEvent
 {
 };
 
-event DrawInstancedEvent
+event ThreadStartWorkerEvent
 {
-    uint32_t drawId;
-    uint32_t topology;
-    uint32_t numVertices;
-    int32_t  startVertex;
-    uint32_t numInstances;
-    uint32_t startInstance;
 };
 
-event DrawIndexedInstancedEvent
+event DrawInfoEvent
 {
     uint32_t drawId;
+    AR_DRAW_TYPE type;
     uint32_t topology;
+    uint32_t numVertices;
     uint32_t numIndices;
     int32_t  indexOffset;
     int32_t  baseVertex;
@@ -64,18 +64,6 @@ event FrameEndEvent
     uint32_t nextDrawId;
 };
 
-///@brief API Stat: Split draw event for DrawInstanced. In certain cases, Rasty can split draws up into smaller draws.
-event DrawInstancedSplitEvent
-{
-    uint32_t drawId;
-};
-
-///@brief API Stat: Split draw event for DrawIndexedInstanced.
-event DrawIndexedInstancedSplitEvent
-{
-    uint32_t drawId;
-};
-
 ///@brief API Stat: Synchonization event.
 event SwrSyncEvent
 {
index f6dde331355dbde29792c13d4cc64fa833407f24..71b723d5f61d53534c018fff24ce38207f33b54d 100644 (file)
@@ -113,3 +113,40 @@ event ClipInfoEvent
     uint32_t validMask;
     uint32_t clipMask;
 };
+
+event DrawInstancedEvent
+{
+    uint32_t drawId;
+    AR_DRAW_TYPE type;
+    uint32_t topology;
+    uint32_t numVertices;
+    int32_t  startVertex;
+    uint32_t numInstances;
+    uint32_t startInstance;
+};
+
+event DrawIndexedInstancedEvent
+{
+    uint32_t drawId;
+    AR_DRAW_TYPE type;
+    uint32_t topology;
+    uint32_t numIndices;
+    int32_t  indexOffset;
+    int32_t  baseVertex;
+    uint32_t numInstances;
+    uint32_t startInstance;
+};
+
+///@brief API Stat: Split draw event for DrawInstanced. In certain cases, Rasty can split draws up into smaller draws.
+event DrawInstancedSplitEvent
+{
+    uint32_t drawId;
+    AR_DRAW_TYPE type;
+};
+
+///@brief API Stat: Split draw event for DrawIndexedInstanced.
+event DrawIndexedInstancedSplitEvent
+{
+    uint32_t drawId;
+    AR_DRAW_TYPE type;
+};
index 99d3cd5bb0125821a8ffd4b457a4849445ad5a3a..cb98cbe7eeafbad5cf3d2c9a770edeb4443c0eab 100644 (file)
@@ -1169,7 +1169,7 @@ void DrawInstanced(
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
     RDTSC_BEGIN(APIDraw, pDC->drawId);
-    AR_API_EVENT(DrawInstancedEvent(pDC->drawId, topology, numVertices, startVertex, numInstances, startInstance));
+    AR_API_EVENT(DrawInstancedEvent(pDC->drawId, ArchRast::Instanced, topology, numVertices, startVertex, numInstances, startInstance));
 
     uint32_t maxVertsPerDraw = MaxVertsPerDraw(pDC, numVertices, topology);
     uint32_t primsPerDraw = GetNumPrims(topology, maxVertsPerDraw);
@@ -1221,7 +1221,7 @@ void DrawInstanced(
         //enqueue DC
         QueueDraw(pContext);
 
-        AR_API_EVENT(DrawInstancedSplitEvent(pDC->drawId));
+        AR_API_EVENT(DrawInstancedSplitEvent(pDC->drawId, ArchRast::InstancedSplit));
 
         remainingVerts -= numVertsForDraw;
         draw++;
@@ -1297,7 +1297,7 @@ void DrawIndexedInstance(
     API_STATE* pState = &pDC->pState->state;
 
     RDTSC_BEGIN(APIDrawIndexed, pDC->drawId);
-    AR_API_EVENT(DrawIndexedInstancedEvent(pDC->drawId, topology, numIndices, indexOffset, baseVertex, numInstances, startInstance));
+    AR_API_EVENT(DrawIndexedInstancedEvent(pDC->drawId, ArchRast::IndexedInstancedSplit, topology, numIndices, indexOffset, baseVertex, numInstances, startInstance));
 
     uint32_t maxIndicesPerDraw = MaxVertsPerDraw(pDC, numIndices, topology);
     uint32_t primsPerDraw = GetNumPrims(topology, maxIndicesPerDraw);
@@ -1366,7 +1366,7 @@ void DrawIndexedInstance(
         //enqueue DC
         QueueDraw(pContext);
 
-        AR_API_EVENT(DrawIndexedInstancedSplitEvent(pDC->drawId));
+        AR_API_EVENT(DrawIndexedInstancedSplitEvent(pDC->drawId, ArchRast::IndexedInstancedSplit));
 
         pIB += maxIndicesPerDraw * indexSize;
         remainingIndices -= numIndicesForDraw;