示例#1
0
        private void WaitForGpu()
        {
            // Schedule a Signal command in the queue.
            _graphicsDevice.CommandQueue.DeviceCommandQueue.Signal(_fence, _fenceValues[_frameIndex]);

            // Wait until the fence has been crossed.
            _fence.SetEventOnCompletion(
                _fenceValues[_frameIndex],
                _fenceEvent.GetSafeWaitHandle().DangerousGetHandle());
            _fenceEvent.WaitOne();

            // Increment the fence value for the current frame.
            _fenceValues[_frameIndex]++;
        }
 private void DeleteEvent()
 {
     try
     {
         if (_waitHandle != null)
         {
             var waitHandleSafeWaitHandle = _waitHandle.GetSafeWaitHandle();
             waitHandleSafeWaitHandle.DangerousRelease();
         }
     }
     catch { }
 }
示例#3
0
        private void WaitForPrevFrame()
        {
            // WAITING FOR THE FRAME TO COMPLETE BEFORE CONTINUING IS NOT BEST PRACTICE.
            // This is code implemented as such for simplicity.
            long localFence = currentFence;

            commandQueue.Signal(fence, localFence);
            currentFence++;

            if (fence.CompletedValue < localFence)
            {
                fence.SetEventOnCompletion(localFence, eventHandle.GetSafeWaitHandle().DangerousGetHandle());
                eventHandle.WaitOne();
            }
        }