render: add DRM dumb buffer allocator

This commit is contained in:
Simon Zeni 2021-01-27 22:10:59 -05:00 committed by Simon Ser
parent 2c90e0f521
commit ed7f2651b6
4 changed files with 286 additions and 1 deletions

View file

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <stdlib.h>
#include <wlr/util/log.h>
@ -7,6 +6,7 @@
#include "render/allocator.h"
#include "render/gbm_allocator.h"
#include "render/shm_allocator.h"
#include "render/drm_dumb_allocator.h"
#include "render/wlr_renderer.h"
#include "types/wlr_buffer.h"
@ -43,6 +43,16 @@ struct wlr_allocator *allocator_autocreate_with_drm_fd(
wlr_log(WLR_DEBUG, "Failed to create shm allocator");
}
uint32_t drm_caps = WLR_BUFFER_CAP_DMABUF | WLR_BUFFER_CAP_DATA_PTR;
if ((backend_caps & drm_caps) && (renderer_caps & drm_caps)
&& drm_fd != -1) {
wlr_log(WLR_DEBUG, "Trying to create drm dumb allocator");
if ((alloc = wlr_drm_dumb_allocator_create(drm_fd)) != NULL) {
return alloc;
}
wlr_log(WLR_DEBUG, "Failed to create drm dumb allocator");
}
wlr_log(WLR_ERROR, "Failed to create allocator");
return NULL;
}