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@intel.com>
This commit is contained in:
Tim Rowley 2016-09-21 13:39:44 -05:00
parent 33a1a09eb0
commit b8a6f06c85
3 changed files with 15 additions and 4 deletions

View 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);

View 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();
}
}

View 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 };