swr: [rasterizer core] generalize compute dispatch mechanism
authorTim Rowley <timothy.o.rowley@intel.com>
Wed, 21 Sep 2016 18:39:44 +0000 (13:39 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 3 Oct 2016 14:57:13 +0000 (09:57 -0500)
Generalize compute dispatch mechanism to support other types of dispatches.

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

index 703f239cc017f584d435725eef6bd90218c0e256..63f764680d68e349b3633d69cb6f3f3324a715ae 100644 (file)
@@ -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);
index b1a27f34c2924dafaa9e49a4e206bba14fddb596..4f331532111dc1f15b8a7f5c59a121cdd23cbc99 100644 (file)
@@ -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();
             }
         }
index 2befe97e7c26c07821d7e11fe363d9de48dbd32e..bfff339a55fc03fee169b2a982464df38e41db7b 100644 (file)
@@ -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 };