pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/51796: graphics/MesaLib Update to 13.0.2 with glamor / egl somewhat working



>Number:         51796
>Category:       pkg
>Synopsis:       graphics/MesaLib Update to 13.0.2 with glamor / egl somewhat working
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 08 07:30:00 +0000 2017
>Originator:     David Shao
>Release:        current pkgsrc
>Organization:
>Environment:
DragonFly  4.7-DEVELOPMENT DragonFly v4.7.0.1108.g10127-DEVELOPMENT #3: Sat Jan  7 12:15:22 PST 2017     xxxxxx@:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64

>Description:
The following patches to the wip/MesaLib mesa 13.0.2 port enable glamor
/ egl to run on a Radeon (CAICOS) Sapphire HD6450 graphics card amd64
machine running any of current NetBSD, FreeBSD 11-RELEASE (probably also
works for FreeBSD 12-current), and DragonFly 4.7-DEVELOPMENT.  Also for
the same OSes on another amd64 machine, IvyBridge Intel integrated runs SNA acceleration.  A patch to libdrm submitted in
pkg/51795: x11/libdrm update xf86drm.c for mesa 13.0.2 needs negotiation
is also required, and possibly patching the OS as submitted in
kern/51786: mesa 13.0.2 libdrm 2.4.74 Radeon needs kernel support, new ioctl or sysctl

Hardware inquiry has shifted to libdrm, so the proposed patches for
FreeBSD and DragonFly using libdevq can be dropped.

The patches have a massive hack for NetBSD:  There is an array of
function pointers table_noop_array that for some reason between
11.2 and 13.0.2 now refuses to link.  Therefore I merely created
a locally defined array netbsd_table_noop_array to at least get
something to run.  However this locally defined array does not have
the right functions when the debug environment variable
LIBGL_DEBUG=verbose
is set, causing total malfunction of keyboard input.

OpenBSD allows the OSMesa build option, so I enabled it in the Makefile
and the PLIST.

FreeBSD 12-current recently switched to llvm 3.9, and this seems to
cause nouveau to fail to properly link.  I have therefore in options.mk
disabled nouveau for this OS.

I have added a glamor option that basically toggles whether
glx-tls is enabled or disabled.  Other options can actually be
independently enabled.

I have added a debug option for --enable-debug.

OpenBSD enables xvmc so there seemed no reason not to at least add
an option to enable it.

r600-llvm-compiler is no longer an configure option.

In the patch below I left out the 1000+ lines initializing the locally
defined array of function pointers.  Only NetBSD requires some
equivalent become it can't handle certain dlopen initializations.


>How-To-Repeat:

>Fix:
diff -Nur wip/MesaLib/Makefile graphics/MesaLib/Makefile
--- wip/MesaLib/Makefile	2017-01-01 08:41:56.000000000 -0800
+++ graphics/MesaLib/Makefile	2017-01-03 13:47:08.000000000 -0800
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.129 2016/10/20 12:06:06 wiz Exp $
 
-DISTNAME=	mesa-13.0.1
+DISTNAME=	mesa-13.0.2
 PKGNAME=	${DISTNAME:S/mesa/MesaLib/}
 CATEGORIES=	graphics x11
 MASTER_SITES=	ftp://ftp.freedesktop.org/pub/mesa/${PKGVERSION_NOREV}/
@@ -42,6 +42,7 @@
 SUBST_FILES.wrapper-bug+=	src/glx/Makefile.in
 SUBST_FILES.wrapper-bug+=	src/mapi/Makefile.in
 SUBST_FILES.wrapper-bug+=	src/mesa/drivers/x11/Makefile.in
+SUBST_FILES.wrapper-bug+=	src/mesa/drivers/osmesa/Makefile.in
 SUBST_SED.wrapper-bug=		-e 's,shared-glapi/libglapi.la,shared-glapi/libglapi_tmp_rename.la,g'
 SUBST_SED.wrapper-bug+=		-e 's,libglapi.la,libglapi_impl.la,g'
 SUBST_SED.wrapper-bug+=		-e 's,libglapi_tmp_rename.la,libglapi.la,g'
@@ -51,7 +52,7 @@
 SUBST_STAGE.drirc=		pre-configure
 SUBST_MESSAGE.drirc=		Fixing hardcoded /etc/drirc references
 SUBST_FILES.drirc+=		src/mesa/drivers/dri/common/xmlconfig.c
-SUBST_SED.drirc+=		 -e 's|/etc/|${PREFIX}/etc/|g'
+SUBST_SED.drirc+=		 -e 's|/etc|${PREFIX}/etc|g'
 
 .include "../../mk/bsd.prefs.mk"
 .include "../../mk/compiler.mk"
diff -Nur wip/MesaLib/PLIST graphics/MesaLib/PLIST
--- wip/MesaLib/PLIST	2016-12-10 22:16:21.000000000 -0800
+++ graphics/MesaLib/PLIST	2016-12-27 19:12:08.000000000 -0800
@@ -11,6 +11,7 @@
 include/GL/glx.h
 include/GL/glx_mangle.h
 include/GL/glxext.h
+${PLIST.osmesa}include/GL/osmesa.h
 ${PLIST.dri}include/GL/internal/dri_interface.h
 ${PLIST.dri}include/GLES/egl.h
 ${PLIST.dri}include/GLES/gl.h
@@ -49,6 +50,7 @@
 lib/libGL.la
 ${PLIST.dri}lib/libGLESv1_CM.la
 ${PLIST.dri}lib/libGLESv2.la
+${PLIST.osmesa}lib/libOSMesa.la
 ${PLIST.gbm}lib/libgbm.la
 lib/libglapi.la
 ${PLIST.wayland}lib/libwayland-egl.la
@@ -56,6 +58,7 @@
 ${PLIST.dri}lib/pkgconfig/dri.pc
 ${PLIST.dri}lib/pkgconfig/egl.pc
 ${PLIST.gbm}lib/pkgconfig/gbm.pc
+${PLIST.osmesa}lib/pkgconfig/osmesa.pc
 lib/pkgconfig/gl.pc
 ${PLIST.dri}lib/pkgconfig/glesv1_cm.pc
 ${PLIST.dri}lib/pkgconfig/glesv2.pc
diff -Nur wip/MesaLib/TODO graphics/MesaLib/TODO
--- wip/MesaLib/TODO	2016-12-20 06:05:47.000000000 -0800
+++ graphics/MesaLib/TODO	2016-12-10 22:16:21.000000000 -0800
@@ -1,5 +1,3 @@
-drmGetDevice() is not supported in libdrm on NetBSD, need alternate
-  implementation of loader_get_pci_id_for_fd() in src/loader/loader.c
 investigate applicability of FreeBSD DEVQ patch
 fix bitrot that broke GLX TLS on NetBSD
 test OSX quartz, check if bug 90311 patch needs regen
diff -Nur wip/MesaLib/distinfo graphics/MesaLib/distinfo
--- wip/MesaLib/distinfo	2016-12-10 22:16:21.000000000 -0800
+++ graphics/MesaLib/distinfo	2017-01-07 22:59:31.699298000 -0800
@@ -1,15 +1,16 @@
 $NetBSD: distinfo,v 1.117 2016/05/18 12:55:28 wiz Exp $
 
-SHA1 (mesa-13.0.1.tar.xz) = 13a6f25b8f66ec788293cbbebb2d2bd7e9cc6195
-RMD160 (mesa-13.0.1.tar.xz) = 884012a4a2c68bf982f4b546b03a8f46ac8932fe
-SHA512 (mesa-13.0.1.tar.xz) = 00ae0eaef742a3954c1461b50cdcc8b9f933e829c89784d66bfcc0890e7e2793350efcad1a06f28bd3c115f04702a43a6f1ac6ce86270ca7799a90f1a5cf5127
-Size (mesa-13.0.1.tar.xz) = 9154288 bytes
-SHA1 (patch-configure) = 619e7b3e70f8f20f5ac61fafe6bb0b87e16a1693
+SHA1 (mesa-13.0.2.tar.xz) = 457331f16b229e02594477307604b0a92a155fd2
+RMD160 (mesa-13.0.2.tar.xz) = 107d2b33f5199bf14a61775c01ddaa2556b4b9dd
+SHA512 (mesa-13.0.2.tar.xz) = e4e2b9d685910f9b1d70958c50f54d059263623865571a92c3aa185914f4f7aa745d74afc9706b64ecd1f8d04c603ad03a78365d976382e2664284dc6a8351be
+Size (mesa-13.0.2.tar.xz) = 9159100 bytes
+SHA1 (patch-configure) = 71d621a23e895d828ef3be348df44574d6c8e2fe
 SHA1 (patch-include_GL_glxext.h) = 830902f2d38a8395cda682c059fc5223e1b0e89e
 SHA1 (patch-src_compiler_glsl_glsl__parser__extras.cpp) = c5046ce848d0b1ea428e29611b6822d4f4ab970d
 SHA1 (patch-src_egl_drivers_dri2_platform__drm.c) = 75144a5c2cbcda3f7ccd708ff2ac03c823c045d7
 SHA1 (patch-src_egl_drivers_dri2_platform__x11.c) = 04b6ef8e755f226fbe3e6f2bea6c9e2a56a783ca
 SHA1 (patch-src_egl_main_eglglobals.c) = 194954826564d1053544a88c771019faf4d07df2
+SHA1 (patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c) = e190c9bc287b2f81ce13e641980fed3ec0ecfacb
 SHA1 (patch-src_gallium_auxiliary_util_u__format__tests.c) = 4d5e4677c2825778c43440ab131b8807f6840975
 SHA1 (patch-src_gallium_auxiliary_util_u__math.h) = 812e4a5291aea47e06505f09891e0434c4d9c34d
 SHA1 (patch-src_gallium_auxiliary_util_u__network.c) = 283f505af780071dc9fd7914f8065e3fb7d8a4fd
@@ -17,6 +18,8 @@
 SHA1 (patch-src_gallium_drivers_nouveau_codegen_nv50__ir__peephole.cpp) = 5fc2ef7eafac3006896af96bac8176c79b17cfdc
 SHA1 (patch-src_gallium_drivers_nouveau_nouveau__vp3__video.c) = ae1b6eb4df3e4db0f37e44118cdf69b16f3c471e
 SHA1 (patch-src_gallium_drivers_nouveau_nv50_nv84__video.c) = 1b4239fe053523835ecac006894bdb0cde0ee626
+SHA1 (patch-src_gallium_state__trackers_clover_llvm_invocation.cpp) = f283ec2fa88bf3a542343db7205ff63d9b5c871f
+SHA1 (patch-src_gallium_state__trackers_clover_llvm_metadata.hpp) = 21973190b9b9521c2c4df20a1982ca4da3c8e90b
 SHA1 (patch-src_gallium_targets_dri_Makefile.in) = a9a8265d97297040a3e3260b362ca920ec852280
 SHA1 (patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c) = 94e05c38ab2a8d2bcc25dd477cbd1fd5d681182a
 SHA1 (patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c) = e4b891e8b4ebe5b8e8c7b8c2c1dbed11b9c417df
@@ -24,12 +27,17 @@
 SHA1 (patch-src_glx_apple_apple__glapi.c) = df70afc24759978f954ac3a774a14e6518dde97a
 SHA1 (patch-src_glx_glxclient.h) = e15256851559dafb7a86e1eb7e9d6afc86de581b
 SHA1 (patch-src_glx_glxcurrent.c) = 713f75bcafb186c7123d19a6aae3deaed9d5fa69
+SHA1 (patch-src_intel_tools_aubinator.c) = 4437e19acab1de56f7335378f210a0d415c71478
+SHA1 (patch-src_mapi_entry.c) = b0af9f644ed5be023010b44981827bfce5986d79
+SHA1 (patch-src_mapi_entry__x86-64__tls.h) = 7653433abf2a1f972beebd20bab43f02db9a9ebf
+SHA1 (patch-src_mapi_entry__x86__tls.h) = a763f1f1a5e4eb458f7a654266e53e6470d3a882
 SHA1 (patch-src_mapi_glapi_gen_gl__gentable.py) = 53026e520a510e54494760a3fa05af6f15dfb9d8
+SHA1 (patch-src_mapi_table.h) = 272d00c45f742303a5ff84da82c1cd585846d6e1
 SHA1 (patch-src_mapi_u__current.c) = 1731375d82119be326b35d141d7879e083d6d620
 SHA1 (patch-src_mapi_u__current.h) = 214dd29cb0c4fe127eb1157b04b12ddfc455b4b0
 SHA1 (patch-src_mesa_drivers_dri_Makefile.in) = 2fb1471045ae88eaa4fca162bf86330b833167fd
 SHA1 (patch-src_mesa_drivers_dri_common_Makefile.in) = 5e160f7d92c2e9f3fa36e52a082a496af67e634e
-SHA1 (patch-src_mesa_drivers_dri_common_xmlconfig.c) = b87644c5ef5fb5d71c3260026d3afdfbaee749a8
+SHA1 (patch-src_mesa_drivers_dri_common_xmlconfig.c) = ad6f459e6df955c6a06cde7e03de7d0324b0281f
 SHA1 (patch-src_mesa_drivers_dri_i915_intel__screen.c) = fd8436e4e3a69250256c2cddf8138effb16bd7b3
 SHA1 (patch-src_mesa_drivers_dri_i965_intel__screen.c) = 7c1a1e5c549f64d4c390e0c87984c44a88d4abfe
 SHA1 (patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c) = c0d465fb65939ead71c9d02b6f6793824dbf441d
@@ -37,9 +45,10 @@
 SHA1 (patch-src_mesa_main_context.c) = 695b0e04cbd08dfed46b4dae5f9602b35e21f5b3
 SHA1 (patch-src_mesa_main_extensions.c) = d650d7ddfe22ddbcd8a4c24b64feb27126521ae0
 SHA1 (patch-src_mesa_main_macros.h) = e0e98dff37bbf96fea2f3adf0dc9ef9911b711d9
-SHA1 (patch-src_mesa_main_shader__query.cpp) = 6273c74161f045363c58f38adeb672287f6a0898
+SHA1 (patch-src_mesa_main_shader__query.cpp) = 3f9c31645d87855759def11344dee16af23c7be3
 SHA1 (patch-src_mesa_tnl_t__pipeline.c) = afc7d5f27aeadacc7c6a762e5aa892e01a0c1317
 SHA1 (patch-src_mesa_x86_common__x86.c) = bdac91384d67ad0238ecd4cdcf5cfc787952a3d9
 SHA1 (patch-src_util_strndup.c) = b8dfae71f1b219e44f884b8fc6f89a86201353c3
 SHA1 (patch-src_util_strndup.h) = a48a0ebefbc79a770db4baa590d3f858bb52cacf
 SHA1 (patch-src_util_u__atomic.h) = 4a567b6fe5bf67fb7f386fa5f37bedb66d593085
+SHA1 (patch-src_util_u__endian.h) = 1ab4cea9eabac5c2d967138f082c57b6c7d524c4
diff -Nur wip/MesaLib/options.mk graphics/MesaLib/options.mk
--- wip/MesaLib/options.mk	2016-12-10 22:16:21.000000000 -0800
+++ graphics/MesaLib/options.mk	2017-01-04 18:25:01.000000000 -0800
@@ -2,6 +2,7 @@
 
 PKG_OPTIONS_VAR=		PKG_OPTIONS.MesaLib
 PKG_SUPPORTED_OPTIONS=		llvm dri
+PKG_SUPPORTED_OPTIONS+=		glamor debug xvmc
 PKG_SUGGESTED_OPTIONS=
 
 # The LLVM option enables JIT accelerated software rendering and
@@ -37,33 +38,50 @@
 # classic DRI
 PLIST_VARS+=	dri swrast_dri i915_dri nouveau_dri i965_dri radeon_dri r200_dri
 # other features
-PLIST_VARS+=	gbm wayland xatracker
+PLIST_VARS+=	gbm wayland xatracker osmesa xvmc
 
 .if !empty(PKG_OPTIONS:Mdri)
 
 CONFIGURE_ARGS+=	--enable-dri
 CONFIGURE_ARGS+=	--enable-egl
 .if ${OPSYS} != "Darwin"
+.if ${OPSYS} != "DragonFly" && ${OPSYS} != "NetBSD"
 CFLAGS+=		-DHAVE_DRI3
 CONFIGURE_ARGS+=	--enable-dri3
+.endif
 CONFIGURE_ARGS+=	--enable-gbm
 PLIST.gbm=		yes
 .endif
+CONFIGURE_ARGS+=	--enable-texture-float
+CONFIGURE_ARGS+=	--enable-osmesa
+PLIST.osmesa=		yes
 CONFIGURE_ARGS+=	--enable-gles1
 CONFIGURE_ARGS+=	--enable-gles2
 
 # Use Thread Local Storage in GLX where it is supported by Mesa and works.
 # XXX Fixme
-#	!empty(MACHINE_PLATFORM:MNetBSD-[789].*-i386) ||
-#	!empty(MACHINE_PLATFORM:MNetBSD-[789].*-x86_64) ||
 .if \
+	!empty(MACHINE_PLATFORM:MNetBSD-[789].*-i386) ||	\
+	!empty(MACHINE_PLATFORM:MNetBSD-[789].*-x86_64) ||	\
 	!empty(MACHINE_PLATFORM:MLinux-*-i386) ||		\
 	!empty(MACHINE_PLATFORM:MLinux-*-x86_64) ||		\
 	!empty(MACHINE_PLATFORM:MFreeBSD-1[0-9].*-x86_64) ||	\
 	!empty(MACHINE_PLATFORM:MDragonFly-*-x86_64)
+PKG_SUGGESTED_OPTIONS+=		glamor	
+.endif
+
+.if !empty(PKG_OPTIONS:Mglamor)
+# Recommended by
+# http://www.freedesktop.org/wiki/Software/Glamor/
+
 CONFIGURE_ARGS+=	--enable-glx-tls
+
 .else
+
+# (EE) Failed to load /usr/pkg/lib/xorg/modules/extensions/libglx.so:
+# /usr/pkg/lib/libGL.so.1: Use of initialized Thread Local Storage with model initial-exec and dlopen is not supported
 CONFIGURE_ARGS+=	--disable-glx-tls
+
 .endif
 
 # DRI on Linux needs either sysfs or udev
@@ -133,9 +151,11 @@
 PLIST.r600=		yes
 GALLIUM_DRIVERS+=	r600
 
+.if ${OPSYS} != "FreeBSD" || empty(OS_VERSION:M12.*)
 # nVidia
 PLIST.nouveau=		yes
 GALLIUM_DRIVERS+=	nouveau
+.endif
 
 # classic DRI radeon
 PLIST.radeon_dri=	yes
@@ -145,10 +165,12 @@
 PLIST.r200_dri=		yes
 DRI_DRIVERS+=		r200
 
+.if ${OPSYS} != "FreeBSD" || empty(OS_VERSION:M12.*)
 # classic DRI nouveau
 PLIST.nouveau_dri=	yes
 DRI_DRIVERS+=		nouveau
 .endif
+.endif
 
 .if ${OPSYS} == "Darwin"
 CONFIGURE_ARGS+=	--with-egl-platforms=x11
@@ -174,7 +196,8 @@
 PLIST.radeonsi=		yes
 GALLIUM_DRIVERS+=	radeonsi
 CONFIGURE_ARGS+=	--enable-gallium-llvm
-CONFIGURE_ARGS+=	--enable-r600-llvm-compiler
+CONFIGURE_ARGS+=	--enable-llvm-shared-libs
+# CONFIGURE_ARGS+=	--enable-r600-llvm-compiler
 .include "../../devel/libelf/buildlink3.mk"
 CPPFLAGS+=		-I${BUILDLINK_PREFIX.libelf}/include/libelf
 .include "../../lang/libLLVM/buildlink3.mk"
@@ -182,7 +205,8 @@
 .else # !llvm
 CONFIGURE_ARGS+=	--disable-xa
 CONFIGURE_ARGS+=	--disable-gallium-llvm
-CONFIGURE_ARGS+=	--disable-r600-llvm-compiler
+CONFIGURE_ARGS+=	--disable-llvm-shared-libs
+# CONFIGURE_ARGS+=	--disable-r600-llvm-compiler
 .endif # llvm
 .else # !dri
 CONFIGURE_ARGS+=	--with-gallium-drivers=
@@ -197,4 +221,13 @@
 .if !empty(PKG_OPTIONS:Mllvm)
 PKG_FAIL_REASON+=	"The llvm PKG_OPTION must also be disabled when dri is disabled"
 .endif
+.endif # dri
+
+.if !empty(PKG_OPTIONS:Mdebug)
+CONFIGURE_ARGS+=	--enable-debug
+.endif
+
+.if !empty(PKG_OPTIONS:Mxvmc)
+.include "../../x11/libXvMC/buildlink3.mk"
+PLIST.xvmc=		yes
 .endif
diff -Nur wip/MesaLib/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c graphics/MesaLib/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
--- wip/MesaLib/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c	2016-12-25 18:06:54.000000000 -0800
@@ -0,0 +1,125 @@
+$NetBSD$
+
+From FreeBSD ports / DragonFly dports, email addresses expunged:
+
+Revert the following commit.
+
+FreeBSD and DragonFly don't have the required render nodes.
+
+-------
+
+From 69a1b9959e59653da262185c4e2cf57d24939b19 Mon Sep 17 00:00:00 2001
+Date: Mon, 29 Jun 2015 12:36:45 +0100
+Subject: pipe-loader: drop support for non-render node devices
+
+Render nodes have been around for quite some time. Removing support via
+the master/primary node allows us to clean up the conditional
+compilation and simplify the build greatly.
+
+For example currently we the pipe-loader, which explicitly links against
+xcb and friends (for X auth) if found at compile-time. That
+would cause problems as one will be forced to use X/xcb, even if it's a
+headless system that is used for opencl.
+
+v2: Clarify the linking topic in the commit message.
+
+--- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+@@ -214,6 +214,16 @@ pipe_loader_drm_probe_fd(struct pipe_loa
+    return false;
+ }
+ 
++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
++static int
++open_drm_minor(int minor)
++{
++   char path[PATH_MAX];
++   snprintf(path, sizeof(path), DRM_DEV_NAME, DRM_DIR_NAME, minor);
++   return open(path, O_RDWR, 0);
++}
++#endif
++
+ static int
+ open_drm_render_node_minor(int minor)
+ {
+@@ -226,7 +236,19 @@ open_drm_render_node_minor(int minor)
+ int
+ pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
+ {
++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
++   int i, k, fd, num_render_node_devs;
++   int j = 0;
++
++   struct {
++      unsigned vendor_id;
++      unsigned chip_id;
++   } render_node_devs[DRM_RENDER_NODE_MAX_NODES];
++
++   /* Look for render nodes first */
++#else
+    int i, j, fd;
++#endif
+ 
+    for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
+         i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
+@@ -241,6 +263,11 @@ pipe_loader_drm_probe(struct pipe_loader
+          continue;
+       }
+ 
++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
++      render_node_devs[j].vendor_id = dev->u.pci.vendor_id;
++      render_node_devs[j].chip_id = dev->u.pci.chip_id;
++
++#endif
+       if (j < ndev) {
+          devs[j] = dev;
+       } else {
+@@ -250,6 +277,48 @@ pipe_loader_drm_probe(struct pipe_loader
+       j++;
+    }
+ 
++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
++   num_render_node_devs = j;
++
++   /* Next look for drm devices. */
++   for (i = 0; i < DRM_MAX_MINOR; i++) {
++      struct pipe_loader_device *dev;
++      boolean duplicate = FALSE;
++      fd = open_drm_minor(i);
++      if (fd < 0)
++         continue;
++
++      if (!pipe_loader_drm_probe_fd(&dev, fd)) {
++         close(fd);
++         continue;
++      }
++
++      /* Check to make sure we aren't already accessing this device via
++       * render nodes.
++       */
++      for (k = 0; k < num_render_node_devs; k++) {
++         if (dev->u.pci.vendor_id == render_node_devs[k].vendor_id &&
++             dev->u.pci.chip_id == render_node_devs[k].chip_id) {
++            close(fd);
++            dev->ops->release(&dev);
++            duplicate = TRUE;
++            break;
++         }
++      }
++
++      if (duplicate)
++         continue;
++
++      if (j < ndev) {
++         devs[j] = dev;
++      } else {
++         dev->ops->release(&dev);
++      }
++
++      j++;
++   }
++
++#endif
+    return j;
+ }
+ 
diff -Nur wip/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp graphics/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp
--- wip/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp	2016-12-23 19:03:51.000000000 -0800
@@ -0,0 +1,37 @@
+$NetBSD$
+
+From freebsd-base-ports
+https://github.com/FreeBSDDesktop/freebsd-ports-graphics/tree/xserver-mesa-next-udev
+
+--- src/gallium/state_trackers/clover/llvm/invocation.cpp.orig	2016-11-10 22:06:40.000000000 +0000
++++ src/gallium/state_trackers/clover/llvm/invocation.cpp
+@@ -85,6 +85,14 @@ namespace {
+       }
+    }
+ 
++#if defined(__FreeBSD__)
++   char* convert(const std::string&s){
++      char *pc = new char[s.size()+1];
++      std::strcpy(pc, s.c_str());
++      return pc;
++   }
++#endif
++
+    std::unique_ptr<LLVMContext>
+    create_context(std::string &r_log) {
+       init_targets();
+@@ -104,8 +112,14 @@ namespace {
+       // Parse the compiler options.  A file name should be present at the end
+       // and must have the .cl extension in order for the CompilerInvocation
+       // class to recognize it as an OpenCL source file.
++
++#if defined(__FreeBSD__)
++      std::vector<const char *> copts;
++      std::transform(opts.begin(), opts.end(), std::back_inserter(copts), convert);
++#else
+       const std::vector<const char *> copts =
+          map(std::mem_fn(&std::string::c_str), opts);
++#endif
+ 
+       if (!clang::CompilerInvocation::CreateFromArgs(
+              c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
diff -Nur wip/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp graphics/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp
--- wip/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp	2017-01-07 22:43:40.330697000 -0800
@@ -0,0 +1,19 @@
+$NetBSD$
+
+From freebsd-base-ports
+https://github.com/FreeBSDDesktop/freebsd-ports-graphics/tree/xserver-mesa-next-udev
+
+--- src/gallium/state_trackers/clover/llvm/metadata.hpp.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/gallium/state_trackers/clover/llvm/metadata.hpp
+@@ -42,7 +42,11 @@ namespace clover {
+          get_kernel_nodes(const ::llvm::Module &mod) {
+             if (const ::llvm::NamedMDNode *n =
+                    mod.getNamedMetadata("opencl.kernels"))
++#if defined(__FreeBSD__)
++               return { n->getOperand(0), n->getOperand(n->getNumOperands()) };
++#else
+                return { n->op_begin(), n->op_end() };
++#endif
+             else
+                return {};
+          }
diff -Nur wip/MesaLib/patches/patch-src_intel_tools_aubinator.c graphics/MesaLib/patches/patch-src_intel_tools_aubinator.c
--- wip/MesaLib/patches/patch-src_intel_tools_aubinator.c	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_intel_tools_aubinator.c	2017-01-07 22:42:28.669295000 -0800
@@ -0,0 +1,24 @@
+$NetBSD$
+
+From freebsd-base-ports
+https://github.com/FreeBSDDesktop/freebsd-ports-graphics/tree/xserver-mesa-next-udev
+
+Not sure if these mmap() flags are right ...
+
+--- src/intel/tools/aubinator.c.orig	2016-11-10 22:06:40.000000000 +0000
++++ src/intel/tools/aubinator.c
+@@ -1225,8 +1225,14 @@ int main(int argc, char *argv[])
+ 
+    /* mmap a terabyte for our gtt space. */
+    gtt_size = 1ul << 40;
++/* MAP_NORESERVE removed in FreeBSD 11 and never was implemented before */
++#if defined(__FreeBSD__) || defined(__DragonFly__)
++   gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE,
++              MAP_PRIVATE | MAP_ANONYMOUS |  MAP_NOSYNC | MAP_NOCORE, -1, 0);
++#else
+    gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE,
+               MAP_PRIVATE | MAP_ANONYMOUS |  MAP_NORESERVE, -1, 0);
++#endif
+    if (gtt == MAP_FAILED) {
+       fprintf(stderr, "failed to alloc gtt space: %s\n", strerror(errno));
+       exit(EXIT_FAILURE);
diff -Nur wip/MesaLib/patches/patch-src_mapi_entry.c graphics/MesaLib/patches/patch-src_mapi_entry.c
--- wip/MesaLib/patches/patch-src_mapi_entry.c	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mapi_entry.c	2017-01-07 22:48:52.076793000 -0800
@@ -0,0 +1,1620 @@
+$NetBSD$
+
+For some reason the previously used table_noop_array has a link error.
+
+HACK: Create new array of noop functions.
+BUG: Using environment variable LIBGL_DEBUG=verbose causes
+massive failure in keyboard input for a Radeon 6450 (CAICOS) card.
+
+--- src/mapi/entry.c.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/mapi/entry.c
+@@ -41,6 +41,1609 @@
+ #define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal)
+ #endif
+ 
++#if defined(__NetBSD__) && defined(GLX_USE_TLS)
++static int netbsd_noop_generic(void) {
++    return 0;
++}
++
++/*
++ * src/mapi/table.h defines
++ *    MAPI_TABLE_NUM_SLOTS to be 
++ *      MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC
++ *       = 1330 + 256 = 1586 entries
++ * according to values from mapi/shared-glapi/glapi_mapi_tmp.h
++ */
++
++const mapi_func netbsd_table_noop_array[] = {
...
++    (mapi_func)netbsd_noop_generic
++};
++#endif /* defined(__NetBSD__) && defined(GLX_USE_TLS) */
++
+ #if defined(USE_X86_ASM) && defined(__GNUC__)
+ #   ifdef GLX_USE_TLS
+ #      include "entry_x86_tls.h"
diff -Nur wip/MesaLib/patches/patch-src_mapi_entry__x86-64__tls.h graphics/MesaLib/patches/patch-src_mapi_entry__x86-64__tls.h
--- wip/MesaLib/patches/patch-src_mapi_entry__x86-64__tls.h	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mapi_entry__x86-64__tls.h	2017-01-07 22:53:41.022442000 -0800
@@ -0,0 +1,32 @@
+$NetBSD: patch-src_mapi_entry__x86-64__tls.h,v 1.2 2015/09/26 08:45:02 tnn Exp $
+
+NetBSD only supports zero-initialized initial-exec tls variables in conjuction
+with dlopen(3) at the moment.
+
+Fix --enable-glx-tls with clang. From FreeBSD.
+
+HACK: Renamed non-linking table_noop_array to locally created
+netbsd_table_noop_array.
+
+--- src/mapi/entry_x86-64_tls.h.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/mapi/entry_x86-64_tls.h
+@@ -41,10 +41,19 @@ __asm__(".text\n"
+    ".balign 32\n"                                        \
+    func ":"
+ 
++#if defined(__NetBSD__) && defined(GLX_USE_TLS)
+ #define STUB_ASM_CODE(slot)                              \
+    "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t"  \
+    "movq %fs:(%rax), %r11\n\t"                           \
++   "testq %r11, %r11\n\t"                                \
++   "cmoveq netbsd_table_noop_array @GOTPCREL(%rip), %r11\n\t"    \
+    "jmp *(8 * " slot ")(%r11)"
++#else
++#define STUB_ASM_CODE(slot)                              \
++   "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t"  \
++   "movq %fs:(%rax), %r11\n\t"                           \
++   "jmp *(8 * " slot ")(%r11)"
++#endif
+ 
+ #define MAPI_TMP_STUB_ASM_GCC
+ #include "mapi_tmp.h"
diff -Nur wip/MesaLib/patches/patch-src_mapi_entry__x86__tls.h graphics/MesaLib/patches/patch-src_mapi_entry__x86__tls.h
--- wip/MesaLib/patches/patch-src_mapi_entry__x86__tls.h	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mapi_entry__x86__tls.h	2017-01-07 22:53:59.062795000 -0800
@@ -0,0 +1,40 @@
+$NetBSD: patch-src_mapi_entry__x86__tls.h,v 1.2 2015/09/26 08:45:02 tnn Exp $
+
+NetBSD only supports zero-initialized initial-exec tls variables in conjuction
+with dlopen(3) at the moment.
+
+Fix --enable-glx-tls with clang. From FreeBSD.
+
+HACK: Renamed non-linking table_noop_array to locally created
+netbsd_table_noop_array.
+
+--- src/mapi/entry_x86_tls.h.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/mapi/entry_x86_tls.h
+@@ -56,10 +56,27 @@ __asm__(".balign 16\n"
+    ".balign 16\n"                \
+    func ":"
+ 
++#if defined(__NetBSD__) && defined(GLX_USE_TLS)
++extern const mapi_func netbsd_table_noop_array[];
+ #define STUB_ASM_CODE(slot)      \
+    "call x86_current_tls\n\t"    \
+    "movl %gs:(%eax), %eax\n\t"   \
++   "testl %eax, %eax\n\t"        \
++   "je 1f\n\t"                   \
++   "jmp *(4 * " slot ")(%eax)\n\t" \
++   "1:\n\t"                      \
++   "call 2f\n"                   \
++   "2:\n\t"                      \
++   "popl %eax\n\t"               \
++   "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
++   "movl netbsd_table_noop_array@GOT(%eax), %eax\n\t" \
+    "jmp *(4 * " slot ")(%eax)"
++#else
++#define STUB_ASM_CODE(slot)      \
++   "call x86_current_tls\n\t"    \
++   "movl %gs:(%eax), %eax\n\t"   \
++   "jmp *(4 * " slot ")(%eax)"
++#endif
+ 
+ #define MAPI_TMP_STUB_ASM_GCC
+ #include "mapi_tmp.h"
diff -Nur wip/MesaLib/patches/patch-src_mapi_table.h graphics/MesaLib/patches/patch-src_mapi_table.h
--- wip/MesaLib/patches/patch-src_mapi_table.h	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mapi_table.h	2017-01-04 17:51:17.000000000 -0800
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- src/mapi/table.h.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/mapi/table.h
+@@ -40,7 +40,9 @@
+ struct mapi_table;
+ 
+ extern const mapi_func table_noop_array[];
+-
++#if defined(__NetBSD__) && defined(GLX_USE_TLS)
++extern const mapi_func netbsd_table_noop_array[];
++#endif
+ 
+ typedef void (*nop_handler_proc)(const char *name);
+ 
diff -Nur wip/MesaLib/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c graphics/MesaLib/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c
--- wip/MesaLib/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c	2016-12-10 22:16:21.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c	2016-12-31 18:23:49.000000000 -0800
@@ -3,7 +3,7 @@
 PR pkg/50202.
 Provide compat strndup for older Darwin.
 
---- src/mesa/drivers/dri/common/xmlconfig.c.orig	2016-01-29 12:21:30.000000000 +0000
+--- src/mesa/drivers/dri/common/xmlconfig.c.orig	2016-11-10 22:05:17.000000000 +0000
 +++ src/mesa/drivers/dri/common/xmlconfig.c
 @@ -50,12 +50,17 @@ extern char *program_invocation_name, *p
  #    define GET_PROGRAM_NAME() program_invocation_short_name
@@ -48,3 +48,12 @@
  /** \brief Find an option in an option cache with the name as key */
  static uint32_t findOption (const driOptionCache *cache, const char *name) {
      uint32_t len = strlen (name);
+@@ -939,7 +962,7 @@ static void parseOneConfigFile (XML_Pars
+ }
+ 
+ #ifndef SYSCONFDIR
+-#define SYSCONFDIR "/etc"
++#define SYSCONFDIR "/usr/pkg/etc"
+ #endif
+ 
+ void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
diff -Nur wip/MesaLib/patches/patch-src_mesa_main_shader__query.cpp graphics/MesaLib/patches/patch-src_mesa_main_shader__query.cpp
--- wip/MesaLib/patches/patch-src_mesa_main_shader__query.cpp	2016-12-10 22:16:21.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_mesa_main_shader__query.cpp	2016-12-25 23:06:47.000000000 -0800
@@ -15,34 +15,44 @@
  src/mesa/main/shader_query.cpp | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
-diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
-index bc6fec5..22d9e0f 100644
---- src/mesa/main/shader_query.cpp
+--- src/mesa/main/shader_query.cpp.orig	2016-11-10 22:05:17.000000000 +0000
 +++ src/mesa/main/shader_query.cpp
-@@ -68,7 +68,7 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
+@@ -70,7 +70,12 @@ _mesa_BindAttribLocation(GLuint program,
     GET_CURRENT_CONTEXT(ctx);
  
     struct gl_shader_program *const shProg =
--      _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation");
++#if defined(__APPLE__)
 +      _mesa_lookup_shader_program_err(ctx, (GLuint)(uintptr_t)program, "glBindAttribLocation");
++#else
+       _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation");
++#endif
++
     if (!shProg)
        return;
  
-@@ -136,7 +136,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
+@@ -114,7 +119,12 @@ _mesa_GetActiveAttrib(GLuint program, GL
        return;
     }
  
--   shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib");
++#if defined(__APPLE__)
 +   shProg = _mesa_lookup_shader_program_err(ctx, (GLuint)(uintptr_t)program, "glGetActiveAttrib");
++#else
+    shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib");
++#endif
++
     if (!shProg)
        return;
  
-@@ -250,7 +250,7 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
+@@ -159,7 +169,12 @@ _mesa_GetAttribLocation(GLuint program,
  {
     GET_CURRENT_CONTEXT(ctx);
     struct gl_shader_program *const shProg =
--      _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation");
++
++#if defined(__APPLE__)
 +      _mesa_lookup_shader_program_err(ctx, (GLuint)(uintptr_t)program, "glGetAttribLocation");
++#else
+       _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation");
++#endif
  
     if (!shProg) {
        return -1;
diff -Nur wip/MesaLib/patches/patch-src_util_u__endian.h graphics/MesaLib/patches/patch-src_util_u__endian.h
--- wip/MesaLib/patches/patch-src_util_u__endian.h	1969-12-31 16:00:00.000000000 -0800
+++ graphics/MesaLib/patches/patch-src_util_u__endian.h	2017-01-07 22:56:46.156062000 -0800
@@ -0,0 +1,16 @@
+$NetBSD$
+
+From freebsd-base-ports
+https://github.com/FreeBSDDesktop/freebsd-ports-graphics/tree/xserver-mesa-next-udev
+
+--- src/util/u_endian.h.orig	2016-11-10 22:05:17.000000000 +0000
++++ src/util/u_endian.h
+@@ -54,7 +54,7 @@
+ # define PIPE_ARCH_BIG_ENDIAN
+ #endif
+ 
+-#elif defined(__OpenBSD__) || defined(__NetBSD__)
++#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <sys/types.h>
+ #include <machine/endian.h>
+ 




Home | Main Index | Thread Index | Old Index