dx12/main.cpp
//-----------------------------------------------------------------------------
// [SECTION] general per-frame function implementations
//-----------------------------------------------------------------------------
[SECTION] general per-frame function implementations
[ SECTION ] general per - frame function implementations
static void
begin_frame()
{
    unsigned nextFrameIndex = g_frameIndex + 1;
    g_frameIndex = nextFrameIndex;
    HANDLE waitableObjects[] = { g_swapChainWaitableObject, nullptr };
    DWORD numWaitableObjects = 1;
    g_currentFrameContext = &g_frameContext[nextFrameIndex % S_FRAME_COUNT];
    size_t fenceValue = g_currentFrameContext->fenceValue;
    if (fenceValue != 0) 
    {
        g_currentFrameContext->fenceValue = 0;
        g_fence->SetEventOnCompletion(fenceValue, g_fenceEvent);
        waitableObjects[1] = g_fenceEvent;
        numWaitableObjects = 2;
    }
    ::WaitForMultipleObjects(numWaitableObjects, waitableObjects, TRUE, INFINITE);
    g_currentFrameContext->commandAllocator->Reset();
}
static void begin_frame ( ) { unsigned nextFrameIndex = g_frameIndex + 1 ; g_frameIndex = nextFrameIndex ; HANDLE waitableObjects [ ] = { g_swapChainWaitableObject , nullptr } ; DWORD numWaitableObjects = 1 ; g_currentFrameContext = & g_frameContext [ nextFrameIndex % S_FRAME_COUNT ] ; size_t fenceValue = g_currentFrameContext -> fenceValue ; if ( fenceValue != 0 ) { g_currentFrameContext -> fenceValue = 0 ; g_fence -> SetEventOnCompletion ( fenceValue , g_fenceEvent ) ; waitableObjects [ 1 ] = g_fenceEvent ; numWaitableObjects = 2 ; } :: WaitForMultipleObjects ( numWaitableObjects , waitableObjects , TRUE , INFINITE ) ; g_currentFrameContext -> commandAllocator -> Reset ( ) ; }
[SECTION] general per-frame function implementations
[ SECTION ] general per - frame function implementations
//----------------------------------------------------------------------------- // wait for next frame //----------------------------------------------------------------------------- // means no fence was signaled