[Mesa-dev] [PATCH 29/31] swr/rast: Consolidate archrast Draw events

George Kyriazis george.kyriazis at intel.com
Tue Feb 13 22:42:47 UTC 2018


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
---
 .../drivers/swr/rasterizer/archrast/archrast.cpp   | 28 ++++++++++++++++
 .../drivers/swr/rasterizer/archrast/events.proto   | 32 ++++++-------------
 .../swr/rasterizer/archrast/events_private.proto   | 37 ++++++++++++++++++++++
 src/gallium/drivers/swr/rasterizer/core/api.cpp    |  8 ++---
 4 files changed, 79 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
index 49e7764..d7a3b29 100644
--- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
+++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
@@ -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)
         {
diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events.proto b/src/gallium/drivers/swr/rasterizer/archrast/events.proto
index c96e7a1..638dfd0 100644
--- a/src/gallium/drivers/swr/rasterizer/archrast/events.proto
+++ b/src/gallium/drivers/swr/rasterizer/archrast/events.proto
@@ -21,28 +21,28 @@
 #
 # 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
 {
diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto b/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto
index f6dde33..71b723d 100644
--- a/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto
+++ b/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto
@@ -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;
+};
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 99d3cd5..cb98cbe 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -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;
-- 
2.7.4



More information about the mesa-dev mailing list