mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
render/allocator/gbm: add bo_flags arg to create function
This allows callers to opt out of SCANOUT, for instance.
This commit is contained in:
parent
bf75706555
commit
a245201dad
3 changed files with 10 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ struct wlr_gbm_allocator {
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
struct gbm_device *gbm_device;
|
struct gbm_device *gbm_device;
|
||||||
|
uint32_t bo_flags;
|
||||||
|
|
||||||
struct wl_list buffers; // wlr_gbm_buffer.link
|
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.
|
* Creates a new GBM allocator from a DRM FD.
|
||||||
*
|
*
|
||||||
|
* bo_flags is a bitfield of enum gbm_bo_flags.
|
||||||
|
*
|
||||||
* Takes ownership over the FD.
|
* 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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include "render/wlr_renderer.h"
|
#include "render/wlr_renderer.h"
|
||||||
|
|
||||||
#if WLR_HAS_GBM_ALLOCATOR
|
#if WLR_HAS_GBM_ALLOCATOR
|
||||||
|
#include <gbm.h>
|
||||||
#include "render/allocator/gbm.h"
|
#include "render/allocator/gbm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -109,7 +110,8 @@ struct wlr_allocator *allocator_autocreate_with_drm_fd(
|
||||||
if (gbm_fd < 0) {
|
if (gbm_fd < 0) {
|
||||||
return NULL;
|
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;
|
return alloc;
|
||||||
}
|
}
|
||||||
close(gbm_fd);
|
close(gbm_fd);
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc,
|
||||||
|
|
||||||
bool has_modifier = true;
|
bool has_modifier = true;
|
||||||
uint64_t fallback_modifier = DRM_FORMAT_MOD_INVALID;
|
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;
|
struct gbm_bo *bo;
|
||||||
#if HAVE_GBM_BO_CREATE_WITH_MODIFIERS2
|
#if HAVE_GBM_BO_CREATE_WITH_MODIFIERS2
|
||||||
bo = gbm_bo_create_with_modifiers2(gbm_device, width, height,
|
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;
|
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;
|
uint64_t cap;
|
||||||
if (drmGetCap(fd, DRM_CAP_PRIME, &cap) ||
|
if (drmGetCap(fd, DRM_CAP_PRIME, &cap) ||
|
||||||
!(cap & DRM_PRIME_CAP_EXPORT)) {
|
!(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);
|
wlr_allocator_init(&alloc->base, &allocator_impl, WLR_BUFFER_CAP_DMABUF);
|
||||||
|
|
||||||
alloc->fd = fd;
|
alloc->fd = fd;
|
||||||
|
alloc->bo_flags = bo_flags;
|
||||||
wl_list_init(&alloc->buffers);
|
wl_list_init(&alloc->buffers);
|
||||||
|
|
||||||
alloc->gbm_device = gbm_create_device(fd);
|
alloc->gbm_device = gbm_create_device(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue