question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What's the most efficient way to render a XAML visual tree onto a DXGI surface?

See original GitHub issue

(I originally posted this question in the Win2D repo but this might be a more appropriate place for it.)

I’m using MediaCapture in a UWP app to get a video stream from a camera with the intent to simultaneously record it and live stream it. For sports, I’d like to overlay scoreboard information that I’ve laid out using XAML controls.

I plan to use either the D3D11 video APIs or a custom video effect (and Win2D if applicable) to do the overlay in real-time. However, both of those techniques require the overlay to be in a DXGI surface and I can’t figure out how to efficiently render the XAML tree into one. The best approach I’ve seen is to use RenderTargetBitmap and then copy the bits to the CPU before pushing them back into DXGI. That seems horribly inefficient.

XamlUIPresenter looks like it would be perfect but

XamlUIPresenter is not intended for general Microsoft DirectX and Windows Runtime interoperation scenarios. You cannot use this API in a UWP app that you submit to the Microsoft Store, it will not pass certification.

Is there a way to do this with supported APIs entirely in video memory without the round trip to the CPU?

Thanks.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kannan95commented, Oct 7, 2018

Thanks for the update @daneuber I’ll definitely watch out for that.

0reactions
Zofwarecommented, Jun 21, 2020

I can confirm that the transparency issue is definitely fixed in Windows 10 build 19041 (aka May 2020, aka 2004). Yay!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the most efficient way to render a XAML visual tree ...
The best approach I've seen is to use RenderTargetBitmap and then copy the bits to the CPU before pushing them back into DXGI....
Read more >
How to build a simple visual tree - Win32 apps
Use the IDCompositionDevice::CreateVisual method to create the visuals, and the IDCompositionVisual::SetContent method to set the bitmap content ...
Read more >
Graphics rendering overview - WPF .NET Framework
The visual tree determines the rendering order of WPF visual and drawing objects. The order of traversal starts with the root visual, which...
Read more >
What's new for XAML and DirectX interop in Windows 8.1
The SwapChainPanel control makes it easier to include 2D and 3D DirectX content within the rest of a XAML app's UI and render...
Read more >
Is it more efficient to build the "visual tree" in xaml rather ...
It is no more efficient to declare it it xaml. I think you are correct in thinking that the performance hit has been...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found