Mesa (master): swr: [rasterizer core] update sync handling
Tim Rowley
torowley at kemper.freedesktop.org
Thu Aug 4 19:57:12 UTC 2016
Module: Mesa
Branch: master
Commit: 57b07498d239745c13d4b8db0e9bf32516a770c0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=57b07498d239745c13d4b8db0e9bf32516a770c0
Author: Tim Rowley <timothy.o.rowley at intel.com>
Date: Mon Jul 25 16:24:58 2016 -0600
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 <timothy.o.rowley at intel.com>
---
src/gallium/drivers/swr/rasterizer/core/api.cpp | 12 ++++++------
src/gallium/drivers/swr/rasterizer/core/backend.cpp | 7 -------
src/gallium/drivers/swr/rasterizer/core/context.h | 2 ++
src/gallium/drivers/swr/rasterizer/core/frontend.cpp | 2 --
src/gallium/drivers/swr/rasterizer/core/threads.cpp | 7 +++++++
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 8a2787b..21b9e3f 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 81abb29..e0392d0 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 13dcdfc..70472b4 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 c797c04..61119d9 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 7e76c4b..0800d17 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)
More information about the mesa-commit
mailing list