[Mesa-dev] [PATCH 12/14] radeon: Build the driver into the shared mesa_dri_drivers.so.

Eric Anholt eric at anholt.net
Mon Sep 30 13:44:49 PDT 2013


This required some reordering of headers to ensure that the symbol name
redefines happened before any prototypes.
---
 configure.ac                                       |  2 +-
 src/mesa/drivers/dri/Makefile.am                   |  4 +
 src/mesa/drivers/dri/r200/Makefile.am              | 18 +---
 src/mesa/drivers/dri/radeon/Makefile.am            | 18 +---
 .../drivers/dri/radeon/radeon_buffer_objects.c     |  3 +-
 .../drivers/dri/radeon/radeon_common_context.h     |  2 +-
 src/mesa/drivers/dri/radeon/radeon_debug.c         |  2 +-
 src/mesa/drivers/dri/radeon/radeon_fog.c           |  1 +
 src/mesa/drivers/dri/radeon/radeon_pixel_read.c    |  2 +-
 src/mesa/drivers/dri/radeon/radeon_screen.c        | 22 ++++-
 src/mesa/drivers/dri/radeon/radeon_screen.h        | 98 ++++++++++++++++++++++
 src/mesa/drivers/dri/radeon/radeon_tile.c          |  1 +
 12 files changed, 135 insertions(+), 38 deletions(-)

diff --git a/configure.ac b/configure.ac
index 87c353a..5649aec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1035,7 +1035,7 @@ fi
 enable_dricore=no
 enable_megadriver=no
 for driver in $DRI_DIRS; do
-    if test $driver != "i965" -a $driver != "nouveau" -a $driver != "i915"; then
+    if test $driver = "swrast"; then
         enable_dricore=yes
     else
         enable_megadriver=yes
diff --git a/src/mesa/drivers/dri/Makefile.am b/src/mesa/drivers/dri/Makefile.am
index 5aff40a..cc1eb2b 100644
--- a/src/mesa/drivers/dri/Makefile.am
+++ b/src/mesa/drivers/dri/Makefile.am
@@ -35,10 +35,14 @@ endif
 
 if HAVE_R200_DRI
 SUBDIRS+=r200
+MEGADRIVERS_DEPS += r200/libr200_dri.la
+MEGADRIVERS += r200_dri.so
 endif
 
 if HAVE_RADEON_DRI
 SUBDIRS+=radeon
+MEGADRIVERS_DEPS += radeon/libradeon_dri.la
+MEGADRIVERS += radeon_dri.so
 endif
 
 if HAVE_SWRAST_DRI
diff --git a/src/mesa/drivers/dri/r200/Makefile.am b/src/mesa/drivers/dri/r200/Makefile.am
index fc0482a..be405d7 100644
--- a/src/mesa/drivers/dri/r200/Makefile.am
+++ b/src/mesa/drivers/dri/r200/Makefile.am
@@ -39,20 +39,8 @@ AM_CFLAGS = \
 dridir = $(DRI_DRIVER_INSTALL_DIR)
 
 if HAVE_R200_DRI
-dri_LTLIBRARIES = r200_dri.la
+noinst_LTLIBRARIES = libr200_dri.la
 endif
 
-r200_dri_la_SOURCES = \
-        $(R200_C_FILES)
-
-r200_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS)
-r200_dri_la_LIBADD = \
-	../common/libdricommon.la \
-	$(DRI_LIB_DEPS) \
-	$(RADEON_LIBS)
-
-# 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: r200_dri.la
-	$(MKDIR_P) $(top_builddir)/$(LIB_DIR);
-	ln -f .libs/r200_dri.so $(top_builddir)/$(LIB_DIR)/r200_dri.so;
+libr200_dri_la_SOURCES = $(R200_C_FILES)
+libr200_dri_la_LIBADD = $(RADEON_LIBS)
diff --git a/src/mesa/drivers/dri/radeon/Makefile.am b/src/mesa/drivers/dri/radeon/Makefile.am
index d13b803..89102df 100644
--- a/src/mesa/drivers/dri/radeon/Makefile.am
+++ b/src/mesa/drivers/dri/radeon/Makefile.am
@@ -39,20 +39,8 @@ AM_CFLAGS = \
 dridir = $(DRI_DRIVER_INSTALL_DIR)
 
 if HAVE_RADEON_DRI
-dri_LTLIBRARIES = radeon_dri.la
+noinst_LTLIBRARIES = libradeon_dri.la
 endif
 
-radeon_dri_la_SOURCES = \
-        $(RADEON_C_FILES)
-
-radeon_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS)
-radeon_dri_la_LIBADD = \
-	../common/libdricommon.la \
-	$(DRI_LIB_DEPS) \
-	$(RADEON_LIBS)
-
-# 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: radeon_dri.la
-	$(MKDIR_P) $(top_builddir)/$(LIB_DIR);
-	ln -f .libs/radeon_dri.so $(top_builddir)/$(LIB_DIR)/radeon_dri.so;
+libradeon_dri_la_SOURCES = $(RADEON_C_FILES)
+libradeon_dri_la_LIBADD = $(RADEON_LIBS)
diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
index 5abc52b..40a16c3 100644
--- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
+++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
@@ -25,13 +25,12 @@
  *
  */
 
-#include "radeon_buffer_objects.h"
-
 #include "main/imports.h"
 #include "main/mtypes.h"
 #include "main/bufferobj.h"
 
 #include "radeon_common.h"
+#include "radeon_buffer_objects.h"
 
 struct radeon_buffer_object *
 get_radeon_buffer_object(struct gl_buffer_object *obj)
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index 8437f34..ab55071 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -7,8 +7,8 @@
 #include "tnl/t_context.h"
 #include "main/colormac.h"
 
-#include "radeon_debug.h"
 #include "radeon_screen.h"
+#include "radeon_debug.h"
 #include "radeon_drm.h"
 #include "dri_util.h"
 #include "tnl/t_vertex.h"
diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c
index dd0afb8..7ddba1a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_debug.c
+++ b/src/mesa/drivers/dri/radeon/radeon_debug.c
@@ -29,8 +29,8 @@
 
 #include "utils.h"
 
-#include "radeon_debug.h"
 #include "radeon_common_context.h"
+#include "radeon_debug.h"
 
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/src/mesa/drivers/dri/radeon/radeon_fog.c b/src/mesa/drivers/dri/radeon/radeon_fog.c
index bd2642b..8b69570 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fog.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fog.c
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/enums.h"
 #include "main/macros.h"
 
+#include "radeon_screen.h"
 #include "radeon_fog.h"
 
 /**********************************************************************/
diff --git a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
index db5e01d..0aa00bd 100644
--- a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
+++ b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c
@@ -33,8 +33,8 @@
 #include "main/readpix.h"
 #include "main/state.h"
 
-#include "radeon_buffer_objects.h"
 #include "radeon_common_context.h"
+#include "radeon_buffer_objects.h"
 #include "radeon_debug.h"
 #include "radeon_mipmap_tree.h"
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index b0cc2d7..b03c3dc 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -764,7 +764,7 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp)
    return (const __DRIconfig **)configs;
 }
 
-const struct __DriverAPIRec driDriverAPI = {
+static const struct __DriverAPIRec radeon_driver_api = {
    .InitScreen      = radeonInitScreen2,
    .DestroyScreen   = radeonDestroyScreen,
 #if defined(RADEON_R200)
@@ -780,10 +780,28 @@ const struct __DriverAPIRec driDriverAPI = {
    .UnbindContext   = radeonUnbindContext,
 };
 
+static const struct __DRIDriverVtableExtensionRec radeon_vtable = {
+   .base = { __DRI_DRIVER_VTABLE, 1 },
+   .vtable = &radeon_driver_api,
+};
+
 /* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
+static const __DRIextension *radeon_driver_extensions[] = {
     &driCoreExtension.base,
     &driDRI2Extension.base,
     &radeon_config_options.base,
+    &radeon_vtable.base,
     NULL
 };
+
+#ifdef RADEON_R200
+PUBLIC const __DRIextension **__driDriverGetExtensions_r200(void)
+{
+   return radeon_driver_extensions;
+}
+#else
+PUBLIC const __DRIextension **__driDriverGetExtensions_radeon(void)
+{
+   return radeon_driver_extensions;
+}
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h
index dd618f5..03abb2a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.h
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.h
@@ -118,5 +118,103 @@ struct __DRIimageRec {
    void *data;
 };
 
+#ifdef RADEON_R200
+/* These defines are to ensure that r200_dri's symbols don't conflict with
+ * radeon's when linked together.
+ */
+#define get_radeon_buffer_object            r200_get_radeon_buffer_object
+#define radeonInitBufferObjectFuncs         r200_radeonInitBufferObjectFuncs
+#define radeonDestroyContext                r200_radeonDestroyContext
+#define radeonInitContext                   r200_radeonInitContext
+#define radeonMakeCurrent                   r200_radeonMakeCurrent
+#define radeon_prepare_render               r200_radeon_prepare_render
+#define radeonUnbindContext                 r200_radeonUnbindContext
+#define radeon_update_renderbuffers         r200_radeon_update_renderbuffers
+#define radeon_check_front_buffer_rendering r200_radeon_check_front_buffer_rendering
+#define radeonCountStateEmitSize            r200_radeonCountStateEmitSize
+#define radeon_draw_buffer                  r200_radeon_draw_buffer
+#define radeonDrawBuffer                    r200_radeonDrawBuffer
+#define radeonEmitState                     r200_radeonEmitState
+#define radeonFinish                        r200_radeonFinish
+#define radeonFlush                         r200_radeonFlush
+#define radeonGetAge                        r200_radeonGetAge
+#define radeonReadBuffer                    r200_radeonReadBuffer
+#define radeonScissor                       r200_radeonScissor
+#define radeonSetCliprects                  r200_radeonSetCliprects
+#define radeonUpdateScissor                 r200_radeonUpdateScissor
+#define radeonUserClear                     r200_radeonUserClear
+#define radeon_viewport                     r200_radeon_viewport
+#define radeon_window_moved                 r200_radeon_window_moved
+#define rcommonBeginBatch                   r200_rcommonBeginBatch
+#define rcommonDestroyCmdBuf                r200_rcommonDestroyCmdBuf
+#define rcommonEnsureCmdBufSpace            r200_rcommonEnsureCmdBufSpace
+#define rcommonFlushCmdBuf                  r200_rcommonFlushCmdBuf
+#define rcommonFlushCmdBufLocked            r200_rcommonFlushCmdBufLocked
+#define rcommonInitCmdBuf                   r200_rcommonInitCmdBuf
+#define radeonAllocDmaRegion                r200_radeonAllocDmaRegion
+#define radeonEmitVec12                     r200_radeonEmitVec12
+#define radeonEmitVec16                     r200_radeonEmitVec16
+#define radeonEmitVec4                      r200_radeonEmitVec4
+#define radeonEmitVec8                      r200_radeonEmitVec8
+#define radeonFreeDmaRegions                r200_radeonFreeDmaRegions
+#define radeon_init_dma                     r200_radeon_init_dma
+#define radeonRefillCurrentDmaRegion        r200_radeonRefillCurrentDmaRegion
+#define radeonReleaseArrays                 r200_radeonReleaseArrays
+#define radeonReleaseDmaRegions             r200_radeonReleaseDmaRegions
+#define radeonReturnDmaRegion               r200_radeonReturnDmaRegion
+#define rcommonAllocDmaLowVerts             r200_rcommonAllocDmaLowVerts
+#define rcommon_emit_vecfog                 r200_rcommon_emit_vecfog
+#define rcommon_emit_vector                 r200_rcommon_emit_vector
+#define rcommon_flush_last_swtcl_prim       r200_rcommon_flush_last_swtcl_prim
+#define _radeon_debug_add_indent            r200__radeon_debug_add_indent
+#define _radeon_debug_remove_indent         r200__radeon_debug_remove_indent
+#define radeon_init_debug                   r200_radeon_init_debug
+#define _radeon_print                       r200__radeon_print
+#define radeon_create_renderbuffer          r200_radeon_create_renderbuffer
+#define radeon_fbo_init                     r200_radeon_fbo_init
+#define radeon_renderbuffer_set_bo          r200_radeon_renderbuffer_set_bo
+#define radeonComputeFogBlendFactor         r200_radeonComputeFogBlendFactor
+#define radeonInitStaticFogData             r200_radeonInitStaticFogData
+#define get_base_teximage_offset            r200_get_base_teximage_offset
+#define get_texture_image_row_stride        r200_get_texture_image_row_stride
+#define get_texture_image_size              r200_get_texture_image_size
+#define radeon_miptree_create               r200_radeon_miptree_create
+#define radeon_miptree_image_offset         r200_radeon_miptree_image_offset
+#define radeon_miptree_matches_image        r200_radeon_miptree_matches_image
+#define radeon_miptree_reference            r200_radeon_miptree_reference
+#define radeon_miptree_unreference          r200_radeon_miptree_unreference
+#define radeon_try_alloc_miptree            r200_radeon_try_alloc_miptree
+#define radeon_validate_texture_miptree     r200_radeon_validate_texture_miptree
+#define radeonReadPixels                    r200_radeonReadPixels
+#define radeon_check_query_active           r200_radeon_check_query_active
+#define radeonEmitQueryEnd                  r200_radeonEmitQueryEnd
+#define radeon_emit_queryobj                r200_radeon_emit_queryobj
+#define radeonInitQueryObjFunctions         r200_radeonInitQueryObjFunctions
+#define radeonInitSpanFuncs                 r200_radeonInitSpanFuncs
+#define copy_rows                           r200_copy_rows
+#define radeonChooseTextureFormat           r200_radeonChooseTextureFormat
+#define radeonChooseTextureFormat_mesa      r200_radeonChooseTextureFormat_mesa
+#define radeonFreeTextureImageBuffer        r200_radeonFreeTextureImageBuffer
+#define radeon_image_target_texture_2d      r200_radeon_image_target_texture_2d
+#define radeon_init_common_texture_funcs    r200_radeon_init_common_texture_funcs
+#define radeonIsFormatRenderable            r200_radeonIsFormatRenderable
+#define radeonNewTextureImage               r200_radeonNewTextureImage
+#define _radeon_texformat_al88              r200__radeon_texformat_al88
+#define _radeon_texformat_argb1555          r200__radeon_texformat_argb1555
+#define _radeon_texformat_argb4444          r200__radeon_texformat_argb4444
+#define _radeon_texformat_argb8888          r200__radeon_texformat_argb8888
+#define _radeon_texformat_rgb565            r200__radeon_texformat_rgb565
+#define _radeon_texformat_rgba8888          r200__radeon_texformat_rgba8888
+#define radeonCopyTexSubImage               r200_radeonCopyTexSubImage
+#define get_tile_size                       r200_get_tile_size
+#define tile_image                          r200_tile_image
+#define untile_image                        r200_untile_image
+#define set_re_cntl_d3d                     r200_set_re_cntl_d3d
+#define radeonDestroyBuffer                 r200_radeonDestroyBuffer
+#endif
+
 extern void radeonDestroyBuffer(__DRIdrawable *driDrawPriv);
+const __DRIextension **__driDriverGetExtensions_radeon(void);
+const __DRIextension **__driDriverGetExtensions_r200(void);
+
 #endif /* __RADEON_SCREEN_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_tile.c b/src/mesa/drivers/dri/radeon/radeon_tile.c
index 403da11..b95961f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tile.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tile.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include "radeon_screen.h"
 #include "radeon_tile.h"
 
 #include <stdint.h>
-- 
1.8.4.rc3



More information about the mesa-dev mailing list