swr: [rasterizer core] separate frontend/backend stats enables
authorTim Rowley <timothy.o.rowley@intel.com>
Fri, 28 Oct 2016 21:10:12 +0000 (16:10 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 14 Nov 2016 15:02:04 +0000 (09:02 -0600)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/api.h
src/gallium/drivers/swr/rasterizer/core/backend.cpp
src/gallium/drivers/swr/rasterizer/core/context.h
src/gallium/drivers/swr/rasterizer/core/threads.cpp
src/gallium/drivers/swr/swr_query.cpp

index b1a426df72c6b8d33f63f2b9b5e8d1012607f4b1..e8e1fdd48415c87195c6437104e64dba7b10d3e5 100644 (file)
@@ -1591,14 +1591,28 @@ VOID* SwrAllocDrawContextMemory(
 /// @brief Enables stats counting
 /// @param hContext - Handle passed back from SwrCreateContext
 /// @param enable - If true then counts are incremented.
-void SwrEnableStats(
+void SwrEnableStatsFE(
     HANDLE hContext,
     bool enable)
 {
     SWR_CONTEXT *pContext = GetContext(hContext);
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
-    pDC->pState->state.enableStats = enable;
+    pDC->pState->state.enableStatsFE = enable;
+}
+
+//////////////////////////////////////////////////////////////////////////
+/// @brief Enables stats counting
+/// @param hContext - Handle passed back from SwrCreateContext
+/// @param enable - If true then counts are incremented.
+void SwrEnableStatsBE(
+    HANDLE hContext,
+    bool enable)
+{
+    SWR_CONTEXT *pContext = GetContext(hContext);
+    DRAW_CONTEXT* pDC = GetDrawContext(pContext);
+
+    pDC->pState->state.enableStatsBE = enable;
 }
 
 //////////////////////////////////////////////////////////////////////////
index fc66cfd0d07ac3b0d1bc13b452b8bd9050e71df2..c4d80165d95baa41008734b5ce61c9ad24096768 100644 (file)
@@ -630,7 +630,15 @@ VOID* SWR_API SwrAllocDrawContextMemory(
 /// @brief Enables stats counting
 /// @param hContext - Handle passed back from SwrCreateContext
 /// @param enable - If true then counts are incremented.
-void SWR_API SwrEnableStats(
+void SWR_API SwrEnableStatsFE(
+    HANDLE hContext,
+    bool enable);
+
+//////////////////////////////////////////////////////////////////////////
+/// @brief Enables stats counting
+/// @param hContext - Handle passed back from SwrCreateContext
+/// @param enable - If true then counts are incremented.
+void SWR_API SwrEnableStatsBE(
     HANDLE hContext,
     bool enable);
 
index 3b228925053a55e6152e3dbe28f43cfcf3119903..c5e6b98064da9167e745cb18c60973dd7b6bb329 100644 (file)
@@ -73,7 +73,7 @@ void ProcessComputeBE(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroup
 
     state.pfnCsFunc(GetPrivateState(pDC), &csContext);
 
-    UPDATE_STAT(CsInvocations, state.totalThreadsInGroup);
+    UPDATE_STAT_BE(CsInvocations, state.totalThreadsInGroup);
 
     AR_END(BEDispatch, 1);
 }
@@ -553,7 +553,7 @@ void BackendSingleSample(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint3
 
                 // execute pixel shader
                 AR_BEGIN(BEPixelShader, pDC->drawId);
-                UPDATE_STAT(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(vCoverageMask)));
+                UPDATE_STAT_BE(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(vCoverageMask)));
                 state.psState.pfnPixelShader(GetPrivateState(pDC), &psContext);
                 AR_END(BEPixelShader, 0);
 
@@ -578,7 +578,7 @@ void BackendSingleSample(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint3
 
                 uint32_t statMask = _simd_movemask_ps(depthPassMask);
                 uint32_t statCount = _mm_popcnt_u32(statMask);
-                UPDATE_STAT(DepthPassCount, statCount);
+                UPDATE_STAT_BE(DepthPassCount, statCount);
 
                 // output merger
                 AR_BEGIN(BEOutputMerger, pDC->drawId);
@@ -763,7 +763,7 @@ void BackendSampleRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_
 
                     // execute pixel shader
                     AR_BEGIN(BEPixelShader, pDC->drawId);
-                    UPDATE_STAT(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(vCoverageMask)));
+                    UPDATE_STAT_BE(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(vCoverageMask)));
                     state.psState.pfnPixelShader(GetPrivateState(pDC), &psContext);
                     AR_END(BEPixelShader, 0);
 
@@ -790,7 +790,7 @@ void BackendSampleRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_
 
                     uint32_t statMask = _simd_movemask_ps(depthPassMask);
                     uint32_t statCount = _mm_popcnt_u32(statMask);
-                    UPDATE_STAT(DepthPassCount, statCount);
+                    UPDATE_STAT_BE(DepthPassCount, statCount);
 
                     // output merger
                     AR_BEGIN(BEOutputMerger, pDC->drawId);
@@ -922,7 +922,7 @@ void BackendPixelRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t
             if(T::bCanEarlyZ && !T::bForcedSampleCount)
             {
                 uint32_t depthPassCount = PixelRateZTest(activeLanes, psContext, BEEarlyDepthTest);
-                UPDATE_STAT(DepthPassCount, depthPassCount);
+                UPDATE_STAT_BE(DepthPassCount, depthPassCount);
             }
 
             // if we have no covered samples that passed depth at this point, go to next tile
@@ -944,7 +944,7 @@ void BackendPixelRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t
             // execute pixel shader
             AR_BEGIN(BEPixelShader, pDC->drawId);
             state.psState.pfnPixelShader(GetPrivateState(pDC), &psContext);
-            UPDATE_STAT(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(activeLanes)));
+            UPDATE_STAT_BE(PsInvocations, _mm_popcnt_u32(_simd_movemask_ps(activeLanes)));
             AR_END(BEPixelShader, 0);
 
             // update active lanes to remove any discarded or oMask'd pixels
@@ -955,7 +955,7 @@ void BackendPixelRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t
             if(!T::bCanEarlyZ && !T::bForcedSampleCount)
             {
                 uint32_t depthPassCount = PixelRateZTest(activeLanes, psContext, BELateDepthTest);
-                UPDATE_STAT(DepthPassCount, depthPassCount);
+                UPDATE_STAT_BE(DepthPassCount, depthPassCount);
             }
 
             // if we have no covered samples that passed depth at this point, skip OM and go to next tile
@@ -1140,7 +1140,7 @@ void BackendNullPS(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t y,
 
                     uint32_t statMask = _simd_movemask_ps(depthPassMask);
                     uint32_t statCount = _mm_popcnt_u32(statMask);
-                    UPDATE_STAT(DepthPassCount, statCount);
+                    UPDATE_STAT_BE(DepthPassCount, statCount);
                 }
 
 Endtile:
index a9de63b8cf1c55d11e9a07f62b2817e236b83ce6..23685b42bb2ff11df64b35357077af2a83a3e686 100644 (file)
@@ -297,14 +297,13 @@ OSALIGNLINE(struct) API_STATE
     SWR_BLEND_STATE         blendState;
     PFN_BLEND_JIT_FUNC      pfnBlendFunc[SWR_NUM_RENDERTARGETS];
 
-    // Stats are incremented when this is true.
-    bool enableStats;
-
     struct
     {
-        uint32_t colorHottileEnable : 8;
-        uint32_t depthHottileEnable: 1;
-        uint32_t stencilHottileEnable : 1;
+        uint32_t enableStatsFE : 1;             // Enable frontend pipeline stats
+        uint32_t enableStatsBE : 1;             // Enable backend pipeline stats
+        uint32_t colorHottileEnable : 8;        // Bitmask of enabled color hottiles
+        uint32_t depthHottileEnable: 1;         // Enable depth buffer hottile
+        uint32_t stencilHottileEnable : 1;      // Enable stencil buffer hottile
     };
 
     PFN_QUANTIZE_DEPTH      pfnQuantizeDepth;
@@ -516,8 +515,8 @@ struct SWR_CONTEXT
     HANDLE* pArContext;
 };
 
-#define UPDATE_STAT(name, count) if (GetApiState(pDC).enableStats) { pDC->dynState.pStats[workerId].name += count; }
-#define UPDATE_STAT_FE(name, count) if (GetApiState(pDC).enableStats) { pDC->dynState.statsFE.name += count; }
+#define UPDATE_STAT_BE(name, count) if (GetApiState(pDC).enableStatsBE) { pDC->dynState.pStats[workerId].name += count; }
+#define UPDATE_STAT_FE(name, count) if (GetApiState(pDC).enableStatsFE) { pDC->dynState.statsFE.name += count; }
 
 // ArchRast instrumentation framework
 #define AR_WORKER_CTX  pContext->pArContext[workerId]
index 701a550df205960500f865a76a99177498c8086f..f7730ffe09f3a1962162b0eb4ad2bc29961e06bf 100644 (file)
@@ -322,7 +322,7 @@ bool CheckDependencyFE(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint32_t lastRe
 /// @brief Update client stats.
 INLINE void UpdateClientStats(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC)
 {
-    if ((pContext->pfnUpdateStats == nullptr) || (GetApiState(pDC).enableStats == false))
+    if ((pContext->pfnUpdateStats == nullptr) || (GetApiState(pDC).enableStatsBE == false))
     {
         return;
     }
@@ -571,7 +571,7 @@ bool WorkOnFifoBE(
 /// @brief Called when FE work is complete for this DC.
 INLINE void CompleteDrawFE(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC)
 {
-    if (pContext->pfnUpdateStatsFE && GetApiState(pDC).enableStats)
+    if (pContext->pfnUpdateStatsFE && GetApiState(pDC).enableStatsFE)
     {
         SWR_STATS_FE& stats = pDC->dynState.statsFE;
 
index 8bb0b16f034e0a7f16f61119923352c347fd24f8..a95e0d8d81605889ce9ca15dce512217ca8d32ba 100644 (file)
@@ -177,8 +177,10 @@ swr_begin_query(struct pipe_context *pipe, struct pipe_query *q)
       swr_update_draw_context(ctx, &pq->result);
 
       /* Only change stat collection if there are no active queries */
-      if (ctx->active_queries == 0)
-         SwrEnableStats(ctx->swrContext, TRUE);
+      if (ctx->active_queries == 0) {
+         SwrEnableStatsFE(ctx->swrContext, TRUE);
+         SwrEnableStatsBE(ctx->swrContext, TRUE);
+      }
       break;
    }
 
@@ -212,8 +214,10 @@ swr_end_query(struct pipe_context *pipe, struct pipe_query *q)
       swr_fence_submit(ctx, pq->fence);
 
       /* Only change stat collection if there are no active queries */
-      if (ctx->active_queries == 0)
-         SwrEnableStats(ctx->swrContext, FALSE);
+      if (ctx->active_queries == 0) {
+         SwrEnableStatsFE(ctx->swrContext, FALSE);
+         SwrEnableStatsBE(ctx->swrContext, FALSE);
+      }
 
       break;
    }