[Mesa-dev] [PATCH 1/3] gallium/scons: OpenSWR Windows support
Kyriazis, George
george.kyriazis at intel.com
Tue Nov 8 22:48:45 UTC 2016
> -----Original Message-----
> From: Jose Fonseca [mailto:jfonseca at vmware.com]
> Sent: Tuesday, November 8, 2016 4:17 PM
> To: Kyriazis, George <george.kyriazis at intel.com>; mesa-
> dev at lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH 1/3] gallium/scons: OpenSWR Windows
> support
>
> On 07/11/16 22:32, George Kyriazis wrote:
> > - Added code to create screen and handle swaps in libgl_gdi.c
> > - Added call to swr SConscript
> > - included llvm 3.9 support for scons (windows swr only support 3.9 and
> > later)
> > - include -DHAVE_SWR to subdirs that need it
> >
> > To buils SWR on windows, use "scons swr libgl-gdi"
> > ---
> > scons/llvm.py | 21 +++++++++++++++++++--
> > src/gallium/SConscript | 1 +
> > src/gallium/targets/libgl-gdi/SConscript | 4 ++++
> > src/gallium/targets/libgl-gdi/libgl_gdi.c | 28
> > +++++++++++++++++++++++----- src/gallium/targets/libgl-xlib/SConscript
> | 4 ++++
> > src/gallium/targets/osmesa/SConscript | 4 ++++
> > 6 files changed, 55 insertions(+), 7 deletions(-)
> >
> > diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a
> > 100644
> > --- a/scons/llvm.py
> > +++ b/scons/llvm.py
> > @@ -106,7 +106,24 @@ def generate(env):
> > ])
> > env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
> > # LIBS should match the output of `llvm-config --libs engine mcjit
> bitwriter x86asmprinter`
> > - if llvm_version >= distutils.version.LooseVersion('3.7'):
> > + if llvm_version >= distutils.version.LooseVersion('3.9'):
> > + env.Prepend(LIBS = [
> > + 'LLVMX86Disassembler', 'LLVMX86AsmParser',
> > + 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter',
> > + 'LLVMDebugInfoCodeView', 'LLVMCodeGen',
> > + 'LLVMScalarOpts', 'LLVMInstCombine',
> > + 'LLVMInstrumentation', 'LLVMTransformUtils',
> > + 'LLVMBitWriter', 'LLVMX86Desc',
> > + 'LLVMMCDisassembler', 'LLVMX86Info',
> > + 'LLVMX86AsmPrinter', 'LLVMX86Utils',
> > + 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget',
> > + 'LLVMAnalysis', 'LLVMProfileData',
> > + 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser',
> > + 'LLVMBitReader', 'LLVMMC', 'LLVMCore',
> > + 'LLVMSupport',
> > + 'LLVMIRReader', 'LLVMASMParser'
> > + ])
> > + elif llvm_version >= distutils.version.LooseVersion('3.7'):
> > env.Prepend(LIBS = [
> > 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
> > 'LLVMX86CodeGen', 'LLVMSelectionDAG',
> > 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env):
> > if '-fno-rtti' in cxxflags:
> > env.Append(CXXFLAGS = ['-fno-rtti'])
> >
> > - components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter',
> 'mcdisassembler']
> > + components = ['engine', 'mcjit', 'bitwriter',
> > + 'x86asmprinter', 'mcdisassembler', 'irreader']
> >
> > env.ParseConfig('llvm-config --libs ' + ' '.join(components))
> > env.ParseConfig('llvm-config --ldflags') diff --git
> > a/src/gallium/SConscript b/src/gallium/SConscript index
> > f98268f..9273db7 100644
> > --- a/src/gallium/SConscript
> > +++ b/src/gallium/SConscript
> > @@ -18,6 +18,7 @@ SConscript([
> > 'drivers/softpipe/SConscript',
> > 'drivers/svga/SConscript',
> > 'drivers/trace/SConscript',
> > + 'drivers/swr/SConscript',
> > ])
> >
> > #
> > diff --git a/src/gallium/targets/libgl-gdi/SConscript
> > b/src/gallium/targets/libgl-gdi/SConscript
> > index 2a52363..ef8050b 100644
> > --- a/src/gallium/targets/libgl-gdi/SConscript
> > +++ b/src/gallium/targets/libgl-gdi/SConscript
> > @@ -30,6 +30,10 @@ if env['llvm']:
> > env.Append(CPPDEFINES = 'HAVE_LLVMPIPE')
> > drivers += [llvmpipe]
> >
> > + if 'swr' in COMMAND_LINE_TARGETS :
> > + env.Append(CPPDEFINES = 'HAVE_SWR')
> > + drivers += [swr]
> > +
> > if env['gcc'] and env['machine'] != 'x86_64':
> > # DEF parser in certain versions of MinGW is busted, as does not behave
> as
> > # MSVC. mingw-w64 works fine.
> > diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c
> > b/src/gallium/targets/libgl-gdi/libgl_gdi.c
> > index 922c186..12576db 100644
> > --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c
> > +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c
> > @@ -51,9 +51,12 @@
> > #include "llvmpipe/lp_public.h"
> > #endif
> >
> > +#ifdef HAVE_SWR
> > +#include "swr/swr_public.h"
> > +#endif
> >
> > static boolean use_llvmpipe = FALSE;
> > -
> > +static boolean use_swr = FALSE;
> >
> > static struct pipe_screen *
> > gdi_screen_create(void)
> > @@ -69,6 +72,8 @@ gdi_screen_create(void)
> >
> > #ifdef HAVE_LLVMPIPE
> > default_driver = "llvmpipe";
> > +#elif HAVE_SWR
> > + default_driver = "swr";
> > #else
> > default_driver = "softpipe";
> > #endif
> > @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE
> > if (strcmp(driver, "llvmpipe") == 0) {
> > screen = llvmpipe_create_screen( winsys );
> > + if (screen)
> > + use_llvmpipe = TRUE;
> > + }
> > +#endif
> > +#ifdef HAVE_SWR
>
> > + if (strcmp(driver, "swr") == 0) {
> > + screen = swr_create_screen( winsys );
> > + if (screen)
> > + use_swr = TRUE;
> > }
> > -#else
> > - (void) driver;
> > #endif
> > + (void) driver;
> >
> > if (screen == NULL) {
> > screen = softpipe_create_screen( winsys );
> > - } else {
> > - use_llvmpipe = TRUE;
> > }
> >
> > if(!screen)
> > @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen,
> > }
> > #endif
> >
> > +#ifdef HAVE_SWR
> > + if (use_swr) {
> > + swr_gdi_swap(screen, res, hDC);
> > + return;
> > + }
> > +#endif
> > +
> > winsys = softpipe_screen(screen)->winsys,
> > dt = softpipe_resource(res)->dt,
> > gdi_sw_display(winsys, dt, hDC);
> > diff --git a/src/gallium/targets/libgl-xlib/SConscript
> > b/src/gallium/targets/libgl-xlib/SConscript
> > index 0a4f31b..43b433b 100644
> > --- a/src/gallium/targets/libgl-xlib/SConscript
> > +++ b/src/gallium/targets/libgl-xlib/SConscript
> > @@ -48,6 +48,10 @@ if env['llvm']:
> > env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE'])
> > env.Prepend(LIBS = [llvmpipe])
> >
> > + if 'swr' in COMMAND_LINE_TARGETS :
> > + env.Append(CPPDEFINES = 'HAVE_SWR')
> > + env.Prepend(LIBS = [swr])
> > +
>
> COMMAND_LINE_TARGETS is not a good way IMHO. It makes no sense that
> the behavior of libgl-xlib varies depending whether we also build another
> target.
>
> Instead you should define a SCons variable, e.g., swr.
>
> scons swr=1 libgl-xlib
>
Yes, I see. The reason why 'swr' was added as a command-line target was that there are 2 additional libraries that are generated here, swrAVX.dll and swrAVX2.dll, which can viewed as 'targets'. I can switch to using a variable, though.
Thanks,
George
>
> > if env['platform'] != 'darwin':
> > # Disallow undefined symbols, except with Address Sanitizer, since
> libasan
> > # is not linked on shared libs, as it should be LD_PRELOAD'ed
> > instead diff --git a/src/gallium/targets/osmesa/SConscript
> > b/src/gallium/targets/osmesa/SConscript
> > index 7a2a00c..ede2782 100644
> > --- a/src/gallium/targets/osmesa/SConscript
> > +++ b/src/gallium/targets/osmesa/SConscript
> > @@ -30,6 +30,10 @@ if env['llvm']:
> > env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
> > env.Prepend(LIBS = [llvmpipe])
> >
> > + if 'swr' in COMMAND_LINE_TARGETS :
> > + env.Append(CPPDEFINES = 'HAVE_SWR')
> > + env.Prepend(LIBS = [swr])
> > +
> > if env['platform'] == 'windows':
> > if env['gcc'] and env['machine'] != 'x86_64':
> > sources += ['osmesa.mingw.def']
> >
>
>
> Jose
More information about the mesa-dev
mailing list