// then moved on if all work is done.)
pContext->pCurDrawContext->threadsDone = pContext->NumFEThreads + pContext->NumBEThreads;
+ if (IsDraw)
+ {
+ InterlockedIncrement((volatile LONG*)&pContext->drawsOutstandingFE);
+ }
+
_ReadWriteBarrier();
{
std::unique_lock<std::mutex> lock(pContext->WaitLock);
RDTSC_STOP(APIWaitForIdle, 1, 0);
}
+void SwrWaitForIdleFE(HANDLE hContext)
+{
+ SWR_CONTEXT *pContext = GetContext(hContext);
+
+ RDTSC_START(APIWaitForIdle);
+
+ while (pContext->drawsOutstandingFE > 0)
+ {
+ _mm_pause();
+ }
+
+ RDTSC_STOP(APIWaitForIdle, 1, 0);
+}
+
void SwrSetVertexBuffers(
HANDLE hContext,
uint32_t numBuffers,
void SWR_API SwrWaitForIdle(
HANDLE hContext);
+//////////////////////////////////////////////////////////////////////////
+/// @brief Blocks until all FE rendering has been completed.
+/// @param hContext - Handle passed back from SwrCreateContext
+void SWR_API SwrWaitForIdleFE(
+ HANDLE hContext);
+
//////////////////////////////////////////////////////////////////////////
/// @brief Set vertex buffer state.
/// @param hContext - Handle passed back from SwrCreateContext
INLINE void ExecuteCallbacks(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
{
- if (pContext->pfnUpdateSoWriteOffset)
- {
- for (uint32_t i = 0; i < MAX_SO_BUFFERS; ++i)
- {
- if ((pDC->dynState.SoWriteOffsetDirty[i]) &&
- (pDC->pState->state.soBuffer[i].soWriteEnable))
- {
- pContext->pfnUpdateSoWriteOffset(GetPrivateState(pDC), i, pDC->dynState.SoWriteOffset[i]);
- }
- }
- }
-
if (pDC->retireCallback.pfnCallbackFunc)
{
pDC->retireCallback.pfnCallbackFunc(pDC->retireCallback.userData,
}
}
+//////////////////////////////////////////////////////////////////////////
+/// @brief Called when FE work is complete for this DC.
+INLINE void CompleteDrawFE(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
+{
+ _ReadWriteBarrier();
+
+ if (pContext->pfnUpdateSoWriteOffset)
+ {
+ for (uint32_t i = 0; i < MAX_SO_BUFFERS; ++i)
+ {
+ if ((pDC->dynState.SoWriteOffsetDirty[i]) &&
+ (pDC->pState->state.soBuffer[i].soWriteEnable))
+ {
+ pContext->pfnUpdateSoWriteOffset(GetPrivateState(pDC), i, pDC->dynState.SoWriteOffset[i]);
+ }
+ }
+ }
+
+ pDC->doneFE = true;
+
+ InterlockedDecrement((volatile LONG*)&pContext->drawsOutstandingFE);
+}
+
void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t &curDrawFE)
{
// Try to grab the next DC from the ring
// successfully grabbed the DC, now run the FE
pDC->FeWork.pfnWork(pContext, pDC, workerId, &pDC->FeWork.desc);
- _ReadWriteBarrier();
- pDC->doneFE = true;
+ CompleteDrawFE(pContext, pDC);
}
}
curDraw++;