summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--video/IndirectDisplay/IddSampleDriver/Driver.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/IndirectDisplay/IddSampleDriver/Driver.cpp b/video/IndirectDisplay/IddSampleDriver/Driver.cpp
index 4ae12af5..ae060298 100644
--- a/video/IndirectDisplay/IddSampleDriver/Driver.cpp
+++ b/video/IndirectDisplay/IddSampleDriver/Driver.cpp
@@ -422,6 +422,7 @@ void SwapChainProcessor::RunCore()
}
else if (SUCCEEDED(hr))
{
+ // We have new frame to process, the surface has a reference on it that the driver has to release
AcquiredBuffer.Attach(Buffer.MetaData.pSurface);
// ==============================
@@ -435,7 +436,17 @@ void SwapChainProcessor::RunCore()
// * a GPU custom compute shader encode operation
// ==============================
+ // We have finished processing this frame hence we release the reference on it.
+ // If the driver forgets to release the reference to the surface, it will be leaked which results in the
+ // surfaces being left around after swapchain is destroyed.
+ // NOTE: Although in this sample we release reference to the surface here; the driver still
+ // owns the Buffer.MetaData.pSurface surface until IddCxSwapChainReleaseAndAcquireBuffer returns
+ // S_OK and gives us a new frame, a driver may want to use the surface in future to re-encode the desktop
+ // for better quality if there is no new frame for a while
AcquiredBuffer.Reset();
+
+ // Indicate to OS that we have finished inital processing of the frame, it is a hint that
+ // OS could start preparing another frame
hr = IddCxSwapChainFinishedProcessingFrame(m_hSwapChain);
if (FAILED(hr))
{