mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
render/allocator: use udmabuf allocator automatically
It makes sense to use udmabuf when the backend wants shm, the renderer wants DMA-BUFs, and we don't have a DRM FD because we're running with a software renderer (e.g. llvmpipe or lavapipe).
This commit is contained in:
parent
cfcf06b8b0
commit
9fdffba170
1 changed files with 18 additions and 0 deletions
|
|
@ -17,6 +17,10 @@
|
||||||
#include "render/allocator/gbm.h"
|
#include "render/allocator/gbm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if WLR_HAS_UDMABUF_ALLOCATOR
|
||||||
|
#include "render/allocator/udmabuf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void wlr_allocator_init(struct wlr_allocator *alloc,
|
void wlr_allocator_init(struct wlr_allocator *alloc,
|
||||||
const struct wlr_allocator_interface *impl, uint32_t buffer_caps) {
|
const struct wlr_allocator_interface *impl, uint32_t buffer_caps) {
|
||||||
assert(impl && impl->destroy && impl->create_buffer);
|
assert(impl && impl->destroy && impl->create_buffer);
|
||||||
|
|
@ -146,6 +150,20 @@ struct wlr_allocator *wlr_allocator_autocreate(struct wlr_backend *backend,
|
||||||
wlr_log(WLR_DEBUG, "Failed to create drm dumb allocator");
|
wlr_log(WLR_DEBUG, "Failed to create drm dumb allocator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t udmabuf_caps = WLR_BUFFER_CAP_DMABUF | WLR_BUFFER_CAP_SHM;
|
||||||
|
if ((backend_caps & udmabuf_caps) && (renderer_caps & udmabuf_caps) &&
|
||||||
|
drm_fd < 0) {
|
||||||
|
#if WLR_HAS_UDMABUF_ALLOCATOR
|
||||||
|
wlr_log(WLR_DEBUG, "Trying udmabuf allocator");
|
||||||
|
if ((alloc = wlr_udmabuf_allocator_create()) != NULL) {
|
||||||
|
return alloc;
|
||||||
|
}
|
||||||
|
wlr_log(WLR_DEBUG, "Failed to create udmabuf allocator");
|
||||||
|
#else
|
||||||
|
wlr_log(WLR_DEBUG, "Skipping udmabuf allocator: disabled at compile-time");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
wlr_log(WLR_ERROR, "Failed to create allocator");
|
wlr_log(WLR_ERROR, "Failed to create allocator");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue