From 8d364221e98cde38b9a9ee21f47787fc60187e4a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 25 Oct 2010 18:42:03 +0100 Subject: gallivm: always enable LLVMAddInstructionCombiningPass() --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 5598ca5c489..0b9a6f745fb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -145,13 +145,7 @@ lp_build_init(void) LLVMAddCFGSimplificationPass(lp_build_pass); LLVMAddPromoteMemoryToRegisterPass(lp_build_pass); LLVMAddConstantPropagationPass(lp_build_pass); - if(util_cpu_caps.has_sse4_1) { - /* FIXME: There is a bug in this pass, whereby the combination of fptosi - * and sitofp (necessary for trunc/floor/ceil/round implementation) - * somehow becomes invalid code. - */ - LLVMAddInstructionCombiningPass(lp_build_pass); - } + LLVMAddInstructionCombiningPass(lp_build_pass); LLVMAddGVNPass(lp_build_pass); } else { /* We need at least this pass to prevent the backends to fail in -- cgit v1.2.3 From 85a08f8fc761d8501fc315d16df6ce0fba9f091e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 18 Oct 2010 06:24:30 -0700 Subject: gallivm: Remove the EMMS opcodes. Unnecessary now that lp_set_target_options() successful disables MMX code emission. --- src/gallium/auxiliary/draw/draw_llvm.c | 10 ---------- src/gallium/drivers/llvmpipe/lp_state_fs.c | 5 ----- 2 files changed, 15 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 140e596f994..2b5f01cda74 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1164,11 +1164,6 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) sampler->destroy(sampler); -#ifdef PIPE_ARCH_X86 - /* Avoid corrupting the FPU stack on 32bit OSes. */ - lp_build_intrinsic(builder, "llvm.x86.mmx.emms", LLVMVoidType(), NULL, 0); -#endif - ret = LLVMBuildLoad(builder, ret_ptr,""); LLVMBuildRet(builder, ret); @@ -1378,11 +1373,6 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian sampler->destroy(sampler); -#ifdef PIPE_ARCH_X86 - /* Avoid corrupting the FPU stack on 32bit OSes. */ - lp_build_intrinsic(builder, "llvm.x86.mmx.emms", LLVMVoidType(), NULL, 0); -#endif - ret = LLVMBuildLoad(builder, ret_ptr,""); LLVMBuildRet(builder, ret); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 9fbedac165f..e4495e33d09 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -761,11 +761,6 @@ generate_fragment(struct llvmpipe_screen *screen, } } -#ifdef PIPE_ARCH_X86 - /* Avoid corrupting the FPU stack on 32bit OSes. */ - lp_build_intrinsic(builder, "llvm.x86.mmx.emms", LLVMVoidType(), NULL, 0); -#endif - LLVMBuildRetVoid(builder); LLVMDisposeBuilder(builder); -- cgit v1.2.3 From 601498ae73e654c2de997ea75075613a694d604d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Nov 2010 13:30:22 +0000 Subject: scons: Revamp how to specify targets to build. Use scons target and dependency system instead of ad-hoc options. Now is simply a matter of naming what to build. For example: scons libgl-xlib scons libgl-gdi scons graw-progs scons llvmpipe and so on. And there is also the possibility of scepcified subdirs, e.g. scons src/gallium/drivers If nothing is specified then everything will be build. There might be some rough corners over the next days. Please bare with me. --- SConstruct | 123 +---- common.py | 40 +- scons/gallium.py | 88 +++- scons/llvm.py | 13 +- scons/udis86.py | 4 +- scons/x11.py | 18 +- src/SConscript | 20 +- src/egl/main/SConscript | 92 ++-- src/egl/main/eglconfig.h | 1 + src/gallium/SConscript | 98 +++- src/gallium/auxiliary/SConscript | 71 +-- src/gallium/drivers/i915/SConscript | 2 +- src/gallium/drivers/i965/SConscript | 2 +- src/gallium/drivers/llvmpipe/README | 65 +-- src/gallium/drivers/llvmpipe/SConscript | 6 +- src/gallium/drivers/rbug/README | 16 +- src/gallium/drivers/softpipe/SConscript | 2 + src/gallium/drivers/sw/SConscript | 1 - src/gallium/drivers/trace/README | 18 +- src/gallium/state_trackers/egl/SConscript | 53 ++- src/gallium/state_trackers/glx/xlib/SConscript | 38 +- src/gallium/state_trackers/python/SConscript | 106 +++-- src/gallium/state_trackers/vega/SConscript | 81 ++-- src/gallium/state_trackers/xorg/SConscript | 63 +-- src/gallium/targets/SConscript | 41 -- src/gallium/targets/SConscript.dri | 32 +- src/gallium/targets/dri-i915/SConscript | 8 +- src/gallium/targets/dri-i965/SConscript | 8 +- src/gallium/targets/dri-r300/SConscript | 8 +- src/gallium/targets/dri-r600/SConscript | 8 +- src/gallium/targets/dri-swrast/SConscript | 5 +- src/gallium/targets/dri-vmwgfx/SConscript | 8 +- src/gallium/targets/egl-gdi/SConscript | 92 ++-- src/gallium/targets/graw-null/SConscript | 40 +- src/gallium/targets/graw-null/graw_null.c | 69 +-- src/gallium/targets/graw-null/graw_util.c | 53 +++ src/gallium/targets/graw-xlib/SConscript | 19 +- src/gallium/targets/graw-xlib/graw_util.c | 50 -- src/gallium/targets/libgl-gdi/SConscript | 85 ++-- src/gallium/targets/libgl-xlib/SConscript | 27 +- src/gallium/targets/xorg-vmwgfx/SConscript | 114 +++-- src/gallium/tests/graw/SConscript | 26 +- src/gallium/tests/unit/SConscript | 4 +- src/gallium/winsys/SConscript | 67 ++- src/glut/glx/SConscript | 1 - src/mapi/glapi/SConscript | 143 +++--- src/mapi/vgapi/.gitignore | 1 + src/mesa/SConscript | 629 +++++++++++++------------ 48 files changed, 1172 insertions(+), 1387 deletions(-) delete mode 100644 src/gallium/targets/SConscript create mode 100644 src/gallium/targets/graw-null/graw_util.c delete mode 100644 src/gallium/targets/graw-xlib/graw_util.c create mode 100644 src/mapi/vgapi/.gitignore (limited to 'src/gallium/auxiliary') diff --git a/SConstruct b/SConstruct index 558ebf90aaa..c6198041fb0 100644 --- a/SConstruct +++ b/SConstruct @@ -3,14 +3,14 @@ # # For example, invoke scons as # -# scons debug=1 dri=0 machine=x86 +# scons build=debug llvm=yes machine=x86 # # to set configuration variables. Or you can write those options to a file # named config.py: # # # config.py -# debug=1 -# dri=0 +# build='debug' +# llvm=True # machine='x86' # # Invoke @@ -30,54 +30,8 @@ import common ####################################################################### # Configuration options -default_statetrackers = 'mesa' -default_targets = 'graw-null' - -if common.default_platform in ('linux', 'freebsd', 'darwin'): - default_drivers = 'softpipe,galahad,failover,svga,i915,i965,trace,identity,llvmpipe' - default_winsys = 'xlib' -elif common.default_platform in ('winddk',): - default_drivers = 'softpipe,svga,i915,i965,trace,identity' - default_winsys = 'all' -elif common.default_platform in ('embedded',): - default_drivers = 'softpipe,llvmpipe' - default_winsys = 'xlib' -else: - default_drivers = 'all' - default_winsys = 'all' - opts = Variables('config.py') common.AddOptions(opts) -opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, - ['mesa', 'python', 'xorg', 'egl'])) -opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, - ['softpipe', 'galahad', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'r600', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx'])) -opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, - ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'r600', 'graw-xlib'])) - -opts.Add(ListVariable('targets', 'driver targets to build', default_targets, - ['dri-i915', - 'dri-i965', - 'dri-nouveau', - 'dri-radeong', - 'dri-swrast', - 'dri-vmwgfx', - 'egl-i915', - 'egl-i965', - 'egl-nouveau', - 'egl-radeon', - 'egl-swrast', - 'egl-vmwgfx', - 'graw-xlib', - 'graw-null', - 'libgl-gdi', - 'libgl-xlib', - 'xorg-i915', - 'xorg-i965', - 'xorg-nouveau', - 'xorg-radeon', - 'xorg-vmwgfx'])) - opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) env = Environment( @@ -87,61 +41,26 @@ env = Environment( ENV = os.environ, ) -if os.environ.has_key('CC'): - env['CC'] = os.environ['CC'] -if os.environ.has_key('CFLAGS'): - env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) -if os.environ.has_key('CXX'): - env['CXX'] = os.environ['CXX'] -if os.environ.has_key('CXXFLAGS'): - env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) -if os.environ.has_key('LDFLAGS'): - env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) +# Backwards compatability with old target configuration variable +try: + targets = ARGUMENTS['targets'] +except KeyError: + pass +else: + targets = targets.split(',') + print 'scons: warning: targets option is deprecated; pass the targets on their own such as' + print + print ' scons %s' % ' '.join(targets) + print + COMMAND_LINE_TARGETS.append(targets) -Help(opts.GenerateHelpText(env)) -# replicate options values in local variables -debug = env['debug'] -dri = env['dri'] -machine = env['machine'] -platform = env['platform'] - -# derived options -x86 = machine == 'x86' -ppc = machine == 'ppc' -gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded') -msvc = platform in ('windows', 'winddk') - -Export([ - 'debug', - 'x86', - 'ppc', - 'dri', - 'platform', - 'gcc', - 'msvc', -]) +Help(opts.GenerateHelpText(env)) ####################################################################### # Environment setup -# Always build trace, rbug, identity, softpipe, and llvmpipe (where possible) -if 'trace' not in env['drivers']: - env['drivers'].append('trace') -if 'rbug' not in env['drivers']: - env['drivers'].append('rbug') -if 'galahad' not in env['drivers']: - env['drivers'].append('galahad') -if 'identity' not in env['drivers']: - env['drivers'].append('identity') -if 'softpipe' not in env['drivers']: - env['drivers'].append('softpipe') -if env['llvm'] and 'llvmpipe' not in env['drivers']: - env['drivers'].append('llvmpipe') -if 'sw' not in env['drivers']: - env['drivers'].append('sw') - # Includes env.Prepend(CPPPATH = [ '#/include', @@ -157,7 +76,7 @@ if env['msvc']: env.Append(CPPPATH = ['#include/c99']) # Embedded -if platform == 'embedded': +if env['platform'] == 'embedded': env.Append(CPPDEFINES = [ '_POSIX_SOURCE', ('_POSIX_C_SOURCE', '199309L'), @@ -174,7 +93,7 @@ if platform == 'embedded': ]) # Posix -if platform in ('posix', 'linux', 'freebsd', 'darwin'): +if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'): env.Append(CPPDEFINES = [ '_POSIX_SOURCE', ('_POSIX_C_SOURCE', '199309L'), @@ -184,9 +103,9 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'): 'PTHREADS', 'HAVE_POSIX_MEMALIGN', ]) - if gcc: + if env['gcc']: env.Append(CFLAGS = ['-fvisibility=hidden']) - if platform == 'darwin': + if env['platform'] == 'darwin': env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) env.Append(LIBS = [ 'm', @@ -212,5 +131,3 @@ SConscript( duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) -env.Default('src') - diff --git a/common.py b/common.py index 13e8dc83e97..b7749c925df 100644 --- a/common.py +++ b/common.py @@ -8,6 +8,8 @@ import subprocess import sys import platform as _platform +import SCons.Script.SConscript + ####################################################################### # Defaults @@ -20,6 +22,15 @@ _platform_map = { default_platform = sys.platform default_platform = _platform_map.get(default_platform, default_platform) +# Search sys.argv[] for a "platform=foo" argument since we don't have +# an 'env' variable at this point. +if 'platform' in SCons.Script.ARGUMENTS: + selected_platform = SCons.Script.ARGUMENTS['platform'] +else: + selected_platform = default_platform + +cross_compiling = selected_platform != default_platform + _machine_map = { 'x86': 'x86', 'i386': 'x86', @@ -37,38 +48,26 @@ if 'PROCESSOR_ARCHITECTURE' in os.environ: else: default_machine = _platform.machine() default_machine = _machine_map.get(default_machine, 'generic') +default_toolchain = 'default' + +if selected_platform == 'windows' and cross_compiling: + default_machine = 'x86' + default_toolchain = 'crossmingw' # find default_llvm value if 'LLVM' in os.environ: default_llvm = 'yes' else: - # Search sys.argv[] for a "platform=foo" argument since we don't have - # an 'env' variable at this point. - platform = default_platform - pattern = re.compile("(platform=)(.*)") - for arg in sys.argv: - m = pattern.match(arg) - if m: - platform = m.group(2) - default_llvm = 'no' try: - if platform != 'windows' and subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: + if selected_platform != 'windows' and \ + subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: default_llvm = 'yes' except: pass -# find default_dri value -if default_platform in ('linux', 'freebsd'): - default_dri = 'yes' -elif default_platform in ('winddk', 'windows', 'wince', 'darwin'): - default_dri = 'no' -else: - default_dri = 'no' - - ####################################################################### # Common options @@ -88,8 +87,7 @@ def AddOptions(opts): allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin', 'sunos5', 'freebsd8'))) - opts.Add('toolchain', 'compiler toolchain', 'default') + opts.Add('toolchain', 'compiler toolchain', default_toolchain) opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) - opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes')) opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no')) diff --git a/scons/gallium.py b/scons/gallium.py index b065b7bc49f..194b1524e6c 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -98,6 +98,38 @@ def num_jobs(): return 1 +def pkg_config_modules(env, name, modules): + '''Simple wrapper for pkg-config.''' + + env[name] = False + + if env['platform'] == 'windows': + return + + if not env.Detect('pkg-config'): + return + + # Put -I and -L flags directly into the environment, as these don't affect + # the compilation of targets that do not use them + try: + env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules)) + except OSError: + return + + # Other flags may affect the compilation of unrelated targets, so store + # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc) + try: + flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules)) + except OSError: + return + prefix = name.upper() + '_' + for flag_name, flag_value in flags.iteritems(): + env[prefix + flag_name] = flag_value + + env[name] = True + + + def generate(env): """Common environment generation code""" @@ -110,21 +142,27 @@ def generate(env): env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) - if env['platform'] == 'embedded': - # Allow overriding compiler from environment - if os.environ.has_key('CC'): - env['CC'] = os.environ['CC'] - # Update CCVERSION to match - pipe = SCons.Action._subproc(env, [env['CC'], '--version'], - stdin = 'devnull', - stderr = 'devnull', - stdout = subprocess.PIPE) - if pipe.wait() == 0: - line = pipe.stdout.readline() - match = re.search(r'[0-9]+(\.[0-9]+)+', line) - if match: - env['CCVERSION'] = match.group(0) - + # Allow override compiler and specify additional flags from environment + if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] + # Update CCVERSION to match + pipe = SCons.Action._subproc(env, [env['CC'], '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + if pipe.wait() == 0: + line = pipe.stdout.readline() + match = re.search(r'[0-9]+(\.[0-9]+)+', line) + if match: + env['CCVERSION'] = match.group(0) + if os.environ.has_key('CFLAGS'): + env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) + if os.environ.has_key('CXX'): + env['CXX'] = os.environ['CXX'] + if os.environ.has_key('CXXFLAGS'): + env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) + if os.environ.has_key('LDFLAGS'): + env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') env['msvc'] = env['CC'] == 'cl' @@ -140,10 +178,16 @@ def generate(env): # Backwards compatability with the debug= profile= options if env['build'] == 'debug': if not env['debug']: - print 'scons: debug option is deprecated: use instead build=release' + print 'scons: warning: debug option is deprecated and will be removed eventually; use instead' + print + print ' scons build=release' + print env['build'] = 'release' if env['profile']: - print 'scons: profile option is deprecated: use instead build=profile' + print 'scons: warning: profile option is deprecated and will be removed eventually; use instead' + print + print ' scons build=profile' + print env['build'] = 'profile' if False: # Enforce SConscripts to use the new build variable @@ -184,6 +228,9 @@ def generate(env): if env.GetOption('num_jobs') <= 1: env.SetOption('num_jobs', num_jobs()) + env.Decider('MD5-timestamp') + env.SetOption('max_drift', 60) + # C preprocessor options cppdefines = [] if env['build'] in ('debug', 'checked'): @@ -499,9 +546,14 @@ def generate(env): # Default libs env.Append(LIBS = []) - # Load LLVM + # Load tools if env['llvm']: env.Tool('llvm') + env.Tool('udis86') + + pkg_config_modules(env, 'x11', ['x11', 'xext']) + pkg_config_modules(env, 'dri', ['libdrm']) + pkg_config_modules(env, 'xorg', ['xorg-server']) # Custom builders and methods env.Tool('custom') diff --git a/scons/llvm.py b/scons/llvm.py index 39fbb910b6d..1b033acb1b3 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -38,6 +38,8 @@ import SCons.Util def generate(env): + env['llvm'] = False + try: llvm_dir = os.environ['LLVM'] except KeyError: @@ -64,13 +66,13 @@ def generate(env): # XXX: There is no llvm-config on Windows, so assume a standard layout if llvm_dir is None: print 'scons: LLVM environment variable must be specified when building for windows' - env.Exit(1) + return # Try to determine the LLVM version from llvm/Config/config.h llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h') if not os.path.exists(llvm_config): print 'scons: could not find %s' % llvm_config - env.Exit(1) + return llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"') llvm_version = None for line in open(llvm_config, 'rt'): @@ -81,7 +83,7 @@ def generate(env): break if llvm_version is None: print 'scons: could not determine the LLVM version from %s' % llvm_config - env.Exit(1) + return env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) env.AppendUnique(CPPDEFINES = [ @@ -133,7 +135,7 @@ def generate(env): else: if not env.Detect('llvm-config'): print 'scons: llvm-config script not found' % llvm_version - env.Exit(1) + return llvm_version = env.backtick('llvm-config --version').rstrip() llvm_version = distutils.version.LooseVersion(llvm_version) @@ -144,11 +146,12 @@ def generate(env): env.ParseConfig('llvm-config --ldflags') except OSError: print 'scons: llvm-config version %s failed' % llvm_version - env.Exit(1) + return else: env['LINK'] = env['CXX'] assert llvm_version is not None + env['llvm'] = True print 'scons: Found LLVM version %s' % llvm_version env['LLVM_VERSION'] = llvm_version diff --git a/scons/udis86.py b/scons/udis86.py index ba71d4eb0b8..bb91d3c35cf 100644 --- a/scons/udis86.py +++ b/scons/udis86.py @@ -31,8 +31,10 @@ def generate(env): conf = env.Configure() if conf.CheckHeader('udis86.h'): # and conf.CheckLib('udis86'): - env.Append(CPPDEFINES = [('HAVE_UDIS86', '1')]) + env['UDIS86'] = True env.Prepend(LIBS = ['udis86']) + else: + env['UDIS86'] = False conf.Finish() diff --git a/scons/x11.py b/scons/x11.py index 99bf079626e..7368618f3bb 100644 --- a/scons/x11.py +++ b/scons/x11.py @@ -29,24 +29,12 @@ Tool-specific initialization for X11 def generate(env): - env.Append(CPPPATH = ['/usr/X11R6/include']) - env.Append(LIBPATH = ['/usr/X11R6/lib']) - - env.Append(LIBS = [ - 'X11', - 'Xext', - 'Xxf86vm', - 'Xdamage', - 'Xfixes', - ]) + # XXX: backwards compatability only + pass def exists(env): - # TODO: actually detect the presence of the headers - if env['platform'] in ('linux', 'freebsd', 'darwin'): - return True - else: - return False + return True # vim:set ts=4 sw=4 et: diff --git a/src/SConscript b/src/SConscript index c3e34be6f76..c42d9bff2d7 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,19 +1,17 @@ Import('*') -if 'egl' in env['statetrackers']: - SConscript('mapi/vgapi/SConscript') - SConscript('egl/main/SConscript') +SConscript('mapi/vgapi/SConscript') -if 'mesa' in env['statetrackers']: - if platform == 'windows': - SConscript('talloc/SConscript') +if env['platform'] == 'windows': + SConscript('egl/main/SConscript') + SConscript('talloc/SConscript') - SConscript('glsl/SConscript') - SConscript('mapi/glapi/SConscript') - SConscript('mesa/SConscript') +SConscript('glsl/SConscript') +SConscript('mapi/glapi/SConscript') +SConscript('mesa/SConscript') - if platform != 'embedded': - SConscript('glut/glx/SConscript') +if env['platform'] != 'embedded': + SConscript('glut/glx/SConscript') SConscript('gallium/SConscript') diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index 8ade85b3572..f001b81600f 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -4,49 +4,49 @@ Import('*') -if env['platform'] != 'winddk': - - env = env.Clone() - - env.Append(CPPDEFINES = [ - '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS', - '_EGL_DRIVER_SEARCH_DIR=\\"\\"', - '_EGL_OS_WINDOWS', - '_EGL_GET_CORE_ADDRESSES', - 'KHRONOS_DLL_EXPORTS', - ]) - - env.Append(CPPPATH = [ - '#/include', - ]) - - egl_sources = [ - 'eglapi.c', - 'eglarray.c', - 'eglconfig.c', - 'eglcontext.c', - 'eglcurrent.c', - 'egldisplay.c', - 'egldriver.c', - 'eglfallbacks.c', - 'eglglobals.c', - 'eglimage.c', - 'egllog.c', - 'eglmisc.c', - 'eglmode.c', - 'eglscreen.c', - 'eglstring.c', - 'eglsurface.c', - 'eglsync.c', - ] - - egl = env.SharedLibrary( - target = 'libEGL', - source = egl_sources + ['egl.def'], - ) - - env.InstallSharedLibrary(egl, version=(1, 4, 0)) - - egl = [env.FindIxes(egl, 'LIBPREFIX', 'LIBSUFFIX')] - - Export('egl') +env = env.Clone() + +env.Append(CPPDEFINES = [ + '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS', + '_EGL_DRIVER_SEARCH_DIR=\\"\\"', + '_EGL_OS_WINDOWS', + '_EGL_GET_CORE_ADDRESSES', + 'KHRONOS_DLL_EXPORTS', +]) + +env.Append(CPPPATH = [ + '#/include', +]) + +egl_sources = [ + 'eglapi.c', + 'eglarray.c', + 'eglconfig.c', + 'eglcontext.c', + 'eglcurrent.c', + 'egldisplay.c', + 'egldriver.c', + 'eglfallbacks.c', + 'eglglobals.c', + 'eglimage.c', + 'egllog.c', + 'eglmisc.c', + 'eglmode.c', + 'eglscreen.c', + 'eglstring.c', + 'eglsurface.c', + 'eglsync.c', +] + +egl = env.SharedLibrary( + target = 'libEGL', + source = egl_sources + ['egl.def'], +) + +installed_egl = env.InstallSharedLibrary(egl, version=(1, 4, 0)) + +env.Alias('egl', installed_egl) + +egl = [env.FindIxes(egl, 'LIBPREFIX', 'LIBSUFFIX')] + +Export('egl') diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 3457670bfa5..2169960fd1d 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -3,6 +3,7 @@ #include +#include #include "egltypedefs.h" diff --git a/src/gallium/SConscript b/src/gallium/SConscript index 3c171552bed..76f9ffb58ab 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -1,30 +1,112 @@ -import os +Import('env') -Import('*') +# +# Auxiliary modules +# SConscript('auxiliary/SConscript') -for driver in env['drivers']: - SConscript(os.path.join('drivers', driver, 'SConscript')) +# +# Drivers +# + +SConscript([ + 'drivers/failover/SConscript', + 'drivers/galahad/SConscript', + 'drivers/i915/SConscript', + 'drivers/i965/SConscript', + 'drivers/identity/SConscript', + 'drivers/llvmpipe/SConscript', + 'drivers/rbug/SConscript', + 'drivers/r300/SConscript', + 'drivers/softpipe/SConscript', + 'drivers/svga/SConscript', + 'drivers/trace/SConscript', +]) + +if env['dri']: + # These drivers depend on drm headers + SConscript([ + # XXX: nouveau drivers have a tight dependency on libdrm, so to enable + # we need some version logic before we enable them. Also, ATM there is + # no nouveau target in scons + #'drivers/nouveau/SConscript', + #'drivers/nv50/SConscript', + #'drivers/nvfx/SConscript', + 'drivers/r600/SConscript', + ]) + +# +# State trackers +# # Needed by some state trackers SConscript('winsys/sw/null/SConscript') SConscript('state_trackers/python/SConscript') -if platform != 'embedded': +if env['platform'] != 'embedded': SConscript('state_trackers/glx/xlib/SConscript') SConscript('state_trackers/dri/SConscript') SConscript('state_trackers/xorg/SConscript') SConscript('state_trackers/egl/SConscript') SConscript('state_trackers/vega/SConscript') -if platform == 'windows': +if env['platform'] == 'windows': SConscript('state_trackers/wgl/SConscript') +# +# Winsys +# + SConscript('winsys/SConscript') -SConscript('targets/SConscript') +# +# Targets +# + +SConscript([ + 'targets/graw-null/SConscript', +]) + +if env['x11']: + SConscript([ + 'targets/graw-xlib/SConscript', + 'targets/libgl-xlib/SConscript', + ]) -if platform != 'embedded': +if env['platform'] == 'windows': + SConscript([ + 'targets/libgl-gdi/SConscript', + #'egl-gdi/SConscript', + ]) + +if env['dri']: + SConscript([ + 'targets/SConscript.dri', + 'targets/dri-i915/SConscript', + 'targets/dri-i965/SConscript', + #'targets/dri-nouveau/SConscript', + 'targets/dri-r300/SConscript', + 'targets/dri-r600/SConscript', + 'targets/dri-swrast/SConscript', + 'targets/dri-vmwgfx/SConscript', + ]) + +if env['xorg']: + SConscript([ + #'targets/xorg-i915/SConscript', + #'targets/xorg-i965/SConscript', + #'targets/xorg-nouveau/SConscript', + #'targets/xorg-radeon/SConscript', + 'targets/xorg-vmwgfx/SConscript', + ]) + + +# +# Unit tests & tools +# + +if env['platform'] != 'embedded': SConscript('tests/unit/SConscript') SConscript('tests/graw/SConscript') + diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 94cd74424a0..0e5da1374ff 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -7,8 +7,6 @@ env.Append(CPPPATH = [ 'util', ]) -env.Tool('udis86') - env.CodeGenerate( target = 'indices/u_indices_gen.c', script = 'indices/u_indices_gen.py', @@ -202,39 +200,42 @@ source = [ ] if env['llvm']: + if env['UDIS86']: + env.Append(CPPDEFINES = [('HAVE_UDIS86', '1')]) + source += [ - 'gallivm/lp_bld_arit.c', - 'gallivm/lp_bld_assert.c', - 'gallivm/lp_bld_bitarit.c', - 'gallivm/lp_bld_const.c', - 'gallivm/lp_bld_conv.c', - 'gallivm/lp_bld_debug.c', - 'gallivm/lp_bld_flow.c', - 'gallivm/lp_bld_format_aos.c', - 'gallivm/lp_bld_format_soa.c', - 'gallivm/lp_bld_format_yuv.c', - 'gallivm/lp_bld_gather.c', - 'gallivm/lp_bld_init.c', - 'gallivm/lp_bld_intr.c', - 'gallivm/lp_bld_logic.c', - 'gallivm/lp_bld_misc.cpp', - 'gallivm/lp_bld_pack.c', - 'gallivm/lp_bld_printf.c', - 'gallivm/lp_bld_quad.c', - 'gallivm/lp_bld_sample.c', - 'gallivm/lp_bld_sample_aos.c', - 'gallivm/lp_bld_sample_soa.c', - 'gallivm/lp_bld_struct.c', - 'gallivm/lp_bld_swizzle.c', - 'gallivm/lp_bld_tgsi_aos.c', - 'gallivm/lp_bld_tgsi_info.c', - 'gallivm/lp_bld_tgsi_soa.c', - 'gallivm/lp_bld_type.c', - 'draw/draw_llvm.c', - 'draw/draw_llvm_sample.c', - 'draw/draw_llvm_translate.c', - 'draw/draw_pt_fetch_shade_pipeline_llvm.c', - 'draw/draw_vs_llvm.c' + 'gallivm/lp_bld_arit.c', + 'gallivm/lp_bld_assert.c', + 'gallivm/lp_bld_bitarit.c', + 'gallivm/lp_bld_const.c', + 'gallivm/lp_bld_conv.c', + 'gallivm/lp_bld_debug.c', + 'gallivm/lp_bld_flow.c', + 'gallivm/lp_bld_format_aos.c', + 'gallivm/lp_bld_format_soa.c', + 'gallivm/lp_bld_format_yuv.c', + 'gallivm/lp_bld_gather.c', + 'gallivm/lp_bld_init.c', + 'gallivm/lp_bld_intr.c', + 'gallivm/lp_bld_logic.c', + 'gallivm/lp_bld_misc.cpp', + 'gallivm/lp_bld_pack.c', + 'gallivm/lp_bld_printf.c', + 'gallivm/lp_bld_quad.c', + 'gallivm/lp_bld_sample.c', + 'gallivm/lp_bld_sample_aos.c', + 'gallivm/lp_bld_sample_soa.c', + 'gallivm/lp_bld_struct.c', + 'gallivm/lp_bld_swizzle.c', + 'gallivm/lp_bld_tgsi_aos.c', + 'gallivm/lp_bld_tgsi_info.c', + 'gallivm/lp_bld_tgsi_soa.c', + 'gallivm/lp_bld_type.c', + 'draw/draw_llvm.c', + 'draw/draw_llvm_sample.c', + 'draw/draw_llvm_translate.c', + 'draw/draw_pt_fetch_shade_pipeline_llvm.c', + 'draw/draw_vs_llvm.c' ] gallium = env.ConvenienceLibrary( @@ -242,4 +243,6 @@ gallium = env.ConvenienceLibrary( source = source, ) +env.Alias('gallium', gallium) + Export('gallium') diff --git a/src/gallium/drivers/i915/SConscript b/src/gallium/drivers/i915/SConscript index d4bf6fef134..1197bbf9620 100644 --- a/src/gallium/drivers/i915/SConscript +++ b/src/gallium/drivers/i915/SConscript @@ -2,7 +2,7 @@ Import('*') env = env.Clone() -if msvc: +if env['msvc']: print 'warning: not building i915g' Return() diff --git a/src/gallium/drivers/i965/SConscript b/src/gallium/drivers/i965/SConscript index 119f914a16d..198275b655c 100644 --- a/src/gallium/drivers/i965/SConscript +++ b/src/gallium/drivers/i965/SConscript @@ -2,7 +2,7 @@ Import('*') env = env.Clone() -if msvc: +if env['msvc']: print 'warning: not building i965g' Return(); diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README index ec30d4d7084..e9374cc6efa 100644 --- a/src/gallium/drivers/llvmpipe/README +++ b/src/gallium/drivers/llvmpipe/README @@ -1,53 +1,6 @@ LLVMPIPE -- a fork of softpipe that employs LLVM for code generation. -Status -====== - -Done so far is: - - - the whole fragment pipeline is code generated in a single function - - - input interpolation - - - depth testing - - - texture sampling - - 1D/2D/3D/cube maps supported - - all texture wrap modes supported - - all texture filtering modes supported - - perhaps not all texture formats yet supported - - - fragment shader TGSI translation - - same level of support as the TGSI SSE2 exec machine, with the exception - we don't fallback to TGSI interpretation when an unsupported opcode is - found, but just ignore it - - done in SoA layout - - input interpolation also code generated - - - alpha testing - - - blend (including logic ops) - - both in SoA and AoS layouts, but only the former used for now - - - code is generic - - intermediates can be vectors of floats, ubytes, fixed point, etc, and of - any width and length - - not all operations are implemented for these types yet though - -Most mesa/progs/demos/* work. - -To do (probably by this order): - - - code generate stipple and stencil testing - - - translate TGSI control flow instructions, and all other remaining opcodes - - - integrate with the draw module for VS code generation - - - code generate the triangle setup and rasterization - - Requirements ============ @@ -98,7 +51,7 @@ Building To build everything on Linux invoke scons as: - scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false + scons build=debug libgl-xlib Alternatively, you can build it with GNU make, if you prefer, by invoking it as @@ -108,19 +61,16 @@ but the rest of these instructions assume that scons is used. For windows is everything the except except the winsys: - scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=gdi dri=false + scons build=debug libgl-gdi Using ===== -On Linux, building will create a drop-in alternative for libGL.so. To use it -set the environment variables: - - export LD_LIBRARY_PATH=$PWD/build/linux-x86_64-debug/lib:$LD_LIBRARY_PATH +On Linux, building will create a drop-in alternative for libGL.so into -or + build/foo/gallium/targets/libgl-xlib/libGL.so - export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib:$LD_LIBRARY_PATH +To use it set the LD_LIBRARY_PATH environment variable accordingly. For performance evaluation pass debug=no to scons, and use the corresponding lib directory without the "-debug" suffix. @@ -136,7 +86,7 @@ Profiling To profile llvmpipe you should pass the options - scons debug=no profile=yes + scons build=profile This will ensure that frame pointers are used both in C and JIT functions, and that no tail call optimizations are done by gcc. @@ -200,5 +150,4 @@ Development Notes interfaces very closely, and appear to be complete enough for code generation. See http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html - for a stand-alone example. - See the llvm-c/Core.h file for reference. + for a stand-alone example. See the llvm-c/Core.h file for reference. diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 49950153a4f..26b258b9569 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -9,8 +9,6 @@ if not env['llvm']: env = env.Clone() -env.Tool('udis86') - env.Append(CPPPATH = ['.']) env.CodeGenerate( @@ -78,6 +76,8 @@ llvmpipe = env.ConvenienceLibrary( lp_tile_soa_os, ]) +env.Alias('llvmpipe', llvmpipe) + if env['platform'] != 'embedded': env = env.Clone() @@ -92,7 +92,7 @@ if env['platform'] != 'embedded': 'sincos', ] - if not msvc: + if not env['msvc']: tests.append('round') for test in tests: diff --git a/src/gallium/drivers/rbug/README b/src/gallium/drivers/rbug/README index b6d3a5cf351..9d7bd4e7695 100644 --- a/src/gallium/drivers/rbug/README +++ b/src/gallium/drivers/rbug/README @@ -7,24 +7,10 @@ This directory contains a Gallium3D remote debugger pipe driver. It provides remote debugging functionality. -= Build Instructions = - -To build, invoke scons on the top dir as - - scons dri=no statetrackers=mesa winsys=xlib - - = Usage = -To use do - - export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib - -ensure the right libGL.so is being picked by doing - - ldd progs/trivial/tri +Do - export XMESA_TRACE=y GALLIUM_RBUG=true progs/trivial/tri which should open gallium remote debugging session. While the program is running diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript index d5f4d28aeff..ea10e8a9f98 100644 --- a/src/gallium/drivers/softpipe/SConscript +++ b/src/gallium/drivers/softpipe/SConscript @@ -37,4 +37,6 @@ softpipe = env.ConvenienceLibrary( 'sp_tile_cache.c', ]) +env.Alias('softpipe', softpipe) + Export('softpipe') diff --git a/src/gallium/drivers/sw/SConscript b/src/gallium/drivers/sw/SConscript index e9ebf751ddd..40d01db2f6d 100644 --- a/src/gallium/drivers/sw/SConscript +++ b/src/gallium/drivers/sw/SConscript @@ -20,7 +20,6 @@ if True: if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') env.Prepend(LIBS = [llvmpipe]) extra.append(llvmpipe) diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index cdcd8d2b4be..c210cba032a 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -7,23 +7,8 @@ This directory contains a Gallium3D trace debugger pipe driver. It can traces all incoming calls. -= Build Instructions = - -To build, invoke scons on the top dir as - - scons dri=no statetrackers=mesa winsys=xlib - - = Usage = -To use do - - export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib - -ensure the right libGL.so is being picked by doing - - ldd progs/trivial/tri - == Tracing == For tracing then do @@ -40,6 +25,7 @@ For remote debugging see: src/gallium/drivers/rbug/README + = Integrating = You can integrate the trace pipe driver either inside the state tracker or the @@ -60,5 +46,5 @@ are automatically wrapped by trace_screen. -- -Jose Fonseca +Jose Fonseca Jakob Bornecrantz diff --git a/src/gallium/state_trackers/egl/SConscript b/src/gallium/state_trackers/egl/SConscript index efcce25e317..8d34e47df0e 100644 --- a/src/gallium/state_trackers/egl/SConscript +++ b/src/gallium/state_trackers/egl/SConscript @@ -3,34 +3,35 @@ Import('*') -if 'egl' in env['statetrackers']: +if env['platform'] != 'windows': + Return() - env = env.Clone() +env = env.Clone() - env.Append(CPPPATH = [ - '#/src/egl/main', - '#/src/gallium/winsys/sw', - '.', - ]) - env.Append(CPPDEFINES = [ - 'HAVE_GDI_BACKEND', - ]) +env.Append(CPPPATH = [ + '#/src/egl/main', + '#/src/gallium/winsys/sw', + '.', +]) +env.Append(CPPDEFINES = [ + 'HAVE_GDI_BACKEND', +]) - common_sources = [ - 'common/egl_g3d.c', - 'common/egl_g3d_api.c', - 'common/egl_g3d_image.c', - 'common/egl_g3d_st.c', - 'common/egl_g3d_sync.c', - 'common/native_helper.c', - ] +common_sources = [ + 'common/egl_g3d.c', + 'common/egl_g3d_api.c', + 'common/egl_g3d_image.c', + 'common/egl_g3d_st.c', + 'common/egl_g3d_sync.c', + 'common/native_helper.c', +] - gdi_sources = common_sources + [ - 'gdi/native_gdi.c', - ] +gdi_sources = common_sources + [ + 'gdi/native_gdi.c', +] - st_egl_gdi = env.ConvenienceLibrary( - target = 'st_egl_gdi', - source = gdi_sources, - ) - Export('st_egl_gdi') +st_egl_gdi = env.ConvenienceLibrary( + target = 'st_egl_gdi', + source = gdi_sources, +) +Export('st_egl_gdi') diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index 9df351a2769..775000eacce 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -3,25 +3,25 @@ Import('*') -if env['platform'] == 'linux' \ - and 'mesa' in env['statetrackers']: +if not env['x11']: + Return() - env = env.Clone() +env = env.Clone() - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/mesa', - '#/src/mesa/main', - ]) +env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + '#/src/mesa/main', +]) - st_xlib = env.ConvenienceLibrary( - target = 'st_xlib', - source = [ - 'glx_api.c', - 'glx_getproc.c', - 'glx_usefont.c', - 'xm_api.c', - 'xm_st.c', - ] - ) - Export('st_xlib') +st_xlib = env.ConvenienceLibrary( +target = 'st_xlib', +source = [ + 'glx_api.c', + 'glx_getproc.c', + 'glx_usefont.c', + 'xm_api.c', + 'xm_st.c', + ] +) +Export('st_xlib') diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index aadeaa0a359..5cb7960f9b5 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -3,57 +3,61 @@ import os.path Import('*') -if 'python' in env['statetrackers']: - - env = env.Clone() - - env.Tool('python') - - env.Tool('swig') - env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe']) - env.Append(SWIGFLAGS = ['-python', '-keyword']) - - env.Append(CPPPATH = '.') - - if env['platform'] == 'windows': - env.Append(LIBS = [ - 'opengl32', - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', - ]) - else: - env.Append(CPPDEFINES = ['GCC_HASCLASSVISIBILITY']) - env.Append(LIBS = [ - 'GL', - 'X11', - ]) - - sources = [ - 'gallium.i', - 'st_device.c', - 'st_sample.c', - 'st_hardpipe_winsys.c', - 'st_softpipe_winsys.c', - ] - - env.Prepend(LIBS = [ - ws_null, - trace, - gallium, - ]) +if env['toolchain'] == 'crossmingw': + # Cross-compilation not supported + Return() + +env = env.Clone() + +env.Tool('python') - if env['llvm']: - env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) - env.Prepend(LIBS = [llvmpipe]) - if True: - env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) - env.Prepend(LIBS = [softpipe]) +env.Tool('swig') +env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe']) +env.Append(SWIGFLAGS = ['-python', '-keyword']) - env['no_import_lib'] = 1 +env.Append(CPPPATH = '.') + +if env['platform'] == 'windows': + env.Append(LIBS = [ + 'opengl32', + 'gdi32', + 'user32', + 'kernel32', + 'ws2_32', + ]) +else: + env.Append(CPPDEFINES = ['GCC_HASCLASSVISIBILITY']) + env.Append(LIBS = [ + 'GL', + 'X11', + ]) - env.SharedLibrary( - target = '_gallium', - source = sources, - ) +sources = [ + 'gallium.i', + 'st_device.c', + 'st_sample.c', + 'st_hardpipe_winsys.c', + 'st_softpipe_winsys.c', +] + +env.Prepend(LIBS = [ + ws_null, + trace, + gallium, +]) + +if env['llvm']: + env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) + env.Prepend(LIBS = [llvmpipe]) +if True: + env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) + env.Prepend(LIBS = [softpipe]) + +env['no_import_lib'] = 1 + +pyst = env.SharedLibrary( + target = '_gallium', + source = sources, +) + +env.Alias('python', pyst) diff --git a/src/gallium/state_trackers/vega/SConscript b/src/gallium/state_trackers/vega/SConscript index 548053eb646..4c6e18f42b2 100644 --- a/src/gallium/state_trackers/vega/SConscript +++ b/src/gallium/state_trackers/vega/SConscript @@ -3,49 +3,48 @@ Import('*') -if 'egl' in env['statetrackers']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/mapi', +]) - env.Append(CPPPATH = [ - '#/src/mapi', - ]) +vega_sources = [ + 'api.c', + 'api_context.c', + 'api_filters.c', + 'api_images.c', + 'api_masks.c', + 'api_misc.c', + 'api_paint.c', + 'api_params.c', + 'api_path.c', + 'api_text.c', + 'api_transform.c', + 'vgu.c', + 'vg_context.c', + 'vg_manager.c', + 'vg_state.c', + 'vg_translate.c', + 'polygon.c', + 'bezier.c', + 'path.c', + 'paint.c', + 'arc.c', + 'image.c', + 'renderer.c', + 'stroker.c', + 'mask.c', + 'shader.c', + 'shaders_cache.c', +] - vega_sources = [ - 'api.c', - 'api_context.c', - 'api_filters.c', - 'api_images.c', - 'api_masks.c', - 'api_misc.c', - 'api_paint.c', - 'api_params.c', - 'api_path.c', - 'api_text.c', - 'api_transform.c', - 'vgu.c', - 'vg_context.c', - 'vg_manager.c', - 'vg_state.c', - 'vg_translate.c', - 'polygon.c', - 'bezier.c', - 'path.c', - 'paint.c', - 'arc.c', - 'image.c', - 'renderer.c', - 'stroker.c', - 'mask.c', - 'shader.c', - 'shaders_cache.c', - ] +# vgapi_header must be generated first +env.Depends(vega_sources, vgapi_header) - # vgapi_header must be generated first - env.Depends(vega_sources, vgapi_header) +st_vega = env.ConvenienceLibrary( + target = 'st_vega', + source = vega_sources, +) - st_vega = env.ConvenienceLibrary( - target = 'st_vega', - source = vega_sources, - ) - Export('st_vega') +Export('st_vega') diff --git a/src/gallium/state_trackers/xorg/SConscript b/src/gallium/state_trackers/xorg/SConscript index 0b598dab6e3..ffaa1c26846 100644 --- a/src/gallium/state_trackers/xorg/SConscript +++ b/src/gallium/state_trackers/xorg/SConscript @@ -3,34 +3,35 @@ Import('*') -if 'xorg' in env['statetrackers']: - - env = env.Clone() - - env.Append(CPPPATH = [ - '#/src/mesa', - ]) - - env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') - - conf = env.Configure() - - if conf.CheckHeader('X11/extensions/dpmsconst.h'): - env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) - - conf.Finish() - - st_xorg = env.ConvenienceLibrary( - target = 'st_xorg', - source = [ 'xorg_composite.c', - 'xorg_crtc.c', - 'xorg_dri2.c', - 'xorg_driver.c', - 'xorg_exa.c', - 'xorg_exa_tgsi.c', - 'xorg_output.c', - 'xorg_renderer.c', - 'xorg_xv.c', - ] - ) - Export('st_xorg') +if not env['x11'] or not env['dri'] or not env['xorg']: + Return() + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/mesa', +]) + +env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') + +conf = env.Configure() + +if conf.CheckHeader('X11/extensions/dpmsconst.h'): + env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) + +conf.Finish() + +st_xorg = env.ConvenienceLibrary( +target = 'st_xorg', +source = [ 'xorg_composite.c', + 'xorg_crtc.c', + 'xorg_dri2.c', + 'xorg_driver.c', + 'xorg_exa.c', + 'xorg_exa_tgsi.c', + 'xorg_output.c', + 'xorg_renderer.c', + 'xorg_xv.c', + ] +) +Export('st_xorg') diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript deleted file mode 100644 index e447d093610..00000000000 --- a/src/gallium/targets/SConscript +++ /dev/null @@ -1,41 +0,0 @@ -import os -Import('*') - -# Compatibility with old build scripts: -# -if 'mesa' in env['statetrackers']: - if 'xlib' in env['winsys'] and 'libgl-xlib' not in env['targets']: - env['targets'].append('libgl-xlib') - if 'gdi' in env['winsys'] and 'libgl-gdi' not in env['targets']: - env['targets'].append('libgl-gdi') - -if not 'graw-xlib' in env['targets'] and not 'graw-null' in env['targets'] and not env['msvc']: - # XXX: disable until MSVC can link correctly - SConscript('graw-null/SConscript') - - -if env['dri']: - SConscript([ - 'SConscript.dri' - ]) - -if 'xorg' in env['statetrackers']: - if 'vmware' in env['winsys']: - SConscript([ - 'xorg-vmwgfx/SConscript', - ]) - -if 'egl' in env['statetrackers']: - SConscript([ - 'egl-gdi/SConscript', - ]) - -# Ideally all non-target directories would produce convenience -# libraries, and the actual shared libraries and other installables -# would be finally assembled in the targets subtree: -# -for target in env['targets']: - SConscript(os.path.join(target, 'SConscript')) - - - diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri index bc8d179e3d9..092223b3690 100644 --- a/src/gallium/targets/SConscript.dri +++ b/src/gallium/targets/SConscript.dri @@ -3,6 +3,9 @@ Import('*') +if not env['dri']: + Return() + drienv = env.Clone() drienv.Replace(CPPPATH = [ @@ -77,32 +80,3 @@ Export([ 'COMMON_DRI_SW_OBJECTS', 'COMMON_DRI_DRM_OBJECTS', ]) - -SConscript([ - 'dri-swrast/SConscript', -]) - -if 'vmware' in env['winsys']: - SConscript([ - 'dri-vmwgfx/SConscript', - ]) - -if 'i915' in env['winsys']: - SConscript([ - 'dri-i915/SConscript', - ]) - -if 'i965' in env['winsys']: - SConscript([ - 'dri-i965/SConscript', - ]) - -if 'radeon' in env['winsys']: - SConscript([ - 'dri-radeong/SConscript', - ]) - -if 'r600' in env['winsys']: - SConscript([ - 'dri-r600/SConscript', - ]) diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript index 172f92d6b82..ab60013830e 100644 --- a/src/gallium/targets/dri-i915/SConscript +++ b/src/gallium/targets/dri-i915/SConscript @@ -1,9 +1,5 @@ Import('*') -if not 'i915' in env['drivers']: - print 'warning: i915 pipe driver not built skipping i915_dri.so' - Return() - env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_intel') @@ -24,8 +20,10 @@ env.Prepend(LIBS = [ COMMON_DRI_DRM_OBJECTS ]) -env.LoadableModule( +module = env.LoadableModule( target = 'i915_dri.so', source = 'target.c', SHLIBPREFIX = '', ) + +env.Alias('dri-i915', module) \ No newline at end of file diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript index 684e3488f71..669f70d6b8d 100644 --- a/src/gallium/targets/dri-i965/SConscript +++ b/src/gallium/targets/dri-i965/SConscript @@ -1,9 +1,5 @@ Import('*') -if not 'i965' in env['drivers']: - print 'warning: i965 pipe driver not built skipping i965_dri.so' - Return() - env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_intel') @@ -27,8 +23,10 @@ env.Prepend(LIBS = [ COMMON_DRI_DRM_OBJECTS ]) -env.LoadableModule( +module = env.LoadableModule( target = 'i965_dri.so', source = 'target.c', SHLIBPREFIX = '', ) + +env.Alias('dri-i965', module) \ No newline at end of file diff --git a/src/gallium/targets/dri-r300/SConscript b/src/gallium/targets/dri-r300/SConscript index 33a458f2e68..005b4bbf7f1 100644 --- a/src/gallium/targets/dri-r300/SConscript +++ b/src/gallium/targets/dri-r300/SConscript @@ -1,9 +1,5 @@ Import('*') -if not 'r300' in env['drivers']: - print 'warning: r300 pipe driver not built skipping r300_dri.so' - Return() - env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_radeon') @@ -23,8 +19,10 @@ env.Prepend(LIBS = [ COMMON_DRI_DRM_OBJECTS ]) -env.SharedLibrary( +module = env.SharedLibrary( target ='r300_dri.so', source = 'target.c', SHLIBPREFIX = '', ) + +env.Alias('dri-r300', module) \ No newline at end of file diff --git a/src/gallium/targets/dri-r600/SConscript b/src/gallium/targets/dri-r600/SConscript index 64d6d2a7f6f..aa771db2d1a 100644 --- a/src/gallium/targets/dri-r600/SConscript +++ b/src/gallium/targets/dri-r600/SConscript @@ -1,9 +1,5 @@ Import('*') -if not 'r600' in env['drivers']: - print 'warning: r600 pipe driver not built skipping r600_dri.so' - Return() - env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_radeon') @@ -22,8 +18,10 @@ env.Prepend(LIBS = [ COMMON_DRI_DRM_OBJECTS ]) -env.SharedLibrary( +module = env.SharedLibrary( target ='r600_dri.so', source = 'target.c', SHLIBPREFIX = '', ) + +env.Alias('dri-r600', module) diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript index d8143471194..b67483800e4 100644 --- a/src/gallium/targets/dri-swrast/SConscript +++ b/src/gallium/targets/dri-swrast/SConscript @@ -27,15 +27,16 @@ if True: if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') env.Prepend(LIBS = [llvmpipe]) swrastg_sources = [ 'swrast_drm_api.c' ] -env.LoadableModule( +module = env.LoadableModule( target ='swrastg_dri.so', source = swrastg_sources, SHLIBPREFIX = '', ) + +env.Alias('dri-swrast', module) diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript index 7afabc7429f..7888e4f2c8b 100644 --- a/src/gallium/targets/dri-vmwgfx/SConscript +++ b/src/gallium/targets/dri-vmwgfx/SConscript @@ -1,9 +1,5 @@ Import('*') -if not 'svga' in env['drivers']: - print 'warning: svga pipe driver not built skipping vmwgfx_dri.so' - Return() - env = drienv.Clone() env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE']) @@ -20,8 +16,10 @@ env.Prepend(LIBS = [ COMMON_DRI_DRM_OBJECTS ]) -env.LoadableModule( +module = env.LoadableModule( target = 'vmwgfx_dri.so', source = 'target.c', SHLIBPREFIX = '', ) + +env.Alias('dri-vmwgfx', module) \ No newline at end of file diff --git a/src/gallium/targets/egl-gdi/SConscript b/src/gallium/targets/egl-gdi/SConscript index 8f8b28ef67b..d52eeb70fd5 100644 --- a/src/gallium/targets/egl-gdi/SConscript +++ b/src/gallium/targets/egl-gdi/SConscript @@ -3,45 +3,53 @@ Import('*') -if env['platform'] == 'windows': - - env = env.Clone() - - env.Append(CPPPATH = [ - '#/src/gallium/state_trackers/egl', - '#/src/gallium/state_trackers/vega', - '#/src/egl/main', - '#/src/mesa', - ]) - - env.Append(CPPDEFINES = [ - 'FEATURE_VG=1', - 'GALLIUM_SOFTPIPE', - 'GALLIUM_RBUG', - 'GALLIUM_TRACE', - ]) - - env.Append(LIBS = [ - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', - ]) - - env['no_import_lib'] = 1 - - drivers = [softpipe] - if env['llvm']: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - drivers += [llvmpipe] - drivers += [identity, trace, rbug] - - apis = [vgapi, st_vega] - - egl_gallium = env.SharedLibrary( - target ='egl_gallium', - source = 'egl-static.c', - LIBS = st_egl_gdi + ws_gdi + drivers + apis + gallium + egl + env['LIBS'], - ) - - env.InstallSharedLibrary(egl_gallium) +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/state_trackers/egl', + '#/src/gallium/state_trackers/vega', + '#/src/egl/main', + '#/src/mesa', +]) + +env.Append(CPPDEFINES = [ + 'FEATURE_VG=1', + 'GALLIUM_SOFTPIPE', + 'GALLIUM_RBUG', + 'GALLIUM_TRACE', +]) + +env.Append(LIBS = [ + 'gdi32', + 'user32', + 'kernel32', + 'ws2_32', +]) + +env.Prepend(LIBS = [ + st_egl_gdi, + ws_gdi, + identity, + trace, + rbug, + softpipe, + vgapi, + st_vega, + gallium, + egl, +]) + +if env['llvm']: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Prepend(LIBS = [llvmpipe]) + +egl_gallium = env.SharedLibrary( + target ='egl_gallium', + source = 'egl-static.c', +) + +env['no_import_lib'] = 1 + +egl_gdi = env.InstallSharedLibrary(egl_gallium) + +env.Alias('egl-gdi', egl_gdi) diff --git a/src/gallium/targets/graw-null/SConscript b/src/gallium/targets/graw-null/SConscript index 3416989d8eb..ebac1728f04 100644 --- a/src/gallium/targets/graw-null/SConscript +++ b/src/gallium/targets/graw-null/SConscript @@ -5,54 +5,28 @@ Import('*') env = env.Clone() -env.Prepend(LIBS = [ - ws_null, - trace, - rbug, - identity, -# gallium, -]) - -env.Append(CPPPATH = [ - '#src/gallium/drivers', -]) +graw_util = env.SharedObject( + source = ['graw_util.c'], +) -if env['platform'] == 'windows': - # For trace - env.Append(LIBS = [ - 'ws2_32', - ]) +env = env.Clone() sources = [ 'graw_null.c', - '../graw-xlib/graw_util.c', + graw_util, ] -if True: - env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') - env.Prepend(LIBS = [softpipe]) - -if env['llvm']: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - env.Prepend(LIBS = [llvmpipe]) - -# Need this for trace, identity drivers referenced by -# gallium_wrap_screen(). -# env.Prepend(LIBS = [gallium]) # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions graw = env.SharedLibrary( - target ='graw', + target = 'graw', source = sources, ) -env.InstallSharedLibrary(graw, version=(1, 0)) - if env['platform'] == 'windows': graw = env.FindIxes(graw, 'LIBPREFIX', 'LIBSUFFIX') else: graw = env.FindIxes(graw, 'SHLIBPREFIX', 'SHLIBSUFFIX') -Export('graw') +Export('graw_util', 'graw') diff --git a/src/gallium/targets/graw-null/graw_null.c b/src/gallium/targets/graw-null/graw_null.c index 5939a5acd3c..f1fe3872c94 100644 --- a/src/gallium/targets/graw-null/graw_null.c +++ b/src/gallium/targets/graw-null/graw_null.c @@ -1,31 +1,5 @@ -#include "pipe/p_compiler.h" -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "target-helpers/wrap_screen.h" -#include "sw/null/null_sw_winsys.h" -#include "os/os_time.h" #include "state_tracker/graw.h" -#ifdef GALLIUM_SOFTPIPE -#include "softpipe/sp_public.h" -#endif - -#ifdef GALLIUM_LLVMPIPE -#include "llvmpipe/lp_public.h" -#endif - -/* Haven't figured out a decent way to build the helper code yet - - * #include it here temporarily. - */ -#include "sw/sw_public.h" -#include "sw/sw.c" - -#include - - -static struct { - void (*draw)(void); -} graw; @@ -37,45 +11,7 @@ graw_create_window_and_screen( int x, enum pipe_format format, void **handle) { - const char *default_driver; - const char *driver; - struct pipe_screen *screen = NULL; - struct sw_winsys *winsys = NULL; - static int dummy; - - - /* Create the underlying winsys, which performs presents to Xlib - * drawables: - */ - winsys = null_sw_create(); - if (winsys == NULL) - return NULL; - -#if defined(GALLIUM_LLVMPIPE) - default_driver = "llvmpipe"; -#elif defined(GALLIUM_SOFTPIPE) - default_driver = "softpipe"; -#else - default_driver = ""; -#endif - - driver = debug_get_option("GALLIUM_DRIVER", default_driver); - -#if defined(GALLIUM_LLVMPIPE) - if (screen == NULL && strcmp(driver, "llvmpipe") == 0) - screen = llvmpipe_create_screen( winsys ); -#endif - -#if defined(GALLIUM_SOFTPIPE) - if (screen == NULL) - screen = softpipe_create_screen( winsys ); -#endif - - *handle = &dummy; - - /* Inject any wrapping layers we want to here: - */ - return gallium_wrap_screen( screen ); + return NULL; } @@ -83,13 +19,10 @@ graw_create_window_and_screen( int x, void graw_set_display_func( void (*draw)( void ) ) { - graw.draw = draw; } void graw_main_loop( void ) { - graw.draw(); - os_time_sleep(100000); } diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c new file mode 100644 index 00000000000..531757f1457 --- /dev/null +++ b/src/gallium/targets/graw-null/graw_util.c @@ -0,0 +1,53 @@ + +#include "pipe/p_compiler.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "tgsi/tgsi_text.h" +#include "util/u_memory.h" +#include "state_tracker/graw.h" + + +/* Helper functions. These are the same for all graw implementations. + */ +PUBLIC void * +graw_parse_geometry_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_gs_state(pipe, &state); +} + +PUBLIC void * +graw_parse_vertex_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_vs_state(pipe, &state); +} + +PUBLIC void * +graw_parse_fragment_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_fs_state(pipe, &state); +} + diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript index 21fce948f43..f7953097872 100644 --- a/src/gallium/targets/graw-xlib/SConscript +++ b/src/gallium/targets/graw-xlib/SConscript @@ -3,13 +3,8 @@ Import('*') -if env['platform'] != 'linux': - Return() - env = env.Clone() -env.Tool('x11') - env.Prepend(LIBS = [ ws_xlib, trace, @@ -18,26 +13,24 @@ env.Prepend(LIBS = [ # gallium, ]) +env.Prepend(LIBS = env['X11_LIBS']) + env.Append(CPPPATH = [ '#src/gallium/drivers', '#src/gallium/include/state_tracker', ]) - sources = [ 'graw_xlib.c', - 'graw_util.c', + graw_util ] -env.Tool('x11') - if True: env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') env.Prepend(LIBS = [softpipe]) if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') env.Prepend(LIBS = [llvmpipe]) # Need this for trace, identity drivers referenced by @@ -51,8 +44,6 @@ graw = env.SharedLibrary( source = sources, ) -env.InstallSharedLibrary(graw, version=(1, 0)) - -graw = env.FindIxes(graw, 'SHLIBPREFIX', 'SHLIBSUFFIX') +graw = env.InstallSharedLibrary(graw, version=(1, 0)) -Export('graw') +env.Alias('graw-xlib', graw) diff --git a/src/gallium/targets/graw-xlib/graw_util.c b/src/gallium/targets/graw-xlib/graw_util.c deleted file mode 100644 index fc7c9ae6f92..00000000000 --- a/src/gallium/targets/graw-xlib/graw_util.c +++ /dev/null @@ -1,50 +0,0 @@ - -#include "pipe/p_compiler.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "tgsi/tgsi_text.h" -#include "util/u_memory.h" -#include "state_tracker/graw.h" - - -/* Helper functions. These are the same for all graw implementations. - */ -void *graw_parse_geometry_shader(struct pipe_context *pipe, - const char *text) -{ - struct tgsi_token tokens[1024]; - struct pipe_shader_state state; - - if (!tgsi_text_translate(text, tokens, Elements(tokens))) - return NULL; - - state.tokens = tokens; - return pipe->create_gs_state(pipe, &state); -} - -void *graw_parse_vertex_shader(struct pipe_context *pipe, - const char *text) -{ - struct tgsi_token tokens[1024]; - struct pipe_shader_state state; - - if (!tgsi_text_translate(text, tokens, Elements(tokens))) - return NULL; - - state.tokens = tokens; - return pipe->create_vs_state(pipe, &state); -} - -void *graw_parse_fragment_shader(struct pipe_context *pipe, - const char *text) -{ - struct tgsi_token tokens[1024]; - struct pipe_shader_state state; - - if (!tgsi_text_translate(text, tokens, Elements(tokens))) - return NULL; - - state.tokens = tokens; - return pipe->create_fs_state(pipe, &state); -} - diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 12fe403f62f..339238756ab 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -3,45 +3,46 @@ Import('*') -if env['platform'] == 'windows': - - env = env.Clone() - - env.Append(CPPPATH = [ - '#src/gallium/state_trackers/wgl', - '#src/gallium/winsys/sw', - ]) - - env.Append(LIBS = [ - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', - talloc, - ]) - - sources = [] - drivers = [] - - if True: - sources = ['gdi_softpipe_winsys.c'] - drivers = [softpipe] - - if env['llvm']: - sources = ['gdi_llvmpipe_winsys.c'] - drivers = [llvmpipe] - - if env['gcc']: - sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] - else: - sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] - - drivers += [trace, rbug] - - env['no_import_lib'] = 1 - - env.SharedLibrary( - target ='opengl32', - source = sources, - LIBS = wgl + ws_gdi + glapi + mesa + drivers + gallium + glsl + env['LIBS'], - ) +env = env.Clone() + +env.Append(CPPPATH = [ + '#src/gallium/state_trackers/wgl', + '#src/gallium/winsys/sw', +]) + +env.Append(LIBS = [ + 'gdi32', + 'user32', + 'kernel32', + 'ws2_32', + talloc, +]) + +sources = [] +drivers = [] + +if True: + sources = ['gdi_softpipe_winsys.c'] + drivers = [softpipe] + +if env['llvm']: + sources = ['gdi_llvmpipe_winsys.c'] + drivers = [llvmpipe] + +if env['gcc']: + sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] +else: + sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] + +drivers += [trace, rbug] + +env['no_import_lib'] = 1 + +opengl32 = env.SharedLibrary( + target ='opengl32', + source = sources, + LIBS = wgl + ws_gdi + glapi + mesa + drivers + gallium + glsl + env['LIBS'], +) + +env.Alias('opengl32', opengl32) +env.Alias('libgl-gdi', opengl32) diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 27b562e1d5d..582760eac93 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -3,17 +3,6 @@ Import('*') -if env['platform'] != 'linux': - Return() - -if 'mesa' not in env['statetrackers']: - print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so' - Return() - -if env['dri']: - print 'warning: DRI enabled: skipping build of xlib libGL.so' - Return() - env = env.Clone() env.Append(CPPPATH = [ @@ -25,6 +14,8 @@ env.Append(CPPPATH = [ env.Append(CPPDEFINES = ['USE_XSHM']) +env.Prepend(LIBS = env['X11_LIBS']) + env.Prepend(LIBS = [ st_xlib, ws_xlib, @@ -42,8 +33,6 @@ sources = [ 'xlib.c', ] -env.Tool('x11') - if True: env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') env.Prepend(LIBS = [softpipe]) @@ -54,10 +43,10 @@ if True: if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') env.Prepend(LIBS = [llvmpipe]) -if 'cell' in env['drivers']: +if False: + # TODO: Detect Cell SDK env.Append(CPPDEFINES = 'GALLIUM_CELL') env.Prepend(LIBS = [cell]) @@ -67,6 +56,8 @@ libgl = env.SharedLibrary( source = sources, ) -if not env['dri']: - # Only install this libGL.so if DRI not enabled - env.InstallSharedLibrary(libgl, version=(1, 5)) +if True: + # XXX: Only install this libGL.so if DRI not enabled + libgl = env.InstallSharedLibrary(libgl, version=(1, 5)) + +env.Alias('libgl-xlib', libgl) diff --git a/src/gallium/targets/xorg-vmwgfx/SConscript b/src/gallium/targets/xorg-vmwgfx/SConscript index 43b2c74f9ce..0a81b33651f 100644 --- a/src/gallium/targets/xorg-vmwgfx/SConscript +++ b/src/gallium/targets/xorg-vmwgfx/SConscript @@ -2,62 +2,58 @@ import os.path Import('*') -if not 'svga' in env['drivers']: - print 'warning: svga pipe driver not built skipping vmwgfx_drv.so' - Return() - -if env['platform'] == 'linux': - - env = env.Clone() - - env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') - - env.Prepend(CPPPATH = [ - '#/include', - '#/src/gallium', - '#/src/mesa', - '#/src/gallium/drivers/svga', - '#/src/gallium/drivers/svga/include', - ]) - - env.Append(CPPDEFINES = [ - ]) - - if env['gcc']: - env.Append(CPPDEFINES = [ - 'HAVE_STDINT_H', - 'HAVE_SYS_TYPES_H', - ]) - - env.Append(CFLAGS = [ - '-std=gnu99', - '-D_FILE_OFFSET_BITS=64', - ]) - - env.Prepend(LIBPATH = [ - ]) - - env.Prepend(LIBS = [ - trace, - rbug, - st_xorg, - svgadrm, - svga, - gallium, - ]) - - sources = [ - 'vmw_ioctl.c', - 'vmw_ctrl.c', - 'vmw_screen.c', - 'vmw_video.c', - 'vmw_xorg.c', - ] - - # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions - env.LoadableModule( - target ='vmwgfx_drv.so', - source = sources, - LIBS = env['LIBS'], - SHLIBPREFIX = '', - ) +env = env.Clone() + +env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') + +env.Prepend(CPPPATH = [ + '#/include', + '#/src/gallium', + '#/src/mesa', + '#/src/gallium/drivers/svga', + '#/src/gallium/drivers/svga/include', +]) + +env.Append(CPPDEFINES = [ +]) + +if env['gcc']: + env.Append(CPPDEFINES = [ + 'HAVE_STDINT_H', + 'HAVE_SYS_TYPES_H', + ]) + +env.Append(CFLAGS = [ + '-std=gnu99', + '-D_FILE_OFFSET_BITS=64', +]) + +env.Prepend(LIBPATH = [ +]) + +env.Prepend(LIBS = [ + trace, + rbug, + st_xorg, + svgadrm, + svga, + gallium, +]) + +sources = [ + 'vmw_ioctl.c', + 'vmw_ctrl.c', + 'vmw_screen.c', + 'vmw_video.c', + 'vmw_xorg.c', +] + +# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions +module = env.LoadableModule( + target ='vmwgfx_drv.so', + source = sources, + LIBS = env['LIBS'], + SHLIBPREFIX = '', +) + +env.Alias('xorg-vmwgfx', module) diff --git a/src/gallium/tests/graw/SConscript b/src/gallium/tests/graw/SConscript index ffde61965b4..3341b884985 100644 --- a/src/gallium/tests/graw/SConscript +++ b/src/gallium/tests/graw/SConscript @@ -1,20 +1,17 @@ Import('*') -try: - graw -except NameError: - print 'warning: graw library not avaiable: skipping build of graw test' - Return() - env = env.Clone() +env.Prepend(LIBS = [gallium]) + env.Prepend(LIBPATH = [graw.dir]) -env.Prepend(LIBS = ['graw'] + gallium) +env.Prepend(LIBS = ['graw']) + -if platform in ('freebsd8', 'sunos5'): +if env['platform'] in ('freebsd8', 'sunos5'): env.Append(LIBS = ['m']) -if platform == 'freebsd8': +if env['platform'] == 'freebsd8': env.Append(LIBS = ['pthread']) progs = [ @@ -29,9 +26,10 @@ progs = [ 'tri-gs', ] -for prog in progs: - env.Program( - target = prog, - source = prog + '.c', +for name in progs: + program = env.Program( + target = name, + source = name + '.c', ) - + #env.Depends(program, graw) + env.Alias('graw-progs', program) diff --git a/src/gallium/tests/unit/SConscript b/src/gallium/tests/unit/SConscript index 359759e22b2..655e8a9b41c 100644 --- a/src/gallium/tests/unit/SConscript +++ b/src/gallium/tests/unit/SConscript @@ -4,10 +4,10 @@ env = env.Clone() env.Prepend(LIBS = [gallium]) -if platform in ('freebsd8', 'sunos5'): +if env['platform'] in ('freebsd8', 'sunos5'): env.Append(LIBS = ['m']) -if platform == 'freebsd8': +if env['platform'] == 'freebsd8': env.Append(LIBS = ['pthread']) progs = [ diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 65b12287df7..d74f8a2e989 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -2,45 +2,38 @@ Import('*') SConscript([ - 'sw/wrapper/SConscript', + 'sw/wrapper/SConscript', ]) -if 'xlib' in env['winsys']: - SConscript([ - 'sw/xlib/SConscript', - ]) +SConscript([ + 'sw/xlib/SConscript', +]) -if 'gdi' in env['winsys']: - SConscript([ - 'sw/gdi/SConscript', - ]) +SConscript([ + 'sw/gdi/SConscript', +]) if env['dri']: - SConscript([ - 'sw/dri/SConscript', - ]) - - if 'vmware' in env['winsys']: - SConscript([ - 'svga/drm/SConscript', - ]) - - if 'i915' in env['winsys']: - SConscript([ - 'i915/drm/SConscript', - ]) - - if 'i965' in env['winsys']: - SConscript([ - 'i965/drm/SConscript', - ]) - - if 'radeon' in env['winsys']: - SConscript([ - 'radeon/drm/SConscript', - ]) - - if 'r600' in env['winsys']: - SConscript([ - 'r600/drm/SConscript', - ]) + SConscript([ + 'sw/dri/SConscript', + ]) + + SConscript([ + 'svga/drm/SConscript', + ]) + + SConscript([ + 'i915/drm/SConscript', + ]) + + SConscript([ + 'i965/drm/SConscript', + ]) + + SConscript([ + 'radeon/drm/SConscript', + ]) + + SConscript([ + 'r600/drm/SConscript', + ]) diff --git a/src/glut/glx/SConscript b/src/glut/glx/SConscript index 29d2cc01494..9363b5ca5cc 100644 --- a/src/glut/glx/SConscript +++ b/src/glut/glx/SConscript @@ -78,7 +78,6 @@ if env['platform'] == 'windows': 'glut.def', ] else: - env.Tool('x11') env.PrependUnique(LIBS = [ 'GLU', 'GL', diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript index 40db237fcbc..77a5f9bd2e3 100644 --- a/src/mapi/glapi/SConscript +++ b/src/mapi/glapi/SConscript @@ -6,77 +6,78 @@ Import('*') if env['platform'] != 'winddk': - env = env.Clone() - - env.Append(CPPDEFINES = [ - 'MAPI_GLAPI_CURRENT', - ]) + env = env.Clone() + + env.Append(CPPDEFINES = [ + 'MAPI_GLAPI_CURRENT', + ]) - if env['platform'] == 'windows': - env.Append(CPPDEFINES = [ - '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - 'WIN32_THREADS', # use Win32 thread API - ]) + if env['platform'] == 'windows': + env.Append(CPPDEFINES = [ + '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers + 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers + 'WIN32_THREADS', # use Win32 thread API + ]) - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/mesa', - ]) - - glapi_sources = [ - 'glapi_dispatch.c', - 'glapi_entrypoint.c', - 'glapi_getproc.c', - 'glapi_nop.c', - 'glthread.c', - ] - - mapi_sources = [ - 'u_current.c', - 'u_execmem.c', - 'u_thread.c', - ] - for s in mapi_sources: - o = env.SharedObject(s[:-2], '../mapi/' + s) - glapi_sources.append(o) + env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + ]) + + glapi_sources = [ + 'glapi_dispatch.c', + 'glapi_entrypoint.c', + 'glapi_getproc.c', + 'glapi_nop.c', + 'glthread.c', + ] + + mapi_sources = [ + 'u_current.c', + 'u_execmem.c', + 'u_thread.c', + ] + for s in mapi_sources: + o = env.SharedObject(s[:-2], '../mapi/' + s) + glapi_sources.append(o) - # - # Assembly sources - # - if gcc and env['machine'] == 'x86': - env.Append(CPPDEFINES = [ - 'USE_X86_ASM', - 'USE_MMX_ASM', - 'USE_3DNOW_ASM', - 'USE_SSE_ASM', - ]) - glapi_sources += [ - 'glapi_x86.S', - ] - elif gcc and env['machine'] == 'x86_64': - env.Append(CPPDEFINES = [ - 'USE_X86_64_ASM', - ]) - glapi_sources += [ - 'glapi_x86-64.S' - ] - elif gcc and env['machine'] == 'ppc': - env.Append(CPPDEFINES = [ - 'USE_PPC_ASM', - 'USE_VMX_ASM', - ]) - glapi_sources += [ - ] - elif gcc and env['machine'] == 'sparc': - glapi_sources += [ - 'glapi_sparc.S' - ] - else: - pass - - glapi = env.ConvenienceLibrary( - target = 'glapi', - source = glapi_sources, - ) - Export('glapi') + # + # Assembly sources + # + if env['gcc'] and env['platform'] != 'windows': + if env['machine'] == 'x86': + env.Append(CPPDEFINES = [ + 'USE_X86_ASM', + 'USE_MMX_ASM', + 'USE_3DNOW_ASM', + 'USE_SSE_ASM', + ]) + glapi_sources += [ + 'glapi_x86.S', + ] + elif env['machine'] == 'x86_64': + env.Append(CPPDEFINES = [ + 'USE_X86_64_ASM', + ]) + glapi_sources += [ + 'glapi_x86-64.S' + ] + elif env['machine'] == 'ppc': + env.Append(CPPDEFINES = [ + 'USE_PPC_ASM', + 'USE_VMX_ASM', + ]) + glapi_sources += [ + ] + elif env['machine'] == 'sparc': + glapi_sources += [ + 'glapi_sparc.S' + ] + else: + pass + + glapi = env.ConvenienceLibrary( + target = 'glapi', + source = glapi_sources, + ) + Export('glapi') diff --git a/src/mapi/vgapi/.gitignore b/src/mapi/vgapi/.gitignore new file mode 100644 index 00000000000..5becb993861 --- /dev/null +++ b/src/mapi/vgapi/.gitignore @@ -0,0 +1 @@ +vgapi_tmp.h diff --git a/src/mesa/SConscript b/src/mesa/SConscript index e54737aed18..7550c6d5ed4 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -4,322 +4,323 @@ Import('*') -if env['platform'] != 'winddk': +env = env.Clone() - env = env.Clone() - - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/glsl', - '#/src/mesa', - ]) - - if env['platform'] == 'windows': - env.Append(CPPDEFINES = [ - '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - 'WIN32_THREADS', # use Win32 thread API - ]) - env.Prepend(CPPPATH = ['#src/talloc']) +env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/glsl', + '#/src/mesa', +]) - # - # Source files - # - - main_sources = [ - 'main/api_arrayelt.c', - 'main/api_exec.c', - 'main/api_loopback.c', - 'main/api_noop.c', - 'main/api_validate.c', - 'main/accum.c', - 'main/arbprogram.c', - 'main/atifragshader.c', - 'main/attrib.c', - 'main/arrayobj.c', - 'main/blend.c', - 'main/bufferobj.c', - 'main/buffers.c', - 'main/clear.c', - 'main/clip.c', - 'main/colortab.c', - 'main/condrender.c', - 'main/context.c', - 'main/convolve.c', - 'main/cpuinfo.c', - 'main/debug.c', - 'main/depth.c', - 'main/depthstencil.c', - 'main/dlist.c', - 'main/dlopen.c', - 'main/drawpix.c', - 'main/drawtex.c', - 'main/enable.c', - 'main/enums.c', - 'main/eval.c', - 'main/execmem.c', - 'main/extensions.c', - 'main/fbobject.c', - 'main/feedback.c', - 'main/ffvertex_prog.c', - 'main/fog.c', - 'main/formats.c', - 'main/framebuffer.c', - 'main/get.c', - 'main/getstring.c', - 'main/hash.c', - 'main/hint.c', - 'main/histogram.c', - 'main/image.c', - 'main/imports.c', - 'main/light.c', - 'main/lines.c', - 'main/matrix.c', - 'main/mipmap.c', - 'main/mm.c', - 'main/multisample.c', - 'main/nvprogram.c', - 'main/pack.c', - 'main/pixel.c', - 'main/pixelstore.c', - 'main/pixeltransfer.c', - 'main/points.c', - 'main/polygon.c', - 'main/querymatrix.c', - 'main/queryobj.c', - 'main/rastpos.c', - 'main/readpix.c', - 'main/remap.c', - 'main/renderbuffer.c', - 'main/scissor.c', - 'main/shaderapi.c', - 'main/shaderobj.c', - 'main/shared.c', - 'main/state.c', - 'main/stencil.c', - 'main/syncobj.c', - 'main/texcompress.c', - 'main/texcompress_s3tc.c', - 'main/texcompress_fxt1.c', - 'main/texenv.c', - 'main/texenvprogram.c', - 'main/texfetch.c', - 'main/texformat.c', - 'main/texgen.c', - 'main/texgetimage.c', - 'main/teximage.c', - 'main/texobj.c', - 'main/texpal.c', - 'main/texparam.c', - 'main/texrender.c', - 'main/texstate.c', - 'main/texstore.c', - 'main/transformfeedback.c', - 'main/uniforms.c', - 'main/varray.c', - 'main/version.c', - 'main/viewport.c', - 'main/vtxfmt.c', - ] - - math_sources = [ - 'math/m_debug_clip.c', - 'math/m_debug_norm.c', - 'math/m_debug_xform.c', - 'math/m_eval.c', - 'math/m_matrix.c', - 'math/m_translate.c', - 'math/m_vector.c', - 'math/m_xform.c', - ] - - vbo_sources = [ - 'vbo/vbo_context.c', - 'vbo/vbo_exec.c', - 'vbo/vbo_exec_api.c', - 'vbo/vbo_exec_array.c', - 'vbo/vbo_exec_draw.c', - 'vbo/vbo_exec_eval.c', - 'vbo/vbo_rebase.c', - 'vbo/vbo_split.c', - 'vbo/vbo_split_copy.c', - 'vbo/vbo_split_inplace.c', - 'vbo/vbo_save.c', - 'vbo/vbo_save_api.c', - 'vbo/vbo_save_draw.c', - 'vbo/vbo_save_loopback.c', - ] - - vf_sources = [ - 'vf/vf.c', - 'vf/vf_generic.c', - 'vf/vf_sse.c', - ] - - statetracker_sources = [ - 'state_tracker/st_atom.c', - 'state_tracker/st_atom_blend.c', - 'state_tracker/st_atom_clip.c', - 'state_tracker/st_atom_constbuf.c', - 'state_tracker/st_atom_depth.c', - 'state_tracker/st_atom_framebuffer.c', - 'state_tracker/st_atom_msaa.c', - 'state_tracker/st_atom_pixeltransfer.c', - 'state_tracker/st_atom_sampler.c', - 'state_tracker/st_atom_scissor.c', - 'state_tracker/st_atom_shader.c', - 'state_tracker/st_atom_rasterizer.c', - 'state_tracker/st_atom_stipple.c', - 'state_tracker/st_atom_texture.c', - 'state_tracker/st_atom_viewport.c', - 'state_tracker/st_cb_accum.c', - 'state_tracker/st_cb_bitmap.c', - 'state_tracker/st_cb_blit.c', - 'state_tracker/st_cb_bufferobjects.c', - 'state_tracker/st_cb_clear.c', - 'state_tracker/st_cb_condrender.c', - 'state_tracker/st_cb_flush.c', - 'state_tracker/st_cb_drawpixels.c', - 'state_tracker/st_cb_drawtex.c', - 'state_tracker/st_cb_eglimage.c', - 'state_tracker/st_cb_fbo.c', - 'state_tracker/st_cb_feedback.c', - 'state_tracker/st_cb_program.c', - 'state_tracker/st_cb_queryobj.c', - 'state_tracker/st_cb_rasterpos.c', - 'state_tracker/st_cb_readpixels.c', - 'state_tracker/st_cb_strings.c', - 'state_tracker/st_cb_texture.c', - 'state_tracker/st_cb_viewport.c', - 'state_tracker/st_cb_xformfb.c', - 'state_tracker/st_context.c', - 'state_tracker/st_debug.c', - 'state_tracker/st_draw.c', - 'state_tracker/st_draw_feedback.c', - 'state_tracker/st_extensions.c', - 'state_tracker/st_format.c', - 'state_tracker/st_gen_mipmap.c', - 'state_tracker/st_manager.c', - 'state_tracker/st_mesa_to_tgsi.c', - 'state_tracker/st_program.c', - 'state_tracker/st_texture.c', - ] - - program_sources = [ - 'program/arbprogparse.c', - 'program/hash_table.c', - 'program/ir_to_mesa.cpp', - 'program/lex.yy.c', - 'program/nvfragparse.c', - 'program/nvvertparse.c', - 'program/program.c', - 'program/program_parse.tab.c', - 'program/program_parse_extra.c', - 'program/prog_cache.c', - 'program/prog_execute.c', - 'program/prog_instruction.c', - 'program/prog_noise.c', - 'program/prog_optimize.c', - 'program/prog_parameter.c', - 'program/prog_parameter_layout.c', - 'program/prog_print.c', - 'program/prog_statevars.c', - 'program/prog_uniform.c', - 'program/programopt.c', - 'program/sampler.cpp', - 'program/symbol_table.c', - ] - - mesa_sources = ( - main_sources + - math_sources + - program_sources + - vbo_sources + - vf_sources + - statetracker_sources - ) +if env['platform'] == 'windows': + env.Append(CPPDEFINES = [ + '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers + 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers + 'WIN32_THREADS', # use Win32 thread API + ]) + env.Prepend(CPPPATH = ['#src/talloc']) - # - # Assembly sources - # - if gcc and env['machine'] == 'x86': - env.Append(CPPDEFINES = [ - 'USE_X86_ASM', - 'USE_MMX_ASM', - 'USE_3DNOW_ASM', - 'USE_SSE_ASM', - ]) - mesa_sources += [ - 'x86/common_x86.c', - 'x86/x86_xform.c', - 'x86/3dnow.c', - 'x86/sse.c', - 'x86/common_x86_asm.S', - 'x86/x86_xform2.S', - 'x86/x86_xform3.S', - 'x86/x86_xform4.S', - 'x86/x86_cliptest.S', - 'x86/mmx_blend.S', - 'x86/3dnow_xform1.S', - 'x86/3dnow_xform2.S', - 'x86/3dnow_xform3.S', - 'x86/3dnow_xform4.S', - 'x86/3dnow_normal.S', - 'x86/sse_xform1.S', - 'x86/sse_xform2.S', - 'x86/sse_xform3.S', - 'x86/sse_xform4.S', - 'x86/sse_normal.S', - 'x86/read_rgba_span_x86.S', - ] - elif gcc and env['machine'] == 'x86_64': - env.Append(CPPDEFINES = [ - 'USE_X86_64_ASM', - ]) - mesa_sources += [ - 'x86-64/x86-64.c', - 'x86-64/xform4.S', - ] - elif gcc and env['machine'] == 'ppc': - env.Append(CPPDEFINES = [ - 'USE_PPC_ASM', - 'USE_VMX_ASM', - ]) - mesa_sources += [ - 'ppc/common_ppc.c', - ] - elif gcc and env['machine'] == 'sparc': - mesa_sources += [ - 'sparc/sparc.c', - 'sparc/clip.S', - 'sparc/norm.S', - 'sparc/xform.S', - ] - else: - pass - - # Generate matypes.h - if gcc and env['machine'] in ('x86', 'x86_64'): - # See http://www.scons.org/wiki/UsingCodeGenerators - gen_matypes = env.Program( - target = 'gen_matypes', - source = 'x86/gen_matypes.c', - ) - matypes = env.Command( - 'matypes.h', - gen_matypes, - gen_matypes[0].abspath + ' > $TARGET', - ) - # Add the dir containing the generated header (somewhere inside the - # build dir) to the include path - env.Append(CPPPATH = [matypes[0].dir]) +# +# Source files +# - # - # Libraries - # +main_sources = [ + 'main/api_arrayelt.c', + 'main/api_exec.c', + 'main/api_loopback.c', + 'main/api_noop.c', + 'main/api_validate.c', + 'main/accum.c', + 'main/arbprogram.c', + 'main/atifragshader.c', + 'main/attrib.c', + 'main/arrayobj.c', + 'main/blend.c', + 'main/bufferobj.c', + 'main/buffers.c', + 'main/clear.c', + 'main/clip.c', + 'main/colortab.c', + 'main/condrender.c', + 'main/context.c', + 'main/convolve.c', + 'main/cpuinfo.c', + 'main/debug.c', + 'main/depth.c', + 'main/depthstencil.c', + 'main/dlist.c', + 'main/dlopen.c', + 'main/drawpix.c', + 'main/drawtex.c', + 'main/enable.c', + 'main/enums.c', + 'main/eval.c', + 'main/execmem.c', + 'main/extensions.c', + 'main/fbobject.c', + 'main/feedback.c', + 'main/ffvertex_prog.c', + 'main/fog.c', + 'main/formats.c', + 'main/framebuffer.c', + 'main/get.c', + 'main/getstring.c', + 'main/hash.c', + 'main/hint.c', + 'main/histogram.c', + 'main/image.c', + 'main/imports.c', + 'main/light.c', + 'main/lines.c', + 'main/matrix.c', + 'main/mipmap.c', + 'main/mm.c', + 'main/multisample.c', + 'main/nvprogram.c', + 'main/pack.c', + 'main/pixel.c', + 'main/pixelstore.c', + 'main/pixeltransfer.c', + 'main/points.c', + 'main/polygon.c', + 'main/querymatrix.c', + 'main/queryobj.c', + 'main/rastpos.c', + 'main/readpix.c', + 'main/remap.c', + 'main/renderbuffer.c', + 'main/scissor.c', + 'main/shaderapi.c', + 'main/shaderobj.c', + 'main/shared.c', + 'main/state.c', + 'main/stencil.c', + 'main/syncobj.c', + 'main/texcompress.c', + 'main/texcompress_s3tc.c', + 'main/texcompress_fxt1.c', + 'main/texenv.c', + 'main/texenvprogram.c', + 'main/texfetch.c', + 'main/texformat.c', + 'main/texgen.c', + 'main/texgetimage.c', + 'main/teximage.c', + 'main/texobj.c', + 'main/texpal.c', + 'main/texparam.c', + 'main/texrender.c', + 'main/texstate.c', + 'main/texstore.c', + 'main/transformfeedback.c', + 'main/uniforms.c', + 'main/varray.c', + 'main/version.c', + 'main/viewport.c', + 'main/vtxfmt.c', +] - mesa = env.ConvenienceLibrary( - target = 'mesa', - source = mesa_sources, - ) - Export('mesa') +math_sources = [ + 'math/m_debug_clip.c', + 'math/m_debug_norm.c', + 'math/m_debug_xform.c', + 'math/m_eval.c', + 'math/m_matrix.c', + 'math/m_translate.c', + 'math/m_vector.c', + 'math/m_xform.c', +] + +vbo_sources = [ + 'vbo/vbo_context.c', + 'vbo/vbo_exec.c', + 'vbo/vbo_exec_api.c', + 'vbo/vbo_exec_array.c', + 'vbo/vbo_exec_draw.c', + 'vbo/vbo_exec_eval.c', + 'vbo/vbo_rebase.c', + 'vbo/vbo_split.c', + 'vbo/vbo_split_copy.c', + 'vbo/vbo_split_inplace.c', + 'vbo/vbo_save.c', + 'vbo/vbo_save_api.c', + 'vbo/vbo_save_draw.c', + 'vbo/vbo_save_loopback.c', +] + +vf_sources = [ + 'vf/vf.c', + 'vf/vf_generic.c', + 'vf/vf_sse.c', +] + +statetracker_sources = [ + 'state_tracker/st_atom.c', + 'state_tracker/st_atom_blend.c', + 'state_tracker/st_atom_clip.c', + 'state_tracker/st_atom_constbuf.c', + 'state_tracker/st_atom_depth.c', + 'state_tracker/st_atom_framebuffer.c', + 'state_tracker/st_atom_msaa.c', + 'state_tracker/st_atom_pixeltransfer.c', + 'state_tracker/st_atom_sampler.c', + 'state_tracker/st_atom_scissor.c', + 'state_tracker/st_atom_shader.c', + 'state_tracker/st_atom_rasterizer.c', + 'state_tracker/st_atom_stipple.c', + 'state_tracker/st_atom_texture.c', + 'state_tracker/st_atom_viewport.c', + 'state_tracker/st_cb_accum.c', + 'state_tracker/st_cb_bitmap.c', + 'state_tracker/st_cb_blit.c', + 'state_tracker/st_cb_bufferobjects.c', + 'state_tracker/st_cb_clear.c', + 'state_tracker/st_cb_condrender.c', + 'state_tracker/st_cb_flush.c', + 'state_tracker/st_cb_drawpixels.c', + 'state_tracker/st_cb_drawtex.c', + 'state_tracker/st_cb_eglimage.c', + 'state_tracker/st_cb_fbo.c', + 'state_tracker/st_cb_feedback.c', + 'state_tracker/st_cb_program.c', + 'state_tracker/st_cb_queryobj.c', + 'state_tracker/st_cb_rasterpos.c', + 'state_tracker/st_cb_readpixels.c', + 'state_tracker/st_cb_strings.c', + 'state_tracker/st_cb_texture.c', + 'state_tracker/st_cb_viewport.c', + 'state_tracker/st_cb_xformfb.c', + 'state_tracker/st_context.c', + 'state_tracker/st_debug.c', + 'state_tracker/st_draw.c', + 'state_tracker/st_draw_feedback.c', + 'state_tracker/st_extensions.c', + 'state_tracker/st_format.c', + 'state_tracker/st_gen_mipmap.c', + 'state_tracker/st_manager.c', + 'state_tracker/st_mesa_to_tgsi.c', + 'state_tracker/st_program.c', + 'state_tracker/st_texture.c', +] + +program_sources = [ + 'program/arbprogparse.c', + 'program/hash_table.c', + 'program/ir_to_mesa.cpp', + 'program/lex.yy.c', + 'program/nvfragparse.c', + 'program/nvvertparse.c', + 'program/program.c', + 'program/program_parse.tab.c', + 'program/program_parse_extra.c', + 'program/prog_cache.c', + 'program/prog_execute.c', + 'program/prog_instruction.c', + 'program/prog_noise.c', + 'program/prog_optimize.c', + 'program/prog_parameter.c', + 'program/prog_parameter_layout.c', + 'program/prog_print.c', + 'program/prog_statevars.c', + 'program/prog_uniform.c', + 'program/programopt.c', + 'program/sampler.cpp', + 'program/symbol_table.c', +] + +mesa_sources = ( + main_sources + + math_sources + + program_sources + + vbo_sources + + vf_sources + + statetracker_sources +) + +# +# Assembly sources +# +if env['gcc'] and env['machine'] == 'x86': + env.Append(CPPDEFINES = [ + 'USE_X86_ASM', + 'USE_MMX_ASM', + 'USE_3DNOW_ASM', + 'USE_SSE_ASM', + ]) + mesa_sources += [ + 'x86/common_x86.c', + 'x86/x86_xform.c', + 'x86/3dnow.c', + 'x86/sse.c', + 'x86/common_x86_asm.S', + 'x86/x86_xform2.S', + 'x86/x86_xform3.S', + 'x86/x86_xform4.S', + 'x86/x86_cliptest.S', + 'x86/mmx_blend.S', + 'x86/3dnow_xform1.S', + 'x86/3dnow_xform2.S', + 'x86/3dnow_xform3.S', + 'x86/3dnow_xform4.S', + 'x86/3dnow_normal.S', + 'x86/sse_xform1.S', + 'x86/sse_xform2.S', + 'x86/sse_xform3.S', + 'x86/sse_xform4.S', + 'x86/sse_normal.S', + 'x86/read_rgba_span_x86.S', + ] +elif env['gcc'] and env['machine'] == 'x86_64': + env.Append(CPPDEFINES = [ + 'USE_X86_64_ASM', + ]) + mesa_sources += [ + 'x86-64/x86-64.c', + 'x86-64/xform4.S', + ] +elif env['gcc'] and env['machine'] == 'ppc': + env.Append(CPPDEFINES = [ + 'USE_PPC_ASM', + 'USE_VMX_ASM', + ]) + mesa_sources += [ + 'ppc/common_ppc.c', + ] +elif env['gcc'] and env['machine'] == 'sparc': + mesa_sources += [ + 'sparc/sparc.c', + 'sparc/clip.S', + 'sparc/norm.S', + 'sparc/xform.S', + ] +else: + pass + +# Generate matypes.h +if env['gcc'] and env['machine'] in ('x86', 'x86_64'): + # See http://www.scons.org/wiki/UsingCodeGenerators + gen_matypes = env.Program( + target = 'gen_matypes', + source = 'x86/gen_matypes.c', + ) + matypes = env.Command( + 'matypes.h', + gen_matypes, + gen_matypes[0].abspath + ' > $TARGET', + ) + # Add the dir containing the generated header (somewhere inside the + # build dir) to the include path + env.Append(CPPPATH = [matypes[0].dir]) + +# +# Libraries +# + +mesa = env.ConvenienceLibrary( + target = 'mesa', + source = mesa_sources, +) + +env.Alias('mesa', mesa) + +Export('mesa') -- cgit v1.2.3 From 2fefbc79ac8bb55197ff817feeca2626585d7a8c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Nov 2010 17:29:28 -0600 Subject: gallivm: implement scatter stores into temp register file Something is not quite right, however. The piglit tests mentioned in fd.o bug 31226 still don't pass. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 51 +++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 3c318cc8c80..cb0ece83eae 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -467,9 +467,35 @@ build_gather(struct lp_build_tgsi_soa_context *bld, } +/** + * Scatter/store vector. + */ +static void +build_scatter(struct lp_build_tgsi_soa_context *bld, + LLVMValueRef base_ptr, + LLVMValueRef indexes, + LLVMValueRef values) +{ + LLVMBuilderRef builder = bld->base.builder; + unsigned i; + + /* + * Loop over elements of index_vec, store scalar value. + */ + for (i = 0; i < bld->base.type.length; i++) { + LLVMValueRef ii = LLVMConstInt(LLVMInt32Type(), i, 0); + LLVMValueRef index = LLVMBuildExtractElement(builder, indexes, ii, ""); + LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr, &index, 1, "scatter_ptr"); + LLVMValueRef val = LLVMBuildExtractElement(builder, values, ii, "scatter_val"); + + LLVMBuildStore(builder, val, scalar_ptr); + } +} + + /** * Read the current value of the ADDR register, convert the floats to - * ints, multiply by four and return the vector of offsets. + * ints, add the base index and return the vector of offsets. * The offsets will be used to index into the constant buffer or * temporary register file. */ @@ -748,6 +774,7 @@ emit_store( LLVMValueRef value) { const struct tgsi_full_dst_register *reg = &inst->Dst[index]; + struct lp_build_context *uint_bld = &bld->uint_bld; LLVMValueRef indirect_index = NULL; switch( inst->Instruction.Saturate ) { @@ -785,9 +812,25 @@ emit_store( case TGSI_FILE_TEMPORARY: if (reg->Register.Indirect) { - /* XXX not done yet */ - debug_printf("WARNING: LLVM scatter store of temp regs" - " not implemented\n"); + LLVMValueRef chan_vec = + lp_build_const_int_vec(uint_bld->type, chan_index); + LLVMValueRef length_vec = + lp_build_const_int_vec(uint_bld->type, bld->base.type.length); + LLVMValueRef index_vec; /* indexes into the temp registers */ + LLVMValueRef temps_array; + LLVMTypeRef float_ptr_type; + + /* index_vec = (indirect_index * 4 + chan_index) * length */ + index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2); + index_vec = lp_build_add(uint_bld, index_vec, chan_vec); + index_vec = lp_build_mul(uint_bld, index_vec, length_vec); + + float_ptr_type = LLVMPointerType(LLVMFloatType(), 0); + temps_array = LLVMBuildBitCast(bld->base.builder, bld->temps_array, + float_ptr_type, ""); + + /* Scatter store values into temp registers */ + build_scatter(bld, temps_array, index_vec, value); } else { LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index, -- cgit v1.2.3 From 3ded3e98ffc36820c8ab318d736eab99bb16f26b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Nov 2010 17:32:21 -0600 Subject: gallivm: add some LLVM var labels --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index cb0ece83eae..8e803c449fa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -457,7 +457,7 @@ build_gather(struct lp_build_tgsi_soa_context *bld, LLVMValueRef index = LLVMBuildExtractElement(bld->base.builder, indexes, ii, ""); LLVMValueRef scalar_ptr = LLVMBuildGEP(bld->base.builder, base_ptr, - &index, 1, ""); + &index, 1, "gather_ptr"); LLVMValueRef scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, ""); res = LLVMBuildInsertElement(bld->base.builder, res, scalar, ii, ""); @@ -1103,32 +1103,32 @@ emit_declaration( LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), last*4 + 4, 0); bld->temps_array = lp_build_array_alloca(bld->base.builder, - vec_type, array_size, ""); + vec_type, array_size, "temparray"); } else { for (i = 0; i < NUM_CHANNELS; i++) bld->temps[idx][i] = lp_build_alloca(bld->base.builder, - vec_type, ""); + vec_type, "temp"); } break; case TGSI_FILE_OUTPUT: for (i = 0; i < NUM_CHANNELS; i++) bld->outputs[idx][i] = lp_build_alloca(bld->base.builder, - vec_type, ""); + vec_type, "output"); break; case TGSI_FILE_ADDRESS: assert(idx < LP_MAX_TGSI_ADDRS); for (i = 0; i < NUM_CHANNELS; i++) bld->addr[idx][i] = lp_build_alloca(bld->base.builder, - vec_type, ""); + vec_type, "addr"); break; case TGSI_FILE_PREDICATE: assert(idx < LP_MAX_TGSI_PREDS); for (i = 0; i < NUM_CHANNELS; i++) bld->preds[idx][i] = lp_build_alloca(bld->base.builder, - vec_type, ""); + vec_type, "predicate"); break; default: -- cgit v1.2.3 From ee9366ab363a71407e4806ce079f98fc064d8734 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 4 Nov 2010 11:37:24 +0100 Subject: tgsi/exec: Cleanup the remaining arithmetic instructions. As a result remove some nasty macros. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 791 +++++++++++++++++---------------- 1 file changed, 413 insertions(+), 378 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 3a71540506d..57ae56e96fd 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -428,6 +428,24 @@ micro_sne(union tgsi_exec_channel *dst, dst->f[3] = src0->f[3] != src1->f[3] ? 1.0f : 0.0f; } +static void +micro_sfl(union tgsi_exec_channel *dst) +{ + dst->f[0] = 0.0f; + dst->f[1] = 0.0f; + dst->f[2] = 0.0f; + dst->f[3] = 0.0f; +} + +static void +micro_str(union tgsi_exec_channel *dst) +{ + dst->f[0] = 1.0f; + dst->f[1] = 1.0f; + dst->f[2] = 1.0f; + dst->f[3] = 1.0f; +} + static void micro_trunc(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src) @@ -453,22 +471,6 @@ enum tgsi_exec_datatype { /* * Shorthand locations of various utility registers (_I = Index, _C = Channel) */ -#define TEMP_0_I TGSI_EXEC_TEMP_00000000_I -#define TEMP_0_C TGSI_EXEC_TEMP_00000000_C -#define TEMP_7F_I TGSI_EXEC_TEMP_7FFFFFFF_I -#define TEMP_7F_C TGSI_EXEC_TEMP_7FFFFFFF_C -#define TEMP_80_I TGSI_EXEC_TEMP_80000000_I -#define TEMP_80_C TGSI_EXEC_TEMP_80000000_C -#define TEMP_FF_I TGSI_EXEC_TEMP_FFFFFFFF_I -#define TEMP_FF_C TGSI_EXEC_TEMP_FFFFFFFF_C -#define TEMP_1_I TGSI_EXEC_TEMP_ONE_I -#define TEMP_1_C TGSI_EXEC_TEMP_ONE_C -#define TEMP_2_I TGSI_EXEC_TEMP_TWO_I -#define TEMP_2_C TGSI_EXEC_TEMP_TWO_C -#define TEMP_128_I TGSI_EXEC_TEMP_128_I -#define TEMP_128_C TGSI_EXEC_TEMP_128_C -#define TEMP_M128_I TGSI_EXEC_TEMP_MINUS_128_I -#define TEMP_M128_C TGSI_EXEC_TEMP_MINUS_128_C #define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I #define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C #define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I @@ -477,26 +479,6 @@ enum tgsi_exec_datatype { #define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C #define TEMP_CC_I TGSI_EXEC_TEMP_CC_I #define TEMP_CC_C TGSI_EXEC_TEMP_CC_C -#define TEMP_3_I TGSI_EXEC_TEMP_THREE_I -#define TEMP_3_C TGSI_EXEC_TEMP_THREE_C -#define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I -#define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C -#define TEMP_R0 TGSI_EXEC_TEMP_R0 -#define TEMP_P0 TGSI_EXEC_TEMP_P0 - -#define IS_CHANNEL_ENABLED(INST, CHAN)\ - ((INST).Dst[0].Register.WriteMask & (1 << (CHAN))) - -#define IS_CHANNEL_ENABLED2(INST, CHAN)\ - ((INST).Dst[1].Register.WriteMask & (1 << (CHAN))) - -#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\ - for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\ - if (IS_CHANNEL_ENABLED( INST, CHAN )) - -#define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\ - for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\ - if (IS_CHANNEL_ENABLED2( INST, CHAN )) /** The execution mask depends on the conditional mask and the loop mask */ @@ -511,6 +493,14 @@ static const union tgsi_exec_channel OneVec = { {1.0f, 1.0f, 1.0f, 1.0f} }; +static const union tgsi_exec_channel P128Vec = { + {128.0f, 128.0f, 128.0f, 128.0f} +}; + +static const union tgsi_exec_channel M128Vec = { + {-128.0f, -128.0f, -128.0f, -128.0f} +}; + /** * Assert that none of the float values in 'chan' are infinite or NaN. @@ -572,8 +562,6 @@ tgsi_exec_set_constant_buffers(struct tgsi_exec_machine *mach, } - - /** * Check if there's a potential src/dst register data dependency when * using SOA execution. @@ -607,18 +595,20 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst) inst->Dst[0].Register.File) && ((inst->Src[i].Register.Index == inst->Dst[0].Register.Index) || - inst->Src[i].Register.Indirect || - inst->Dst[0].Register.Indirect)) { + inst->Src[i].Register.Indirect || + inst->Dst[0].Register.Indirect)) { /* loop over dest channels */ uint channelsWritten = 0x0; - FOR_EACH_ENABLED_CHANNEL(*inst, chan) { - /* check if we're reading a channel that's been written */ - uint swizzle = tgsi_util_get_full_src_register_swizzle(&inst->Src[i], chan); - if (channelsWritten & (1 << swizzle)) { - return TRUE; - } + for (chan = 0; chan < NUM_CHANNELS; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + /* check if we're reading a channel that's been written */ + uint swizzle = tgsi_util_get_full_src_register_swizzle(&inst->Src[i], chan); + if (channelsWritten & (1 << swizzle)) { + return TRUE; + } - channelsWritten |= (1 << chan); + channelsWritten |= (1 << chan); + } } } } @@ -813,18 +803,18 @@ tgsi_exec_machine_create( void ) mach->MaxGeometryShaderOutputs = TGSI_MAX_TOTAL_VERTICES; mach->Predicates = &mach->Temps[TGSI_EXEC_TEMP_P0]; - /* Setup constants. */ + /* Setup constants needed by the SSE2 executor. */ for( i = 0; i < 4; i++ ) { - mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000; - mach->Temps[TEMP_7F_I].xyzw[TEMP_7F_C].u[i] = 0x7FFFFFFF; - mach->Temps[TEMP_80_I].xyzw[TEMP_80_C].u[i] = 0x80000000; - mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].u[i] = 0xFFFFFFFF; - mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].f[i] = 1.0f; - mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].f[i] = 2.0f; - mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].f[i] = 128.0f; - mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].f[i] = -128.0f; - mach->Temps[TEMP_3_I].xyzw[TEMP_3_C].f[i] = 3.0f; - mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C].f[i] = 0.5f; + mach->Temps[TGSI_EXEC_TEMP_00000000_I].xyzw[TGSI_EXEC_TEMP_00000000_C].u[i] = 0x00000000; + mach->Temps[TGSI_EXEC_TEMP_7FFFFFFF_I].xyzw[TGSI_EXEC_TEMP_7FFFFFFF_C].u[i] = 0x7FFFFFFF; + mach->Temps[TGSI_EXEC_TEMP_80000000_I].xyzw[TGSI_EXEC_TEMP_80000000_C].u[i] = 0x80000000; + mach->Temps[TGSI_EXEC_TEMP_FFFFFFFF_I].xyzw[TGSI_EXEC_TEMP_FFFFFFFF_C].u[i] = 0xFFFFFFFF; /* not used */ + mach->Temps[TGSI_EXEC_TEMP_ONE_I].xyzw[TGSI_EXEC_TEMP_ONE_C].f[i] = 1.0f; + mach->Temps[TGSI_EXEC_TEMP_TWO_I].xyzw[TGSI_EXEC_TEMP_TWO_C].f[i] = 2.0f; /* not used */ + mach->Temps[TGSI_EXEC_TEMP_128_I].xyzw[TGSI_EXEC_TEMP_128_C].f[i] = 128.0f; + mach->Temps[TGSI_EXEC_TEMP_MINUS_128_I].xyzw[TGSI_EXEC_TEMP_MINUS_128_C].f[i] = -128.0f; + mach->Temps[TGSI_EXEC_TEMP_THREE_I].xyzw[TGSI_EXEC_TEMP_THREE_C].f[i] = 3.0f; + mach->Temps[TGSI_EXEC_TEMP_HALF_I].xyzw[TGSI_EXEC_TEMP_HALF_C].f[i] = 0.5f; } #ifdef DEBUG @@ -886,27 +876,35 @@ micro_div( } static void -micro_float_clamp(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) +micro_rcc(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src) { uint i; for (i = 0; i < 4; i++) { - if (src->f[i] > 0.0f) { - if (src->f[i] > 1.884467e+019f) + float recip = 1.0f / src->f[i]; + + if (recip > 0.0f) { + if (recip > 1.884467e+019f) { dst->f[i] = 1.884467e+019f; - else if (src->f[i] < 5.42101e-020f) + } + else if (recip < 5.42101e-020f) { dst->f[i] = 5.42101e-020f; - else - dst->f[i] = src->f[i]; + } + else { + dst->f[i] = recip; + } } else { - if (src->f[i] < -1.884467e+019f) + if (recip < -1.884467e+019f) { dst->f[i] = -1.884467e+019f; - else if (src->f[i] > -5.42101e-020f) + } + else if (recip > -5.42101e-020f) { dst->f[i] = -5.42101e-020f; - else - dst->f[i] = src->f[i]; + } + else { + dst->f[i] = recip; + } } } } @@ -958,60 +956,6 @@ micro_mul(union tgsi_exec_channel *dst, dst->f[3] = src0->f[3] * src1->f[3]; } -#if 0 -static void -micro_imul64( - union tgsi_exec_channel *dst0, - union tgsi_exec_channel *dst1, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) -{ - dst1->i[0] = src0->i[0] * src1->i[0]; - dst1->i[1] = src0->i[1] * src1->i[1]; - dst1->i[2] = src0->i[2] * src1->i[2]; - dst1->i[3] = src0->i[3] * src1->i[3]; - dst0->i[0] = 0; - dst0->i[1] = 0; - dst0->i[2] = 0; - dst0->i[3] = 0; -} -#endif - -#if 0 -static void -micro_umul64( - union tgsi_exec_channel *dst0, - union tgsi_exec_channel *dst1, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) -{ - dst1->u[0] = src0->u[0] * src1->u[0]; - dst1->u[1] = src0->u[1] * src1->u[1]; - dst1->u[2] = src0->u[2] * src1->u[2]; - dst1->u[3] = src0->u[3] * src1->u[3]; - dst0->u[0] = 0; - dst0->u[1] = 0; - dst0->u[2] = 0; - dst0->u[3] = 0; -} -#endif - - -#if 0 -static void -micro_movc( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1, - const union tgsi_exec_channel *src2 ) -{ - dst->u[0] = src0->u[0] ? src1->u[0] : src2->u[0]; - dst->u[1] = src0->u[1] ? src1->u[1] : src2->u[1]; - dst->u[2] = src0->u[2] ? src1->u[2] : src2->u[2]; - dst->u[3] = src0->u[3] ? src1->u[3] : src2->u[3]; -} -#endif - static void micro_neg( union tgsi_exec_channel *dst, @@ -1607,9 +1551,6 @@ store_dest(struct tgsi_exec_machine *mach, #define FETCH(VAL,INDEX,CHAN)\ fetch_source(mach, VAL, &inst->Src[INDEX], CHAN, TGSI_EXEC_DATA_FLOAT) -#define STORE(VAL,INDEX,CHAN)\ - store_dest(mach, VAL, &inst->Dst[INDEX], inst, CHAN, TGSI_EXEC_DATA_FLOAT) - /** * Execute ARB-style KIL which is predicated by a src register. @@ -1753,7 +1694,7 @@ exec_tex(struct tgsi_exec_machine *mach, union tgsi_exec_channel r[4]; const union tgsi_exec_channel *lod = &ZeroVec; enum tgsi_sampler_control control; - uint chan_index; + uint chan; if (modifier != TEX_MODIFIER_NONE) { FETCH(&r[3], 0, CHAN_W); @@ -1825,8 +1766,10 @@ exec_tex(struct tgsi_exec_machine *mach, assert(0); } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&r[chan_index], 0, chan_index); + for (chan = 0; chan < NUM_CHANNELS; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT); + } } } @@ -1836,7 +1779,7 @@ exec_txd(struct tgsi_exec_machine *mach, { const uint unit = inst->Src[3].Register.Index; union tgsi_exec_channel r[4]; - uint chan_index; + uint chan; /* * XXX: This is fake TXD -- the derivatives are not taken into account, yet. @@ -1886,8 +1829,10 @@ exec_txd(struct tgsi_exec_machine *mach, assert(0); } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&r[chan_index], 0, chan_index); + for (chan = 0; chan < NUM_CHANNELS; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT); + } } } @@ -2021,6 +1966,26 @@ exec_declaration(struct tgsi_exec_machine *mach, } } +typedef void (* micro_op)(union tgsi_exec_channel *dst); + +static void +exec_vector(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst, + micro_op op, + enum tgsi_exec_datatype dst_datatype) +{ + unsigned int chan; + + for (chan = 0; chan < NUM_CHANNELS; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + union tgsi_exec_channel dst; + + op(&dst); + store_dest(mach, &dst, &inst->Dst[0], inst, chan, dst_datatype); + } + } +} + typedef void (* micro_unary_op)(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src); @@ -2073,6 +2038,27 @@ typedef void (* micro_binary_op)(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, const union tgsi_exec_channel *src1); +static void +exec_scalar_binary(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst, + micro_binary_op op, + enum tgsi_exec_datatype dst_datatype, + enum tgsi_exec_datatype src_datatype) +{ + unsigned int chan; + union tgsi_exec_channel src[2]; + union tgsi_exec_channel dst; + + fetch_source(mach, &src[0], &inst->Src[0], CHAN_X, src_datatype); + fetch_source(mach, &src[1], &inst->Src[1], CHAN_Y, src_datatype); + op(&dst, &src[0], &src[1]); + for (chan = 0; chan < NUM_CHANNELS; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + store_dest(mach, &dst, &inst->Dst[0], inst, chan, dst_datatype); + } + } +} + static void exec_vector_binary(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst, @@ -2319,6 +2305,289 @@ exec_nrm3(struct tgsi_exec_machine *mach, } } +static void +exec_scs(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XY) { + union tgsi_exec_channel arg; + union tgsi_exec_channel result; + + fetch_source(mach, &arg, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + micro_cos(&result, &arg); + store_dest(mach, &result, &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + micro_sin(&result, &arg); + store_dest(mach, &result, &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + store_dest(mach, &ZeroVec, &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_x2d(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[4]; + union tgsi_exec_channel d[2]; + + fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT); + fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XZ) { + fetch_source(mach, &r[2], &inst->Src[2], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[2], &r[2], &r[0]); + fetch_source(mach, &r[3], &inst->Src[2], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[3], &r[3], &r[1]); + micro_add(&r[2], &r[2], &r[3]); + fetch_source(mach, &r[3], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_add(&d[0], &r[2], &r[3]); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_YW) { + fetch_source(mach, &r[2], &inst->Src[2], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[2], &r[2], &r[0]); + fetch_source(mach, &r[3], &inst->Src[2], CHAN_W, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[3], &r[3], &r[1]); + micro_add(&r[2], &r[2], &r[3]); + fetch_source(mach, &r[3], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_add(&d[1], &r[2], &r[3]); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + store_dest(mach, &d[0], &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + store_dest(mach, &d[1], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + store_dest(mach, &d[0], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &d[1], &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_rfl(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[9]; + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XYZ) { + /* r0 = dp3(src0, src0) */ + fetch_source(mach, &r[2], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[0], &r[2], &r[2]); + fetch_source(mach, &r[4], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[8], &r[4], &r[4]); + micro_add(&r[0], &r[0], &r[8]); + fetch_source(mach, &r[6], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[8], &r[6], &r[6]); + micro_add(&r[0], &r[0], &r[8]); + + /* r1 = dp3(src0, src1) */ + fetch_source(mach, &r[3], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[1], &r[2], &r[3]); + fetch_source(mach, &r[5], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[8], &r[4], &r[5]); + micro_add(&r[1], &r[1], &r[8]); + fetch_source(mach, &r[7], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + micro_mul(&r[8], &r[6], &r[7]); + micro_add(&r[1], &r[1], &r[8]); + + /* r1 = 2 * r1 / r0 */ + micro_add(&r[1], &r[1], &r[1]); + micro_div(&r[1], &r[1], &r[0]); + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + micro_mul(&r[2], &r[2], &r[1]); + micro_sub(&r[2], &r[2], &r[3]); + store_dest(mach, &r[2], &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + micro_mul(&r[4], &r[4], &r[1]); + micro_sub(&r[4], &r[4], &r[5]); + store_dest(mach, &r[4], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + micro_mul(&r[6], &r[6], &r[1]); + micro_sub(&r[6], &r[6], &r[7]); + store_dest(mach, &r[6], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_xpd(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[6]; + union tgsi_exec_channel d[3]; + + fetch_source(mach, &r[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + fetch_source(mach, &r[1], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + + micro_mul(&r[2], &r[0], &r[1]); + + fetch_source(mach, &r[3], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + fetch_source(mach, &r[4], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + + micro_mul(&r[5], &r[3], &r[4] ); + micro_sub(&d[CHAN_X], &r[2], &r[5]); + + fetch_source(mach, &r[2], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT); + + micro_mul(&r[3], &r[3], &r[2]); + + fetch_source(mach, &r[5], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + + micro_mul(&r[1], &r[1], &r[5]); + micro_sub(&d[CHAN_Y], &r[3], &r[1]); + + micro_mul(&r[5], &r[5], &r[4]); + micro_mul(&r[0], &r[0], &r[2]); + micro_sub(&d[CHAN_Z], &r[5], &r[0]); + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + store_dest(mach, &d[CHAN_X], &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + store_dest(mach, &d[CHAN_Y], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + store_dest(mach, &d[CHAN_Z], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_dst(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[2]; + union tgsi_exec_channel d[4]; + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + fetch_source(mach, &r[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_mul(&d[CHAN_Y], &r[0], &r[1]); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + fetch_source(mach, &d[CHAN_Z], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + fetch_source(mach, &d[CHAN_W], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT); + } + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + store_dest(mach, &d[CHAN_Y], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + store_dest(mach, &d[CHAN_Z], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &d[CHAN_W], &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_log(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[3]; + + fetch_source(mach, &r[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_abs(&r[2], &r[0]); /* r2 = abs(r0) */ + micro_lg2(&r[1], &r[2]); /* r1 = lg2(r2) */ + micro_flr(&r[0], &r[1]); /* r0 = floor(r1) */ + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + store_dest(mach, &r[0], &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + micro_exp2(&r[0], &r[0]); /* r0 = 2 ^ r0 */ + micro_div(&r[0], &r[2], &r[0]); /* r0 = r2 / r0 */ + store_dest(mach, &r[0], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + store_dest(mach, &r[1], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_exp(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[3]; + + fetch_source(mach, &r[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_flr(&r[1], &r[0]); /* r1 = floor(r0) */ + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + micro_exp2(&r[2], &r[1]); /* r2 = 2 ^ r1 */ + store_dest(mach, &r[2], &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + micro_sub(&r[2], &r[0], &r[1]); /* r2 = r0 - r1 */ + store_dest(mach, &r[2], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + micro_exp2(&r[2], &r[0]); /* r2 = 2 ^ r0 */ + store_dest(mach, &r[2], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + +static void +exec_lit(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + union tgsi_exec_channel r[3]; + union tgsi_exec_channel d[3]; + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_X, TGSI_EXEC_DATA_FLOAT); + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_YZ) { + fetch_source(mach, &r[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { + micro_max(&d[CHAN_Y], &r[0], &ZeroVec); + store_dest(mach, &d[CHAN_Y], &inst->Dst[0], inst, CHAN_Y, TGSI_EXEC_DATA_FLOAT); + } + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { + fetch_source(mach, &r[1], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); + micro_max(&r[1], &r[1], &ZeroVec); + + fetch_source(mach, &r[2], &inst->Src[0], CHAN_W, TGSI_EXEC_DATA_FLOAT); + micro_min(&r[2], &r[2], &P128Vec); + micro_max(&r[2], &r[2], &M128Vec); + micro_pow(&r[1], &r[1], &r[2]); + micro_lt(&d[CHAN_Z], &ZeroVec, &r[0], &r[1], &ZeroVec); + store_dest(mach, &d[CHAN_Z], &inst->Dst[0], inst, CHAN_Z, TGSI_EXEC_DATA_FLOAT); + } + } + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + static void exec_break(struct tgsi_exec_machine *mach) { @@ -2702,9 +2971,7 @@ exec_instruction( const struct tgsi_full_instruction *inst, int *pc ) { - uint chan_index; union tgsi_exec_channel r[10]; - union tgsi_exec_channel d[8]; (*pc)++; @@ -2718,36 +2985,7 @@ exec_instruction( break; case TGSI_OPCODE_LIT: - if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { - FETCH( &r[0], 0, CHAN_X ); - if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { - micro_max(&d[CHAN_Y], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]); - } - - if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { - FETCH( &r[1], 0, CHAN_Y ); - micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); - - FETCH( &r[2], 0, CHAN_W ); - micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] ); - micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] ); - micro_pow( &r[1], &r[1], &r[2] ); - micro_lt(&d[CHAN_Z], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]); - } - - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - STORE(&d[CHAN_Y], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - STORE(&d[CHAN_Z], 0, CHAN_Z); - } - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X ); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); - } + exec_lit(mach, inst); break; case TGSI_OPCODE_RCP: @@ -2759,44 +2997,11 @@ exec_instruction( break; case TGSI_OPCODE_EXP: - FETCH( &r[0], 0, CHAN_X ); - micro_flr( &r[1], &r[0] ); /* r1 = floor(r0) */ - if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { - micro_exp2( &r[2], &r[1] ); /* r2 = 2 ^ r1 */ - STORE( &r[2], 0, CHAN_X ); /* store r2 */ - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { - micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */ - STORE( &r[2], 0, CHAN_Y ); /* store r2 */ - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { - micro_exp2( &r[2], &r[0] ); /* r2 = 2 ^ r0 */ - STORE( &r[2], 0, CHAN_Z ); /* store r2 */ - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); - } + exec_exp(mach, inst); break; case TGSI_OPCODE_LOG: - FETCH( &r[0], 0, CHAN_X ); - micro_abs( &r[2], &r[0] ); /* r2 = abs(r0) */ - micro_lg2( &r[1], &r[2] ); /* r1 = lg2(r2) */ - micro_flr( &r[0], &r[1] ); /* r0 = floor(r1) */ - if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { - STORE( &r[0], 0, CHAN_X ); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { - micro_exp2( &r[0], &r[0] ); /* r0 = 2 ^ r0 */ - micro_div( &r[0], &r[2], &r[0] ); /* r0 = r2 / r0 */ - STORE( &r[0], 0, CHAN_Y ); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { - STORE( &r[1], 0, CHAN_Z ); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); - } + exec_log(mach, inst); break; case TGSI_OPCODE_MUL: @@ -2816,30 +3021,7 @@ exec_instruction( break; case TGSI_OPCODE_DST: - if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { - FETCH( &r[0], 0, CHAN_Y ); - FETCH( &r[1], 1, CHAN_Y); - micro_mul(&d[CHAN_Y], &r[0], &r[1]); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { - FETCH(&d[CHAN_Z], 0, CHAN_Z); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { - FETCH(&d[CHAN_W], 1, CHAN_W); - } - - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - STORE(&d[CHAN_Y], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - STORE(&d[CHAN_Z], 0, CHAN_Z); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) { - STORE(&d[CHAN_W], 0, CHAN_W); - } + exec_dst(mach, inst); break; case TGSI_OPCODE_MIN: @@ -2903,53 +3085,11 @@ exec_instruction( break; case TGSI_OPCODE_POW: - FETCH(&r[0], 0, CHAN_X); - FETCH(&r[1], 1, CHAN_X); - - micro_pow( &r[0], &r[0], &r[1] ); - - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - STORE( &r[0], 0, chan_index ); - } + exec_scalar_binary(mach, inst, micro_pow, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_XPD: - FETCH(&r[0], 0, CHAN_Y); - FETCH(&r[1], 1, CHAN_Z); - - micro_mul( &r[2], &r[0], &r[1] ); - - FETCH(&r[3], 0, CHAN_Z); - FETCH(&r[4], 1, CHAN_Y); - - micro_mul( &r[5], &r[3], &r[4] ); - micro_sub(&d[CHAN_X], &r[2], &r[5]); - - FETCH(&r[2], 1, CHAN_X); - - micro_mul( &r[3], &r[3], &r[2] ); - - FETCH(&r[5], 0, CHAN_X); - - micro_mul( &r[1], &r[1], &r[5] ); - micro_sub(&d[CHAN_Y], &r[3], &r[1]); - - micro_mul( &r[5], &r[5], &r[4] ); - micro_mul( &r[0], &r[0], &r[2] ); - micro_sub(&d[CHAN_Z], &r[5], &r[0]); - - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - STORE(&d[CHAN_X], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - STORE(&d[CHAN_Y], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - STORE(&d[CHAN_Z], 0, CHAN_Z); - } - if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); - } + exec_xpd(mach, inst); break; case TGSI_OPCODE_ABS: @@ -2957,12 +3097,7 @@ exec_instruction( break; case TGSI_OPCODE_RCC: - FETCH(&r[0], 0, CHAN_X); - micro_div(&r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0]); - micro_float_clamp(&r[0], &r[0]); - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&r[0], 0, chan_index); - } + exec_scalar_unary(mach, inst, micro_rcc, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_DPH: @@ -3006,52 +3141,7 @@ exec_instruction( break; case TGSI_OPCODE_RFL: - if (IS_CHANNEL_ENABLED(*inst, CHAN_X) || - IS_CHANNEL_ENABLED(*inst, CHAN_Y) || - IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - /* r0 = dp3(src0, src0) */ - FETCH(&r[2], 0, CHAN_X); - micro_mul(&r[0], &r[2], &r[2]); - FETCH(&r[4], 0, CHAN_Y); - micro_mul(&r[8], &r[4], &r[4]); - micro_add(&r[0], &r[0], &r[8]); - FETCH(&r[6], 0, CHAN_Z); - micro_mul(&r[8], &r[6], &r[6]); - micro_add(&r[0], &r[0], &r[8]); - - /* r1 = dp3(src0, src1) */ - FETCH(&r[3], 1, CHAN_X); - micro_mul(&r[1], &r[2], &r[3]); - FETCH(&r[5], 1, CHAN_Y); - micro_mul(&r[8], &r[4], &r[5]); - micro_add(&r[1], &r[1], &r[8]); - FETCH(&r[7], 1, CHAN_Z); - micro_mul(&r[8], &r[6], &r[7]); - micro_add(&r[1], &r[1], &r[8]); - - /* r1 = 2 * r1 / r0 */ - micro_add(&r[1], &r[1], &r[1]); - micro_div(&r[1], &r[1], &r[0]); - - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - micro_mul(&r[2], &r[2], &r[1]); - micro_sub(&r[2], &r[2], &r[3]); - STORE(&r[2], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - micro_mul(&r[4], &r[4], &r[1]); - micro_sub(&r[4], &r[4], &r[5]); - STORE(&r[4], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - micro_mul(&r[6], &r[6], &r[1]); - micro_sub(&r[6], &r[6], &r[7]); - STORE(&r[6], 0, CHAN_Z); - } - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) { - STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W); - } + exec_rfl(mach, inst); break; case TGSI_OPCODE_SEQ: @@ -3059,9 +3149,7 @@ exec_instruction( break; case TGSI_OPCODE_SFL: - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, chan_index); - } + exec_vector(mach, inst, micro_sfl, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_SGT: @@ -3081,9 +3169,7 @@ exec_instruction( break; case TGSI_OPCODE_STR: - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, chan_index); - } + exec_vector(mach, inst, micro_str, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_TEX: @@ -3140,42 +3226,7 @@ exec_instruction( break; case TGSI_OPCODE_X2D: - FETCH(&r[0], 1, CHAN_X); - FETCH(&r[1], 1, CHAN_Y); - if (IS_CHANNEL_ENABLED(*inst, CHAN_X) || - IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - FETCH(&r[2], 2, CHAN_X); - micro_mul(&r[2], &r[2], &r[0]); - FETCH(&r[3], 2, CHAN_Y); - micro_mul(&r[3], &r[3], &r[1]); - micro_add(&r[2], &r[2], &r[3]); - FETCH(&r[3], 0, CHAN_X); - micro_add(&d[CHAN_X], &r[2], &r[3]); - - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y) || - IS_CHANNEL_ENABLED(*inst, CHAN_W)) { - FETCH(&r[2], 2, CHAN_Z); - micro_mul(&r[2], &r[2], &r[0]); - FETCH(&r[3], 2, CHAN_W); - micro_mul(&r[3], &r[3], &r[1]); - micro_add(&r[2], &r[2], &r[3]); - FETCH(&r[3], 0, CHAN_Y); - micro_add(&d[CHAN_Y], &r[2], &r[3]); - - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - STORE(&d[CHAN_X], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - STORE(&d[CHAN_Y], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - STORE(&d[CHAN_X], 0, CHAN_Z); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) { - STORE(&d[CHAN_Y], 0, CHAN_W); - } + exec_x2d(mach, inst); break; case TGSI_OPCODE_ARA: @@ -3283,23 +3334,7 @@ exec_instruction( break; case TGSI_OPCODE_SCS: - if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) || IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) { - FETCH( &r[0], 0, CHAN_X ); - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - micro_cos(&r[1], &r[0]); - STORE(&r[1], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - micro_sin(&r[1], &r[0]); - STORE(&r[1], 0, CHAN_Y); - } - } - if( IS_CHANNEL_ENABLED( *inst, CHAN_Z ) ) { - STORE( &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, CHAN_Z ); - } - if( IS_CHANNEL_ENABLED( *inst, CHAN_W ) ) { - STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); - } + exec_scs(mach, inst); break; case TGSI_OPCODE_NRM: -- cgit v1.2.3 From f93d6f929f2439f87950df2c30c6c48b6dcac395 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 4 Nov 2010 11:51:10 +0100 Subject: tgsi/exec: Get rid of obsolete condition codes. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 10 ---------- src/gallium/auxiliary/tgsi/tgsi_exec.h | 27 ++++----------------------- 2 files changed, 4 insertions(+), 33 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 57ae56e96fd..7892a67f04c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -477,8 +477,6 @@ enum tgsi_exec_datatype { #define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C #define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I #define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C -#define TEMP_CC_I TGSI_EXEC_TEMP_CC_I -#define TEMP_CC_C TGSI_EXEC_TEMP_CC_C /** The execution mask depends on the conditional mask and the loop mask */ @@ -3719,14 +3717,6 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach ) mach->Primitives[0] = 0; } - for (i = 0; i < QUAD_SIZE; i++) { - mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C].u[i] = - (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_X_SHIFT) | - (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Y_SHIFT) | - (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Z_SHIFT) | - (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_W_SHIFT); - } - /* execute declarations (interpolants) */ for (i = 0; i < mach->NumDeclarations; i++) { exec_declaration( mach, mach->Declarations+i ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 9d62c1d7e7e..bd5492e9497 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -131,34 +131,15 @@ struct tgsi_sampler #define TGSI_EXEC_TEMP_PRIMITIVE_I (TGSI_EXEC_NUM_TEMPS + 2) #define TGSI_EXEC_TEMP_PRIMITIVE_C 2 -/* NVIDIA condition code (CC) vector - */ -#define TGSI_EXEC_CC_GT 0x01 -#define TGSI_EXEC_CC_EQ 0x02 -#define TGSI_EXEC_CC_LT 0x04 -#define TGSI_EXEC_CC_UN 0x08 - -#define TGSI_EXEC_CC_X_MASK 0x000000ff -#define TGSI_EXEC_CC_X_SHIFT 0 -#define TGSI_EXEC_CC_Y_MASK 0x0000ff00 -#define TGSI_EXEC_CC_Y_SHIFT 8 -#define TGSI_EXEC_CC_Z_MASK 0x00ff0000 -#define TGSI_EXEC_CC_Z_SHIFT 16 -#define TGSI_EXEC_CC_W_MASK 0xff000000 -#define TGSI_EXEC_CC_W_SHIFT 24 - -#define TGSI_EXEC_TEMP_CC_I (TGSI_EXEC_NUM_TEMPS + 2) -#define TGSI_EXEC_TEMP_CC_C 3 - -#define TGSI_EXEC_TEMP_THREE_I (TGSI_EXEC_NUM_TEMPS + 3) -#define TGSI_EXEC_TEMP_THREE_C 0 +#define TGSI_EXEC_TEMP_THREE_I (TGSI_EXEC_NUM_TEMPS + 2) +#define TGSI_EXEC_TEMP_THREE_C 3 #define TGSI_EXEC_TEMP_HALF_I (TGSI_EXEC_NUM_TEMPS + 3) -#define TGSI_EXEC_TEMP_HALF_C 1 +#define TGSI_EXEC_TEMP_HALF_C 0 /* execution mask, each value is either 0 or ~0 */ #define TGSI_EXEC_MASK_I (TGSI_EXEC_NUM_TEMPS + 3) -#define TGSI_EXEC_MASK_C 2 +#define TGSI_EXEC_MASK_C 1 /* 4 register buffer for various purposes */ #define TGSI_EXEC_TEMP_R0 (TGSI_EXEC_NUM_TEMPS + 4) -- cgit v1.2.3 From 420400f67fce15512a8fcab770dde83a3eacc5cc Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 4 Nov 2010 12:20:14 +0100 Subject: tgsi/build: Reduce interface clutter. Make private those functions that are used internally only. --- src/gallium/auxiliary/tgsi/tgsi_build.c | 821 ++++++++++++++++---------------- src/gallium/auxiliary/tgsi/tgsi_build.h | 161 ------- 2 files changed, 404 insertions(+), 578 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c index 6dbedf15ca8..1f7d7f190aa 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.c +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c @@ -63,17 +63,6 @@ header_bodysize_grow( struct tgsi_header *header ) header->BodySize++; } -struct tgsi_processor -tgsi_default_processor( void ) -{ - struct tgsi_processor processor; - - processor.Processor = TGSI_PROCESSOR_FRAGMENT; - processor.Padding = 0; - - return processor; -} - struct tgsi_processor tgsi_build_processor( unsigned type, @@ -81,8 +70,8 @@ tgsi_build_processor( { struct tgsi_processor processor; - processor = tgsi_default_processor(); processor.Processor = type; + processor.Padding = 0; header_headersize_grow( header ); @@ -93,7 +82,19 @@ tgsi_build_processor( * declaration */ -struct tgsi_declaration +static void +declaration_grow( + struct tgsi_declaration *declaration, + struct tgsi_header *header ) +{ + assert( declaration->NrTokens < 0xFF ); + + declaration->NrTokens++; + + header_bodysize_grow( header ); +} + +static struct tgsi_declaration tgsi_default_declaration( void ) { struct tgsi_declaration declaration; @@ -112,7 +113,7 @@ tgsi_default_declaration( void ) return declaration; } -struct tgsi_declaration +static struct tgsi_declaration tgsi_build_declaration( unsigned file, unsigned usage_mask, @@ -144,16 +145,96 @@ tgsi_build_declaration( return declaration; } -static void -declaration_grow( +static struct tgsi_declaration_range +tgsi_default_declaration_range( void ) +{ + struct tgsi_declaration_range dr; + + dr.First = 0; + dr.Last = 0; + + return dr; +} + +static struct tgsi_declaration_range +tgsi_build_declaration_range( + unsigned first, + unsigned last, struct tgsi_declaration *declaration, struct tgsi_header *header ) { - assert( declaration->NrTokens < 0xFF ); + struct tgsi_declaration_range declaration_range; - declaration->NrTokens++; + assert( last >= first ); + assert( last <= 0xFFFF ); - header_bodysize_grow( header ); + declaration_range.First = first; + declaration_range.Last = last; + + declaration_grow( declaration, header ); + + return declaration_range; +} + +static struct tgsi_declaration_dimension +tgsi_default_declaration_dimension(void) +{ + struct tgsi_declaration_dimension dd; + + dd.Index2D = 0; + dd.Padding = 0; + + return dd; +} + +static struct tgsi_declaration_dimension +tgsi_build_declaration_dimension(unsigned index_2d, + struct tgsi_declaration *declaration, + struct tgsi_header *header) +{ + struct tgsi_declaration_dimension dd; + + assert(index_2d <= 0xFFFF); + + dd.Index2D = index_2d; + dd.Padding = 0; + + declaration_grow(declaration, header); + + return dd; +} + +static struct tgsi_declaration_semantic +tgsi_default_declaration_semantic( void ) +{ + struct tgsi_declaration_semantic ds; + + ds.Name = TGSI_SEMANTIC_POSITION; + ds.Index = 0; + ds.Padding = 0; + + return ds; +} + +static struct tgsi_declaration_semantic +tgsi_build_declaration_semantic( + unsigned semantic_name, + unsigned semantic_index, + struct tgsi_declaration *declaration, + struct tgsi_header *header ) +{ + struct tgsi_declaration_semantic ds; + + assert( semantic_name <= TGSI_SEMANTIC_COUNT ); + assert( semantic_index <= 0xFFFF ); + + ds.Name = semantic_name; + ds.Index = semantic_index; + ds.Padding = 0; + + declaration_grow( declaration, header ); + + return ds; } struct tgsi_full_declaration @@ -257,104 +338,11 @@ tgsi_build_full_declaration( return size; } -struct tgsi_declaration_range -tgsi_default_declaration_range( void ) -{ - struct tgsi_declaration_range dr; - - dr.First = 0; - dr.Last = 0; - - return dr; -} - -struct tgsi_declaration_range -tgsi_build_declaration_range( - unsigned first, - unsigned last, - struct tgsi_declaration *declaration, - struct tgsi_header *header ) -{ - struct tgsi_declaration_range declaration_range; - - assert( last >= first ); - assert( last <= 0xFFFF ); - - declaration_range = tgsi_default_declaration_range(); - declaration_range.First = first; - declaration_range.Last = last; - - declaration_grow( declaration, header ); - - return declaration_range; -} - -struct tgsi_declaration_dimension -tgsi_default_declaration_dimension(void) -{ - struct tgsi_declaration_dimension dd; - - dd.Index2D = 0; - dd.Padding = 0; - - return dd; -} - -struct tgsi_declaration_dimension -tgsi_build_declaration_dimension(unsigned index_2d, - struct tgsi_declaration *declaration, - struct tgsi_header *header) -{ - struct tgsi_declaration_dimension dd; - - assert(index_2d <= 0xFFFF); - - dd = tgsi_default_declaration_dimension(); - dd.Index2D = index_2d; - - declaration_grow(declaration, header); - - return dd; -} - -struct tgsi_declaration_semantic -tgsi_default_declaration_semantic( void ) -{ - struct tgsi_declaration_semantic ds; - - ds.Name = TGSI_SEMANTIC_POSITION; - ds.Index = 0; - ds.Padding = 0; - - return ds; -} - -struct tgsi_declaration_semantic -tgsi_build_declaration_semantic( - unsigned semantic_name, - unsigned semantic_index, - struct tgsi_declaration *declaration, - struct tgsi_header *header ) -{ - struct tgsi_declaration_semantic ds; - - assert( semantic_name <= TGSI_SEMANTIC_COUNT ); - assert( semantic_index <= 0xFFFF ); - - ds = tgsi_default_declaration_semantic(); - ds.Name = semantic_name; - ds.Index = semantic_index; - - declaration_grow( declaration, header ); - - return ds; -} - /* * immediate */ -struct tgsi_immediate +static struct tgsi_immediate tgsi_default_immediate( void ) { struct tgsi_immediate immediate; @@ -367,7 +355,7 @@ tgsi_default_immediate( void ) return immediate; } -struct tgsi_immediate +static struct tgsi_immediate tgsi_build_immediate( struct tgsi_header *header ) { @@ -406,7 +394,7 @@ immediate_grow( header_bodysize_grow( header ); } -union tgsi_immediate_data +static union tgsi_immediate_data tgsi_build_immediate_float32( float value, struct tgsi_immediate *immediate, @@ -480,7 +468,7 @@ tgsi_default_instruction( void ) return instruction; } -struct tgsi_instruction +static struct tgsi_instruction tgsi_build_instruction(unsigned opcode, unsigned saturate, unsigned predicate, @@ -519,52 +507,312 @@ instruction_grow( header_bodysize_grow( header ); } -struct tgsi_full_instruction -tgsi_default_full_instruction( void ) +struct tgsi_instruction_predicate +tgsi_default_instruction_predicate(void) { - struct tgsi_full_instruction full_instruction; - unsigned i; + struct tgsi_instruction_predicate instruction_predicate; - full_instruction.Instruction = tgsi_default_instruction(); - full_instruction.Predicate = tgsi_default_instruction_predicate(); - full_instruction.Label = tgsi_default_instruction_label(); - full_instruction.Texture = tgsi_default_instruction_texture(); - for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) { - full_instruction.Dst[i] = tgsi_default_full_dst_register(); - } - for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) { - full_instruction.Src[i] = tgsi_default_full_src_register(); - } + instruction_predicate.SwizzleX = TGSI_SWIZZLE_X; + instruction_predicate.SwizzleY = TGSI_SWIZZLE_Y; + instruction_predicate.SwizzleZ = TGSI_SWIZZLE_Z; + instruction_predicate.SwizzleW = TGSI_SWIZZLE_W; + instruction_predicate.Negate = 0; + instruction_predicate.Index = 0; + instruction_predicate.Padding = 0; - return full_instruction; + return instruction_predicate; } -unsigned -tgsi_build_full_instruction( - const struct tgsi_full_instruction *full_inst, - struct tgsi_token *tokens, - struct tgsi_header *header, - unsigned maxsize ) +static struct tgsi_instruction_predicate +tgsi_build_instruction_predicate(int index, + unsigned negate, + unsigned swizzleX, + unsigned swizzleY, + unsigned swizzleZ, + unsigned swizzleW, + struct tgsi_instruction *instruction, + struct tgsi_header *header) { - unsigned size = 0; - unsigned i; - struct tgsi_instruction *instruction; - struct tgsi_token *prev_token; + struct tgsi_instruction_predicate instruction_predicate; - if( maxsize <= size ) - return 0; - instruction = (struct tgsi_instruction *) &tokens[size]; - size++; + instruction_predicate = tgsi_default_instruction_predicate(); + instruction_predicate.SwizzleX = swizzleX; + instruction_predicate.SwizzleY = swizzleY; + instruction_predicate.SwizzleZ = swizzleZ; + instruction_predicate.SwizzleW = swizzleW; + instruction_predicate.Negate = negate; + instruction_predicate.Index = index; - *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode, - full_inst->Instruction.Saturate, - full_inst->Instruction.Predicate, - full_inst->Instruction.NumDstRegs, - full_inst->Instruction.NumSrcRegs, - header); - prev_token = (struct tgsi_token *) instruction; + instruction_grow(instruction, header); - if (full_inst->Instruction.Predicate) { + return instruction_predicate; +} + +static struct tgsi_instruction_label +tgsi_default_instruction_label( void ) +{ + struct tgsi_instruction_label instruction_label; + + instruction_label.Label = 0; + instruction_label.Padding = 0; + + return instruction_label; +} + +static struct tgsi_instruction_label +tgsi_build_instruction_label( + unsigned label, + struct tgsi_token *prev_token, + struct tgsi_instruction *instruction, + struct tgsi_header *header ) +{ + struct tgsi_instruction_label instruction_label; + + instruction_label.Label = label; + instruction_label.Padding = 0; + instruction->Label = 1; + + instruction_grow( instruction, header ); + + return instruction_label; +} + +static struct tgsi_instruction_texture +tgsi_default_instruction_texture( void ) +{ + struct tgsi_instruction_texture instruction_texture; + + instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN; + instruction_texture.Padding = 0; + + return instruction_texture; +} + +static struct tgsi_instruction_texture +tgsi_build_instruction_texture( + unsigned texture, + struct tgsi_token *prev_token, + struct tgsi_instruction *instruction, + struct tgsi_header *header ) +{ + struct tgsi_instruction_texture instruction_texture; + + instruction_texture.Texture = texture; + instruction_texture.Padding = 0; + instruction->Texture = 1; + + instruction_grow( instruction, header ); + + return instruction_texture; +} + +static struct tgsi_src_register +tgsi_default_src_register( void ) +{ + struct tgsi_src_register src_register; + + src_register.File = TGSI_FILE_NULL; + src_register.SwizzleX = TGSI_SWIZZLE_X; + src_register.SwizzleY = TGSI_SWIZZLE_Y; + src_register.SwizzleZ = TGSI_SWIZZLE_Z; + src_register.SwizzleW = TGSI_SWIZZLE_W; + src_register.Negate = 0; + src_register.Absolute = 0; + src_register.Indirect = 0; + src_register.Dimension = 0; + src_register.Index = 0; + + return src_register; +} + +static struct tgsi_src_register +tgsi_build_src_register( + unsigned file, + unsigned swizzle_x, + unsigned swizzle_y, + unsigned swizzle_z, + unsigned swizzle_w, + unsigned negate, + unsigned absolute, + unsigned indirect, + unsigned dimension, + int index, + struct tgsi_instruction *instruction, + struct tgsi_header *header ) +{ + struct tgsi_src_register src_register; + + assert( file < TGSI_FILE_COUNT ); + assert( swizzle_x <= TGSI_SWIZZLE_W ); + assert( swizzle_y <= TGSI_SWIZZLE_W ); + assert( swizzle_z <= TGSI_SWIZZLE_W ); + assert( swizzle_w <= TGSI_SWIZZLE_W ); + assert( negate <= 1 ); + assert( index >= -0x8000 && index <= 0x7FFF ); + + src_register.File = file; + src_register.SwizzleX = swizzle_x; + src_register.SwizzleY = swizzle_y; + src_register.SwizzleZ = swizzle_z; + src_register.SwizzleW = swizzle_w; + src_register.Negate = negate; + src_register.Absolute = absolute; + src_register.Indirect = indirect; + src_register.Dimension = dimension; + src_register.Index = index; + + instruction_grow( instruction, header ); + + return src_register; +} + +static struct tgsi_dimension +tgsi_default_dimension( void ) +{ + struct tgsi_dimension dimension; + + dimension.Indirect = 0; + dimension.Dimension = 0; + dimension.Padding = 0; + dimension.Index = 0; + + return dimension; +} + +static struct tgsi_full_src_register +tgsi_default_full_src_register( void ) +{ + struct tgsi_full_src_register full_src_register; + + full_src_register.Register = tgsi_default_src_register(); + full_src_register.Indirect = tgsi_default_src_register(); + full_src_register.Dimension = tgsi_default_dimension(); + full_src_register.DimIndirect = tgsi_default_src_register(); + + return full_src_register; +} + +static struct tgsi_dimension +tgsi_build_dimension( + unsigned indirect, + unsigned index, + struct tgsi_instruction *instruction, + struct tgsi_header *header ) +{ + struct tgsi_dimension dimension; + + dimension.Indirect = indirect; + dimension.Dimension = 0; + dimension.Padding = 0; + dimension.Index = index; + + instruction_grow( instruction, header ); + + return dimension; +} + +static struct tgsi_dst_register +tgsi_default_dst_register( void ) +{ + struct tgsi_dst_register dst_register; + + dst_register.File = TGSI_FILE_NULL; + dst_register.WriteMask = TGSI_WRITEMASK_XYZW; + dst_register.Indirect = 0; + dst_register.Dimension = 0; + dst_register.Index = 0; + dst_register.Padding = 0; + + return dst_register; +} + +static struct tgsi_dst_register +tgsi_build_dst_register( + unsigned file, + unsigned mask, + unsigned indirect, + unsigned dimension, + int index, + struct tgsi_instruction *instruction, + struct tgsi_header *header ) +{ + struct tgsi_dst_register dst_register; + + assert( file < TGSI_FILE_COUNT ); + assert( mask <= TGSI_WRITEMASK_XYZW ); + assert( index >= -32768 && index <= 32767 ); + + dst_register.File = file; + dst_register.WriteMask = mask; + dst_register.Indirect = indirect; + dst_register.Dimension = dimension; + dst_register.Index = index; + dst_register.Padding = 0; + + instruction_grow( instruction, header ); + + return dst_register; +} + +static struct tgsi_full_dst_register +tgsi_default_full_dst_register( void ) +{ + struct tgsi_full_dst_register full_dst_register; + + full_dst_register.Register = tgsi_default_dst_register(); + full_dst_register.Indirect = tgsi_default_src_register(); + full_dst_register.Dimension = tgsi_default_dimension(); + full_dst_register.DimIndirect = tgsi_default_src_register(); + + return full_dst_register; +} + +struct tgsi_full_instruction +tgsi_default_full_instruction( void ) +{ + struct tgsi_full_instruction full_instruction; + unsigned i; + + full_instruction.Instruction = tgsi_default_instruction(); + full_instruction.Predicate = tgsi_default_instruction_predicate(); + full_instruction.Label = tgsi_default_instruction_label(); + full_instruction.Texture = tgsi_default_instruction_texture(); + for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) { + full_instruction.Dst[i] = tgsi_default_full_dst_register(); + } + for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) { + full_instruction.Src[i] = tgsi_default_full_src_register(); + } + + return full_instruction; +} + +unsigned +tgsi_build_full_instruction( + const struct tgsi_full_instruction *full_inst, + struct tgsi_token *tokens, + struct tgsi_header *header, + unsigned maxsize ) +{ + unsigned size = 0; + unsigned i; + struct tgsi_instruction *instruction; + struct tgsi_token *prev_token; + + if( maxsize <= size ) + return 0; + instruction = (struct tgsi_instruction *) &tokens[size]; + size++; + + *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode, + full_inst->Instruction.Saturate, + full_inst->Instruction.Predicate, + full_inst->Instruction.NumDstRegs, + full_inst->Instruction.NumSrcRegs, + header); + prev_token = (struct tgsi_token *) instruction; + + if (full_inst->Instruction.Predicate) { struct tgsi_instruction_predicate *instruction_predicate; if (maxsize <= size) { @@ -794,268 +1042,7 @@ tgsi_build_full_instruction( return size; } -struct tgsi_instruction_predicate -tgsi_default_instruction_predicate(void) -{ - struct tgsi_instruction_predicate instruction_predicate; - - instruction_predicate.SwizzleX = TGSI_SWIZZLE_X; - instruction_predicate.SwizzleY = TGSI_SWIZZLE_Y; - instruction_predicate.SwizzleZ = TGSI_SWIZZLE_Z; - instruction_predicate.SwizzleW = TGSI_SWIZZLE_W; - instruction_predicate.Negate = 0; - instruction_predicate.Index = 0; - instruction_predicate.Padding = 0; - - return instruction_predicate; -} - -struct tgsi_instruction_predicate -tgsi_build_instruction_predicate(int index, - unsigned negate, - unsigned swizzleX, - unsigned swizzleY, - unsigned swizzleZ, - unsigned swizzleW, - struct tgsi_instruction *instruction, - struct tgsi_header *header) -{ - struct tgsi_instruction_predicate instruction_predicate; - - instruction_predicate = tgsi_default_instruction_predicate(); - instruction_predicate.SwizzleX = swizzleX; - instruction_predicate.SwizzleY = swizzleY; - instruction_predicate.SwizzleZ = swizzleZ; - instruction_predicate.SwizzleW = swizzleW; - instruction_predicate.Negate = negate; - instruction_predicate.Index = index; - - instruction_grow(instruction, header); - - return instruction_predicate; -} - -struct tgsi_instruction_label -tgsi_default_instruction_label( void ) -{ - struct tgsi_instruction_label instruction_label; - - instruction_label.Label = 0; - instruction_label.Padding = 0; - - return instruction_label; -} - -struct tgsi_instruction_label -tgsi_build_instruction_label( - unsigned label, - struct tgsi_token *prev_token, - struct tgsi_instruction *instruction, - struct tgsi_header *header ) -{ - struct tgsi_instruction_label instruction_label; - - instruction_label = tgsi_default_instruction_label(); - instruction_label.Label = label; - instruction->Label = 1; - - instruction_grow( instruction, header ); - - return instruction_label; -} - -struct tgsi_instruction_texture -tgsi_default_instruction_texture( void ) -{ - struct tgsi_instruction_texture instruction_texture; - - instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN; - instruction_texture.Padding = 0; - - return instruction_texture; -} - -struct tgsi_instruction_texture -tgsi_build_instruction_texture( - unsigned texture, - struct tgsi_token *prev_token, - struct tgsi_instruction *instruction, - struct tgsi_header *header ) -{ - struct tgsi_instruction_texture instruction_texture; - - instruction_texture = tgsi_default_instruction_texture(); - instruction_texture.Texture = texture; - instruction->Texture = 1; - - instruction_grow( instruction, header ); - - return instruction_texture; -} - -struct tgsi_src_register -tgsi_default_src_register( void ) -{ - struct tgsi_src_register src_register; - - src_register.File = TGSI_FILE_NULL; - src_register.SwizzleX = TGSI_SWIZZLE_X; - src_register.SwizzleY = TGSI_SWIZZLE_Y; - src_register.SwizzleZ = TGSI_SWIZZLE_Z; - src_register.SwizzleW = TGSI_SWIZZLE_W; - src_register.Negate = 0; - src_register.Absolute = 0; - src_register.Indirect = 0; - src_register.Dimension = 0; - src_register.Index = 0; - - return src_register; -} - -struct tgsi_src_register -tgsi_build_src_register( - unsigned file, - unsigned swizzle_x, - unsigned swizzle_y, - unsigned swizzle_z, - unsigned swizzle_w, - unsigned negate, - unsigned absolute, - unsigned indirect, - unsigned dimension, - int index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ) -{ - struct tgsi_src_register src_register; - - assert( file < TGSI_FILE_COUNT ); - assert( swizzle_x <= TGSI_SWIZZLE_W ); - assert( swizzle_y <= TGSI_SWIZZLE_W ); - assert( swizzle_z <= TGSI_SWIZZLE_W ); - assert( swizzle_w <= TGSI_SWIZZLE_W ); - assert( negate <= 1 ); - assert( index >= -0x8000 && index <= 0x7FFF ); - - src_register = tgsi_default_src_register(); - src_register.File = file; - src_register.SwizzleX = swizzle_x; - src_register.SwizzleY = swizzle_y; - src_register.SwizzleZ = swizzle_z; - src_register.SwizzleW = swizzle_w; - src_register.Negate = negate; - src_register.Absolute = absolute; - src_register.Indirect = indirect; - src_register.Dimension = dimension; - src_register.Index = index; - - instruction_grow( instruction, header ); - - return src_register; -} - -struct tgsi_full_src_register -tgsi_default_full_src_register( void ) -{ - struct tgsi_full_src_register full_src_register; - - full_src_register.Register = tgsi_default_src_register(); - full_src_register.Indirect = tgsi_default_src_register(); - full_src_register.Dimension = tgsi_default_dimension(); - full_src_register.DimIndirect = tgsi_default_src_register(); - - return full_src_register; -} - - -struct tgsi_dimension -tgsi_default_dimension( void ) -{ - struct tgsi_dimension dimension; - - dimension.Indirect = 0; - dimension.Dimension = 0; - dimension.Padding = 0; - dimension.Index = 0; - - return dimension; -} - -struct tgsi_dimension -tgsi_build_dimension( - unsigned indirect, - unsigned index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ) -{ - struct tgsi_dimension dimension; - - dimension = tgsi_default_dimension(); - dimension.Indirect = indirect; - dimension.Index = index; - - instruction_grow( instruction, header ); - - return dimension; -} - -struct tgsi_dst_register -tgsi_default_dst_register( void ) -{ - struct tgsi_dst_register dst_register; - - dst_register.File = TGSI_FILE_NULL; - dst_register.WriteMask = TGSI_WRITEMASK_XYZW; - dst_register.Indirect = 0; - dst_register.Dimension = 0; - dst_register.Index = 0; - dst_register.Padding = 0; - - return dst_register; -} - -struct tgsi_dst_register -tgsi_build_dst_register( - unsigned file, - unsigned mask, - unsigned indirect, - unsigned dimension, - int index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ) -{ - struct tgsi_dst_register dst_register; - - assert( file < TGSI_FILE_COUNT ); - assert( mask <= TGSI_WRITEMASK_XYZW ); - assert( index >= -32768 && index <= 32767 ); - - dst_register = tgsi_default_dst_register(); - dst_register.File = file; - dst_register.WriteMask = mask; - dst_register.Index = index; - dst_register.Indirect = indirect; - dst_register.Dimension = dimension; - - instruction_grow( instruction, header ); - - return dst_register; -} - -struct tgsi_full_dst_register -tgsi_default_full_dst_register( void ) -{ - struct tgsi_full_dst_register full_dst_register; - - full_dst_register.Register = tgsi_default_dst_register(); - full_dst_register.Indirect = tgsi_default_src_register(); - full_dst_register.Dimension = tgsi_default_dimension(); - full_dst_register.DimIndirect = tgsi_default_src_register(); - - return full_dst_register; -} - -struct tgsi_property +static struct tgsi_property tgsi_default_property( void ) { struct tgsi_property property; @@ -1068,7 +1055,7 @@ tgsi_default_property( void ) return property; } -struct tgsi_property +static struct tgsi_property tgsi_build_property(unsigned property_name, struct tgsi_header *header) { @@ -1107,7 +1094,7 @@ property_grow( header_bodysize_grow( header ); } -struct tgsi_property_data +static struct tgsi_property_data tgsi_build_property_data( unsigned value, struct tgsi_property *property, diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h index 112107a0881..3f236a9c241 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.h +++ b/src/gallium/auxiliary/tgsi/tgsi_build.h @@ -44,9 +44,6 @@ extern "C" { struct tgsi_header tgsi_build_header( void ); -struct tgsi_processor -tgsi_default_processor( void ); - struct tgsi_processor tgsi_build_processor( unsigned processor, @@ -56,21 +53,6 @@ tgsi_build_processor( * declaration */ -struct tgsi_declaration -tgsi_default_declaration( void ); - -struct tgsi_declaration -tgsi_build_declaration( - unsigned file, - unsigned usage_mask, - unsigned interpolate, - unsigned dimension, - unsigned semantic, - unsigned centroid, - unsigned invariant, - unsigned cylindrical_wrap, - struct tgsi_header *header ); - struct tgsi_full_declaration tgsi_default_full_declaration( void ); @@ -81,54 +63,13 @@ tgsi_build_full_declaration( struct tgsi_header *header, unsigned maxsize ); -struct tgsi_declaration_range -tgsi_default_declaration_range( void ); - -struct tgsi_declaration_range -tgsi_build_declaration_range( - unsigned first, - unsigned last, - struct tgsi_declaration *declaration, - struct tgsi_header *header ); - -struct tgsi_declaration_dimension -tgsi_default_declaration_dimension(void); - -struct tgsi_declaration_dimension -tgsi_build_declaration_dimension(unsigned index_2d, - struct tgsi_declaration *declaration, - struct tgsi_header *header); - -struct tgsi_declaration_semantic -tgsi_default_declaration_semantic( void ); - -struct tgsi_declaration_semantic -tgsi_build_declaration_semantic( - unsigned semantic_name, - unsigned semantic_index, - struct tgsi_declaration *declaration, - struct tgsi_header *header ); - /* * immediate */ -struct tgsi_immediate -tgsi_default_immediate( void ); - -struct tgsi_immediate -tgsi_build_immediate( - struct tgsi_header *header ); - struct tgsi_full_immediate tgsi_default_full_immediate( void ); -union tgsi_immediate_data -tgsi_build_immediate_float32( - float value, - struct tgsi_immediate *immediate, - struct tgsi_header *header ); - unsigned tgsi_build_full_immediate( const struct tgsi_full_immediate *full_imm, @@ -140,23 +81,9 @@ tgsi_build_full_immediate( * properties */ -struct tgsi_property -tgsi_default_property( void ); - -struct tgsi_property -tgsi_build_property( - unsigned property_name, - struct tgsi_header *header ); - struct tgsi_full_property tgsi_default_full_property( void ); -struct tgsi_property_data -tgsi_build_property_data( - unsigned value, - struct tgsi_property *property, - struct tgsi_header *header ); - unsigned tgsi_build_full_property( const struct tgsi_full_property *full_prop, @@ -171,15 +98,6 @@ tgsi_build_full_property( struct tgsi_instruction tgsi_default_instruction( void ); -struct tgsi_instruction -tgsi_build_instruction( - unsigned opcode, - unsigned saturate, - unsigned predicate, - unsigned num_dst_regs, - unsigned num_src_regs, - struct tgsi_header *header ); - struct tgsi_full_instruction tgsi_default_full_instruction( void ); @@ -193,85 +111,6 @@ tgsi_build_full_instruction( struct tgsi_instruction_predicate tgsi_default_instruction_predicate(void); -struct tgsi_instruction_predicate -tgsi_build_instruction_predicate(int index, - unsigned negate, - unsigned swizzleX, - unsigned swizzleY, - unsigned swizzleZ, - unsigned swizzleW, - struct tgsi_instruction *instruction, - struct tgsi_header *header); - -struct tgsi_instruction_label -tgsi_default_instruction_label( void ); - -struct tgsi_instruction_label -tgsi_build_instruction_label( - unsigned label, - struct tgsi_token *prev_token, - struct tgsi_instruction *instruction, - struct tgsi_header *header ); - -struct tgsi_instruction_texture -tgsi_default_instruction_texture( void ); - -struct tgsi_instruction_texture -tgsi_build_instruction_texture( - unsigned texture, - struct tgsi_token *prev_token, - struct tgsi_instruction *instruction, - struct tgsi_header *header ); - -struct tgsi_src_register -tgsi_default_src_register( void ); - -struct tgsi_src_register -tgsi_build_src_register( - unsigned file, - unsigned swizzle_x, - unsigned swizzle_y, - unsigned swizzle_z, - unsigned swizzle_w, - unsigned negate, - unsigned absolute, - unsigned indirect, - unsigned dimension, - int index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ); - -struct tgsi_full_src_register -tgsi_default_full_src_register( void ); - - -struct tgsi_dimension -tgsi_default_dimension( void ); - -struct tgsi_dimension -tgsi_build_dimension( - unsigned indirect, - unsigned index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ); - -struct tgsi_dst_register -tgsi_default_dst_register( void ); - -struct tgsi_dst_register -tgsi_build_dst_register( - unsigned file, - unsigned mask, - unsigned indirect, - unsigned dimension, - int index, - struct tgsi_instruction *instruction, - struct tgsi_header *header ); - -struct tgsi_full_dst_register -tgsi_default_full_dst_register( void ); - - #if defined __cplusplus } #endif -- cgit v1.2.3 From 5b294a5d17c818ecbb1295fdd20825da9b106792 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Nov 2010 09:28:06 -0600 Subject: gallivm: added debug code to dump temp registers --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 8e803c449fa..f36f3fcaf21 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -58,6 +58,7 @@ #include "lp_bld_tgsi.h" #include "lp_bld_limits.h" #include "lp_bld_debug.h" +#include "lp_bld_printf.h" #define FOR_EACH_CHANNEL( CHAN )\ @@ -1083,6 +1084,52 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld, lp_build_mask_check(bld->mask); } + +/** + * Emit code which will dump the value of all the temporary registers + * to stdout. + */ +static void +emit_dump_temps(struct lp_build_tgsi_soa_context *bld) +{ + LLVMBuilderRef builder = bld->base.builder; + LLVMValueRef temp_ptr; + LLVMValueRef i0 = lp_build_const_int32(0); + LLVMValueRef i1 = lp_build_const_int32(1); + LLVMValueRef i2 = lp_build_const_int32(2); + LLVMValueRef i3 = lp_build_const_int32(3); + int index; + int n = bld->info->file_max[TGSI_FILE_TEMPORARY]; + + for (index = 0; index < n; index++) { + LLVMValueRef idx = lp_build_const_int32(index); + LLVMValueRef v[4][4], res; + int chan; + + lp_build_printf(builder, "TEMP[%d]:\n", idx); + + for (chan = 0; chan < 4; chan++) { + temp_ptr = get_temp_ptr(bld, index, chan); + res = LLVMBuildLoad(bld->base.builder, temp_ptr, ""); + v[chan][0] = LLVMBuildExtractElement(builder, res, i0, ""); + v[chan][1] = LLVMBuildExtractElement(builder, res, i1, ""); + v[chan][2] = LLVMBuildExtractElement(builder, res, i2, ""); + v[chan][3] = LLVMBuildExtractElement(builder, res, i3, ""); + } + + lp_build_printf(builder, " X: %f %f %f %f\n", + v[0][0], v[0][1], v[0][2], v[0][3]); + lp_build_printf(builder, " Y: %f %f %f %f\n", + v[1][0], v[1][1], v[1][2], v[1][3]); + lp_build_printf(builder, " Z: %f %f %f %f\n", + v[2][0], v[2][1], v[2][2], v[2][3]); + lp_build_printf(builder, " W: %f %f %f %f\n", + v[3][0], v[3][1], v[3][2], v[3][3]); + } +} + + + static void emit_declaration( struct lp_build_tgsi_soa_context *bld, @@ -1783,6 +1830,10 @@ emit_instruction( break; case TGSI_OPCODE_END: + if (0) { + /* for debugging */ + emit_dump_temps(bld); + } *pc = -1; break; -- cgit v1.2.3 From ede232e9898698258391a280a098a7ba951b0099 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Nov 2010 09:31:56 -0600 Subject: gallivm: add pixel offsets in scatter stores We want to do the scatter store to sequential locations in memory for the vector of pixels we're processing in SOA format. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index f36f3fcaf21..e15baa3727c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -489,6 +489,10 @@ build_scatter(struct lp_build_tgsi_soa_context *bld, LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr, &index, 1, "scatter_ptr"); LLVMValueRef val = LLVMBuildExtractElement(builder, values, ii, "scatter_val"); + if (0) + lp_build_printf(builder, "scatter %d: val %f at %d %p\n", + ii, val, index, scalar_ptr); + LLVMBuildStore(builder, val, scalar_ptr); } } @@ -813,21 +817,33 @@ emit_store( case TGSI_FILE_TEMPORARY: if (reg->Register.Indirect) { + LLVMBuilderRef builder = bld->base.builder; LLVMValueRef chan_vec = lp_build_const_int_vec(uint_bld->type, chan_index); LLVMValueRef length_vec = lp_build_const_int_vec(uint_bld->type, bld->base.type.length); LLVMValueRef index_vec; /* indexes into the temp registers */ LLVMValueRef temps_array; + LLVMValueRef pixel_offsets; LLVMTypeRef float_ptr_type; + int i; + + /* build pixel offset vector: {0, 1, 2, 3, ...} */ + pixel_offsets = uint_bld->undef; + for (i = 0; i < bld->base.type.length; i++) { + LLVMValueRef ii = lp_build_const_int32(i); + pixel_offsets = LLVMBuildInsertElement(builder, pixel_offsets, + ii, ii, ""); + } - /* index_vec = (indirect_index * 4 + chan_index) * length */ + /* index_vec = (indirect_index * 4 + chan_index) * length + offsets */ index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2); index_vec = lp_build_add(uint_bld, index_vec, chan_vec); index_vec = lp_build_mul(uint_bld, index_vec, length_vec); + index_vec = lp_build_add(uint_bld, index_vec, pixel_offsets); float_ptr_type = LLVMPointerType(LLVMFloatType(), 0); - temps_array = LLVMBuildBitCast(bld->base.builder, bld->temps_array, + temps_array = LLVMBuildBitCast(builder, bld->temps_array, float_ptr_type, ""); /* Scatter store values into temp registers */ -- cgit v1.2.3 From fb94747b6639ba976aaaaba5a37aa2fe56999310 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Nov 2010 10:00:58 -0600 Subject: gallivm: added lp_elem_type() --- src/gallium/auxiliary/gallivm/lp_bld_type.c | 16 ++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_type.h | 4 ++++ 2 files changed, 20 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index 06f1aae6dcc..5205c7ada91 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -187,6 +187,22 @@ lp_build_int32_vec4_type(void) } +/** + * Create element of vector type + */ +struct lp_type +lp_elem_type(struct lp_type type) +{ + struct lp_type res_type; + + assert(type.length > 1); + res_type = type; + res_type.length = 1; + + return res_type; +} + + /** * Create unsigned integer type variation of given type. */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index fec1d3dfbc6..a135d0df847 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -364,6 +364,10 @@ lp_unorm8_vec4_type(void) } +struct lp_type +lp_elem_type(struct lp_type type); + + struct lp_type lp_uint_type(struct lp_type type); -- cgit v1.2.3 From e7f5d19a1106351f2db8f62f59f51be86eaa93df Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Nov 2010 10:01:28 -0600 Subject: gallivm: implement execution mask for scatter stores --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 41 ++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index e15baa3727c..a74cefd41e1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -120,9 +120,12 @@ struct lp_build_tgsi_soa_context { struct lp_build_context base; - /* Builder for integer masks and indices */ + /* Builder for vector integer masks and indices */ struct lp_build_context uint_bld; + /* Builder for scalar elements of shader's data type (float) */ + struct lp_build_context elem_bld; + LLVMValueRef consts_ptr; const LLVMValueRef *pos; const LLVMValueRef (*inputs)[NUM_CHANNELS]; @@ -472,14 +475,26 @@ build_gather(struct lp_build_tgsi_soa_context *bld, * Scatter/store vector. */ static void -build_scatter(struct lp_build_tgsi_soa_context *bld, - LLVMValueRef base_ptr, - LLVMValueRef indexes, - LLVMValueRef values) +emit_mask_scatter(struct lp_build_tgsi_soa_context *bld, + LLVMValueRef base_ptr, + LLVMValueRef indexes, + LLVMValueRef values, + struct lp_exec_mask *mask, + LLVMValueRef pred) { LLVMBuilderRef builder = bld->base.builder; unsigned i; + /* Mix the predicate and execution mask */ + if (mask->has_mask) { + if (pred) { + pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, ""); + } + else { + pred = mask->exec_mask; + } + } + /* * Loop over elements of index_vec, store scalar value. */ @@ -488,12 +503,22 @@ build_scatter(struct lp_build_tgsi_soa_context *bld, LLVMValueRef index = LLVMBuildExtractElement(builder, indexes, ii, ""); LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr, &index, 1, "scatter_ptr"); LLVMValueRef val = LLVMBuildExtractElement(builder, values, ii, "scatter_val"); + LLVMValueRef scalar_pred = pred ? + LLVMBuildExtractElement(builder, pred, ii, "scatter_pred") : NULL; if (0) lp_build_printf(builder, "scatter %d: val %f at %d %p\n", ii, val, index, scalar_ptr); - LLVMBuildStore(builder, val, scalar_ptr); + if (scalar_pred) { + LLVMValueRef real_val, dst_val; + dst_val = LLVMBuildLoad(builder, scalar_ptr, ""); + real_val = lp_build_select(&bld->elem_bld, scalar_pred, val, dst_val); + LLVMBuildStore(builder, real_val, scalar_ptr); + } + else { + LLVMBuildStore(builder, val, scalar_ptr); + } } } @@ -847,7 +872,8 @@ emit_store( float_ptr_type, ""); /* Scatter store values into temp registers */ - build_scatter(bld, temps_array, index_vec, value); + emit_mask_scatter(bld, temps_array, index_vec, value, + &bld->exec_mask, pred); } else { LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index, @@ -2192,6 +2218,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, memset(&bld, 0, sizeof bld); lp_build_context_init(&bld.base, builder, type); lp_build_context_init(&bld.uint_bld, builder, lp_uint_type(type)); + lp_build_context_init(&bld.elem_bld, builder, lp_elem_type(type)); bld.mask = mask; bld.pos = pos; bld.inputs = inputs; -- cgit v1.2.3 From ef6b7e0a30814badd201ca1b3e1f5afb4ba21fef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Nov 2010 13:35:20 -0600 Subject: tgsi: remove unused function --- src/gallium/auxiliary/tgsi/tgsi_build.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c index 1f7d7f190aa..16a205f2068 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.c +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c @@ -176,17 +176,6 @@ tgsi_build_declaration_range( return declaration_range; } -static struct tgsi_declaration_dimension -tgsi_default_declaration_dimension(void) -{ - struct tgsi_declaration_dimension dd; - - dd.Index2D = 0; - dd.Padding = 0; - - return dd; -} - static struct tgsi_declaration_dimension tgsi_build_declaration_dimension(unsigned index_2d, struct tgsi_declaration *declaration, -- cgit v1.2.3 From e8d6b2793ff3907d3646eeaceaa00e2a04728e67 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Nov 2010 08:49:53 -0600 Subject: gallivm: alloca() was called too often for temporary arrays Need to increment the array index to point to the last value. Before, we were calling lp_build_array_alloca() over and over for no reason. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index a74cefd41e1..897b09ff22b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1189,10 +1189,12 @@ emit_declaration( case TGSI_FILE_TEMPORARY: assert(idx < LP_MAX_TGSI_TEMPS); if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) { + /* ignore 'first' - we want to index into a 0-based array */ LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), last*4 + 4, 0); bld->temps_array = lp_build_array_alloca(bld->base.builder, vec_type, array_size, "temparray"); + idx = last; } else { for (i = 0; i < NUM_CHANNELS; i++) bld->temps[idx][i] = lp_build_alloca(bld->base.builder, -- cgit v1.2.3 From 55c5408ad049423597cd274e7abcd2d91a16ead3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Nov 2010 08:51:53 -0600 Subject: gallivm: add const qualifiers, fix comment string --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 897b09ff22b..9f21e6d5e6c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1178,9 +1178,8 @@ emit_declaration( const struct tgsi_full_declaration *decl) { LLVMTypeRef vec_type = bld->base.vec_type; - - unsigned first = decl->Range.First; - unsigned last = decl->Range.Last; + const unsigned first = decl->Range.First; + const unsigned last = decl->Range.Last; unsigned idx, i; for (idx = first; idx <= last; ++idx) { @@ -1193,7 +1192,8 @@ emit_declaration( LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), last*4 + 4, 0); bld->temps_array = lp_build_array_alloca(bld->base.builder, - vec_type, array_size, "temparray"); + vec_type, array_size, + "temporary"); idx = last; } else { for (i = 0; i < NUM_CHANNELS; i++) -- cgit v1.2.3 From 834cde584466622bd76616c0e6222e1e87e12e20 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 5 Nov 2010 17:46:53 +0000 Subject: scons: Remove old pipebuffer SConscript --- src/gallium/auxiliary/pipebuffer/SConscript | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/gallium/auxiliary/pipebuffer/SConscript (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/pipebuffer/SConscript b/src/gallium/auxiliary/pipebuffer/SConscript deleted file mode 100644 index a074a554717..00000000000 --- a/src/gallium/auxiliary/pipebuffer/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -Import('*') - -pipebuffer = env.ConvenienceLibrary( - target = 'pipebuffer', - source = [ - 'pb_buffer_fenced.c', - 'pb_buffer_malloc.c', - 'pb_bufmgr_alt.c', - 'pb_bufmgr_cache.c', - 'pb_bufmgr_debug.c', - 'pb_bufmgr_mm.c', - 'pb_bufmgr_ondemand.c', - 'pb_bufmgr_pool.c', - 'pb_bufmgr_slab.c', - 'pb_validate.c', - ]) - -auxiliaries.insert(0, pipebuffer) -- cgit v1.2.3 From 9e7132b52debd3d592391ce89d3582027cb0e161 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 8 Nov 2010 17:23:32 +0100 Subject: os: Open file streams in binary mode. Otherwise we'll get garbled data on Windows. --- src/gallium/auxiliary/os/os_stream_stdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/os/os_stream_stdc.c b/src/gallium/auxiliary/os/os_stream_stdc.c index 37e7d063e2b..afd3ff6dcea 100644 --- a/src/gallium/auxiliary/os/os_stream_stdc.c +++ b/src/gallium/auxiliary/os/os_stream_stdc.c @@ -106,7 +106,7 @@ os_file_stream_create(const char *filename) stream->base.flush = &os_stdc_stream_flush; stream->base.vprintf = &os_stdc_stream_vprintf; - stream->file = fopen(filename, "w"); + stream->file = fopen(filename, "wb"); if(!stream->file) goto no_file; -- cgit v1.2.3 From 528c3cd24169c6b6c0da60cb2b8f765eb7f05cdc Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 8 Nov 2010 17:37:57 -0500 Subject: gallivm: implement indirect addressing of the output registers --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 110 ++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 5 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 9f21e6d5e6c..eb434ba7b85 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -144,6 +144,12 @@ struct lp_build_tgsi_soa_context */ LLVMValueRef temps_array; + /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is + * set in the indirect_files field. + * The outputs[] array above is unused then. + */ + LLVMValueRef outputs_array; + const struct tgsi_shader_info *info; /** bitmask indicating which register files are accessed indirectly */ unsigned indirect_files; @@ -439,6 +445,28 @@ get_temp_ptr(struct lp_build_tgsi_soa_context *bld, } } +/** + * Return pointer to a output register channel (src or dest). + * Note that indirect addressing cannot be handled here. + * \param index which output register + * \param chan which channel of the output register. + */ +static LLVMValueRef +get_output_ptr(struct lp_build_tgsi_soa_context *bld, + unsigned index, + unsigned chan) +{ + assert(chan < 4); + if (bld->indirect_files & (1 << TGSI_FILE_OUTPUT)) { + LLVMValueRef lindex = lp_build_const_int32(index * 4 + chan); + return LLVMBuildGEP(bld->base.builder, bld->outputs_array, &lindex, 1, ""); + } + else { + return bld->outputs[index][chan]; + } +} + + /** * Gather vector. @@ -836,8 +864,45 @@ emit_store( switch( reg->Register.File ) { case TGSI_FILE_OUTPUT: - lp_exec_mask_store(&bld->exec_mask, pred, value, - bld->outputs[reg->Register.Index][chan_index]); + if (reg->Register.Indirect) { + LLVMBuilderRef builder = bld->base.builder; + LLVMValueRef chan_vec = + lp_build_const_int_vec(uint_bld->type, chan_index); + LLVMValueRef length_vec = + lp_build_const_int_vec(uint_bld->type, bld->base.type.length); + LLVMValueRef index_vec; /* indexes into the temp registers */ + LLVMValueRef outputs_array; + LLVMValueRef pixel_offsets; + LLVMTypeRef float_ptr_type; + int i; + + /* build pixel offset vector: {0, 1, 2, 3, ...} */ + pixel_offsets = uint_bld->undef; + for (i = 0; i < bld->base.type.length; i++) { + LLVMValueRef ii = lp_build_const_int32(i); + pixel_offsets = LLVMBuildInsertElement(builder, pixel_offsets, + ii, ii, ""); + } + + /* index_vec = (indirect_index * 4 + chan_index) * length + offsets */ + index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2); + index_vec = lp_build_add(uint_bld, index_vec, chan_vec); + index_vec = lp_build_mul(uint_bld, index_vec, length_vec); + index_vec = lp_build_add(uint_bld, index_vec, pixel_offsets); + + float_ptr_type = LLVMPointerType(LLVMFloatType(), 0); + outputs_array = LLVMBuildBitCast(builder, bld->outputs_array, + float_ptr_type, ""); + + /* Scatter store values into temp registers */ + emit_mask_scatter(bld, outputs_array, index_vec, value, + &bld->exec_mask, pred); + } + else { + LLVMValueRef out_ptr = get_output_ptr(bld, reg->Register.Index, + chan_index); + lp_exec_mask_store(&bld->exec_mask, pred, value, out_ptr); + } break; case TGSI_FILE_TEMPORARY: @@ -1203,9 +1268,19 @@ emit_declaration( break; case TGSI_FILE_OUTPUT: - for (i = 0; i < NUM_CHANNELS; i++) - bld->outputs[idx][i] = lp_build_alloca(bld->base.builder, - vec_type, "output"); + if (bld->indirect_files & (1 << TGSI_FILE_OUTPUT)) { + /* ignore 'first' - we want to index into a 0-based array */ + LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), + last*4 + 4, 0); + bld->outputs_array = lp_build_array_alloca(bld->base.builder, + vec_type, array_size, + "outputs_array"); + idx = last; + } else { + for (i = 0; i < NUM_CHANNELS; i++) + bld->outputs[idx][i] = lp_build_alloca(bld->base.builder, + vec_type, "output"); + } break; case TGSI_FILE_ADDRESS: @@ -2308,6 +2383,31 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, opcode_info->mnemonic); } + /* If we have indirect addressing in outputs we need to copy our alloca array + * to the outputs slots specified by the called */ + if (bld.indirect_files & (1 << TGSI_FILE_OUTPUT)) { + tgsi_parse_init(&parse, tokens); + while( !tgsi_parse_end_of_tokens( &parse ) ) { + tgsi_parse_token( &parse ); + + switch( parse.FullToken.Token.Type ) { + case TGSI_TOKEN_TYPE_DECLARATION: { + const struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration; + /* Inputs already interpolated */ + if (decl->Declaration.File == TGSI_FILE_OUTPUT) { + unsigned idx = decl->Range.Last; + const unsigned first = decl->Range.First; + const unsigned last = decl->Range.Last; + for (idx = first; idx <= last; ++idx) + for (i = 0; i < NUM_CHANNELS; i++) + bld.outputs[idx][i] = get_output_ptr(&bld, idx, i); + } + break; + } + } + } + } + if (0) { LLVMBasicBlockRef block = LLVMGetInsertBlock(builder); LLVMValueRef function = LLVMGetBasicBlockParent(block); -- cgit v1.2.3 From 10740acf46e08960dde790005d65a98440f313bc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 9 Nov 2010 19:47:24 +0000 Subject: gallivm: Allocate TEMP/OUT arrays only once. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 59 ++++++++++--------------- 1 file changed, 23 insertions(+), 36 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index eb434ba7b85..5321a25452e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1252,15 +1252,7 @@ emit_declaration( switch (decl->Declaration.File) { case TGSI_FILE_TEMPORARY: assert(idx < LP_MAX_TGSI_TEMPS); - if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) { - /* ignore 'first' - we want to index into a 0-based array */ - LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), - last*4 + 4, 0); - bld->temps_array = lp_build_array_alloca(bld->base.builder, - vec_type, array_size, - "temporary"); - idx = last; - } else { + if (!(bld->indirect_files & (1 << TGSI_FILE_TEMPORARY))) { for (i = 0; i < NUM_CHANNELS; i++) bld->temps[idx][i] = lp_build_alloca(bld->base.builder, vec_type, "temp"); @@ -1268,15 +1260,7 @@ emit_declaration( break; case TGSI_FILE_OUTPUT: - if (bld->indirect_files & (1 << TGSI_FILE_OUTPUT)) { - /* ignore 'first' - we want to index into a 0-based array */ - LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), - last*4 + 4, 0); - bld->outputs_array = lp_build_array_alloca(bld->base.builder, - vec_type, array_size, - "outputs_array"); - idx = last; - } else { + if (!(bld->indirect_files & (1 << TGSI_FILE_OUTPUT))) { for (i = 0; i < NUM_CHANNELS; i++) bld->outputs[idx][i] = lp_build_alloca(bld->base.builder, vec_type, "output"); @@ -2314,6 +2298,22 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, lp_exec_mask_init(&bld.exec_mask, &bld.base); + if (bld.indirect_files & (1 << TGSI_FILE_TEMPORARY)) { + LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), + info->file_max[TGSI_FILE_TEMPORARY]*4 + 4, 0); + bld.temps_array = lp_build_array_alloca(bld.base.builder, + bld.base.vec_type, array_size, + "temp_array"); + } + + if (bld.indirect_files & (1 << TGSI_FILE_OUTPUT)) { + LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), + info->file_max[TGSI_FILE_OUTPUT]*4 + 4, 0); + bld.outputs_array = lp_build_array_alloca(bld.base.builder, + bld.base.vec_type, array_size, + "output_array"); + } + tgsi_parse_init( &parse, tokens ); while( !tgsi_parse_end_of_tokens( &parse ) ) { @@ -2386,24 +2386,11 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, /* If we have indirect addressing in outputs we need to copy our alloca array * to the outputs slots specified by the called */ if (bld.indirect_files & (1 << TGSI_FILE_OUTPUT)) { - tgsi_parse_init(&parse, tokens); - while( !tgsi_parse_end_of_tokens( &parse ) ) { - tgsi_parse_token( &parse ); - - switch( parse.FullToken.Token.Type ) { - case TGSI_TOKEN_TYPE_DECLARATION: { - const struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration; - /* Inputs already interpolated */ - if (decl->Declaration.File == TGSI_FILE_OUTPUT) { - unsigned idx = decl->Range.Last; - const unsigned first = decl->Range.First; - const unsigned last = decl->Range.Last; - for (idx = first; idx <= last; ++idx) - for (i = 0; i < NUM_CHANNELS; i++) - bld.outputs[idx][i] = get_output_ptr(&bld, idx, i); - } - break; - } + unsigned index, chan; + assert(info->num_outputs <= info->file_max[TGSI_FILE_OUTPUT] + 1); + for (index = 0; index < info->num_outputs; ++index) { + for (chan = 0; chan < NUM_CHANNELS; ++chan) { + bld.outputs[index][chan] = get_output_ptr(&bld, index, chan); } } } -- cgit v1.2.3 From f623d0c1c217d990f207306eb968172af79fa969 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 9 Nov 2010 16:48:33 -0500 Subject: gallivm: implement indirect addressing over inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of messing with the callers simply copy our inputs into a alloca array at the beginning of the function and then use it. Reviewed-by: José Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 67 +++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 5321a25452e..7f0f058c222 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -150,6 +150,12 @@ struct lp_build_tgsi_soa_context */ LLVMValueRef outputs_array; + /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is + * set in the indirect_files field. + * The inputs[] array above is unused then. + */ + LLVMValueRef inputs_array; + const struct tgsi_shader_info *info; /** bitmask indicating which register files are accessed indirectly */ unsigned indirect_files; @@ -466,8 +472,6 @@ get_output_ptr(struct lp_build_tgsi_soa_context *bld, } } - - /** * Gather vector. * XXX the lp_build_gather() function should be capable of doing this @@ -661,7 +665,38 @@ emit_fetch( break; case TGSI_FILE_INPUT: - res = bld->inputs[reg->Register.Index][swizzle]; + if (reg->Register.Indirect) { + LLVMValueRef swizzle_vec = + lp_build_const_int_vec(uint_bld->type, swizzle); + LLVMValueRef length_vec = + lp_build_const_int_vec(uint_bld->type, bld->base.type.length); + LLVMValueRef index_vec; /* index into the const buffer */ + LLVMValueRef inputs_array; + LLVMTypeRef float4_ptr_type; + + /* index_vec = (indirect_index * 4 + swizzle) * length */ + index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2); + index_vec = lp_build_add(uint_bld, index_vec, swizzle_vec); + index_vec = lp_build_mul(uint_bld, index_vec, length_vec); + + /* cast inputs_array pointer to float* */ + float4_ptr_type = LLVMPointerType(LLVMFloatType(), 0); + inputs_array = LLVMBuildBitCast(uint_bld->builder, bld->inputs_array, + float4_ptr_type, ""); + + /* Gather values from the temporary register array */ + res = build_gather(bld, inputs_array, index_vec); + } else { + if (bld->indirect_files & (1 << TGSI_FILE_INPUT)) { + LLVMValueRef lindex = lp_build_const_int32(reg->Register.Index * 4 + swizzle); + LLVMValueRef input_ptr = LLVMBuildGEP(bld->base.builder, + bld->inputs_array, &lindex, 1, ""); + res = LLVMBuildLoad(bld->base.builder, input_ptr, ""); + } + else { + res = bld->inputs[reg->Register.Index][swizzle]; + } + } assert(res); break; @@ -2314,6 +2349,32 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, "output_array"); } + /* If we have indirect addressing in inputs we need to copy them into + * our alloca array to be able to iterate over them */ + if (bld.indirect_files & (1 << TGSI_FILE_INPUT)) { + unsigned index, chan; + LLVMTypeRef vec_type = bld.base.vec_type; + LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), + info->file_max[TGSI_FILE_INPUT]*4 + 4, 0); + bld.inputs_array = lp_build_array_alloca(bld.base.builder, + vec_type, array_size, + "input_array"); + + assert(info->num_inputs <= info->file_max[TGSI_FILE_INPUT] + 1); + + for (index = 0; index < info->num_inputs; ++index) { + for (chan = 0; chan < NUM_CHANNELS; ++chan) { + LLVMValueRef lindex = lp_build_const_int32(index * 4 + chan); + LLVMValueRef input_ptr = + LLVMBuildGEP(bld.base.builder, bld.inputs_array, + &lindex, 1, ""); + LLVMValueRef value = bld.inputs[index][chan]; + if (value) + LLVMBuildStore(bld.base.builder, value, input_ptr); + } + } + } + tgsi_parse_init( &parse, tokens ); while( !tgsi_parse_end_of_tokens( &parse ) ) { -- cgit v1.2.3