/// <summary> /// Waits until all prepared frames are renderd and the GPU has no more tasks. /// Use this method carefully since it will usually come with a huge stall! /// </summary> public void WaitUntilAllFramesCompleted() { if (NumCompletedFramesGPU != NumCompletedFramesCPU) { FrameFence.WaitForCompletion(NumCompletedFramesCPU, TimeSpan.MaxValue); } }
/// <summary> /// Waits until only Desc.MaxFramesInFlight-1 frames are inflight and will then trigger the OnBeginRendering event. /// If an application is highly GPU bound, it will wait for the GPU to complete the rendering for this swapChain in this function. /// </summary> public void BeginFrame() { // Fullfill the MaxFramesInFlight constraint. Assert.Debug(NumFramesInFlight <= Desc.MaxFramesInFlight, "It should be impossible to have more than Desc.MaxFramesInFlight frames in flight."); if (NumFramesInFlight == Desc.MaxFramesInFlight) { FrameFence.WaitForCompletion(NumCompletedFramesGPU + 1, TimeSpan.MaxValue); } // Anounce frame start to all listeners. OnBeginFrame?.Invoke(activeInFlightFrameIndex); }