File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Open diff view settings
video/IndirectDisplay/IddSampleDriver Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -422,6 +422,7 @@ void SwapChainProcessor::RunCore()
422422 }
423423 else if (SUCCEEDED (hr))
424424 {
425+ // We have new frame to process, the surface has a reference on it that the driver has to release
425426 AcquiredBuffer.Attach (Buffer.MetaData .pSurface );
426427
427428 // ==============================
@@ -435,7 +436,17 @@ void SwapChainProcessor::RunCore()
435436 // * a GPU custom compute shader encode operation
436437 // ==============================
437438
439+ // We have finished processing this frame hence we release the reference on it.
440+ // If the driver forgets to release the reference to the surface, it will be leaked which results in the
441+ // surfaces being left around after swapchain is destroyed.
442+ // NOTE: Although in this sample we release reference to the surface here; the driver still
443+ // owns the Buffer.MetaData.pSurface surface until IddCxSwapChainReleaseAndAcquireBuffer returns
444+ // S_OK and gives us a new frame, a driver may want to use the surface in future to re-encode the desktop
445+ // for better quality if there is no new frame for a while
438446 AcquiredBuffer.Reset ();
447+
448+ // Indicate to OS that we have finished inital processing of the frame, it is a hint that
449+ // OS could start preparing another frame
439450 hr = IddCxSwapChainFinishedProcessingFrame (m_hSwapChain);
440451 if (FAILED (hr))
441452 {
You can’t perform that action at this time.
0 commit comments