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);
uint32_t threadGroupId = 0;
while (queue.getWork(threadGroupId))
{
- ProcessComputeBE(pDC, workerId, threadGroupId, pSpillFillBuffer);
-
+ queue.dispatch(pDC, workerId, threadGroupId, pSpillFillBuffer);
queue.finishedWork();
}
}
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
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/// @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.
mTasksOutstanding = totalTasks;
mpTaskData = pTaskData;
+ mPfnDispatch = pfnDispatch;
}
//////////////////////////////////////////////////////////////////////////
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 };