C#C
C#5mo ago
Flo

SkiaSharp, DX11 and DirectComposition

Hey, I've been stuck on this issue for a few months now and thought I could ask for help.

Scenario:

I create a plain Win32 window using P/Invokes using SkiaSharp for rendering. I would like to get maximum performance by utilizing GPU acceleration, using DX11 as a SkiaSharp backend and enabling the WS_EX_NOREDIRECTIONBITMAP long in the window styles, while still maintaining compatibility with things like per pixel transparency and mica.

The problem:

For that I thought of using DirectComposition in combination with a DX11 device as a backend for SkiaSharp, which is officially supported in the latest version.

That all only works in theory though. I've been trying using Vortice to create a DX11 device and a Swapchain with alpha channel, which I then can later use for SkiaSharp. When trying that, SkiaSharp gave me a SEHException.

This stuff is, at least in my opinion, heavily under-documented and probably not intended for such specific use cases, however I can not sleep at night and know there must be a solution to this.
I've also tried Angle, same issues. OpenGL is no option as it does not like rendering directly to windows with per pixel alpha (at least I believe so). And Vulkan I think would not like that as well.

I've also attached the code that I've partially written myself. The DirectCompositionContext is mostly copied from the Vortice samples, but I got that to work without throwing errors and outputting (at least I think so) proper handles.
The only thing that I did get working was using DirectX as a backend for SkiaSharp but leaving out the features I need and also swapping the buffers manually to the window using the CPU (which eliminates the reason for GPU accel in the first place)

Also, another note: Sorry if this question sounds absolutely stupid or if I'm simply missing something, but I've been stuck so long on this and just want to get it over with.
DXCC.cs12.75KB
SDXCC.cs1.35KB
Was this page helpful?