Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Support older wlr_linux_dmabuf_v1 clients #1304

Merged
merged 1 commit into from
Oct 13, 2018
Merged

Conversation

nyorain
Copy link
Contributor

@nyorain nyorain commented Oct 12, 2018

If a client uses an older version of the dmabuf protocol, use the
formats event instead of modifiers (since that didn't exist in older
versions).
With a bit of necessary guessing, support dmabuf importing even when
EGL_EXT_image_dma_buf_import_modifiers isn't present instead of
failing up front.


Makes weston-simple-dmabuf-v4l work (at least with XR24 formats since the gl renderer does not support yuv). See the help manual of that program for information (loading the dummy vivid kernel module). Mainly useful to test dmabuf support (e.g. in renderers, think you can guess what i needed this for).

Note that the way we support older versions of the protocol is implemented different from weston: in weston, the modifier the client passes the compositor are simply ignored (see here) which may (theoretically?) cause problems later on i guess (reading garbage). We never ignore the modifier, but assume that without the modifiers egl extension it expects linear data (DRM_FORMAT_MOD_LINEAR).
Otherwise we implement roughly the same guessing that weston does when the egl modifiers extension is not present (note that this is still the case for amd drivers. Not sure if it will soon change since amd doesn't really seem to use public modifiers so we should really support this case as good as we can).

I guess @agx should have a look at this since it seems like he implemented the protocol in the first place.

render/egl.c Outdated
DRM_FORMAT_ARGB8888,
DRM_FORMAT_XRGB8888,
};
static unsigned num = 2;
Copy link
Member

Choose a reason for hiding this comment

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

This can be sizeof(fallback_formats) / sizeof(fallback_formats[0])

render/egl.c Outdated
}

memcpy(*formats, fallback_formats, num * sizeof(**formats));
return 2;
Copy link
Member

Choose a reason for hiding this comment

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

return num

render/egl.c Show resolved Hide resolved
uint32_t modifier_lo = modifiers[j] & 0xFFFFFFFF;
uint32_t modifier_hi = modifiers[j] >> 32;
zwp_linux_dmabuf_v1_send_modifier(resource,
formats[i],
Copy link
Member

Choose a reason for hiding this comment

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

Style: don't align those, indenting them is enough

} else if (modifiers[j] == DRM_FORMAT_MOD_LINEAR ||
modifiers == &modifier_invalid) {
zwp_linux_dmabuf_v1_send_format(resource,
formats[i]);
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

If a client uses an older version of the dmabuf protocol, use the
`formats` event instead of `modifiers` (since that didn't exist in older
versions).
With a bit of necessary guessing, support dmabuf importing even when
EGL_EXT_image_dma_buf_import_modifiers isn't present instead of
failing up front.
@nyorain
Copy link
Contributor Author

nyorain commented Oct 12, 2018

Thanks, should all be fixed now

@emersion
Copy link
Member

I tried to test but failed to run weston-simple-dmabuf-v4l. How did you test? (I think I'm missing a modprobe or something)

It fails to create XR24 buffers.

@nyorain
Copy link
Contributor Author

nyorain commented Oct 13, 2018

Unless you have a webcam or something (even if you do it probably won't work with gl since most can only use some kind of yuv buffers), you have to use modprobe the vivid kernel module which adds a dummy video output that can use XR24 buffers (you should see colored blocks with some information).

@nyorain
Copy link
Contributor Author

nyorain commented Oct 13, 2018

btw this does also work on master on platforms that implement the EGL_EXT_image_dma_buf_import_modifiers extension (but only since the weston client does not respect the advertised formats, otherwise it would need this patch. Sadly i know no correct older client to show this). But with this it should also work on platforms without the egl extension (everything amd at the moment).

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

LGTM and works

@ddevault ddevault merged commit e4a1560 into swaywm:master Oct 13, 2018
@ddevault
Copy link
Contributor

Thanks!

colemickens added a commit to colemickens/wlroots-eglstreams that referenced this pull request Oct 14, 2018
This PR broke a private nixpkgs definition I have for wlroots: swaywm#1304

It is fixed by changing `#include <drm_fourcc.h>` to `#include <libdrm/drm_fourcc.h>`, which follows what is already done in the dmabuf example.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants