emersion / xdg-desktop-portal-wlr

xdg-desktop-portal backend for wlroots
MIT License
596 stars 59 forks source link

dmabuf support next generation #152

Closed columbarius closed 2 years ago

columbarius commented 3 years ago

This MR aims to implement screensharing with dmabufs with the new workflow using pipewire buffers.

NOTE: This is work in progress and will change frequently.

Depends: #141 Includes: #159 Supersedes #48 Resolves: #9

columbarius commented 3 years ago

@emersion do we want one global gbm_device, or do we want one for each screencast_instance (trying to use the same as the display)?

columbarius commented 3 years ago

All right, dmabuf screencasting with implicit modifiers seems to be working. Obs negotiates dmabuf sharing, chromium and the python screencast script negotiate shm copy. Firefox fails, because of a patch to the webrtc code, which looked at the time to be a good idea, but it wasn't. Will try to get it reverted.

columbarius commented 3 years ago

We can now read the supported format modifier pairs from wlroots and can allocate buffers with arbitrary modifiers (or at least the one pipewire chooses for now).

I added a force_mod_linear option to force implicit modifiers to always be linear, might be helpfull for clients, which mmap or debugging. The commit should be very easy to drop if we don't need/want that.

Note: this probably contains some errors in the last commits. I pushed it to test the format modifier pair selection.

columbarius commented 3 years ago

fixed the format handling.

columbarius commented 3 years ago

@emersion is there sth. i have to care wrt. multi gpu? like adding an option to force a specific device, or one device per screencast instance/output?

tinywrkb commented 3 years ago

https://github.com/flathub/org.chromium.Chromium/pull/135

columbarius commented 3 years ago

amazing! thx. for the note!

columbarius commented 3 years ago

Since gnome and kde currently only support implicit modifiers and most clients are aiming at that target, do we want to split this MR into one implementing implicit modifiers and a followup extending it to support explicit modifiers?

columbarius commented 3 years ago

Added support for multiplanar dmabufs.

We still need to wait for pipewire to let us fixate onto a modifier.

escalade commented 3 years ago

I played with this PR a bit for fun, seems to work well but I've run into a 100% cpu on the process sometimes. Since it's draft maybe you aren't interested in any testing for now, but let me know if you want me to produce some logs on the issue.

columbarius commented 3 years ago

@escalade Thanks for testing! The 100% cpu usage probably comes from us waiting for a new buffer from pipewire to become available.

Could you please report if you see a lot out of buffer lines in your log? Also I'm interesting what gpu you have and what modifiers you support. xdpw should print the list in the log on startup.

escalade commented 3 years ago

Yes indeed:

2021/08/14 10:45:08 [WARN] - pipewire: out of buffers 2021/08/14 10:45:08 [WARN] - wlroots: failed to dequeue buffer 2021/08/14 10:45:08 [WARN] - pipewire: out of buffers 2021/08/14 10:45:08 [WARN] - wlroots: failed to dequeue buffer 2021/08/14 10:45:08 [WARN] - pipewire: out of buffers

I'm using an Intel Iris Plus 655 GPU. Latest wlroots/sway git and xdpw + this PR. How do I check supported modifiers?

columbarius commented 3 years ago

Yes indeed:

2021/08/14 10:45:08 [WARN] - pipewire: out of buffers 2021/08/14 10:45:08 [WARN] - wlroots: failed to dequeue buffer 2021/08/14 10:45:08 [WARN] - pipewire: out of buffers 2021/08/14 10:45:08 [WARN] - wlroots: failed to dequeue buffer 2021/08/14 10:45:08 [WARN] - pipewire: out of buffers

I'm using an Intel Iris Plus 655 GPU. Latest wlroots/sway git and xdpw + this PR. How do I check supported modifiers?

When you start xdpw with loglevel TRACE, you should get some lines wlroots: format <format> (<modifier>) when starting.

columbarius commented 2 years ago

Updated and rebased onto #159