diff --git a/include/render/allocator/gbm.h b/include/render/allocator/gbm.h index ea3e3243b..05c05dd3b 100644 --- a/include/render/allocator/gbm.h +++ b/include/render/allocator/gbm.h @@ -20,6 +20,7 @@ struct wlr_gbm_allocator { int fd; struct gbm_device *gbm_device; + uint32_t bo_flags; struct wl_list buffers; // wlr_gbm_buffer.link }; @@ -27,8 +28,10 @@ struct wlr_gbm_allocator { /** * Creates a new GBM allocator from a DRM FD. * + * bo_flags is a bitfield of enum gbm_bo_flags. + * * Takes ownership over the FD. */ -struct wlr_allocator *wlr_gbm_allocator_create_with_drm_fd(int drm_fd); +struct wlr_allocator *wlr_gbm_allocator_create_with_drm_fd(int drm_fd, uint32_t bo_flags); #endif diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index ff31fb7e8..092db3296 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -16,6 +16,7 @@ #include "render/wlr_renderer.h" #if WLR_HAS_GBM_ALLOCATOR +#include #include "render/allocator/gbm.h" #endif @@ -109,7 +110,8 @@ struct wlr_allocator *allocator_autocreate_with_drm_fd( if (gbm_fd < 0) { return NULL; } - if ((alloc = wlr_gbm_allocator_create_with_drm_fd(gbm_fd)) != NULL) { + uint32_t bo_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; + if ((alloc = wlr_gbm_allocator_create_with_drm_fd(gbm_fd, bo_flags)) != NULL) { return alloc; } close(gbm_fd); diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c index 9c9dc75c6..51b87e9ae 100644 --- a/render/allocator/gbm.c +++ b/render/allocator/gbm.c @@ -97,7 +97,7 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc, bool has_modifier = true; uint64_t fallback_modifier = DRM_FORMAT_MOD_INVALID; - uint32_t flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; + uint32_t flags = alloc->bo_flags; struct gbm_bo *bo; #if HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 bo = gbm_bo_create_with_modifiers2(gbm_device, width, height, @@ -192,7 +192,7 @@ static struct wlr_gbm_allocator *get_gbm_alloc_from_alloc( return alloc; } -struct wlr_allocator *wlr_gbm_allocator_create_with_drm_fd(int fd) { +struct wlr_allocator *wlr_gbm_allocator_create_with_drm_fd(int fd, uint32_t bo_flags) { uint64_t cap; if (drmGetCap(fd, DRM_CAP_PRIME, &cap) || !(cap & DRM_PRIME_CAP_EXPORT)) { @@ -207,6 +207,7 @@ struct wlr_allocator *wlr_gbm_allocator_create_with_drm_fd(int fd) { wlr_allocator_init(&alloc->base, &allocator_impl, WLR_BUFFER_CAP_DMABUF); alloc->fd = fd; + alloc->bo_flags = bo_flags; wl_list_init(&alloc->buffers); alloc->gbm_device = gbm_create_device(fd);