Skip to content
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

zwp_linux_dmabuf_v1 protocol #318

Merged
merged 1 commit into from
Oct 5, 2023
Merged

zwp_linux_dmabuf_v1 protocol #318

merged 1 commit into from
Oct 5, 2023

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Nov 10, 2022

An implementation of this protocol is useful with the screencopy protocol.

The implementation here is incomplete, in particular the dmabuf feedback code. Only implementing version 3, without that makes this simpler, but presumably that mechanism is useful if complicated where supported by the compositor.

src/dmabuf.rs Outdated Show resolved Hide resolved
@ids1024 ids1024 force-pushed the dmabuf branch 6 times, most recently from 88d9e21 to cd7e7f5 Compare November 15, 2022 22:17
@ids1024 ids1024 marked this pull request as ready for review November 15, 2022 22:25
@ids1024
Copy link
Member Author

ids1024 commented Nov 15, 2022

Okay, this should be pretty complete now. I've made it require version 3, since that's what Mesa currently requires. It expects the application to handle both version 3 and 4.

@ids1024
Copy link
Member Author

ids1024 commented Nov 17, 2022

Oh I guess this should in some way handle wl_buffer::Release for dma_buf buffers? Not sure exactly how that would best be exposed. If further abstractions aren't added that could be another method on the handler trait.

@ids1024
Copy link
Member Author

ids1024 commented Jan 12, 2023

Actually it might make sense to just take a generic udata like RawPool::create_buffer, and not provide a Dispatch implementation for the WlBuffer. But that's not easily possible with the way the Created event works.

I guess the data could be stored with the ZwpLinuxBufferParamsV1, but I don't know if that could be accessed from within event_created_child!.

@ids1024
Copy link
Member Author

ids1024 commented Jan 12, 2023

Added a DmabufHandler::released() method, and some more documentation.

@ids1024
Copy link
Member Author

ids1024 commented Jan 12, 2023

I'm generally happy with the API here now, or in any case can't think of ways to improve it.

///
/// In version `4`, it is a protocol error if `format`/`modifier` pair wasn't
/// advertised as supported.
pub fn add(&self, fd: BorrowedFd<'_>, plane_idx: u32, offset: u32, stride: u32, modifier: u64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brings up a question. Should Smithay's Dmabuf type be put into another crate to allow both Smithay and sctk to have a DmabufBuilder and the Weak/Strong dmabuf types?

Although if we do that, Smithay's current use of dmabuf is very graphics api dependent (remember a dmabuf is just a memory object that is given meaning by a format, stride, plane count and modifiers).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we could get rid of the DmabufParams type and have create and create_immed methods of DmabufState that take a Dmabuf. This could be useful in some cases. Though maybe not most.

These functions would still have to deal with the protocol error if the format/modifier wasn't advertised.

Normally on the client-side this is handled by Mesa, but an
implementation is necessary for using screencopy, for instance.

This required at least version 3, which seems reasonable since that is
the same version Mesa currently requires. Applications using this will
need to handle both version 3 and version 4.
Copy link
Member

@i509VCB i509VCB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smithay dmabuf stuff can probably happen later.

Otherwise this looks good (and I actually find I need it as well)

@wash2 wash2 merged commit bf7d667 into Smithay:master Oct 5, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants