From 205347272369f554ab274e3ec62002ecdcc7f3c0 Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Wed, 31 Jan 2018 13:22:19 -0600 Subject: [PATCH] swr/rast: Add clipper stats. Clipper event is now: event ClipperEvent { uint32_t drawId; uint32_t trivialRejectCount; uint32_t trivialAcceptCount; uint32_t mustClipCount; }; Reviewed-by: Bruce Cherniak --- .../swr/rasterizer/archrast/archrast.cpp | 18 +++++++++++------- .../swr/rasterizer/archrast/events.proto | 10 ++++++---- .../rasterizer/archrast/events_private.proto | 18 ++++++++++++------ src/gallium/drivers/swr/rasterizer/core/clip.h | 2 ++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp index afea1d3ff1d..49e7764bd55 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp @@ -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; diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events.proto b/src/gallium/drivers/swr/rasterizer/archrast/events.proto index f9be5844333..c96e7a1bd7b 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/events.proto +++ b/src/gallium/drivers/swr/rasterizer/archrast/events.proto @@ -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; }; diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto b/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto index e0fe9b93104..f6dde331355 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto +++ b/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto @@ -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; +}; diff --git a/src/gallium/drivers/swr/rasterizer/core/clip.h b/src/gallium/drivers/swr/rasterizer/core/clip.h index f47b4b004d0..1d336b6aff6 100644 --- a/src/gallium/drivers/swr/rasterizer/core/clip.h +++ b/src/gallium/drivers/swr/rasterizer/core/clip.h @@ -715,6 +715,8 @@ public: clipMask = primMask & ComputeClipMask(); } + AR_EVENT(ClipInfoEvent(numInvoc, validMask, clipMask)); + if (clipMask) { RDTSC_BEGIN(FEGuardbandClip, pa.pDC->drawId); -- 2.30.2