-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]: dmabuf support #48
Conversation
Currently I use the strlcpy function from bsd as it is used in wayvnc. I'm not a huge fan, of using a string function not provided by the stdlibs of the os. If you have a preferred function to copy strings, I'm happy to use that. |
@emersion This build probably needs at least libdrm to build on alpine. Would it be possible to add that? |
5dd8a34
to
9fc7fe7
Compare
You can use strdup, which is nice and safe, and is available everywhere. As for libdrm, we had that dependency once upon a time and it should be fine to add. Just update the meson config and the .builds/*.yml files as needed. |
@danshick All right, thanks. |
src/screencast/screencast.c
Outdated
@@ -25,6 +25,7 @@ void xdpw_screencast_instance_init(struct xdpw_screencast_context *ctx, | |||
cast->framerate = out->framerate; | |||
cast->with_cursor = with_cursor; | |||
cast->refcount = 1; | |||
cast->type = XDPW_INSTANCE_SCP_SHM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this declaration is used to change between shm screencopy and dmabuf screencopy.
20ca6a1
to
09292f0
Compare
I found in the wlroots screencop-dmabuf.c example the option to create a linear dmabuf... which didn't work with pipewire (on intel). |
I realised, we messed up the difference between the modifier and the format. https://github.com/wayland-project/wayland-protocols/blob/master/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml#L144 |
Does this offer any advantage over screencopy alone? If this is just an experiment, that's fine, but I don't think it'll be merged.
Where did we mess this up? At the moment, the color format is being handled properly AFAIK. |
I guess not really. I don't know how to benchmark it to be sure, but it's more like a workaround for testing. I probably move it to another branch I guess?
The color format yes, but the modifier is not handled properly. |
The modifier is meaningless for traditional screencopy. It is always a linear frame. |
All this commit was missing was the Flag Will rebase this pr and add that flag ... |
One possible option to solve temporarily afaik would be to use the modifier format parameter to determine if a consumer uses mmap for dmabufs. If a client or pipewire (PW_FLAG_MAP_BUFFER) uses mmap, they should set the modifier to 0 (This has to be proposed to pipewire). In that case, we could just deliver MemPtr (if supported, but that should be the case every time), mapped by us. |
I think I need to recap. On the wlroots side, we have screencopy, screencopy-dmabuf, and export-dmabuf. In the memptr case (which I believe is what we do right now), we would be forced to continue using screencopy? Or am I misunderstanding memptr? Of course, if we see support for modifiers, we can supply a dmabuf fd from export-dmabuf (or screencopy-dmabuf, if we're concerned about a race condition). I guess what I'd like to understand is how the buffer types correspond with the various flags that can be set, and what the corresponding mapping behavior should be. |
Sure.
Pipewire:
If you want another buffer type PW_STREAM_FLAG_MAP_BUFFERS is not an option, you have to use PW_STREAM_FLAG_ALLOC_BUFFERS and do the buffer allocation on your own, that's where we need:
So long story short: Even if we use screencopy dmabuf, we can either create a linear buffer or one with a modifier. For now i only have seen clients either support full modifiers (obs, either wlrobs or obs-xdg-portal (currently merging a patch)), or none (which means mmaping dmabuf). In the none case i would guess, we would get better results, if we do the transition from dmabuf to shm and map the dmabuf with gbm and copy the content to shared memory. Tangent about changing wroots protocol on the fly: |
Do we know why pipewire is still offering to mmap dmabufs? Is there any case in which this is desirable? Also, doesn't the client have to opt-in to dmabuf buffers for negotiation purposes? Shouldn't the MAP_BUFFERS flag preclude the client from negotiating a dmabuf format successfully? (I'm only asking here because I know you've had more discussions with Wim on this than me)
Okay, this is the part I was most confused about. So a producer can claim MemFd with the ALLOC_BUFFERS flag, but there's no reason that a consumer couldn't then request MemPtr on its end and let pipewire do the mapping.
So if we were to use screencopy-dmabuf exclusively and used gbm to map it linearly, we would still have to call this a dmabuf buffer on the pipewire side, because even in linear, it still isn't kosher to mmap a dma-buf (without fencing?, I remember daniels mentioning this sowewhere).
I really think we need to discuss with Wim about some way to allow negotiation to involve a round trip. Right now, a producer cannot change much about what it offers if the client doesn't support renegotiation. It'd be great to be able to signal to pipewire (maybe inside of the param_changed callback) that we would like it to hint to the consumer to try a different pipewire node. We could set up a node for each protocol, start with best possible, and continually fall back until we can negotiate properly. This should be easy for consumers to implement too, it's just a retry, and consumers that don't listen to this hint could still fail like they do today, so it should also be backwards compatible. |
Because of #65 I looked into chromium screensharing, which didn't work for me. Still doesn't work with this patch. Reason seems to be https://github.com/emersion/xdg-desktop-portal-wlr/pull/48/files#diff-25e29cec459c41df3c682e4e3ed522d43aeda1c932c4b8e96d3910925e50fbf4R361 which stops the negotiation. |
Some discussion i had with danshick
|
This is obsolete by #152 |
This Draft is going to implement screen sharing via wlr-export-dmabuf-unstable-v1 #9.
The first step will be to move from the current shm implementation to a protocol agnostic one with different choosable protocols.
After that the above mentioned protocol will be added.
This Draft is currently to display and discuss the current progress and will not be compilable at every time.
It contains 3 or 4 steps marked by dependent branches: