Support external textures in OSR mode - revisted (issue #1006)

#158 · Created  · Last updated

Declined pull request

This PR has been manually merged in master revisions 713eebc and 1e6b870 with minor style and documentation fixes.

Closed by: ·2018-09-27


Similar to pull request 144 with a few key differences:

  • Modify CEF to not render to the hidden window - this will cause Chromium to use an off-screen gl FBO vs. the default frame buffer for the native window. Chromium already contains code to render with acceleration off-screen - we just need to modify CEF to use it.

  • Modify Chromium to use a shared texture directly for the offscreen FBO. The color attachment for the FBO will be a gl texture that is mapped to a D3D11 shared texture.

  • Chromium will be responsible for creating the D3D11 shared texture and only associate it with a pbuffer (required for interop) one time.

  • When the off-screen FBO is used, CEF will perform no timing - it simply notifies the client that a frame was rendered.

This pull request still uses much of the ExternalTextureManager code originally created by @irichardsnv . However, the key difference is there is no separate copy frame request issued by CEF since the off-screen FBO is already directly using the shared texture. Also, the AcquireSync and ReleaseSync were broken up into separate commands since we only associate the shared texture to a pbuffer once.

The changes to CEF include a new method added to the RenderHandler - OnAcceleratedPaint. Applications can enable accelerated OSR with the following options on CefWindowInfo:

CefWindowInfo info; info.windowless_rendering_enabled = true; info.shared_texture_enabled = true;

This will tell CEF to use the OffscreenBrowserCompositorSurface in Chromium rather than the default window based output. CEF will then call OnAcceleratedPaint directly when a frame is ready vs. trying to setup a copy frame request. The CefCopyFrameGenerator is not used at all.

Client applications can use the command-line switch disable-gpu-vsync to have Chromium perform unthrottled rendering. Any required throttling for timing can be performed by the client application in the new OnAcceleratedPaint handler.

This PR also supports the ability to issue BeginFrame requests directly to Chromium with the following option:

CefWindowInfo info; info.windowless_rendering_enabled = true; info.shared_texture_enabled = true; info.external_begin_frame_enabled = true;

If external_begin_frame_enabled is set to true, then your application is required to issue a call to SendExternalBeginFrame at the desired interval.

Here is a sample application using the new OnAcceleratedPaint handler to efficiently render a HTML view off-screen and then combine it with other D3D11 layers.

0 attachments

Loading commits...