swr: build driver proper separate from rasterizer
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 29 Jun 2017 19:37:07 +0000 (14:37 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Tue, 11 Jul 2017 18:38:20 +0000 (13:38 -0500)
swr used to build and link the rasterizer to the driver, and to support
multiple architectures we needed to have multiple versions of the
driver/rasterizer combination, which needed to link in much of mesa.

Changing to having one instance of the driver and just building
architecture specific versions of the rasterizer gives a large reduction
in disk space.

libGL.so        6464 Kb ->  7000 Kb
libswrAVX.so   10068 Kb ->  5432 Kb
libswrAVX2.so   9828 Kb ->  5200 Kb

Total          26360 Kb -> 17632 Kb

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/drivers/swr/Makefile.am
src/gallium/drivers/swr/SConscript
src/gallium/drivers/swr/swr_context.cpp
src/gallium/drivers/swr/swr_loader.cpp
src/gallium/drivers/swr/swr_screen.h

index 4b4bd3793b37d7f6125b86f882bad83928e7a026..74612280fe73729e67d86ab923810109f48fb063 100644 (file)
@@ -26,7 +26,14 @@ AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) $(SWR_CXX11_CXXFLAGS)
 
 noinst_LTLIBRARIES = libmesaswr.la
 
-libmesaswr_la_SOURCES = $(LOADER_SOURCES)
+# gen_knobs.* included here to provide driver access to swr configuration
+libmesaswr_la_SOURCES = \
+       $(CXX_SOURCES) \
+       $(COMMON_CXX_SOURCES) \
+       $(JITTER_CXX_SOURCES) \
+       rasterizer/codegen/gen_knobs.cpp \
+       rasterizer/codegen/gen_knobs.h \
+       $(LOADER_SOURCES)
 
 COMMON_CXXFLAGS = \
        -fno-strict-aliasing \
@@ -43,12 +50,15 @@ COMMON_CXXFLAGS = \
        -I$(srcdir)/rasterizer/jitter \
        -I$(srcdir)/rasterizer/archrast
 
+# SWR_AVX_CXXFLAGS needed for intrinsic usage in swr api headers
+libmesaswr_la_CXXFLAGS = \
+       $(SWR_AVX_CXXFLAGS) \
+       $(COMMON_CXXFLAGS)
+
 COMMON_SOURCES = \
-       $(CXX_SOURCES) \
        $(ARCHRAST_CXX_SOURCES) \
        $(COMMON_CXX_SOURCES) \
        $(CORE_CXX_SOURCES) \
-       $(JITTER_CXX_SOURCES) \
        $(MEMORY_CXX_SOURCES) \
        $(BUILT_SOURCES)
 
@@ -207,19 +217,12 @@ rasterizer.intermediate: rasterizer/codegen/gen_backends.py rasterizer/codegen/t
                --cpp \
                --hpp
 
-COMMON_LIBADD = \
-       $(top_builddir)/src/gallium/auxiliary/libgallium.la \
-       $(top_builddir)/src/mesa/libmesagallium.la \
-       $(LLVM_LIBS)
-
 COMMON_LDFLAGS = \
        -shared \
        -module \
        -no-undefined \
        $(GC_SECTIONS) \
-       $(NO_UNDEFINED) \
-       $(LLVM_LDFLAGS)
-
+       $(NO_UNDEFINED)
 
 lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
 
@@ -231,9 +234,6 @@ libswrAVX_la_CXXFLAGS = \
 libswrAVX_la_SOURCES = \
        $(COMMON_SOURCES)
 
-libswrAVX_la_LIBADD = \
-       $(COMMON_LIBADD)
-
 libswrAVX_la_LDFLAGS = \
        $(COMMON_LDFLAGS)
 
@@ -245,9 +245,6 @@ libswrAVX2_la_CXXFLAGS = \
 libswrAVX2_la_SOURCES = \
        $(COMMON_SOURCES)
 
-libswrAVX2_la_LIBADD = \
-       $(COMMON_LIBADD)
-
 libswrAVX2_la_LDFLAGS = \
        $(COMMON_LDFLAGS)
 
index 512269afbefcb76b66e1400cd066ba4192d5bcc1..cdfb91a5bba42d15f3a70fb2739d77ed11599c44 100644 (file)
@@ -30,12 +30,6 @@ else:
     llvm_includedir = env.backtick('%s --includedir' % llvm_config).rstrip()
     print "llvm include dir %s" % llvm_includedir
 
-# the loader is included in the mesa lib itself
-# All the remaining files are in loadable modules
-loadersource = env.ParseSourceList('Makefile.sources', [
-    'LOADER_SOURCES'
-])
-
 if not env['msvc'] :
     env.Append(CCFLAGS = [
         '-std=c++11',
@@ -191,16 +185,12 @@ built_sources += [backendPixelRateFiles, genRasterizerFiles]
 
 source = built_sources
 source += env.ParseSourceList(swrroot + 'Makefile.sources', [
-    'CXX_SOURCES',
     'ARCHRAST_CXX_SOURCES',
     'COMMON_CXX_SOURCES',
     'CORE_CXX_SOURCES',
-    'JITTER_CXX_SOURCES',
     'MEMORY_CXX_SOURCES'
 ])
 
-env.Prepend(LIBS = [ mesautil, mesa, gallium ])
-
 env.Prepend(CPPPATH = [
     '.',
     'rasterizer',
@@ -242,14 +232,24 @@ swrAVX2 = envavx2.SharedLibrary(
     )
 env.Alias('swrAVX2', swrAVX2)
 
+source = env.ParseSourceList(swrroot + 'Makefile.sources', [
+    'CXX_SOURCES',
+    'COMMON_CXX_SOURCES',
+    'JITTER_CXX_SOURCES',
+    'LOADER_SOURCES'
+])
+source += [
+    'rasterizer/codegen/gen_knobs.cpp',
+    'rasterizer/archrast/gen_ar_event.cpp',
+    ]
 
 # main SWR lib
-swr = env.ConvenienceLibrary(
+envSWR = envavx.Clone() # pick up the arch flag for intrinsic usage
+swr = envSWR.ConvenienceLibrary(
     target = 'swr',
-    source = loadersource,
+    source = source,
     )
 
-
 # treat arch libs as dependencies, even though they are not linked
 # into swr, so we don't have to build them separately
 Depends(swr, ['swrAVX', 'swrAVX2'])
index 9648278c691784b25d8edeffd4773a6af2c9eed3..c058870f2762bf279d6c5b0ed2909f1cd580be2c 100644 (file)
@@ -467,7 +467,7 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
       AlignedMalloc(sizeof(struct swr_context), KNOB_SIMD_BYTES);
    memset(ctx, 0, sizeof(struct swr_context));
 
-   SwrGetInterface(ctx->api);
+   swr_screen(p_screen)->pfnSwrGetInterface(ctx->api);
    ctx->swrDC.pAPI = &ctx->api;
 
    ctx->blendJIT =
index 4d71a671044747046a93730b44d67e54ee8a46ca..d56fb0e59fb0d86b71482c1423719e807ec56b80 100644 (file)
 #include "util/u_cpu_detect.h"
 #include "util/u_dl.h"
 #include "swr_public.h"
-
-#include "pipe/p_screen.h"
+#include "swr_screen.h"
 
 #include <stdio.h>
 
-typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys);
-
 struct pipe_screen *
 swr_create_screen(struct sw_winsys *winsys)
 {
@@ -57,16 +54,17 @@ swr_create_screen(struct sw_winsys *winsys)
       exit(-1);
    }
 
-   util_dl_proc pScreenProc = util_dl_get_proc_address(pLibrary, "swr_create_screen_internal");
+   util_dl_proc pApiProc = util_dl_get_proc_address(pLibrary, "SwrGetInterface");
 
-   if (!pScreenProc) {
+   if (!pApiProc) {
       fprintf(stderr, "SWR library search failure: %s\n", util_dl_error());
       exit(-1);
    }
 
-   screen_create_proc pScreenCreate = (screen_create_proc)pScreenProc;
+   struct pipe_screen *screen = swr_create_screen_internal(winsys);
+   swr_screen(screen)->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
 
-   return pScreenCreate(winsys);
+   return screen;
 }
 
 
index dc1bb47f02d5acce13f5d93640b4ab431d012d1c..a10f42653543f58459b537871b90f7285477d2d2 100644 (file)
@@ -47,6 +47,8 @@ struct swr_screen {
    uint8_t msaa_max_count;
 
    HANDLE hJitMgr;
+
+   PFNSwrGetInterface pfnSwrGetInterface;
 };
 
 static INLINE struct swr_screen *