Merge pull request #289051 from K900/mesa-24.0.1

mesa: 23.3.5 -> 24.0.1

authored by K900 and committed by GitHub 98c30519 8fcbe6ad

+52 -308
-56
pkgs/development/libraries/mesa/backports/0001-dri-added-build-dependencies-for-systems-using-non-s.patch
··· 1 - From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 - From: "duncan.hopkins" <duncan.hopkins@foundry.com> 3 - Date: Tue, 17 Oct 2023 09:34:31 +0100 4 - Subject: [PATCH] dri: added build dependencies for systems using non-standard 5 - prefixed X11 libs. 6 - 7 - To get MacOS to build, some extra dependencies need to be added to a couple of build targets. 8 - This mainly shows up when not installing the dependencies in the default prefix locations. 9 - On MacOS, this happens when using a custom build of brew to install the dependencies to 'odd' locations. 10 - 11 - Reviewed-by: Adam Jackson <ajax@redhat.com> 12 - Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25992> 13 - --- 14 - src/gallium/targets/dri/meson.build | 2 +- 15 - src/glx/meson.build | 2 +- 16 - src/loader/meson.build | 2 +- 17 - 3 files changed, 3 insertions(+), 3 deletions(-) 18 - 19 - diff --git a/src/gallium/targets/dri/meson.build b/src/gallium/targets/dri/meson.build 20 - index 66619bba0db..6d3ef197e74 100644 21 - --- a/src/gallium/targets/dri/meson.build 22 - +++ b/src/gallium/targets/dri/meson.build 23 - @@ -49,7 +49,7 @@ libgallium_dri = shared_library( 24 - link_depends : gallium_dri_link_depends, 25 - link_with : [ 26 - libdri, libmesa, libgalliumvl, 27 - - libgallium, libglapi, libpipe_loader_static, libws_null, libwsw, libswdri, 28 - + libgallium, libglapi, libloader, libpipe_loader_static, libws_null, libwsw, libswdri, 29 - libswkmsdri, 30 - ], 31 - dependencies : [ 32 - diff --git a/src/glx/meson.build b/src/glx/meson.build 33 - index 7ec3e3e0d88..1a5e9833956 100644 34 - --- a/src/glx/meson.build 35 - +++ b/src/glx/meson.build 36 - @@ -136,7 +136,7 @@ libglx = static_library( 37 - ], 38 - dependencies : [ 39 - idep_mesautil, idep_xmlconfig, 40 - - dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd, dep_xxf86vm, dep_xshmfence 41 - + dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_xext, dep_glvnd, dep_xxf86vm, dep_xshmfence 42 - ], 43 - ) 44 - 45 - diff --git a/src/loader/meson.build b/src/loader/meson.build 46 - index 35f9991ba2f..043cc852112 100644 47 - --- a/src/loader/meson.build 48 - +++ b/src/loader/meson.build 49 - @@ -47,6 +47,6 @@ libloader = static_library( 50 - c_args : loader_c_args, 51 - gnu_symbol_visibility : 'hidden', 52 - include_directories : [inc_include, inc_src, inc_util], 53 - - dependencies : [dep_libdrm, dep_thread, dep_xcb_xrandr], 54 - + dependencies : [dep_libdrm, dep_thread, dep_xcb, dep_xcb_xrandr], 55 - build_by_default : false, 56 - )
-103
pkgs/development/libraries/mesa/backports/0002-util-Update-util-libdrm.h-stubs-to-allow-loader.c-to.patch
··· 1 - From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 - From: "duncan.hopkins" <duncan.hopkins@foundry.com> 3 - Date: Tue, 17 Oct 2023 14:36:39 +0100 4 - Subject: [PATCH] util: Update util/libdrm.h stubs to allow loader.c to compile 5 - on MacOS. 6 - 7 - MacOS does not have the libdrm libraries so is missing xf86drm.h. 8 - util/libdrm.h already has a collection of stubs for systems that do not support the libraries. 9 - 10 - A compile on MacOS will fail with the source that uses newer drm functions and structures. 11 - Update adds in missing items that MacOS code needs to compile and run. 12 - New code is copied from the public repository: https://gitlab.freedesktop.org/mesa/drm/-/blob/main/xf86drm.h 13 - 14 - Reviewed-by: Adam Jackson <ajax@redhat.com> 15 - Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25992> 16 - --- 17 - src/util/libdrm.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 18 - 1 file changed, 57 insertions(+) 19 - 20 - diff --git a/src/util/libdrm.h b/src/util/libdrm.h 21 - index cc153cf88ab..e3af494b8d1 100644 22 - --- a/src/util/libdrm.h 23 - +++ b/src/util/libdrm.h 24 - @@ -44,22 +44,79 @@ 25 - #define DRM_BUS_PLATFORM 2 26 - #define DRM_BUS_HOST1X 3 27 - 28 - +typedef struct _drmPciDeviceInfo { 29 - + uint16_t vendor_id; 30 - + uint16_t device_id; 31 - + uint16_t subvendor_id; 32 - + uint16_t subdevice_id; 33 - + uint8_t revision_id; 34 - +} drmPciDeviceInfo, *drmPciDeviceInfoPtr; 35 - + 36 - +#define DRM_PLATFORM_DEVICE_NAME_LEN 512 37 - + 38 - +typedef struct _drmPlatformBusInfo { 39 - + char fullname[DRM_PLATFORM_DEVICE_NAME_LEN]; 40 - +} drmPlatformBusInfo, *drmPlatformBusInfoPtr; 41 - + 42 - +typedef struct _drmPlatformDeviceInfo { 43 - + char **compatible; /* NULL terminated list of compatible strings */ 44 - +} drmPlatformDeviceInfo, *drmPlatformDeviceInfoPtr; 45 - + 46 - +#define DRM_HOST1X_DEVICE_NAME_LEN 512 47 - + 48 - +typedef struct _drmHost1xBusInfo { 49 - + char fullname[DRM_HOST1X_DEVICE_NAME_LEN]; 50 - +} drmHost1xBusInfo, *drmHost1xBusInfoPtr; 51 - + 52 - +typedef struct _drmPciBusInfo { 53 - + uint16_t domain; 54 - + uint8_t bus; 55 - + uint8_t dev; 56 - + uint8_t func; 57 - +} drmPciBusInfo, *drmPciBusInfoPtr; 58 - + 59 - typedef struct _drmDevice { 60 - char **nodes; /* DRM_NODE_MAX sized array */ 61 - int available_nodes; /* DRM_NODE_* bitmask */ 62 - int bustype; 63 - + union { 64 - + drmPciBusInfoPtr pci; 65 - + drmPlatformBusInfoPtr platform; 66 - + drmHost1xBusInfoPtr host1x; 67 - + } businfo; 68 - + union { 69 - + drmPciDeviceInfoPtr pci; 70 - + } deviceinfo; 71 - /* ... */ 72 - } drmDevice, *drmDevicePtr; 73 - 74 - +static inline int 75 - +drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device) 76 - +{ 77 - + return -ENOENT; 78 - +} 79 - + 80 - static inline int 81 - drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices) 82 - { 83 - return -ENOENT; 84 - } 85 - 86 - +static inline int 87 - +drmGetDeviceFromDevId(dev_t dev_id, uint32_t flags, drmDevicePtr *device) 88 - +{ 89 - + return -ENOENT; 90 - +} 91 - + 92 - +static inline void 93 - +drmFreeDevice(drmDevicePtr *device) {} 94 - + 95 - static inline void 96 - drmFreeDevices(drmDevicePtr devices[], int count) {} 97 - 98 - +static inline char* 99 - +drmGetDeviceNameFromFd2(int fd) { return NULL;} 100 - + 101 - typedef struct _drmVersion { 102 - int version_major; /**< Major version */ 103 - int version_minor; /**< Minor version */
-53
pkgs/development/libraries/mesa/backports/0003-glx-fix-automatic-zink-fallback-loading-between-hw-a.patch
··· 1 - From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 - From: "duncan.hopkins" <duncan.hopkins@foundry.com> 3 - Date: Wed, 1 Nov 2023 11:31:13 +0000 4 - Subject: [PATCH] glx: fix automatic zink fallback loading between hw and sw 5 - drivers on MacOS 6 - 7 - The combination of defines used when compile the code on MacOS is hiding variables. 8 - Patch allows basic MacOS build to compile and run. 9 - 10 - Reviewed-by: Adam Jackson <ajax@redhat.com> 11 - Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25992> 12 - --- 13 - src/glx/glxext.c | 10 ++++++++-- 14 - 1 file changed, 8 insertions(+), 2 deletions(-) 15 - 16 - diff --git a/src/glx/glxext.c b/src/glx/glxext.c 17 - index 7712e54c1d6..454f2c36a77 100644 18 - --- a/src/glx/glxext.c 19 - +++ b/src/glx/glxext.c 20 - @@ -878,12 +878,16 @@ __glXInitialize(Display * dpy) 21 - 22 - dpyPriv->glXDrawHash = __glxHashCreate(); 23 - 24 - + Bool zink = False; 25 - + Bool try_zink = False; 26 - + 27 - #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 28 - Bool glx_direct = !debug_get_bool_option("LIBGL_ALWAYS_INDIRECT", false); 29 - Bool glx_accel = !debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false); 30 - const char *env = getenv("MESA_LOADER_DRIVER_OVERRIDE"); 31 - - Bool zink = env && !strcmp(env, "zink"); 32 - - Bool try_zink = False; 33 - + 34 - + zink = env && !strcmp(env, "zink"); 35 - + try_zink = False; 36 - 37 - dpyPriv->drawHash = __glxHashCreate(); 38 - 39 - @@ -928,12 +932,14 @@ __glXInitialize(Display * dpy) 40 - 41 - if (!AllocAndFetchScreenConfigs(dpy, dpyPriv, zink | try_zink)) { 42 - Bool fail = True; 43 - +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 44 - if (try_zink) { 45 - free(dpyPriv->screens); 46 - dpyPriv->driswDisplay->destroyDisplay(dpyPriv->driswDisplay); 47 - dpyPriv->driswDisplay = driswCreateDisplay(dpy, false); 48 - fail = !AllocAndFetchScreenConfigs(dpy, dpyPriv, False); 49 - } 50 - +#endif 51 - if (fail) { 52 - free(dpyPriv); 53 - return NULL;
+52 -37
pkgs/development/libraries/mesa/default.nix
··· 1 - { stdenv, lib, fetchurl, fetchpatch, buildPackages 1 + { stdenv, lib, fetchurl, fetchpatch, fetchCrate, buildPackages 2 2 , meson, pkg-config, ninja 3 3 , intltool, bison, flex, file, python3Packages, wayland-scanner 4 4 , expat, libdrm, xorg, wayland, wayland-protocols, openssl ··· 10 10 if stdenv.isLinux then 11 11 [ 12 12 "d3d12" # WSL emulated GPU (aka Dozen) 13 + "kmsro" # special "render only" driver for GPUs without a display controller 13 14 "nouveau" # Nvidia 14 15 "radeonsi" # new AMD (GCN+) 15 16 "r300" # very old AMD ··· 38 39 [ 39 40 "amd" # AMD (aka RADV) 40 41 "microsoft-experimental" # WSL virtualized GPU (aka DZN/Dozen) 42 + "nouveau-experimental" # Nouveau (aka NVK) 41 43 "swrast" # software renderer (aka Lavapipe) 42 44 ] 43 45 ++ lib.optionals (stdenv.hostPlatform.isAarch -> lib.versionAtLeast stdenv.hostPlatform.parsed.cpu.version "6") [ ··· 66 68 , enableOpenCL ? stdenv.isLinux && stdenv.isx86_64 67 69 , enablePatentEncumberedCodecs ? true 68 70 , jdupes 71 + , rustPlatform 69 72 , rust-bindgen 70 73 , rustc 71 74 , spirv-llvm-translator ··· 74 77 , udev 75 78 }: 76 79 77 - /** Packaging design: 78 - - The basic mesa ($out) contains headers and libraries (GLU is in libGLU now). 79 - This or the mesa attribute (which also contains GLU) are small (~ 2 MB, mostly headers) 80 - and are designed to be the buildInput of other packages. 81 - - DRI drivers are compiled into $drivers output, which is much bigger and 82 - depends on LLVM. These should be searched at runtime in 83 - "/run/opengl-driver{,-32}/lib/*" and so are kind-of impure (given by NixOS). 84 - (I suppose on non-NixOS one would create the appropriate symlinks from there.) 85 - - libOSMesa is in $osmesa (~4 MB) 86 - */ 80 + # When updating this package, please verify at least these build (assuming x86_64-linux): 81 + # nix build .#mesa .#pkgsi686Linux.mesa .#pkgsCross.aarch64-multiplatform.mesa .#pkgsMusl.mesa 87 82 88 83 let 89 - version = "23.3.5"; 90 - hash = "sha256-acyxJ4ZB/1utccoPhmGIrrGpKq3E27nTX1CuvsW4tQ8="; 84 + version = "24.0.1"; 85 + hash = "sha256-84cZKwjEccVFWQ3RIjCio0MkSAS1/oZv7GrqAuq1dhM="; 91 86 92 87 # Release calendar: https://www.mesa3d.org/release-calendar.html 93 88 # Release frequency: https://www.mesa3d.org/releasing.html#schedule ··· 98 93 haveWayland = lib.elem "wayland" eglPlatforms; 99 94 haveZink = lib.elem "zink" galliumDrivers; 100 95 haveDozen = (lib.elem "d3d12" galliumDrivers) || (lib.elem "microsoft-experimental" vulkanDrivers); 96 + 97 + rustDeps = [ 98 + { 99 + pname = "proc-macro2"; 100 + version = "1.0.70"; 101 + hash = "sha256-e4ZgyZUTu5nAtaH5QVkLelqJQX/XPj/rWkzf/g2c+1g="; 102 + } 103 + { 104 + pname = "quote"; 105 + version = "1.0.33"; 106 + hash = "sha256-VWRCZJO0/DJbNu0/V9TLaqlwMot65YjInWT9VWg57DY="; 107 + } 108 + { 109 + pname = "syn"; 110 + version = "2.0.39"; 111 + hash = "sha256-Mjen2L/omhVbhU/+Ao65mogs3BP3fY+Bodab3uU63EI="; 112 + } 113 + { 114 + pname = "unicode-ident"; 115 + version = "1.0.12"; 116 + hash = "sha256-KX8NqYYw6+rGsoR9mdZx8eT1HIPEUUyxErdk2H/Rlj8="; 117 + } 118 + ]; 119 + 120 + copyRustDep = dep: '' 121 + cp -R --no-preserve=mode,ownership ${fetchCrate dep} subprojects/${dep.pname}-${dep.version} 122 + cp -R subprojects/packagefiles/${dep.pname}/* subprojects/${dep.pname}-${dep.version}/ 123 + ''; 124 + 125 + copyRustDeps = lib.concatStringsSep "\n" (builtins.map copyRustDep rustDeps); 126 + 101 127 self = stdenv.mkDerivation { 102 128 pname = "mesa"; 103 129 inherit version; ··· 113 139 inherit hash; 114 140 }; 115 141 116 - # TODO: 117 - # revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved 118 - # ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog 119 142 patches = [ 120 - # fixes pkgsMusl.mesa build 121 - ./musl.patch 122 - 123 143 ./opencl.patch 124 - 125 - # Backports to fix build 126 - # FIXME: remove when applied upstream 127 - 128 - # Fix build on macOS 129 - ./backports/0001-dri-added-build-dependencies-for-systems-using-non-s.patch 130 - ./backports/0002-util-Update-util-libdrm.h-stubs-to-allow-loader.c-to.patch 131 - ./backports/0003-glx-fix-automatic-zink-fallback-loading-between-hw-a.patch 132 144 ]; 133 145 134 146 postPatch = '' ··· 141 153 "get_option('datadir')" "'${placeholder "out"}/share'" 142 154 substituteInPlace src/amd/vulkan/meson.build --replace \ 143 155 "get_option('datadir')" "'${placeholder "out"}/share'" 156 + 157 + ${copyRustDeps} 144 158 ''; 145 159 146 160 outputs = [ "out" "dev" "drivers" ] ··· 152 166 # in case anything wants to use it at some point 153 167 ++ lib.optional haveDozen "spirv2dxil"; 154 168 155 - # FIXME: this fixes rusticl/iris segfaulting on startup, _somehow_. 156 - # Needs more investigating. 169 + # Keep build-ids so drivers can use them for caching, etc. 170 + # Also some drivers segfault without this. 157 171 separateDebugInfo = true; 158 172 173 + # Needed to discover llvm-config for cross 159 174 preConfigure = '' 160 175 PATH=${llvmPackages.libllvm.dev}/bin:$PATH 161 176 ''; 162 177 163 - # TODO: Figure out how to enable opencl without having a runtime dependency on clang 164 178 mesonFlags = [ 165 179 "--sysconfdir=/etc" 166 180 "--datadir=${placeholder "drivers"}/share" # Vendor files ··· 212 226 "-Dopencl-spirv=true" 213 227 214 228 # Rusticl, new OpenCL frontend 215 - "-Dgallium-rusticl=true" "-Drust_std=2021" 229 + "-Dgallium-rusticl=true" 216 230 "-Dclang-libdir=${llvmPackages.clang-unwrapped.lib}/lib" 217 231 ] ++ lib.optionals (!withValgrind) [ 218 232 "-Dvalgrind=disabled" 219 233 ] ++ lib.optionals (!withLibunwind) [ 220 234 "-Dlibunwind=disabled" 221 235 ] ++ lib.optional enablePatentEncumberedCodecs 222 - "-Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec" 236 + "-Dvideo-codecs=all" 223 237 ++ lib.optional (vulkanLayers != []) "-D vulkan-layers=${builtins.concatStringsSep "," vulkanLayers}"; 224 238 239 + strictDeps = true; 240 + 225 241 buildInputs = with xorg; [ 226 242 expat glslang llvmPackages.libllvm libglvnd xorgproto 227 243 libX11 libXext libxcb libXt libXfixes libxshmfence libXrandr 228 244 libffi libvdpau libelf libXvMC 229 - libpthreadstubs openssl /*or another sha1 provider*/ 245 + libpthreadstubs openssl 230 246 zstd 231 247 ] ++ lib.optionals withLibunwind [ 232 248 libunwind ··· 239 255 ++ lib.optional haveZink vulkan-loader 240 256 ++ lib.optional haveDozen directx-headers; 241 257 242 - depsBuildBuild = [ pkg-config ] 243 - ++ lib.optional enableOpenCL buildPackages.stdenv.cc; 258 + depsBuildBuild = [ pkg-config buildPackages.stdenv.cc ]; 244 259 245 260 nativeBuildInputs = [ 246 261 meson pkg-config ninja 247 262 intltool bison flex file 248 263 python3Packages.python python3Packages.mako python3Packages.ply 249 264 jdupes glslang 250 - ] ++ lib.optionals enableOpenCL [ rust-bindgen rustc ] 251 - ++ lib.optional haveWayland wayland-scanner; 265 + rustc rust-bindgen rustPlatform.bindgenHook 266 + ] ++ lib.optional haveWayland wayland-scanner; 252 267 253 268 propagatedBuildInputs = with xorg; [ 254 269 libXdamage libXxf86vm
-59
pkgs/development/libraries/mesa/musl.patch
··· 1 - diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h 2 - index 06ca90564f0..bb244f8f358 100644 3 - --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h 4 - +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h 5 - @@ -30,6 +30,7 @@ 6 - 7 - #include <amdgpu.h> 8 - #include <pthread.h> 9 - +#include <sys/types.h> 10 - #include "util/list.h" 11 - #include "util/rwlock.h" 12 - #include "ac_gpu_info.h" 13 - diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h 14 - index 22f99c41909..2f3195926be 100644 15 - --- a/src/gallium/drivers/freedreno/freedreno_util.h 16 - +++ b/src/gallium/drivers/freedreno/freedreno_util.h 17 - @@ -108,6 +108,8 @@ extern bool fd_binning_enabled; 18 - #include <sys/types.h> 19 - #include <sys/syscall.h> 20 - 21 - +#define gettid() ((pid_t)syscall(SYS_gettid)) 22 - + 23 - #define DBG(fmt, ...) \ 24 - do { \ 25 - if (FD_DBG(MSGS)) \ 26 - diff --git a/src/gallium/frontends/nine/nine_debug.c b/src/gallium/frontends/nine/nine_debug.c 27 - index f3a6a945025..f4a6c41a612 100644 28 - --- a/src/gallium/frontends/nine/nine_debug.c 29 - +++ b/src/gallium/frontends/nine/nine_debug.c 30 - @@ -65,7 +65,7 @@ _nine_debug_printf( unsigned long flag, 31 - { 32 - static boolean first = TRUE; 33 - static unsigned long dbg_flags = DBG_ERROR | DBG_WARN; 34 - - unsigned long tid = 0; 35 - + pthread_t tid = 0; 36 - 37 - if (first) { 38 - first = FALSE; 39 - @@ -74,7 +74,7 @@ _nine_debug_printf( unsigned long flag, 40 - 41 - #if defined(HAVE_PTHREAD) 42 - if (dbg_flags & DBG_TID) 43 - - tid = (unsigned long)pthread_self(); 44 - + tid = pthread_self(); 45 - #endif 46 - 47 - if (dbg_flags & flag) { 48 - diff --git a/src/util/rand_xor.c b/src/util/rand_xor.c 49 - index 81b64f1ea71..56ebd2eccdf 100644 50 - --- a/src/util/rand_xor.c 51 - +++ b/src/util/rand_xor.c 52 - @@ -28,6 +28,7 @@ 53 - #if defined(HAVE_GETRANDOM) 54 - #include <sys/random.h> 55 - #endif 56 - +#include <sys/types.h> /* size_t, ssize_t */ 57 - #include <unistd.h> 58 - #include <fcntl.h> 59 - #endif