swr: [rasterizer core] update sync handling
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 25 Jul 2016 22:24:58 +0000 (16:24 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Thu, 4 Aug 2016 19:38:34 +0000 (14:38 -0500)
Sync now uses a callback to ensure that it's called by the last
thread moving past a DC.  This will help with the new counter
handling.

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

index 8a2787beb7e53755112ac636f7247e4b4fcb9041..21b9e3f8c7d98747db5c5dee07698f87258d35de 100644 (file)
@@ -334,6 +334,7 @@ DRAW_CONTEXT* GetDrawContext(SWR_CONTEXT *pContext, bool isSplitDraw = false)
         pCurDrawContext->doneFE = false;
         pCurDrawContext->FeLock = 0;
         pCurDrawContext->threadsDone = 0;
+        pCurDrawContext->retireCallback.pfnCallbackFunc = nullptr;
 
         // Assign unique drawId for this DC
         pCurDrawContext->drawId = pContext->dcRing.GetHead();
@@ -400,13 +401,12 @@ void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, uint64_t userData, uint
 
     pDC->FeWork.type = SYNC;
     pDC->FeWork.pfnWork = ProcessSync;
-    pDC->FeWork.desc.sync.pfnCallbackFunc = pfnFunc;
-    pDC->FeWork.desc.sync.userData = userData;
-    pDC->FeWork.desc.sync.userData2 = userData2;
-    pDC->FeWork.desc.sync.userData3 = userData3;
 
-    // cannot execute until all previous draws have completed
-    pDC->dependent = true;
+    // Setup callback function
+    pDC->retireCallback.pfnCallbackFunc = pfnFunc;
+    pDC->retireCallback.userData = userData;
+    pDC->retireCallback.userData2 = userData2;
+    pDC->retireCallback.userData3 = userData3;
 
     //enqueue
     QueueDraw(pContext);
index 81abb29e8922075a5b0c6f7393d9e2bdf4546007..e0392d056d516ffdb531b9752ea76c220e76a91d 100644 (file)
@@ -80,16 +80,9 @@ void ProcessComputeBE(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroup
 
 void ProcessSyncBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pUserData)
 {
-    SYNC_DESC *pSync = (SYNC_DESC*)pUserData;
-
     uint32_t x, y;
     MacroTileMgr::getTileIndices(macroTile, x, y);
     SWR_ASSERT(x == 0 && y == 0);
-
-    if (pSync->pfnCallbackFunc != nullptr)
-    {
-        pSync->pfnCallbackFunc(pSync->userData, pSync->userData2, pSync->userData3);
-    }
 }
 
 void ProcessQueryStatsBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pUserData)
index 13dcdfca2eedf51838c841892d0a7521f6ea7776..70472b4bf989299b673ff73c041865501b86b23c 100644 (file)
@@ -392,6 +392,8 @@ struct DRAW_CONTEXT
 
     volatile OSALIGNLINE(uint32_t)   FeLock;
     volatile int64_t    threadsDone;
+
+    SYNC_DESC       retireCallback; // Call this func when this DC is retired.
 };
 
 static_assert((sizeof(DRAW_CONTEXT) & 63) == 0, "Invalid size for DRAW_CONTEXT");
index c797c042d1cc4818ed26c5d960fdc606a6373cd4..61119d986dd301695fb0df6def5891980ffe7671 100644 (file)
@@ -72,11 +72,9 @@ void ProcessSync(
     uint32_t workerId,
     void *pUserData)
 {
-    SYNC_DESC *pSync = (SYNC_DESC*)pUserData;
     BE_WORK work;
     work.type = SYNC;
     work.pfnWork = ProcessSyncBE;
-    work.desc.sync = *pSync;
 
     MacroTileMgr *pTileMgr = pDC->pTileMgr;
     pTileMgr->enqueue(0, 0, &work);
index 7e76c4bdda717fa836c446ccb7ada2176387b83f..0800d17aec246f973178d2069bd37ec283093118 100644 (file)
@@ -328,6 +328,13 @@ INLINE int64_t CompleteDrawContextInl(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
 
     if (result == 0)
     {
+        if (pDC->retireCallback.pfnCallbackFunc)
+        {
+            pDC->retireCallback.pfnCallbackFunc(pDC->retireCallback.userData,
+                                                pDC->retireCallback.userData2,
+                                                pDC->retireCallback.userData3);
+        }
+
         // Cleanup memory allocations
         pDC->pArena->Reset(true);
         if (!pDC->isCompute)