[Mesa-dev] [PATCH 2/2] swr: build driver proper separate from rasterizer

Tim Rowley timothy.o.rowley at intel.com
Fri Jul 7 21:25:34 UTC 2017


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
---
 src/gallium/drivers/swr/Makefile.am     | 24 +++++++++++++-----------
 src/gallium/drivers/swr/swr_context.cpp |  2 +-
 src/gallium/drivers/swr/swr_loader.cpp  | 14 ++++++--------
 src/gallium/drivers/swr/swr_screen.h    |  2 ++
 4 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
index 4b4bd37..e764e0d 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -26,7 +26,13 @@ AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) $(SWR_CXX11_CXXFLAGS)
 
 noinst_LTLIBRARIES = libmesaswr.la
 
-libmesaswr_la_SOURCES = $(LOADER_SOURCES)
+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 +49,15 @@ COMMON_CXXFLAGS = \
 	-I$(srcdir)/rasterizer/jitter \
 	-I$(srcdir)/rasterizer/archrast
 
+libmesaswr_la_CXXFLAGS = \
+	$(SWR_AVX_CXXFLAGS) \
+	-DKNOB_ARCH=KNOB_ARCH_AVX \
+	$(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 +216,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
 
diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp
index 9648278..c058870 100644
--- a/src/gallium/drivers/swr/swr_context.cpp
+++ b/src/gallium/drivers/swr/swr_context.cpp
@@ -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 =
diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp
index 4d71a67..d56fb0e 100644
--- a/src/gallium/drivers/swr/swr_loader.cpp
+++ b/src/gallium/drivers/swr/swr_loader.cpp
@@ -24,13 +24,10 @@
 #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;
 }
 
 
diff --git a/src/gallium/drivers/swr/swr_screen.h b/src/gallium/drivers/swr/swr_screen.h
index dc1bb47..a10f426 100644
--- a/src/gallium/drivers/swr/swr_screen.h
+++ b/src/gallium/drivers/swr/swr_screen.h
@@ -47,6 +47,8 @@ struct swr_screen {
    uint8_t msaa_max_count;
 
    HANDLE hJitMgr;
+
+   PFNSwrGetInterface pfnSwrGetInterface;
 };
 
 static INLINE struct swr_screen *
-- 
2.7.4



More information about the mesa-dev mailing list