swr: [rasterizer core] make dirtytile list point directly to macrotilequeues
authorTim Rowley <timothy.o.rowley@intel.com>
Tue, 16 Aug 2016 18:40:47 +0000 (12:40 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 17 Aug 2016 22:08:55 +0000 (17:08 -0500)
Speeds up high geometry HPC workloads.

Signed-off-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/rasterizer/core/threads.cpp
src/gallium/drivers/swr/rasterizer/core/tilemgr.cpp
src/gallium/drivers/swr/rasterizer/core/tilemgr.h

index dce23b2486e3ebf7e61c0eb0635148936a9a32ba..9665f09e2c852feac23daffda0e0d3d3353c44e6 100644 (file)
@@ -465,10 +465,12 @@ void WorkOnFifoBE(
         }
 
         // Grab the list of all dirty macrotiles. A tile is dirty if it has work queued to it.
-        std::vector<uint32_t> &macroTiles = pDC->pTileMgr->getDirtyTiles();
+        auto &macroTiles = pDC->pTileMgr->getDirtyTiles();
 
-        for (uint32_t tileID : macroTiles)
+        for (auto tile : macroTiles)
         {
+            uint32_t tileID = tile->mId;
+
             // Only work on tiles for this numa node
             uint32_t x, y;
             pDC->pTileMgr->getTileIndices(tileID, x, y);
@@ -477,9 +479,7 @@ void WorkOnFifoBE(
                 continue;
             }
 
-            MacroTileQueue &tile = pDC->pTileMgr->getMacroTileQueue(tileID);
-            
-            if (!tile.getNumQueued())
+            if (!tile->getNumQueued())
             {
                 continue;
             }
@@ -490,26 +490,26 @@ void WorkOnFifoBE(
                 continue;
             }
 
-            if (tile.tryLock())
+            if (tile->tryLock())
             {
                 BE_WORK *pWork;
 
                 RDTSC_START(WorkerFoundWork);
 
-                uint32_t numWorkItems = tile.getNumQueued();
+                uint32_t numWorkItems = tile->getNumQueued();
                 SWR_ASSERT(numWorkItems);
 
-                pWork = tile.peek();
+                pWork = tile->peek();
                 SWR_ASSERT(pWork);
                 if (pWork->type == DRAW)
                 {
                     pContext->pHotTileMgr->InitializeHotTiles(pContext, pDC, tileID);
                 }
 
-                while ((pWork = tile.peek()) != nullptr)
+                while ((pWork = tile->peek()) != nullptr)
                 {
                     pWork->pfnWork(pDC, workerId, tileID, &pWork->desc);
-                    tile.dequeue();
+                    tile->dequeue();
                 }
                 RDTSC_STOP(WorkerFoundWork, numWorkItems, pDC->drawId);
 
index e0aa8dd03079a7ccf92c42fd05bd3f9f97260dce..1bd1805b52b61923b250799a50df8db92b7697be 100644 (file)
@@ -54,11 +54,12 @@ void MacroTileMgr::enqueue(uint32_t x, uint32_t y, BE_WORK *pWork)
 
     MacroTileQueue &tile = mTiles[id];
     tile.mWorkItemsFE++;
+    tile.mId = id;
 
     if (tile.mWorkItemsFE == 1)
     {
         tile.clear(mArena);
-        mDirtyTiles.push_back(id);
+        mDirtyTiles.push_back(&tile);
     }
 
     mWorkItemsProduced++;
index 41d29ba0c7a81c1f9042a6a79b38e811439f157c..4ec02838ab9ac3c5532ed04aed4b288ded58dd58 100644 (file)
@@ -95,6 +95,7 @@ struct MacroTileQueue
     ///@todo This will all be private.
     uint32_t mWorkItemsFE = 0;
     uint32_t mWorkItemsBE = 0;
+    uint32_t mId = 0;
 
 private:
     QUEUE<BE_WORK> mFifo;
@@ -123,8 +124,7 @@ public:
         mDirtyTiles.clear();
     }
 
-    INLINE std::vector<uint32_t>& getDirtyTiles() { return mDirtyTiles; }
-    INLINE MacroTileQueue& getMacroTileQueue(uint32_t id) { return mTiles[id]; }
+    INLINE std::vector<MacroTileQueue*>& getDirtyTiles() { return mDirtyTiles; }
     void markTileComplete(uint32_t id);
 
     INLINE bool isWorkComplete()
@@ -145,7 +145,7 @@ private:
     std::unordered_map<uint32_t, MacroTileQueue> mTiles;
 
     // Any tile that has work queued to it is a dirty tile.
-    std::vector<uint32_t> mDirtyTiles;
+    std::vector<MacroTileQueue*> mDirtyTiles;
 
     OSALIGNLINE(LONG) mWorkItemsProduced { 0 };
     OSALIGNLINE(volatile LONG) mWorkItemsConsumed { 0 };