changeset 7251:e3bf1ceb1511 default tip @

Mesa 3D: Fix building for Linux without libdrm. * src/mesa-1-libdrm.patch: Add new patch. * dist-files.mk: Add new file to list.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 12 Jun 2024 20:54:42 +0200
parents ce6bd65c37c6
children
files dist-files.mk src/mesa-1-libdrm.patch
diffstat 2 files changed, 132 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dist-files.mk	Mon Jun 10 10:08:59 2024 -0400
+++ b/dist-files.mk	Wed Jun 12 20:54:42 2024 +0200
@@ -334,6 +334,7 @@
   matio.mk \
   mdbtools.mk \
   mesa-proto.mk \
+  mesa-1-libdrm.patch \
   mesa.mk \
   mingw-blas-1-xerbla.patch \
   mingw-cairo-1-ssize-t-defined.patch \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesa-1-libdrm.patch	Wed Jun 12 20:54:42 2024 +0200
@@ -0,0 +1,131 @@
+Use udmabuf only with libdrm
+
+diff -urN mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_screen.c.orig mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_screen.c
+--- mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_screen.c.orig	2024-06-05 21:01:42.000000000 +0200
++++ mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_screen.c	2024-06-12 20:34:04.481383250 +0200
+@@ -122,12 +122,12 @@
+ 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;
+@@ -1158,7 +1158,7 @@
+                                               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 -urN mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_texture.c.orig mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_texture.c
+--- mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_texture.c.orig	2024-06-05 21:01:42.000000000 +0200
++++ mesa-24.1.1/src/gallium/drivers/llvmpipe/lp_texture.c	2024-06-12 20:41:09.292520240 +0200
+@@ -263,7 +263,7 @@
+    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
+ 
+@@ -351,7 +351,7 @@
+    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,
+@@ -507,7 +507,7 @@
+       }
+    }
+ 
+-#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
+@@ -661,7 +661,7 @@
+ 
+    if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
+       void *data;
+-#ifdef HAVE_LINUX_UDMABUF_H
++#if defined (HAVE_LIBDRM) && defined (HAVE_LINUX_UDMABUF_H)
+       struct llvmpipe_memory_fd_alloc *alloc;
+       uint64_t size;
+       if(_screen->import_memory_fd(_screen, whandle->handle, (struct pipe_memory_allocation**)&alloc, &size, true)) {
+@@ -730,7 +730,7 @@
+    struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
+ 
+    whandle->stride = lpr->row_stride[0];
+-#ifdef HAVE_LINUX_UDMABUF_H
++#if defined (HAVE_LIBDRM) && defined (HAVE_LINUX_UDMABUF_H)
+    whandle->modifier = DRM_FORMAT_MOD_LINEAR;
+    if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
+       if (!lpr->dmabuf_alloc) {
+@@ -1112,7 +1112,7 @@
+ }
+ 
+ 
+-#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_fd_alloc *alloc,
+@@ -1188,7 +1188,7 @@
+ 
+    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;
+@@ -1227,7 +1227,7 @@
+    struct llvmpipe_memory_fd_alloc *alloc = CALLOC_STRUCT(llvmpipe_memory_fd_alloc);
+    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);
+@@ -1272,7 +1272,7 @@
+    if (alloc->type == LLVMPIPE_MEMORY_FD_TYPE_OPAQUE) {
+       os_free_fd(alloc->data);
+    }
+-#ifdef HAVE_LINUX_UDMABUF_H
++#if defined (HAVE_LIBDRM) && defined (HAVE_LINUX_UDMABUF_H)
+    else {
+       munmap(alloc->data, alloc->size);
+       if (alloc->dmabuf_fd >= 0)
+@@ -1444,7 +1444,7 @@
+    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)
+ {
+@@ -1505,7 +1505,7 @@
+    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;