Closed Bug 1961723 Opened 11 months ago Closed 10 months ago

[HDR] Recycle wl_buffers if possible for direct composition

Categories

(Core :: Graphics: WebRender, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: stransky, Assigned: stransky)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

[HDR] Recycle wl_buffers if possible for video playback to save GPU cycles.

Flags: needinfo?(stransky)

Thanks for working on this issue. Here are the stacktraces which may related to firefox requesting compositor to create/delete wl_buffer on every video frame.
https://gist.github.com/alen6516/14fc0d0add2c926e0fe855836492d152

I think we may extend it to all dmabuf based wl_buffers used by native compositor.

Assignee: nobody → stransky
Status: NEW → ASSIGNED

If DMABufSurface are recycled we don't want to create/delete wl_buffer for recycled frames as it eats GPU/power resources.
Instead store wl_buffers for DMABuf surfaces and re-use them if possible.
The behaviour is inspired by MPV which does the same.

When recycled WaylandBuffer is detached/deleted, don't call wl_buffer_add_listener() as it throws protocol error but only update
WaylandBuffer reference by wl_proxy_set_user_data().

We want to recycle dmabuf surfaces and wl_buffers for decoded video frames so we need to make sure we always
use the same smabuf surface for particular ffmpeg frame.

Add mFFMPEGSurfaceID filed do VideoFrameSurface to keep track of assigned FFmpeg frame and also invalidate
all frames when video frames are flushed.

Add mHoldByFFmpeg wich ensured we don't reuse VideoFrameSurface untill is returned by genco rendering process
(with IsUsedByRenderer()).

Implement unified VideoFramePool<LIBAV_VER>::GetTargetVideoFrameSurface() method to get new VideoFrameSurface according to
requested configuration.

During seek FFmpeg may allocate new dmabuf frames so we need to remove ffmpeg ID's and allocate new surfaces.

WaylandBufferDMABUFHolder stores wl_buffer for external dmabuf surface and allows us to use existing wl_buffer for dmabuf surface instead of creating
a new one. That saves GPU resources and GPU power (MPV does the same).

In this patch add WaylandBufferDMABUFHolder to NativeLayerRootWayland and cache wl_buffers there for surfaces which can be recycled.

Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/06ec04c554f6 [Linux] Add DMABufSurface fields to allow cross process surface recycling r=emilio https://hg.mozilla.org/integration/autoland/rev/cff7e5dc3e0c [Linux] Add WaylandBufferDMABUFHolder class to cache wl_buffer and allow WaylandBufferDMABUF to set wl_buffer from external source r=emilio https://hg.mozilla.org/integration/autoland/rev/60eadd491fbd [Linux] Update WaylandSurface for recycled WaylandBuffers r=emilio https://hg.mozilla.org/integration/autoland/rev/9ea1e7698e4c [Linux] Rework FFmpegVideoFramePool to keep FFmpeg surface ID and DMABufSurface UID matched r=alwu https://hg.mozilla.org/integration/autoland/rev/ad4fbdad7b5e [Linux] Invalidate FFmpeg frames if video stream is sought r=alwu https://hg.mozilla.org/integration/autoland/rev/f62a9f8d52f0 [Linux] Use WaylandBufferDMABUFHolder at NativeLayerWayland to hold wl_buffers for external dmabuf surfaces r=lsalzman
QA Whiteboard: [qa-triage-done-c141/b140]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: