summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorValentine Burley <valentine.burley@gmail.com>2024-08-26 11:36:51 +0000
committerEric Engestrom <eric@engestrom.ch>2024-08-27 09:08:25 +0200
commit6acc836b911bb14b952a58efd2f05cb93de9844d (patch)
tree83922cf649e6eb89d3f3946fb451670318b43ed7 /src/gallium
parent5eb0a7d8095aab6139c79fb7ae0b8587e5abaf43 (diff)
llvmpipe: Only use udmabuf with libdrm
It's possible to have the linux/udmabuf.h header but not libdrm in some setups, like under Termux. Fixes: 112063a060e ("llvmpipe: Only use udmabuf if header is found") Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Lucas Fryzek <lfryzek@igalia.com> Signed-off-by: Valentine Burley <valentine.burley@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30853> (cherry picked from commit 4cfaf10c10598ff705af988d8261fb8fcffb5c59)
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.c6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c24
2 files changed, 15 insertions, 15 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 7daa5319a12..9f803d7f59c 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -123,12 +123,12 @@ llvmpipe_get_name(struct pipe_screen *screen)
static int
llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
{
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
struct llvmpipe_screen *lscreen = llvmpipe_screen(screen);
#endif
switch (param) {
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
case PIPE_CAP_DMABUF:
if (lscreen->udmabuf_fd != -1)
return DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT;
@@ -1173,7 +1173,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
screen->num_threads);
screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
screen->udmabuf_fd = open("/dev/udmabuf", O_RDWR);
#endif
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 2aab5bfb20d..f8797bb394c 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -63,7 +63,7 @@
#include "drm-uapi/drm_fourcc.h"
#endif
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
@@ -303,7 +303,7 @@ llvmpipe_resource_create_all(struct pipe_screen *_screen,
pipe_reference_init(&lpr->base.reference, 1);
lpr->base.screen = &screen->base;
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
lpr->dmabuf_alloc = NULL;
#endif
@@ -410,7 +410,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
return llvmpipe_resource_create_front(_screen, templat, NULL);
}
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
static struct pipe_resource *
llvmpipe_resource_create_with_modifiers(struct pipe_screen *_screen,
const struct pipe_resource *templat,
@@ -566,7 +566,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
}
}
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
if (lpr->dmabuf_alloc)
pscreen->free_memory_fd(pscreen, (struct pipe_memory_allocation*)lpr->dmabuf_alloc);
#endif
@@ -730,7 +730,7 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
lpr->size_required = lpr->sample_stride;
if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
struct llvmpipe_memory_allocation *alloc;
uint64_t size;
/* Not all winsys implement displaytarget_create_mapped so we need to check
@@ -797,7 +797,7 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
struct sw_winsys *winsys = screen->winsys;
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
if (!lpr->dmabuf_alloc) {
lpr->dmabuf_alloc = (struct llvmpipe_memory_allocation*)_screen->allocate_memory_fd(_screen, lpr->size_required, (int*)&whandle->handle, true);
@@ -1345,7 +1345,7 @@ llvmpipe_free_memory(struct pipe_screen *pscreen,
}
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
static void*
llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
struct llvmpipe_memory_allocation *alloc,
@@ -1421,7 +1421,7 @@ llvmpipe_allocate_memory_fd(struct pipe_screen *pscreen,
alloc->mem_fd = -1;
alloc->dmabuf_fd = -1;
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
if (dmabuf) {
struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
alloc->type = LLVMPIPE_MEMORY_FD_TYPE_DMA_BUF;
@@ -1460,7 +1460,7 @@ llvmpipe_import_memory_fd(struct pipe_screen *screen,
struct llvmpipe_memory_allocation *alloc = CALLOC_STRUCT(llvmpipe_memory_allocation);
alloc->mem_fd = -1;
alloc->dmabuf_fd = -1;
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
if (dmabuf) {
off_t mmap_size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
@@ -1505,7 +1505,7 @@ llvmpipe_free_memory_fd(struct pipe_screen *screen,
if (alloc->type == LLVMPIPE_MEMORY_FD_TYPE_OPAQUE) {
os_free_fd(alloc->cpu_addr);
}
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
else {
munmap(alloc->cpu_addr, alloc->size);
if (alloc->dmabuf_fd >= 0)
@@ -1720,7 +1720,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
return false;
}
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
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)
{
@@ -1781,7 +1781,7 @@ llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
screen->import_memory_fd = llvmpipe_import_memory_fd;
screen->free_memory_fd = llvmpipe_free_memory_fd;
#endif
-#ifdef HAVE_LINUX_UDMABUF_H
+#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
screen->query_dmabuf_modifiers = llvmpipe_query_dmabuf_modifiers;
screen->is_dmabuf_modifier_supported = llvmpipe_is_dmabuf_modifier_supported;
screen->get_dmabuf_modifier_planes = llvmpipe_get_dmabuf_modifier_planes;