Mesa (master): swr: [rasterizer core] minor cleanup to thread initialization

Tim Rowley torowley at kemper.freedesktop.org
Mon Aug 29 17:55:41 UTC 2016


Module: Mesa
Branch: master
Commit: a4efbd14d382855a21d13bad510a4f67757480ab
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a4efbd14d382855a21d13bad510a4f67757480ab

Author: Tim Rowley <timothy.o.rowley at intel.com>
Date:   Mon Aug 22 15:30:08 2016 -0500

swr: [rasterizer core] minor cleanup to thread initialization

Signed-off-by: Tim Rowley <timothy.o.rowley at intel.com>

---

 src/gallium/drivers/swr/rasterizer/core/api.cpp     | 10 +---------
 src/gallium/drivers/swr/rasterizer/core/context.h   |  2 +-
 src/gallium/drivers/swr/rasterizer/core/threads.cpp | 13 ++++++++++---
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 7108a83..3e2a67d 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -104,14 +104,6 @@ HANDLE SwrCreateContext(
 
     CreateThreadPool(pContext, &pContext->threadPool);
 
-    // Calling createThreadPool() above can set SINGLE_THREADED
-    if (pContext->threadInfo.SINGLE_THREADED)
-    {
-        pContext->NumWorkerThreads = 1;
-        pContext->NumFEThreads = 1;
-        pContext->NumBEThreads = 1;
-    }
-
     pContext->ppScratch = new uint8_t*[pContext->NumWorkerThreads];
     pContext->pStats = new SWR_STATS[pContext->NumWorkerThreads];
 
@@ -356,7 +348,7 @@ DRAW_CONTEXT* GetDrawContext(SWR_CONTEXT *pContext, bool isSplitDraw = false)
         pCurDrawContext->threadsDone = 0;
         pCurDrawContext->retireCallback.pfnCallbackFunc = nullptr;
 
-        pCurDrawContext->dynState.Reset(pContext->threadPool.numThreads);
+        pCurDrawContext->dynState.Reset(pContext->NumWorkerThreads);
 
         // Assign unique drawId for this DC
         pCurDrawContext->drawId = pContext->dcRing.GetHead();
diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h
index fe78cd6..f24b8f0 100644
--- a/src/gallium/drivers/swr/rasterizer/core/context.h
+++ b/src/gallium/drivers/swr/rasterizer/core/context.h
@@ -373,7 +373,7 @@ struct DRAW_DYNAMIC_STATE
         SWR_STATS* pSavePtr = pStats;
         memset(this, 0, sizeof(*this));
         pStats = pSavePtr;
-        memset(pStats, 0, sizeof(SWR_STATS) * (numThreads ? numThreads : 1));
+        memset(pStats, 0, sizeof(SWR_STATS) * numThreads);
     }
     ///@todo Currently assumes only a single FE can do stream output for a draw.
     uint32_t SoWriteOffset[4];
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index ed03d70..24e7812 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -877,8 +877,6 @@ void CreateThreadPool(SWR_CONTEXT *pContext, THREAD_POOL *pPool)
         }
         else
         {
-            pPool->numThreads = 0;
-            numThreads = 1;
             pContext->threadInfo.SINGLE_THREADED = true;
         }
     }
@@ -895,6 +893,11 @@ void CreateThreadPool(SWR_CONTEXT *pContext, THREAD_POOL *pPool)
         }
     }
 
+    if (pContext->threadInfo.SINGLE_THREADED)
+    {
+        numThreads = 1;
+    }
+
     // Initialize DRAW_CONTEXT's per-thread stats
     for (uint32_t dc = 0; dc < KNOB_MAX_DRAWS_IN_FLIGHT; ++dc)
     {
@@ -904,10 +907,14 @@ void CreateThreadPool(SWR_CONTEXT *pContext, THREAD_POOL *pPool)
 
     if (pContext->threadInfo.SINGLE_THREADED)
     {
+        pContext->NumWorkerThreads = 1;
+        pContext->NumFEThreads = 1;
+        pContext->NumBEThreads = 1;
+        pPool->numThreads = 0;
+
         return;
     }
 
-
     pPool->numThreads = numThreads;
     pContext->NumWorkerThreads = pPool->numThreads;
 




More information about the mesa-commit mailing list