I have a Direct Composition swap chain as the root visual of my window. I want to draw semi transparent custom controls over the swap chain, so I use an IDCompositionVirtualSurface as the content of a child visual and on every frame call IDCompositionSurface::BeginDraw() to obtain an ID2D1DeviceContext pointer, render the controls, then IDCompositionSurface::EndDraw() and IDCompositionDevice::Commit(). This however results in very high CPU and GPU usage (according to Task Manager rendering the controls with the swap chain directly typically uses ~2% CPU and ~0.5 GPU, the numbers easily go up to ~20% if the above method is used). Is this expected behavior? Is this the intended use case for Direct Composition?
The rendering code looks like this:
ID2D1DeviceContext* pDC;
IDXGISwapChain* pSC;
IDCompositionSurface* pDCompSurface;
IDCompositionDevice* pDCompDevice;
VOID OnPaint()
{
POINT pt;
ID2D1DeviceContext* pDCompDC;
pDC->BeginDraw();
//Draw bottom content here with pDC
pDCompSurface->BeginDraw(0, IID_PPV_ARGS(&pDCompDC), &pt);
//Draw top content here with pDCompDC
pDCompSurface->EndDraw();
pDCompDC->Release();
pDCompDevice->Commit();
pDC->EndDraw();
pSC->Present(1, 0);
}