Exemplo n.º 1
0
        private void WaitForPrevFrame()
        {
            // waiting for the frame to complete before continuing is not best practice
            // this is code implemented as such for simplicity
            Direct3D12.H1CommandListFenceSet cmdFenceSet = m_DeviceContext.CommandListFenceSet;
            Int32 id             = Convert.ToInt32(Direct3D12.H1GlobalDX12Definitions.CMDQUEUE_GRAPHICS);
            Int64 currFenceValue = cmdFenceSet.GetCurrentValue(id);
            Fence currFence      = cmdFenceSet.GetFence(id);

            // get command queue to signal currFenceValue
            m_DeviceContext.MainCommandListPool.CommandQueue.Signal(currFence, currFenceValue);

            if (currFence.CompletedValue < currFenceValue)
            {
                cmdFenceSet.WaitForFence(currFenceValue, id);
            }

            // update fence value
            cmdFenceSet.SetCurrentValue(currFenceValue + 1, id);
            // update back buffer index
            m_FrameIndex = m_SwapChainDX12.SwapChain.CurrentBackBufferIndex;
        }