Mesa (master): swr: [rasterizer core] generalize compute dispatch mechanism

Tim Rowley torowley at kemper.freedesktop.org
Mon Oct 3 16:29:37 UTC 2016


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

Author: Tim Rowley <timothy.o.rowley at intel.com>
Date:   Wed Sep 21 13:39:44 2016 -0500

swr: [rasterizer core] generalize compute dispatch mechanism

Generalize compute dispatch mechanism to support other types of dispatches.

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

---

 src/gallium/drivers/swr/rasterizer/core/api.cpp     |  2 +-
 src/gallium/drivers/swr/rasterizer/core/threads.cpp |  3 +--
 src/gallium/drivers/swr/rasterizer/core/tilemgr.h   | 14 +++++++++++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 703f239..63f7646 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -1425,7 +1425,7 @@ void SwrDispatch(
     uint32_t totalThreadGroups = threadGroupCountX * threadGroupCountY * threadGroupCountZ;
     uint32_t dcIndex = pDC->drawId % KNOB_MAX_DRAWS_IN_FLIGHT;
     pDC->pDispatch = &pContext->pDispatchQueueArray[dcIndex];
-    pDC->pDispatch->initialize(totalThreadGroups, pTaskData);
+    pDC->pDispatch->initialize(totalThreadGroups, pTaskData, &ProcessComputeBE);
 
     QueueDispatch(pContext);
     AR_API_END(APIDispatch, threadGroupCountX * threadGroupCountY * threadGroupCountZ);
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index b1a27f3..4f33153 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -670,8 +670,7 @@ void WorkOnCompute(
             uint32_t threadGroupId = 0;
             while (queue.getWork(threadGroupId))
             {
-                ProcessComputeBE(pDC, workerId, threadGroupId, pSpillFillBuffer);
-
+                queue.dispatch(pDC, workerId, threadGroupId, pSpillFillBuffer);
                 queue.finishedWork();
             }
         }
diff --git a/src/gallium/drivers/swr/rasterizer/core/tilemgr.h b/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
index 2befe97..bfff339 100644
--- a/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
+++ b/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
@@ -151,6 +151,8 @@ private:
     OSALIGNLINE(volatile LONG) mWorkItemsConsumed { 0 };
 };
 
+typedef void(*PFN_DISPATCH)(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroupId, void*& pSpillFillBuffer);
+
 //////////////////////////////////////////////////////////////////////////
 /// DispatchQueue - work queue for dispatch
 //////////////////////////////////////////////////////////////////////////
@@ -161,7 +163,7 @@ public:
 
     //////////////////////////////////////////////////////////////////////////
     /// @brief Setup the producer consumer counts.
-    void initialize(uint32_t totalTasks, void* pTaskData)
+    void initialize(uint32_t totalTasks, void* pTaskData, PFN_DISPATCH pfnDispatch)
     {
         // The available and outstanding counts start with total tasks.
         // At the start there are N tasks available and outstanding.
@@ -173,6 +175,7 @@ public:
         mTasksOutstanding = totalTasks;
 
         mpTaskData = pTaskData;
+        mPfnDispatch = pfnDispatch;
     }
 
     //////////////////////////////////////////////////////////////////////////
@@ -226,7 +229,16 @@ public:
         return mpTaskData;
     }
 
+    //////////////////////////////////////////////////////////////////////////
+    /// @brief Dispatches a unit of work
+    void dispatch(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroupId, void*& pSpillFillBuffer)
+    {
+        SWR_ASSERT(mPfnDispatch != nullptr);
+        mPfnDispatch(pDC, workerId, threadGroupId, pSpillFillBuffer);
+    }
+
     void* mpTaskData{ nullptr };        // The API thread will set this up and the callback task function will interpet this.
+    PFN_DISPATCH mPfnDispatch{ nullptr };      // Function to call per dispatch
 
     OSALIGNLINE(volatile LONG) mTasksAvailable{ 0 };
     OSALIGNLINE(volatile LONG) mTasksOutstanding{ 0 };




More information about the mesa-commit mailing list