CEF offscreen rendering with shared textures using skia

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Sun Jan 28, 2024 3:12 am

Why not create a mojo like FrameSinkVideoConsumerStub and name it FrameSinkTextureConsumerStub, and use the same design structure? The final texture is encoded into video anyway.
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby cybersight » Mon Jan 29, 2024 11:48 am

Could Dawn / WebGPU help at all with this?
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Tue Jan 30, 2024 8:00 am

Update: I'm goint to implement a method that supports macOS (via IOSurface) and Windows (via DXGI) using GMB buffers. My idea is implement another FrameSink that is dedicated to pop copyable resource up to the CEF layer, in parallel with existing VideoCapture method
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Fri Feb 02, 2024 12:18 pm

Update: I managed to pass the DXGI handle out. I'm working on the patch now. The codebase of chromium changes a lot in viz::service.
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Sat Feb 03, 2024 1:36 am

It turns out the existing VideoCapturer can finish this job already. We just need to patch the RenderableGpuMemoryBufferVideoFramePoolImpl to support ARGB NativeTexture so that the GMB on Windows will use BufferFactoryDXGI as backend and it also has SHARED_KEYEDMUTEX | NTHANDLE attribute already.
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Sat Feb 03, 2024 1:40 am

So after investigation the minimum patch will be:

video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB);
video_capturer_->Start(this, viz::mojom::BufferFormatPreference::kDefault);
changes to
video_capturer_->Start(this, viz::mojom::BufferFormatPreference::kPreferGpuMemoryBuffer);

and at the other side if the format is ARGB and preferGpuMemoryBuffer, we pass out the DXGI handle.
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Sat Feb 03, 2024 9:46 am

I finished the implementation.

I also create a CL to chromium: https://chromium-review.googlesource.co ... /+/5265077
(But I got no hope it will get merged)

There're also some changes to the CEF: https://bitbucket.org/reitovovo/cef/src/master-osr/

My test shows it runs like expected.
Last edited by reito on Sat Feb 03, 2024 10:24 am, edited 1 time in total.
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby magreenblatt » Sat Feb 03, 2024 10:23 am

It looks like you linked the Chromium changes twice. What is the correct URL for the CEF changes?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF offscreen rendering with shared textures using skia

Postby reito » Sat Feb 03, 2024 10:25 am

magreenblatt wrote:It looks like you linked the Chromium changes twice. What is the correct URL for the CEF changes?


Sorry, link updated.

Also, this method could be easily port to macOS because on mac the backing factory use IOSurface. We only need to add some mac specific code at CEF (OnFrameCaptured) handler
reito
Techie
 
Posts: 18
Joined: Sat Jan 27, 2024 11:19 pm

Re: CEF offscreen rendering with shared textures using skia

Postby magreenblatt » Sat Feb 03, 2024 10:36 am

Thanks, looks like the specific CEF commit is https://bitbucket.org/reitovovo/cef/com ... 570dba346e
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

PreviousNext

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 183 guests