render/allocator: store shadow buffer preference in wlr_drm_dumb_allocator

This commit is contained in:
Simon Zeni 2023-11-03 15:42:43 -04:00
parent b8d36a9499
commit 2c1f23096c
2 changed files with 9 additions and 0 deletions

View file

@ -25,6 +25,7 @@ struct wlr_drm_dumb_allocator {
struct wlr_allocator base; struct wlr_allocator base;
struct wl_list buffers; // wlr_drm_dumb_buffer.link struct wl_list buffers; // wlr_drm_dumb_buffer.link
int drm_fd; int drm_fd;
bool prefer_shadow;
}; };
/** /**

View file

@ -97,6 +97,7 @@ static struct wlr_drm_dumb_buffer *create_buffer(
.height = buffer->height, .height = buffer->height,
.format = format->format, .format = format->format,
.modifier = DRM_FORMAT_MOD_LINEAR, .modifier = DRM_FORMAT_MOD_LINEAR,
.prefer_shadow = alloc->prefer_shadow,
.n_planes = 1, .n_planes = 1,
.offset[0] = 0, .offset[0] = 0,
.stride[0] = buffer->stride, .stride[0] = buffer->stride,
@ -216,6 +217,12 @@ struct wlr_allocator *wlr_drm_dumb_allocator_create(int drm_fd) {
return NULL; return NULL;
} }
uint64_t prefer_shadow;
if (drmGetCap(drm_fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) < 0) {
wlr_log(WLR_ERROR, "Failed to get DRM capabilities");
return NULL;
}
struct wlr_drm_dumb_allocator *alloc = calloc(1, sizeof(*alloc)); struct wlr_drm_dumb_allocator *alloc = calloc(1, sizeof(*alloc));
if (alloc == NULL) { if (alloc == NULL) {
return NULL; return NULL;
@ -224,6 +231,7 @@ struct wlr_allocator *wlr_drm_dumb_allocator_create(int drm_fd) {
WLR_BUFFER_CAP_DATA_PTR | WLR_BUFFER_CAP_DMABUF); WLR_BUFFER_CAP_DATA_PTR | WLR_BUFFER_CAP_DMABUF);
alloc->drm_fd = drm_fd; alloc->drm_fd = drm_fd;
alloc->prefer_shadow = prefer_shadow;
wl_list_init(&alloc->buffers); wl_list_init(&alloc->buffers);
wlr_log(WLR_DEBUG, "Created DRM dumb allocator"); wlr_log(WLR_DEBUG, "Created DRM dumb allocator");