mesa: remove darwin-specific derivations

The ‘mesa-darwin’ stuff was very out of date (2012). This moves darwin
to use the newer mesa. Stuff seems to build okay. Needs more testing
on other stuff though (libraries work). No drivers build but that is
how it should work on macOS.

/cc @cstrahan @Anton-Latukha
This commit is contained in:
Matthew Bauer
2018-08-25 15:59:19 -05:00
parent bd1ebb0fa0
commit 16879e2f6a
14 changed files with 125 additions and 593 deletions
@@ -0,0 +1,76 @@
diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h
index 45cb6075e6..62937311b9 100644
--- a/include/c11/threads_posix.h
+++ b/include/c11/threads_posix.h
@@ -36,6 +36,11 @@
#include <sched.h>
#include <stdint.h> /* for intptr_t */
+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#endif
+
/*
Configuration macro:
@@ -383,12 +388,25 @@ tss_set(tss_t key, void *val)
/*-------------------- 7.25.7 Time functions --------------------*/
// 7.25.6.1
#ifndef HAVE_TIMESPEC_GET
+
static inline int
timespec_get(struct timespec *ts, int base)
{
if (!ts) return 0;
if (base == TIME_UTC) {
+#ifdef __MACH__
+ if (ts != NULL) {
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ ts->tv_sec = mts.tv_sec;
+ ts->tv_nsec = mts.tv_nsec;
+ }
+#else
clock_gettime(CLOCK_REALTIME, ts);
+#endif
return base;
}
return 0;
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1208ebb315..e1378fb1f0 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -65,6 +65,11 @@
#include "util/u_vector.h"
#include "mapi/glapi/glapi.h"
+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#endif
+
#define NUM_ATTRIBS 12
static void
@@ -3092,7 +3097,17 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
/* We override the clock to monotonic when creating the condition
* variable. */
+#ifdef __MACH__
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ current.tv_sec = mts.tv_sec;
+ current.tv_nsec = mts.tv_nsec;
+#else
clock_gettime(CLOCK_MONOTONIC, &current);
+#endif
/* calculating when to expire */
expire.tv_nsec = timeout % 1000000000L;
+41 -37
View File
@@ -8,6 +8,8 @@
, galliumDrivers ? null
, driDrivers ? null
, vulkanDrivers ? null
, eglPlatforms ? [ "x11" ] ++ lib.optionals stdenv.isLinux [ "wayland" "drm" ]
, OpenGL, Xplugin
}:
/** Packaging design:
@@ -29,19 +31,21 @@ else
let
defaultGalliumDrivers =
if stdenv.isAarch32
optionals (builtins.elem "drm" eglPlatforms)
(if stdenv.isAarch32
then ["virgl" "nouveau" "freedreno" "vc4" "etnaviv" "imx"]
else if stdenv.isAarch64
then ["virgl" "nouveau" "vc4" ]
else ["virgl" "svga" "i915" "r300" "r600" "radeonsi" "nouveau"];
else ["virgl" "svga" "i915" "r300" "r600" "radeonsi" "nouveau"]);
defaultDriDrivers =
if (stdenv.isAarch32 || stdenv.isAarch64)
optionals (builtins.elem "drm" eglPlatforms)
(if (stdenv.isAarch32 || stdenv.isAarch64)
then ["nouveau"]
else ["i915" "i965" "nouveau" "radeon" "r200"];
else ["i915" "i965" "nouveau" "radeon" "r200"]);
defaultVulkanDrivers =
if (stdenv.isAarch32 || stdenv.isAarch64)
optionals stdenv.isLinux (if (stdenv.isAarch32 || stdenv.isAarch64)
then []
else ["intel"] ++ lib.optional enableRadv "radeon";
else ["intel"] ++ lib.optional enableRadv "radeon");
in
let gallium_ = galliumDrivers; dri_ = driDrivers; vulkan_ = vulkanDrivers; in
@@ -51,11 +55,11 @@ let
(if gallium_ == null
then defaultGalliumDrivers
else gallium_)
++ ["swrast" "virgl"];
++ lib.optional stdenv.isLinux "swrast";
driDrivers =
(if dri_ == null
then defaultDriDrivers
else dri_) ++ ["swrast"];
then optionals (elem "drm" eglPlatforms) defaultDriDrivers
else dri_) ++ lib.optional stdenv.isLinux "swrast";
vulkanDrivers =
if vulkan_ == null
then defaultVulkanDrivers
@@ -89,9 +93,10 @@ let self = stdenv.mkDerivation {
./symlink-drivers.patch
./missing-includes.patch # dev_t needs sys/stat.h, time_t needs time.h, etc.-- fixes build w/musl
./disk_cache-include-dri-driver-path-in-cache-key.patch
];
] ++ lib.optional stdenv.isDarwin ./darwin-clock-gettime.patch;
outputs = [ "out" "dev" "drivers" "osmesa" ];
outputs = [ "out" "dev" "drivers" ]
++ lib.optional (elem "swrast" galliumDrivers) "osmesa";
# TODO: Figure out how to enable opencl without having a runtime dependency on clang
configureFlags = [
@@ -99,18 +104,10 @@ let self = stdenv.mkDerivation {
"--localstatedir=/var"
"--with-dri-driverdir=$(drivers)/lib/dri"
"--with-dri-searchpath=${libglvnd.driverLink}/lib/dri"
"--with-platforms=x11,wayland,drm"
]
++ (optional (galliumDrivers != [])
("--with-gallium-drivers=" +
builtins.concatStringsSep "," galliumDrivers))
++ (optional (driDrivers != [])
("--with-dri-drivers=" +
builtins.concatStringsSep "," driDrivers))
++ (optional (vulkanDrivers != [])
("--with-vulkan-drivers=" +
builtins.concatStringsSep "," vulkanDrivers))
++ [
"--with-platforms=${concatStringsSep "," eglPlatforms}"
"--with-gallium-drivers=${concatStringsSep "," galliumDrivers}"
"--with-dri-drivers=${concatStringsSep "," driDrivers}"
"--with-vulkan-drivers=${concatStringsSep "," vulkanDrivers}"
(enableFeature stdenv.isLinux "dri3")
(enableFeature stdenv.isLinux "nine") # Direct3D in Wine
"--enable-libglvnd"
@@ -121,17 +118,18 @@ let self = stdenv.mkDerivation {
"--enable-glx"
# https://bugs.freedesktop.org/show_bug.cgi?id=35268
(enableFeature (!stdenv.hostPlatform.isMusl) "glx-tls")
"--enable-gallium-osmesa" # used by wine
# used by wine
(enableFeature (elem "swrast" galliumDrivers) "gallium-osmesa")
"--enable-llvm"
"--enable-egl"
"--enable-xa" # used in vmware driver
"--enable-gbm"
(enableFeature stdenv.isLinux "egl")
(enableFeature stdenv.isLinux "xa") # used in vmware driver
(enableFeature stdenv.isLinux "gbm")
"--enable-xvmc"
"--enable-vdpau"
"--enable-shared-glapi"
"--enable-llvm-shared-libs"
"--enable-omx-bellagio"
"--enable-va"
(enableFeature stdenv.isLinux "omx-bellagio")
(enableFeature stdenv.isLinux "va")
"--disable-opencl"
];
@@ -139,16 +137,18 @@ let self = stdenv.mkDerivation {
propagatedBuildInputs = with xorg;
[ libXdamage libXxf86vm ]
++ optional stdenv.isLinux libdrm;
++ optional stdenv.isLinux libdrm
++ optionals stdenv.isDarwin [ OpenGL Xplugin ];
buildInputs = with xorg; [
expat llvmPackages.llvm libglvnd
glproto dri2proto dri3proto presentproto
libX11 libXext libxcb libXt libXfixes libxshmfence
libffi wayland wayland-protocols libvdpau libelf libXvMC
libomxil-bellagio libva-minimal libpthreadstubs openssl/*or another sha1 provider*/
libffi libvdpau libelf libXvMC
libpthreadstubs openssl/*or another sha1 provider*/
valgrind-light python2 python2.pkgs.Mako
];
] ++ lib.optionals stdenv.isLinux [ wayland wayland-protocols
libomxil-bellagio libva-minimal ];
enableParallelBuilding = true;
doCheck = false;
@@ -160,7 +160,7 @@ let self = stdenv.mkDerivation {
];
# TODO: probably not all .la files are completely fixed, but it shouldn't matter;
postInstall = ''
postInstall = optionalString (galliumDrivers != []) ''
# move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
mv -t "$drivers/lib/" \
$out/lib/libXvMC* \
@@ -214,7 +214,7 @@ let self = stdenv.mkDerivation {
# TODO:
# check $out doesn't depend on llvm: builder failures are ignored
# for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
postFixup = ''
postFixup = optionalString (galliumDrivers != []) ''
# add RPATH so the drivers can find the moved libgallium and libdricore9
# moved here to avoid problems with stripping patchelfed files
for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
@@ -234,7 +234,9 @@ let self = stdenv.mkDerivation {
# Use stub libraries from libglvnd and headers from Mesa.
buildCommand = ''
ln -s ${libglvnd.out} $out
mkdir -p $out/nix-support
ln -s ${libglvnd.out}/lib $out/lib
mkdir -p $dev/{,lib/pkgconfig,nix-support}
echo "$out" > $dev/nix-support/propagated-build-inputs
ln -s ${self.dev}/include $dev/include
@@ -256,6 +258,8 @@ let self = stdenv.mkDerivation {
genPkgConfig egl EGL
genPkgConfig glesv1_cm GLESv1_CM
genPkgConfig glesv2 GLESv2
'' + lib.optionalString stdenv.isDarwin ''
echo ${OpenGL} > $out/nix-support/propagated-build-inputs
'';
};
};
@@ -264,7 +268,7 @@ let self = stdenv.mkDerivation {
description = "An open source implementation of OpenGL";
homepage = https://www.mesa3d.org/;
license = licenses.mit; # X11 variant, in most files
platforms = platforms.linux;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ vcunat ];
};
};