aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/drivers/dri')
-rw-r--r--mesalib/src/mesa/drivers/dri/Makefile.am67
-rw-r--r--mesalib/src/mesa/drivers/dri/common/Makefile.am11
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.c76
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.h2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/megadriver_stub.c41
-rw-r--r--mesalib/src/mesa/drivers/dri/gen-symbol-redefs.py68
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/Makefile.am18
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/Makefile.sources6
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c19
9 files changed, 263 insertions, 45 deletions
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am
index 7fa0ad73d..a85a5aa91 100644
--- a/mesalib/src/mesa/drivers/dri/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/Makefile.am
@@ -1,29 +1,45 @@
+dridir = $(DRI_DRIVER_INSTALL_DIR)
+
SUBDIRS =
+MEGADRIVERS =
+MEGADRIVERS_DEPS =
SUBDIRS+=common
if HAVE_I915_DRI
-SUBDIRS+=i915
+SUBDIRS += i915
+MEGADRIVERS_DEPS += i915/libi915_dri.la
+MEGADRIVERS += i915_dri.so
endif
if HAVE_I965_DRI
-SUBDIRS+=i965
+SUBDIRS += i965
+MEGADRIVERS_DEPS += i965/libi965_dri.la
+MEGADRIVERS += i965_dri.so
endif
if HAVE_NOUVEAU_DRI
-SUBDIRS+=nouveau
+SUBDIRS += nouveau
+MEGADRIVERS_DEPS += nouveau/libnouveau_dri.la
+MEGADRIVERS += nouveau_vieux_dri.so
endif
if HAVE_R200_DRI
-SUBDIRS+=r200
+SUBDIRS += r200
+MEGADRIVERS_DEPS += r200/libr200_dri.la
+MEGADRIVERS += r200_dri.so
endif
if HAVE_RADEON_DRI
-SUBDIRS+=radeon
+SUBDIRS += radeon
+MEGADRIVERS_DEPS += radeon/libradeon_dri.la
+MEGADRIVERS += radeon_dri.so
endif
if HAVE_SWRAST_DRI
-SUBDIRS+=swrast
+SUBDIRS += swrast
+MEGADRIVERS_DEPS += swrast/libswrast_dri.la
+MEGADRIVERS += swrast_dri.so
endif
pkgconfigdir = $(libdir)/pkgconfig
@@ -31,3 +47,42 @@ pkgconfig_DATA = dri.pc
driincludedir = $(includedir)/GL/internal
driinclude_HEADERS = $(top_srcdir)/include/GL/internal/dri_interface.h
+
+nodist_EXTRA_mesa_dri_drivers_la_SOURCES = dummy.cpp
+mesa_dri_drivers_la_SOURCES =
+mesa_dri_drivers_la_LDFLAGS = \
+ -module -avoid-version -shared \
+ -Wl,-Bsymbolic \
+ $()
+mesa_dri_drivers_la_LIBADD = \
+ ../../libmesa.la \
+ common/libmegadriver_stub.la \
+ common/libdricommon.la \
+ $(MEGADRIVERS_DEPS) \
+ $(DRI_LIB_DEPS) \
+ $()
+
+if NEED_MEGADRIVER
+dri_LTLIBRARIES = mesa_dri_drivers.la
+
+# Add a link to allow setting LD_LIBRARY_PATH/LIBGL_DRIVERS_PATH to /lib of the build tree.
+all-local: mesa_dri_drivers.la
+ $(MKDIR_P) $(top_builddir)/$(LIB_DIR);
+ $(AM_V_GEN)ln -f .libs/mesa_dri_drivers.so \
+ $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.so;
+ $(AM_V_GEN)for i in $(MEGADRIVERS); do \
+ ln -f $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.so \
+ $(top_builddir)/$(LIB_DIR)/$$i; \
+ done;
+
+# hardlink each megadriver instance, but don't actually have
+# mesa_dri_drivers.so in the set of final installed files.
+install-data-hook:
+ for i in $(MEGADRIVERS); do \
+ ln -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so \
+ $(DESTDIR)$(dridir)/$$i; \
+ done;
+ $(RM) -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so
+ $(RM) -f $(DESTDIR)$(dridir)/mesa_dri_drivers.la
+
+endif
diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am
index ce4119d0f..9f49ff3ae 100644
--- a/mesalib/src/mesa/drivers/dri/common/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am
@@ -27,11 +27,11 @@ AM_CFLAGS = \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
$(DEFINES) \
- $(LIBDRM_CFLAGS) \
$(VISIBILITY_CFLAGS)
noinst_LTLIBRARIES = \
libdricommon.la \
+ libmegadriver_stub.la \
libdri_test_stubs.la
libdricommon_la_SOURCES = \
@@ -43,4 +43,13 @@ libdri_test_stubs_la_SOURCES = \
dri_test.c
libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
+libmegadriver_stub_la_SOURCES = megadriver_stub.c
+
sysconf_DATA = drirc
+
+if DRICOMMON_NEED_LIBDRM
+AM_CFLAGS += $(LIBDRM_CFLAGS)
+libdricommon_la_LDFLAGS = $(LIBDRM_LIBS)
+else
+AM_CFLAGS += -D__NOT_HAVE_DRM_H
+endif
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index db44eede6..c28b0fc41 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -82,6 +82,23 @@ setupLoaderExtensions(__DRIscreen *psp,
}
/**
+ * This pointer determines which driver API we'll use in the case of the
+ * loader not passing us an explicit driver extensions list (that would,
+ * itself, contain a pointer to a driver API.)
+ *
+ * A driver's driDriverGetExtensions_drivername() can update this pointer to
+ * what it's returning, and a loader that is ignorant of createNewScreen2()
+ * will get the correct driver screen created, as long as no other
+ * driDriverGetExtensions() happened in between the first one and the
+ * createNewScreen().
+ *
+ * This allows the X Server to not require the significant dri_interface.h
+ * updates for doing createNewScreen2(), which would discourage backporting of
+ * the X Server patches to support the new loader interface.
+ */
+const struct __DriverAPIRec *globalDriverAPI = &driDriverAPI;
+
+/**
* This is the first entrypoint in the driver called by the DRI driver loader
* after dlopen()ing it.
*
@@ -89,9 +106,10 @@ setupLoaderExtensions(__DRIscreen *psp,
* Display.
*/
static __DRIscreen *
-dri2CreateNewScreen(int scrn, int fd,
- const __DRIextension **extensions,
- const __DRIconfig ***driver_configs, void *data)
+dri2CreateNewScreen2(int scrn, int fd,
+ const __DRIextension **extensions,
+ const __DRIextension **driver_extensions,
+ const __DRIconfig ***driver_configs, void *data)
{
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
@@ -100,7 +118,20 @@ dri2CreateNewScreen(int scrn, int fd,
if (!psp)
return NULL;
- psp->driver = &driDriverAPI;
+ /* By default, use the global driDriverAPI symbol (non-megadrivers). */
+ psp->driver = globalDriverAPI;
+
+ /* If the driver exposes its vtable through its extensions list
+ * (megadrivers), use that instead.
+ */
+ if (driver_extensions) {
+ for (int i = 0; driver_extensions[i]; i++) {
+ if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
+ psp->driver =
+ ((__DRIDriverVtableExtension *)driver_extensions[i])->vtable;
+ }
+ }
+ }
setupLoaderExtensions(psp, extensions);
@@ -154,12 +185,31 @@ dri2CreateNewScreen(int scrn, int fd,
return psp;
}
+static __DRIscreen *
+dri2CreateNewScreen(int scrn, int fd,
+ const __DRIextension **extensions,
+ const __DRIconfig ***driver_configs, void *data)
+{
+ return dri2CreateNewScreen2(scrn, fd, extensions, NULL,
+ driver_configs, data);
+}
+
/** swrast driver createNewScreen entrypoint. */
static __DRIscreen *
-driCreateNewScreen(int scrn, const __DRIextension **extensions,
- const __DRIconfig ***driver_configs, void *data)
+driSWRastCreateNewScreen(int scrn, const __DRIextension **extensions,
+ const __DRIconfig ***driver_configs, void *data)
+{
+ return dri2CreateNewScreen2(scrn, -1, extensions, NULL,
+ driver_configs, data);
+}
+
+static __DRIscreen *
+driSWRastCreateNewScreen2(int scrn, const __DRIextension **extensions,
+ const __DRIextension **driver_extensions,
+ const __DRIconfig ***driver_configs, void *data)
{
- return dri2CreateNewScreen(scrn, -1, extensions, driver_configs, data);
+ return dri2CreateNewScreen2(scrn, -1, extensions, driver_extensions,
+ driver_configs, data);
}
/**
@@ -688,7 +738,7 @@ const __DRIcoreExtension driCoreExtension = {
/** DRI2 interface */
const __DRIdri2Extension driDRI2Extension = {
- .base = { __DRI_DRI2, 3 },
+ .base = { __DRI_DRI2, 4 },
.createNewScreen = dri2CreateNewScreen,
.createNewDrawable = dri2CreateNewDrawable,
@@ -697,15 +747,17 @@ const __DRIdri2Extension driDRI2Extension = {
.createNewContextForAPI = dri2CreateNewContextForAPI,
.allocateBuffer = dri2AllocateBuffer,
.releaseBuffer = dri2ReleaseBuffer,
- .createContextAttribs = dri2CreateContextAttribs
+ .createContextAttribs = dri2CreateContextAttribs,
+ .createNewScreen2 = dri2CreateNewScreen2,
};
const __DRIswrastExtension driSWRastExtension = {
- { __DRI_SWRAST, __DRI_SWRAST_VERSION },
- driCreateNewScreen,
+ { __DRI_SWRAST, 4 },
+ driSWRastCreateNewScreen,
dri2CreateNewDrawable,
dri2CreateNewContextForAPI,
- dri2CreateContextAttribs
+ dri2CreateContextAttribs,
+ driSWRastCreateNewScreen2,
};
const __DRI2configQueryExtension dri2ConfigQueryExtension = {
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h
index 61c80bc45..5b56061e2 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.h
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h
@@ -116,7 +116,7 @@ struct __DriverAPIRec {
};
extern const struct __DriverAPIRec driDriverAPI;
-
+extern const struct __DriverAPIRec *globalDriverAPI;
/**
* Per-screen private driver information.
diff --git a/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c
new file mode 100644
index 000000000..6bf5d7327
--- /dev/null
+++ b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "dri_util.h"
+
+static const
+__DRIconfig **stub_error_init_screen(__DRIscreen *psp)
+{
+ fprintf(stderr, "An updated DRI driver loader (libGL.so or X Server) is "
+ "required for this Mesa driver.\n");
+ return NULL;
+}
+
+/**
+ * This is a stub driDriverAPI that is referenced by dri_util.c but should
+ * never be used.
+ */
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = stub_error_init_screen,
+};
diff --git a/mesalib/src/mesa/drivers/dri/gen-symbol-redefs.py b/mesalib/src/mesa/drivers/dri/gen-symbol-redefs.py
new file mode 100644
index 000000000..ebe4aaa65
--- /dev/null
+++ b/mesalib/src/mesa/drivers/dri/gen-symbol-redefs.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright © 2013 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+import sys
+import argparse
+import re
+import subprocess
+
+# Example usages:
+# ./gen-symbol-redefs.py i915/.libs/libi915_dri.a old_ i915 i830
+# ./gen-symbol-redefs.py r200/.libs/libr200_dri.a r200_ r200
+
+argparser = argparse.ArgumentParser(description="Generates #defines to hide driver global symbols outside of a driver's namespace.")
+argparser.add_argument("file",
+ metavar = 'file',
+ help='libdrivername.a file to read')
+argparser.add_argument("newprefix",
+ metavar = 'newprefix',
+ help='New prefix to give non-driver global symbols')
+argparser.add_argument('prefixes',
+ metavar='prefix',
+ nargs='*',
+ help='driver-specific prefixes')
+args = argparser.parse_args()
+
+stdout = subprocess.check_output(['nm', args.file])
+
+for line in stdout.splitlines():
+ m = re.match("[0-9a-z]+ [BT] (.*)", line)
+ if not m:
+ continue
+
+ symbol = m.group(1)
+
+ has_good_prefix = re.match(args.newprefix, symbol) != None
+ for prefix in args.prefixes:
+ if re.match(prefix, symbol):
+ has_good_prefix = True
+ break
+ if has_good_prefix:
+ continue
+
+ # This is the single public entrypoint.
+ if re.match("__driDriverGetExtensions", symbol):
+ continue
+
+ print '#define {0:35} {1}{0}'.format(symbol, args.newprefix)
diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
index c51ad2d87..0837b4518 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
@@ -34,19 +34,5 @@ AM_CFLAGS = \
$(DEFINES) \
$(VISIBILITY_CFLAGS)
-dridir = $(DRI_DRIVER_INSTALL_DIR)
-dri_LTLIBRARIES = swrast_dri.la
-
-swrast_dri_la_SOURCES = \
- $(SWRAST_C_FILES)
-
-swrast_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS)
-
-swrast_dri_la_LIBADD = \
- $(DRI_LIB_DEPS)
-
-# Provide compatibility with scripts for the old Mesa build system for
-# a while by putting a link to the driver into /lib of the build tree.
-all-local: swrast_dri.la
- $(MKDIR_P) $(top_builddir)/$(LIB_DIR);
- ln -f .libs/swrast_dri.so $(top_builddir)/$(LIB_DIR)/swrast_dri.so;
+noinst_LTLIBRARIES = libswrast_dri.la
+libswrast_dri_la_SOURCES = $(SWRAST_C_FILES)
diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
index fc7ef32db..70e432feb 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
+++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
@@ -1,11 +1,5 @@
SWRAST_DRIVER_FILES = \
swrast.c
-SWRAST_COMMON_FILES = \
- ../common/utils.c \
- ../common/dri_util.c \
- ../common/xmlconfig.c
-
SWRAST_C_FILES = \
- $(SWRAST_COMMON_FILES) \
$(SWRAST_DRIVER_FILES)
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index 4725a7f42..bfa2efd21 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -59,6 +59,7 @@
#include "swrast_priv.h"
#include "swrast/s_context.h"
+const __DRIextension **__driDriverGetExtensions_swrast(void);
/**
* Screen and config-related functions
@@ -819,7 +820,7 @@ dri_unbind_context(__DRIcontext * cPriv)
}
-const struct __DriverAPIRec driDriverAPI = {
+static const struct __DriverAPIRec swrast_driver_api = {
.InitScreen = dri_init_screen,
.DestroyScreen = dri_destroy_screen,
.CreateContext = dri_create_context,
@@ -831,9 +832,21 @@ const struct __DriverAPIRec driDriverAPI = {
.UnbindContext = dri_unbind_context,
};
-/* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
+static const struct __DRIDriverVtableExtensionRec swrast_vtable = {
+ .base = { __DRI_DRIVER_VTABLE, 1 },
+ .vtable = &swrast_driver_api,
+};
+
+static const __DRIextension *swrast_driver_extensions[] = {
&driCoreExtension.base,
&driSWRastExtension.base,
+ &swrast_vtable.base,
NULL
};
+
+PUBLIC const __DRIextension **__driDriverGetExtensions_swrast(void)
+{
+ globalDriverAPI = &swrast_driver_api;
+
+ return swrast_driver_extensions;
+}