C#, UWP and skia

110 views
Skip to first unread message

Bharatvaj

unread,
May 17, 2022, 3:25:02 AM5/17/22
to skia-discuss
Hi, I can compile and render with WinRT/C++ core app. However I am getting a DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED when I try to render with a SwapChainPanel in C# UWP app which has the C++ WinRT Component(skia+rendering logic)  as a reference.

Searching for the above error gives the description, "The IDCompositionDevice::CreateTargetForHwnd method was called with hwnd and topmost parameters for which a visual tree already exists."

I am creating and initializing IDXGISwapChain3 and setting it to the SwapChainPanel like this
swapChainPanelNative->SetSwapChain(fSwapChain);

What am I doing wrong? Is UWP with SwapChainPanel supported?

Bharatvaj

unread,
May 18, 2022, 8:12:20 AM5/18/22
to skia-discuss
For anyone facing this issue, I was able resolve it by following this page.
Apparently I was using CreateChainForCoreWindow in WinRT/C++ core app and that has to be changed to CreateSwapChainForComposition for it to work in UWP app.

    HRESULT hr = factory->CreateSwapChainForComposition(
        fQueue,
        &swapChainDesc,
        nullptr,
        swapChain.put()
    );

This is the relevant code I changed for making Skia D3D example to work with UWP.

Regards,
Bharatvaj
Reply all
Reply to author
Forward
0 new messages