mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 22:30:12 +01:00
llvmpipe: Only use udmabuf if header is found
Fixes #11032 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28810>
This commit is contained in:
parent
053b5f3e0c
commit
112063a060
3 changed files with 16 additions and 16 deletions
|
|
@ -1373,7 +1373,7 @@ if not ['linux'].contains(host_machine.system())
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
|
foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
|
||||||
'cet.h', 'pthread_np.h', 'renderdoc_app.h', 'sys/inotify.h']
|
'cet.h', 'pthread_np.h', 'renderdoc_app.h', 'sys/inotify.h', 'linux/udmabuf.h']
|
||||||
if cc.check_header(h)
|
if cc.check_header(h)
|
||||||
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
|
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -122,12 +122,12 @@ llvmpipe_get_name(struct pipe_screen *screen)
|
||||||
static int
|
static int
|
||||||
llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
|
llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
struct llvmpipe_screen *lscreen = llvmpipe_screen(screen);
|
struct llvmpipe_screen *lscreen = llvmpipe_screen(screen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (param) {
|
switch (param) {
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
case PIPE_CAP_DMABUF:
|
case PIPE_CAP_DMABUF:
|
||||||
if (lscreen->udmabuf_fd != -1)
|
if (lscreen->udmabuf_fd != -1)
|
||||||
return DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT;
|
return DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT;
|
||||||
|
|
@ -1158,7 +1158,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
|
||||||
screen->num_threads);
|
screen->num_threads);
|
||||||
screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
|
screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
screen->udmabuf_fd = open("/dev/udmabuf", O_RDWR);
|
screen->udmabuf_fd = open("/dev/udmabuf", O_RDWR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
#include "drm-uapi/drm_fourcc.h"
|
#include "drm-uapi/drm_fourcc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
@ -263,7 +263,7 @@ llvmpipe_resource_create_all(struct pipe_screen *_screen,
|
||||||
pipe_reference_init(&lpr->base.reference, 1);
|
pipe_reference_init(&lpr->base.reference, 1);
|
||||||
lpr->base.screen = &screen->base;
|
lpr->base.screen = &screen->base;
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
lpr->dmabuf_alloc = NULL;
|
lpr->dmabuf_alloc = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -351,7 +351,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
|
||||||
return llvmpipe_resource_create_front(_screen, templat, NULL);
|
return llvmpipe_resource_create_front(_screen, templat, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
static struct pipe_resource *
|
static struct pipe_resource *
|
||||||
llvmpipe_resource_create_with_modifiers(struct pipe_screen *_screen,
|
llvmpipe_resource_create_with_modifiers(struct pipe_screen *_screen,
|
||||||
const struct pipe_resource *templat,
|
const struct pipe_resource *templat,
|
||||||
|
|
@ -507,7 +507,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
if (lpr->dmabuf_alloc)
|
if (lpr->dmabuf_alloc)
|
||||||
pscreen->free_memory_fd(pscreen, (struct pipe_memory_allocation*)lpr->dmabuf_alloc);
|
pscreen->free_memory_fd(pscreen, (struct pipe_memory_allocation*)lpr->dmabuf_alloc);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -661,7 +661,7 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
|
||||||
|
|
||||||
if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
|
if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
|
||||||
void *data;
|
void *data;
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
struct llvmpipe_memory_fd_alloc *alloc;
|
struct llvmpipe_memory_fd_alloc *alloc;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
if(_screen->import_memory_fd(_screen, whandle->handle, (struct pipe_memory_allocation**)&alloc, &size, true)) {
|
if(_screen->import_memory_fd(_screen, whandle->handle, (struct pipe_memory_allocation**)&alloc, &size, true)) {
|
||||||
|
|
@ -730,7 +730,7 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
|
||||||
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
|
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
|
||||||
|
|
||||||
whandle->stride = lpr->row_stride[0];
|
whandle->stride = lpr->row_stride[0];
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
||||||
if (!lpr->dmabuf_alloc) {
|
if (!lpr->dmabuf_alloc) {
|
||||||
|
|
@ -1112,7 +1112,7 @@ llvmpipe_free_memory(struct pipe_screen *screen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
static void*
|
static void*
|
||||||
llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
|
llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
|
||||||
struct llvmpipe_memory_fd_alloc *alloc,
|
struct llvmpipe_memory_fd_alloc *alloc,
|
||||||
|
|
@ -1188,7 +1188,7 @@ llvmpipe_allocate_memory_fd(struct pipe_screen *pscreen,
|
||||||
|
|
||||||
alloc->mem_fd = -1;
|
alloc->mem_fd = -1;
|
||||||
alloc->dmabuf_fd = -1;
|
alloc->dmabuf_fd = -1;
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
if (dmabuf) {
|
if (dmabuf) {
|
||||||
struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
|
struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
|
||||||
alloc->type = LLVMPIPE_MEMORY_FD_TYPE_DMA_BUF;
|
alloc->type = LLVMPIPE_MEMORY_FD_TYPE_DMA_BUF;
|
||||||
|
|
@ -1227,7 +1227,7 @@ llvmpipe_import_memory_fd(struct pipe_screen *screen,
|
||||||
struct llvmpipe_memory_fd_alloc *alloc = CALLOC_STRUCT(llvmpipe_memory_fd_alloc);
|
struct llvmpipe_memory_fd_alloc *alloc = CALLOC_STRUCT(llvmpipe_memory_fd_alloc);
|
||||||
alloc->mem_fd = -1;
|
alloc->mem_fd = -1;
|
||||||
alloc->dmabuf_fd = -1;
|
alloc->dmabuf_fd = -1;
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
if (dmabuf) {
|
if (dmabuf) {
|
||||||
off_t mmap_size = lseek(fd, 0, SEEK_END);
|
off_t mmap_size = lseek(fd, 0, SEEK_END);
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
|
@ -1272,7 +1272,7 @@ llvmpipe_free_memory_fd(struct pipe_screen *screen,
|
||||||
if (alloc->type == LLVMPIPE_MEMORY_FD_TYPE_OPAQUE) {
|
if (alloc->type == LLVMPIPE_MEMORY_FD_TYPE_OPAQUE) {
|
||||||
os_free_fd(alloc->data);
|
os_free_fd(alloc->data);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
else {
|
else {
|
||||||
munmap(alloc->data, alloc->size);
|
munmap(alloc->data, alloc->size);
|
||||||
if (alloc->dmabuf_fd >= 0)
|
if (alloc->dmabuf_fd >= 0)
|
||||||
|
|
@ -1444,7 +1444,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
static void
|
static void
|
||||||
llvmpipe_query_dmabuf_modifiers(struct pipe_screen *pscreen, enum pipe_format format, int max, uint64_t *modifiers, unsigned int *external_only, int *count)
|
llvmpipe_query_dmabuf_modifiers(struct pipe_screen *pscreen, enum pipe_format format, int max, uint64_t *modifiers, unsigned int *external_only, int *count)
|
||||||
{
|
{
|
||||||
|
|
@ -1505,7 +1505,7 @@ llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
|
||||||
screen->import_memory_fd = llvmpipe_import_memory_fd;
|
screen->import_memory_fd = llvmpipe_import_memory_fd;
|
||||||
screen->free_memory_fd = llvmpipe_free_memory_fd;
|
screen->free_memory_fd = llvmpipe_free_memory_fd;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
screen->query_dmabuf_modifiers = llvmpipe_query_dmabuf_modifiers;
|
screen->query_dmabuf_modifiers = llvmpipe_query_dmabuf_modifiers;
|
||||||
screen->is_dmabuf_modifier_supported = llvmpipe_is_dmabuf_modifier_supported;
|
screen->is_dmabuf_modifier_supported = llvmpipe_is_dmabuf_modifier_supported;
|
||||||
screen->get_dmabuf_modifier_planes = llvmpipe_get_dmabuf_modifier_planes;
|
screen->get_dmabuf_modifier_planes = llvmpipe_get_dmabuf_modifier_planes;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue