cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.84k stars 2.92k forks source link

Feature Request - WPF Add DirectX Accelerated rendering #2770

Open amaitland opened 5 years ago

amaitland commented 5 years ago

Now that #2527 has been implemented we should look at adding DirectX Accelerated rendering to the WPF implementation.

This will likely be disabled by default initially and depending on the additional libraries/dependencies required might be a Nuget package of its own.

WPF is DirectX 9 and the CEF OnAcceleratedPaint implementation is DirectX 11 only. Microsoft provide some D3D11 examples at https://github.com/Microsoft/WPFDXInterop thought they haven't been updated in years.

I personally have no experience with DirectX so I'm looking for volunteers to help out.

Please only comment if you are interested and capable of helping, there is currently no set time frame for this.

amaitland commented 5 years ago

Chromium changes are likely to break OnAcceleratedPaint in the near future, see https://bitbucket.org/chromiumembedded/cef/issues/2575/viz-implementation-for-osr for details

Ratcha9 commented 5 years ago

I don't get it. Is viz compatible with direct x? Hope they will reimplement shared textures...

alphamax commented 5 years ago

Hello,

I get onboard a bit late but I keep an eye on this subject. I tried to make OnAcceleratedPaint called on the abstract Render handler and it does not work. I properly sent "shared-texture-enabled", "1" in the command line and windowInfo.SharedTextureEnabled = true; on CreateOffscreenBrowserWindowInfo.

(PS, I have one of the latest master version)

Any idea on what I am failing?

Once this part called, I think I may succeed in filling the gap.

Thanks, Regards,

amaitland commented 5 years ago

I properly sent "shared-texture-enabled", "1"

Pretty sure that's only for testing with cefclient.

windowInfo.SharedTextureEnabled = true; on CreateOffscreenBrowserWindowInfo.

Please post the code you've used.

(PS, I have one of the latest master version)

If you are going to reference master then please provide a link to the commit you've used. I merged a huge number of changes just two days ago, maybe your using an older build?

alphamax commented 5 years ago

Thanks for your quick response. I have tested with the latest version of today => this commit The code you requested is:

    protected virtual IWindowInfo CreateOffscreenBrowserWindowInfo(IntPtr handle)
    {
        var windowInfo = new WindowInfo();
        windowInfo.SetAsWindowless(handle);
        windowInfo.SharedTextureEnabled = true;
        return windowInfo;
    }

I do not break either inside RenderClientAdapter.h > OnAcceleratedPaint. Maybe I have missed something to go through AcceleratedPaint.

Thanks,

amaitland commented 5 years ago

A very quick test and OnAcceleratedPaint is called as expected with https://github.com/cefsharp/CefSharp/commit/f77c6d2cb404694a2598e905bad6af110e4fdb5f

Double check your debugger is set correctly, try attaching to the managed c# implementation.

amaitland commented 5 years ago

OnAcceleratedPaint no longer works as it's been temp removed from CEF, see https://bitbucket.org/chromiumembedded/cef/issues/2575/viz-implementation-for-osr#comment-53013860

alphamax commented 5 years ago

Noticed 😭

kkwpsv commented 4 years ago

Now, I have made OnAcceleratedPaint basically work with CEF 73. But OnAcceleratedPaint was broken with newer CEF . If OnAcceleratedPaint would be fixed later without too many changes, I'll make a pr for this.

The performance of OnAcceleratedPaint is better than OnPaint, but it doesn't seem to be as good as native CEF.

amaitland commented 4 years ago

There is a PR to re-implement the feature in CEF. Subscribe to https://bitbucket.org/chromiumembedded/cef/pull-requests/285 to keep updated with the latest.

alphamax commented 4 years ago

Ok, perfect, I'll follow it ! Thanks for the update !

xmine64 commented 1 year ago

Is OnAcceleratedPaint working in the latest version, or something is wrong in my implementation? I have enabled shared texture but still OnPaint is getting called instead of OnAcceleratedPaint.

xmine64 commented 1 year ago

OK I could run cef-mixer with latest chromium, despite it's upside-down but still it's working. There should be something wrong in my code.

image

image
witcher112 commented 5 months ago

It looks like OnAcceleratedPaint just landed on Chromium 124

https://chromium-review.googlesource.com/c/chromium/src/+/5265077

Do I assume correctly that once CefSharp 124 is there OnAcceleratedPaint is going to work again?

amaitland commented 5 months ago

Do I assume correctly that once CefSharp 124 is there OnAcceleratedPaint is going to work again?

No.

CEF still needs to re-add support.

Updated PR https://bitbucket.org/chromiumembedded/cef/pull-requests/734

amaitland commented 5 months ago

Looks like CEF has merged the changes and they should be in the M124 branch with commit https://bitbucket.org/chromiumembedded/cef/commits/77c1e82898a7f46164e0b997431318bcf9743592

The API has changed, so will need someone to map the CefAcceleratedPaintInfo structure