render/allocator: add udmabuf allocator

udmabuf can create a DMA-BUF backed by a memfd. This is useful
when running with a software implementation of GL/Vulkan: the memfd
can be passed to the parent compositor via wl_shm and the DMA-BUF
can be imported via the usual APIs into GL/Vulkan.
This commit is contained in:
Simon Ser 2024-10-03 12:31:52 +02:00
parent 1c604207c6
commit 7cf8e80ffe
7 changed files with 209 additions and 3 deletions

View file

@ -1,6 +1,6 @@
allocators = get_option('allocators')
if 'auto' in allocators and get_option('auto_features').enabled()
allocators = ['gbm']
allocators = ['gbm', 'udmabuf']
elif 'auto' in allocators and get_option('auto_features').disabled()
allocators = []
endif
@ -23,3 +23,22 @@ if gbm.found()
has = cc.has_function('gbm_bo_get_fd_for_plane', dependencies: [gbm])
internal_config.set10('HAVE_GBM_BO_GET_FD_FOR_PLANE', has)
endif
udmabuf = false
if 'udmabuf' in allocators or 'auto' in allocators
args = ['-D_GNU_SOURCE']
prefix = [
'#include <sys/mman.h>',
'#include <fcntl.h>',
]
udmabuf = (cc.has_function('memfd_create', args: args, prefix: prefix) and
cc.has_define('F_ADD_SEALS', args: args, prefix: prefix) and
cc.has_header('linux/udmabuf.h'))
endif
if 'udmabuf' in allocators and not udmabuf
error('memfd_create(), F_ADD_SEALS and <linux/udmabuf.h> are required for the udmabuf allocator')
endif
if udmabuf
wlr_files += files('udmabuf.c')
features += { 'udmabuf-allocator': true }
endif