From: Tim Rowley Date: Mon, 25 Jul 2016 22:24:58 +0000 (-0600) Subject: swr: [rasterizer core] update sync handling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57b07498d239745c13d4b8db0e9bf32516a770c0;p=mesa.git swr: [rasterizer core] update sync handling 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 --- diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index 8a2787beb7e..21b9e3f8c7d 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -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); diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.cpp b/src/gallium/drivers/swr/rasterizer/core/backend.cpp index 81abb29e892..e0392d056d5 100644 --- a/src/gallium/drivers/swr/rasterizer/core/backend.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/backend.cpp @@ -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) diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h index 13dcdfca2ee..70472b4bf98 100644 --- a/src/gallium/drivers/swr/rasterizer/core/context.h +++ b/src/gallium/drivers/swr/rasterizer/core/context.h @@ -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"); diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp index c797c042d1c..61119d986dd 100644 --- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp @@ -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); diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index 7e76c4bdda7..0800d17aec2 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -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)