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

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


i915 has symbols for formerly-shared code that conflict with i965, so we
define them away using gen-symbol-redefs.py.  Options considered:

- This option.  Downsides: The symbols in profiling and debugging don't
  match the source.  The symbol list may change in the future and we won't
  notice without manually running the tool again.

- Use objcopy --localize-hidden to automatically demote our symbols to
  locals.  This didn't work on i965 due to c++ weak symbols (which can't
  be localized), but could work on i915.  We could do it on i915 only, but
  it does produce libtool warnings at link time due to libtool not knowing
  if the resulting .o file is safe to link (stupid libtool).  Plus you end
  up with different symbols of the same name, which is confusing for
  debugging too.  On the other hand, no future symbol conflicts long term.

- Write our own libelf tool that handles c++ weak symbols like we want and
  apply it to all drivers.  All the downsides of above, but applies
  uniformly across drivers.

- Edit the files to just rename all the i915 or i965 symbols that
  conflict.  There are on the order of 100 that have a prefix we used to
  share, so it would take a bit of typing.  Fewest downsides, but still
  can have conflicts long term.

Ultimately, this is the least invasive change at the moment, and we can
see if the "more symbol conflicts appear later" thing is a real concern or
not.

Note that the ability to compile a version of i915 without INTEL_DEBUG env
support is dropped.  It's too useful.
---
 configure.ac                                  |   2 +-
 src/mesa/drivers/dri/Makefile.am              |   2 +
 src/mesa/drivers/dri/i915/Makefile.am         |  16 +---
 src/mesa/drivers/dri/i915/intel_context.c     |   2 -
 src/mesa/drivers/dri/i915/intel_mipmap_tree.h |   1 +
 src/mesa/drivers/dri/i915/intel_screen.c      |  15 +++-
 src/mesa/drivers/dri/i915/intel_screen.h      | 103 ++++++++++++++++++++++++++
 7 files changed, 123 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 92f6a26..87c353a 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"; then
+    if test $driver != "i965" -a $driver != "nouveau" -a $driver != "i915"; 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 6152fcc..5aff40a 100644
--- a/src/mesa/drivers/dri/Makefile.am
+++ b/src/mesa/drivers/dri/Makefile.am
@@ -17,6 +17,8 @@ endif
 
 if HAVE_I915_DRI
 SUBDIRS+=i915
+MEGADRIVERS_DEPS += i915/libi915_dri.la
+MEGADRIVERS += i915_dri.so
 endif
 
 if HAVE_I965_DRI
diff --git a/src/mesa/drivers/dri/i915/Makefile.am b/src/mesa/drivers/dri/i915/Makefile.am
index 46dd4c2..93ae663 100644
--- a/src/mesa/drivers/dri/i915/Makefile.am
+++ b/src/mesa/drivers/dri/i915/Makefile.am
@@ -38,18 +38,8 @@ AM_CFLAGS = \
 dridir = $(DRI_DRIVER_INSTALL_DIR)
 
 if HAVE_I915_DRI
-dri_LTLIBRARIES = i915_dri.la
+noinst_LTLIBRARIES = libi915_dri.la
 endif
 
-i915_dri_la_SOURCES = $(i915_FILES)
-i915_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS)
-i915_dri_la_LIBADD = \
-	../common/libdricommon.la \
-	$(DRI_LIB_DEPS) \
-	$(INTEL_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: i915_dri.la
-	$(MKDIR_P) $(top_builddir)/$(LIB_DIR);
-	ln -f .libs/i915_dri.so $(top_builddir)/$(LIB_DIR)/i915_dri.so;
+libi915_dri_la_SOURCES = $(i915_FILES)
+libi915_dri_la_LIBADD = $(INTEL_LIBS)
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index d25358b..2748514 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -58,9 +58,7 @@
 #include "utils.h"
 #include "../glsl/ralloc.h"
 
-#ifndef INTEL_DEBUG
 int INTEL_DEBUG = (0);
-#endif
 
 
 static const GLubyte *
diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.h b/src/mesa/drivers/dri/i915/intel_mipmap_tree.h
index 2b2a644..1142af6 100644
--- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.h
@@ -30,6 +30,7 @@
 
 #include <assert.h>
 
+#include "intel_screen.h"
 #include "intel_regions.h"
 
 #ifdef __cplusplus
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index 49bae5d..dcf5997 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -1190,7 +1190,7 @@ intelReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
 }
 
 
-const struct __DriverAPIRec driDriverAPI = {
+static const struct __DriverAPIRec i915_driver_api = {
    .InitScreen		 = intelInitScreen2,
    .DestroyScreen	 = intelDestroyScreen,
    .CreateContext	 = intelCreateContext,
@@ -1203,10 +1203,21 @@ const struct __DriverAPIRec driDriverAPI = {
    .ReleaseBuffer        = intelReleaseBuffer
 };
 
+static const struct __DRIDriverVtableExtensionRec i915_vtable = {
+   .base = { __DRI_DRIVER_VTABLE, 1 },
+   .vtable = &i915_driver_api,
+};
+
 /* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
+static const __DRIextension *i915_driver_extensions[] = {
     &driCoreExtension.base,
     &driDRI2Extension.base,
+    &i915_vtable.base,
     &i915_config_options.base,
     NULL
 };
+
+PUBLIC const __DRIextension **__driDriverGetExtensions_i915(void)
+{
+   return i915_driver_extensions;
+}
diff --git a/src/mesa/drivers/dri/i915/intel_screen.h b/src/mesa/drivers/dri/i915/intel_screen.h
index 331ce90..4ae259c 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.h
+++ b/src/mesa/drivers/dri/i915/intel_screen.h
@@ -55,10 +55,113 @@ struct intel_screen
    driOptionCache optionCache;
 };
 
+/* These defines are to ensure that i915_dri's symbols don't conflict with
+ * i965's when linked together.
+ */
+#define intel_region_alloc                  old_intel_region_alloc
+#define intel_region_alloc_for_fd           old_intel_region_alloc_for_fd
+#define intel_region_alloc_for_handle       old_intel_region_alloc_for_handle
+#define intel_region_flink                  old_intel_region_flink
+#define intel_region_get_aligned_offset     old_intel_region_get_aligned_offset
+#define intel_region_get_tile_masks         old_intel_region_get_tile_masks
+#define intel_region_reference              old_intel_region_reference
+#define intel_region_release                old_intel_region_release
+#define intel_bufferobj_buffer              old_intel_bufferobj_buffer
+#define intel_bufferobj_source              old_intel_bufferobj_source
+#define intelInitBufferObjectFuncs          old_intelInitBufferObjectFuncs
+#define intel_upload_data                   old_intel_upload_data
+#define intel_upload_finish                 old_intel_upload_finish
+#define intel_batchbuffer_data              old_intel_batchbuffer_data
+#define intel_batchbuffer_emit_mi_flush     old_intel_batchbuffer_emit_mi_flush
+#define intel_batchbuffer_emit_reloc        old_intel_batchbuffer_emit_reloc
+#define intel_batchbuffer_emit_reloc_fenced old_intel_batchbuffer_emit_reloc_fenced
+#define _intel_batchbuffer_flush            old__intel_batchbuffer_flush
+#define intel_batchbuffer_free              old_intel_batchbuffer_free
+#define intel_batchbuffer_init              old_intel_batchbuffer_init
+#define intelInitClearFuncs                 old_intelInitClearFuncs
+#define intelInitExtensions                 old_intelInitExtensions
+#define intel_miptree_copy_teximage         old_intel_miptree_copy_teximage
+#define intel_miptree_create                old_intel_miptree_create
+#define intel_miptree_create_for_bo         old_intel_miptree_create_for_bo
+#define intel_miptree_create_for_dri2_buffer old_intel_miptree_create_for_dri2_buffer
+#define intel_miptree_create_for_renderbuffer old_intel_miptree_create_for_renderbuffer
+#define intel_miptree_create_layout         old_intel_miptree_create_layout
+#define intel_miptree_get_dimensions_for_image old_intel_miptree_get_dimensions_for_image
+#define intel_miptree_get_image_offset      old_intel_miptree_get_image_offset
+#define intel_miptree_get_tile_offsets      old_intel_miptree_get_tile_offsets
+#define intel_miptree_map                   old_intel_miptree_map
+#define intel_miptree_map_raw               old_intel_miptree_map_raw
+#define intel_miptree_match_image           old_intel_miptree_match_image
+#define intel_miptree_reference             old_intel_miptree_reference
+#define intel_miptree_release               old_intel_miptree_release
+#define intel_miptree_set_image_offset      old_intel_miptree_set_image_offset
+#define intel_miptree_set_level_info        old_intel_miptree_set_level_info
+#define intel_miptree_unmap                 old_intel_miptree_unmap
+#define intel_miptree_unmap_raw             old_intel_miptree_unmap_raw
+#define i945_miptree_layout_2d              old_i945_miptree_layout_2d
+#define intel_get_texture_alignment_unit    old_intel_get_texture_alignment_unit
+#define intelInitTextureImageFuncs          old_intelInitTextureImageFuncs
+#define intel_miptree_create_for_teximage   old_intel_miptree_create_for_teximage
+#define intelSetTexBuffer                   old_intelSetTexBuffer
+#define intelSetTexBuffer2                  old_intelSetTexBuffer2
+#define intelInitTextureSubImageFuncs       old_intelInitTextureSubImageFuncs
+#define intelInitTextureCopyImageFuncs      old_intelInitTextureCopyImageFuncs
+#define intel_finalize_mipmap_tree          old_intel_finalize_mipmap_tree
+#define intelInitTextureFuncs               old_intelInitTextureFuncs
+#define intel_check_blit_fragment_ops       old_intel_check_blit_fragment_ops
+#define intelInitPixelFuncs                 old_intelInitPixelFuncs
+#define intelBitmap                         old_intelBitmap
+#define intelCopyPixels                     old_intelCopyPixels
+#define intelDrawPixels                     old_intelDrawPixels
+#define intelReadPixels                     old_intelReadPixels
+#define intel_check_front_buffer_rendering  old_intel_check_front_buffer_rendering
+#define intelInitBufferFuncs                old_intelInitBufferFuncs
+#define intelClearWithBlit                  old_intelClearWithBlit
+#define intelEmitCopyBlit                   old_intelEmitCopyBlit
+#define intelEmitImmediateColorExpandBlit   old_intelEmitImmediateColorExpandBlit
+#define intel_emit_linear_blit              old_intel_emit_linear_blit
+#define intel_miptree_blit                  old_intel_miptree_blit
+#define i945_miptree_layout                 old_i945_miptree_layout
+#define intel_init_texture_formats          old_intel_init_texture_formats
+#define intelCalcViewport                   old_intelCalcViewport
+#define INTEL_DEBUG                         old_INTEL_DEBUG
+#define intelDestroyContext                 old_intelDestroyContext
+#define intelFinish                         old_intelFinish
+#define _intel_flush                        old__intel_flush
+#define intel_flush_rendering_to_batch      old_intel_flush_rendering_to_batch
+#define intelInitContext                    old_intelInitContext
+#define intelInitDriverFunctions            old_intelInitDriverFunctions
+#define intelMakeCurrent                    old_intelMakeCurrent
+#define intel_prepare_render                old_intel_prepare_render
+#define intelUnbindContext                  old_intelUnbindContext
+#define intel_update_renderbuffers          old_intel_update_renderbuffers
+#define aub_dump_bmp                        old_aub_dump_bmp
+#define get_time                            old_get_time
+#define intel_translate_blend_factor        old_intel_translate_blend_factor
+#define intel_translate_compare_func        old_intel_translate_compare_func
+#define intel_translate_logic_op            old_intel_translate_logic_op
+#define intel_translate_shadow_compare_func old_intel_translate_shadow_compare_func
+#define intel_translate_stencil_op          old_intel_translate_stencil_op
+#define intel_init_syncobj_functions        old_intel_init_syncobj_functions
+#define intelChooseRenderState              old_intelChooseRenderState
+#define intelFallback                       old_intelFallback
+#define intel_finish_vb                     old_intel_finish_vb
+#define intel_flush_prim                    old_intel_flush_prim
+#define intel_get_prim_space                old_intel_get_prim_space
+#define intelInitTriFuncs                   old_intelInitTriFuncs
+#define intel_set_prim                      old_intel_set_prim
+#define intel_create_private_renderbuffer   old_intel_create_private_renderbuffer
+#define intel_create_renderbuffer           old_intel_create_renderbuffer
+#define intel_fbo_init                      old_intel_fbo_init
+#define intel_get_rb_region                 old_intel_get_rb_region
+#define intel_renderbuffer_set_draw_offset  old_intel_renderbuffer_set_draw_offset
+
 extern void intelDestroyContext(__DRIcontext * driContextPriv);
 
 extern GLboolean intelUnbindContext(__DRIcontext * driContextPriv);
 
+const __DRIextension **__driDriverGetExtensions_i915(void);
+
 extern GLboolean
 intelMakeCurrent(__DRIcontext * driContextPriv,
                  __DRIdrawable * driDrawPriv,
-- 
1.8.4.rc3



More information about the mesa-dev mailing list