swr/rast: Add clipper stats.
authorGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 31 Jan 2018 19:22:19 +0000 (13:22 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 16 Feb 2018 16:53:59 +0000 (10:53 -0600)
Clipper event is now:

event ClipperEvent
{
    uint32_t drawId;
    uint32_t trivialRejectCount;
    uint32_t trivialAcceptCount;
    uint32_t mustClipCount;
};

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/clip.h

index afea1d3ff1d71780790a167ad0f2ee83dd39aa01..49e7764bd55ec1e07be286237fcc54043a969ac7 100644 (file)
@@ -50,7 +50,9 @@ namespace ArchRast
 
     struct CStats
     {
-        uint32_t clippedVerts = 0;
+        uint32_t trivialRejectCount;
+        uint32_t trivialAcceptCount;
+        uint32_t mustClipCount;
     };
 
     struct TEStats
@@ -164,6 +166,13 @@ namespace ArchRast
         }
 
 
+        virtual void Handle(const ClipInfoEvent& event)
+        {
+            mClipper.mustClipCount += _mm_popcnt_u32(event.data.clipMask);
+            mClipper.trivialRejectCount += event.data.numInvocations - _mm_popcnt_u32(event.data.validMask);
+            mClipper.trivialAcceptCount += _mm_popcnt_u32(event.data.validMask & ~event.data.clipMask);
+        }
+
         // Flush cached events for this draw
         virtual void FlushDraw(uint32_t drawId)
         {
@@ -202,7 +211,7 @@ namespace ArchRast
         virtual void Handle(const FrontendDrawEndEvent& event)
         {
             //Clipper
-            EventHandlerFile::Handle(VertsClipped(event.data.drawId, mClipper.clippedVerts));
+            EventHandlerFile::Handle(ClipperEvent(event.data.drawId, mClipper.trivialRejectCount, mClipper.trivialAcceptCount, mClipper.mustClipCount));
 
             //Tesselator
             EventHandlerFile::Handle(TessPrims(event.data.drawId, mTS.inputPrims));
@@ -225,11 +234,6 @@ namespace ArchRast
             mGS.vertsInput += event.data.vertsInput;
         }
 
-        virtual void Handle(const ClipVertexCount& event)
-        {
-            mClipper.clippedVerts += (_mm_popcnt_u32(event.data.primMask) * event.data.vertsPerPrim);
-        }
-
         virtual void Handle(const TessPrimCount& event)
         {
             mTS.inputPrims += event.data.primCount;
index f9be5844333379cbdb674e604a5f3a9ea255b9a8..c96e7a1bd7ba8191c7dd03363e7788fd03cd5724 100644 (file)
@@ -262,14 +262,16 @@ event GSVertsInput
     uint64_t vertsInput;
 };
 
-event VertsClipped
+event TessPrims
 {
     uint32_t drawId;
-    uint64_t clipCount;
+    uint64_t primCount;
 };
 
-event TessPrims
+event ClipperEvent
 {
     uint32_t drawId;
-    uint64_t primCount;
+    uint32_t trivialRejectCount;
+    uint32_t trivialAcceptCount;
+    uint32_t mustClipCount;
 };
index e0fe9b93104e0b9bdd8c3b588bba6b0ec47c5808..f6dde331355dbde29792c13d4cc64fa833407f24 100644 (file)
@@ -90,12 +90,6 @@ event FrontendDrawEndEvent
     uint32_t drawId;
 };
 
-event ClipVertexCount
-{
-    uint64_t vertsPerPrim;
-    uint64_t primMask;
-};
-
 event TessPrimCount
 {
     uint64_t primCount;
@@ -107,3 +101,15 @@ event GSPrimInfo
     uint64_t primGeneratedCount;
     uint64_t vertsInput;
 };
+
+// validMask is primitives that still need to be clipped. They weren't rejected due to trivial reject or nan.
+// clipMask is primitives that need to be clipped. So trivial accepts will be 0 while validMask for that is 1.
+// Trivial reject is numInvocations - pop_cnt32(validMask)
+// Trivial accept is validMask & ~clipMask
+// Must clip count is pop_cnt32(clipMask)
+event ClipInfoEvent
+{
+    uint32_t numInvocations;
+    uint32_t validMask;
+    uint32_t clipMask;
+};
index f47b4b004d005f65ca613f791efdbfad72efc6e0..1d336b6aff6225989dbc505d182d02fa6ce7839c 100644 (file)
@@ -715,6 +715,8 @@ public:
             clipMask = primMask & ComputeClipMask();
         }
 
+        AR_EVENT(ClipInfoEvent(numInvoc, validMask, clipMask));
+
         if (clipMask)
         {
             RDTSC_BEGIN(FEGuardbandClip, pa.pDC->drawId);