-
Notifications
You must be signed in to change notification settings - Fork 343
Support older wlr_linux_dmabuf_v1 clients #1304
Conversation
render/egl.c
Outdated
DRM_FORMAT_ARGB8888, | ||
DRM_FORMAT_XRGB8888, | ||
}; | ||
static unsigned num = 2; |
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.
This can be sizeof(fallback_formats) / sizeof(fallback_formats[0])
render/egl.c
Outdated
} | ||
|
||
memcpy(*formats, fallback_formats, num * sizeof(**formats)); | ||
return 2; |
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.
return num
types/wlr_linux_dmabuf_v1.c
Outdated
uint32_t modifier_lo = modifiers[j] & 0xFFFFFFFF; | ||
uint32_t modifier_hi = modifiers[j] >> 32; | ||
zwp_linux_dmabuf_v1_send_modifier(resource, | ||
formats[i], |
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.
Style: don't align those, indenting them is enough
types/wlr_linux_dmabuf_v1.c
Outdated
} else if (modifiers[j] == DRM_FORMAT_MOD_LINEAR || | ||
modifiers == &modifier_invalid) { | ||
zwp_linux_dmabuf_v1_send_format(resource, | ||
formats[i]); |
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.
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.
Thanks, should all be fixed now |
I tried to test but failed to run It fails to create XR24 buffers. |
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 |
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). |
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.
LGTM and works
Thanks! |
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.
If a client uses an older version of the dmabuf protocol, use the
formats
event instead ofmodifiers
(since that didn't exist in olderversions).
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.