diff options
author | marha <marha@users.sourceforge.net> | 2011-03-13 20:15:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-13 20:15:26 +0000 |
commit | b5d1fd89898edb34f73679b542c754d837d44cf8 (patch) | |
tree | b3d14f22d0c5fd984f5ec1ed71ad5263a46e1583 /mesalib | |
parent | 77ec02adbc8f9657e7749b307d3cc86ccbd163ea (diff) | |
download | vcxsrv-b5d1fd89898edb34f73679b542c754d837d44cf8.tar.gz vcxsrv-b5d1fd89898edb34f73679b542c754d837d44cf8.tar.bz2 vcxsrv-b5d1fd89898edb34f73679b542c754d837d44cf8.zip |
xkeyboard-config libxcb pixman mesalib git update 13 Mar 2011
Diffstat (limited to 'mesalib')
-rw-r--r-- | mesalib/configs/linux-llvm | 88 | ||||
-rw-r--r-- | mesalib/configure.ac | 3820 | ||||
-rw-r--r-- | mesalib/scons/gallium.py | 1249 | ||||
-rw-r--r-- | mesalib/scons/llvm.py | 332 | ||||
-rw-r--r-- | mesalib/scons/udis86.py | 44 | ||||
-rw-r--r-- | mesalib/src/glsl/glsl_types.h | 956 | ||||
-rw-r--r-- | mesalib/src/mesa/main/ff_fragment_shader.cpp | 1435 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/state.c | 19 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texenvprogram.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/program/program.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_clear.c | 1180 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 2 |
13 files changed, 4605 insertions, 4525 deletions
diff --git a/mesalib/configs/linux-llvm b/mesalib/configs/linux-llvm index e6999539a..cd4730d67 100644 --- a/mesalib/configs/linux-llvm +++ b/mesalib/configs/linux-llvm @@ -1,44 +1,44 @@ -# -*-makefile-*- -# Configuration for Linux and LLVM with optimizations -# Builds the llvmpipe gallium driver - -include $(TOP)/configs/linux - -CONFIG_NAME = linux-llvm - -# Add llvmpipe driver -GALLIUM_DRIVERS_DIRS += llvmpipe - -OPT_FLAGS = -O3 -ansi -pedantic -ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign - -DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86 - -# override -std=c99 -CFLAGS += -std=gnu99 - -LLVM_VERSION := $(shell llvm-config --version) - -ifeq ($(LLVM_VERSION),) - $(warning Could not find LLVM! Make Sure 'llvm-config' is in the path) - MESA_LLVM=0 -else - MESA_LLVM=1 - HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=)) - DEFINES += -DHAVE_LLVM=$(HAVE_LLVM) -# $(info Using LLVM version: $(LLVM_VERSION)) -endif - -ifeq ($(MESA_LLVM),1) - LLVM_CFLAGS=`llvm-config --cppflags` - LLVM_CXXFLAGS=`llvm-config --cxxflags backend bitreader engine ipo interpreter instrumentation` -Wno-long-long - LLVM_LDFLAGS = $(shell llvm-config --ldflags backend bitreader engine ipo interpreter instrumentation) - LLVM_LIBS = $(shell llvm-config --libs backend bitwriter bitreader engine ipo interpreter instrumentation) - MKLIB_OPTIONS=-cplusplus -else - LLVM_CFLAGS= - LLVM_CXXFLAGS= -endif - -LD = g++ -GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -lstdc++ -ludis86 +# -*-makefile-*-
+# Configuration for Linux and LLVM with optimizations
+# Builds the llvmpipe gallium driver
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-llvm
+
+# Add llvmpipe driver
+GALLIUM_DRIVERS_DIRS += llvmpipe
+
+OPT_FLAGS = -O3 -ansi -pedantic
+ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
+
+DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE
+
+# override -std=c99
+CFLAGS += -std=gnu99
+
+LLVM_VERSION := $(shell llvm-config --version)
+
+ifeq ($(LLVM_VERSION),)
+ $(warning Could not find LLVM! Make Sure 'llvm-config' is in the path)
+ MESA_LLVM=0
+else
+ MESA_LLVM=1
+ HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=))
+ DEFINES += -DHAVE_LLVM=$(HAVE_LLVM)
+# $(info Using LLVM version: $(LLVM_VERSION))
+endif
+
+ifeq ($(MESA_LLVM),1)
+ LLVM_CFLAGS=`llvm-config --cppflags`
+ LLVM_CXXFLAGS=`llvm-config --cxxflags backend bitreader engine ipo interpreter instrumentation` -Wno-long-long
+ LLVM_LDFLAGS = $(shell llvm-config --ldflags backend bitreader engine ipo interpreter instrumentation)
+ LLVM_LIBS = $(shell llvm-config --libs backend bitwriter bitreader engine ipo interpreter instrumentation)
+ MKLIB_OPTIONS=-cplusplus
+else
+ LLVM_CFLAGS=
+ LLVM_CXXFLAGS=
+endif
+
+LD = g++
+GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -lstdc++
diff --git a/mesalib/configure.ac b/mesalib/configure.ac index d33ca301f..7b8010a76 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -1,1913 +1,1907 @@ -dnl Process this file with autoconf to create configure. - -AC_PREREQ([2.59]) - -dnl Versioning - scrape the version from configs/default -m4_define([mesa_version], - [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n' | tr -d '\r'])]) -m4_ifval(mesa_version,, - [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])]) - -dnl Tell the user about autoconf.html in the --help output -m4_divert_once([HELP_END], [ -See docs/autoconf.html for more details on the options for Mesa.]) - -AC_INIT([Mesa],[mesa_version], - [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa]) -AC_CONFIG_AUX_DIR([bin]) -AC_CANONICAL_HOST - -dnl Versions for external dependencies -LIBDRM_REQUIRED=2.4.24 -LIBDRM_RADEON_REQUIRED=2.4.24 -LIBDRM_INTEL_REQUIRED=2.4.24 -DRI2PROTO_REQUIRED=2.1 -GLPROTO_REQUIRED=1.4.11 -LIBDRM_XORG_REQUIRED=2.4.24 -LIBKMS_XORG_REQUIRED=1.0.0 - -dnl Check for progs -AC_PROG_CPP -AC_PROG_CC -AC_PROG_CXX -AC_CHECK_PROGS([MAKE], [gmake make]) -AC_CHECK_PROGS([PYTHON2], [python2 python]) -AC_PATH_PROG([MKDEP], [makedepend]) -AC_PATH_PROG([SED], [sed]) - -if test "x$MKDEP" = "x"; then - AC_MSG_ERROR([makedepend is required to build Mesa]) -fi - -dnl Our fallback install-sh is a symlink to minstall. Use the existing -dnl configuration in that case. -AC_PROG_INSTALL -test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)' - -dnl We need a POSIX shell for parts of the build. Assume we have one -dnl in most cases. -case "$host_os" in -solaris*) - # Solaris /bin/sh is too old/non-POSIX compliant - AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh]) - SHELL="$POSIX_SHELL" - ;; -esac - -dnl clang is mostly GCC-compatible, but its version is much lower, -dnl so we have to check for it. -AC_MSG_CHECKING([if compiling with clang]) - -AC_COMPILE_IFELSE( -[AC_LANG_PROGRAM([], [[ -#ifndef __clang__ - not clang -#endif -]])], -[CLANG=yes], [CLANG=no]) - -AC_MSG_RESULT([$CLANG]) - -dnl If we're using GCC, make sure that it is at least version 3.3.0. Older -dnl versions are explictly not supported. -if test "x$GCC" = xyes -a "x$CLANG" = xno; then - AC_MSG_CHECKING([whether gcc version is sufficient]) - major=0 - minor=0 - - GCC_VERSION=`$CC -dumpversion` - if test $? -eq 0; then - major=`echo $GCC_VERSION | cut -d. -f1` - minor=`echo $GCC_VERSION | cut -d. -f1` - fi - - if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then - AC_MSG_RESULT([no]) - AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.]) - else - AC_MSG_RESULT([yes]) - fi -fi - - -MKDEP_OPTIONS=-fdepend -dnl Ask gcc where it's keeping its secret headers -if test "x$GCC" = xyes; then - for dir in include include-fixed; do - GCC_INCLUDES=`$CC -print-file-name=$dir` - if test "x$GCC_INCLUDES" != x && \ - test "$GCC_INCLUDES" != "$dir" && \ - test -d "$GCC_INCLUDES"; then - MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES" - fi - done -fi -AC_SUBST([MKDEP_OPTIONS]) - -dnl Make sure the pkg-config macros are defined -m4_ifndef([PKG_PROG_PKG_CONFIG], - [m4_fatal([Could not locate the pkg-config autoconf macros. - These are usually located in /usr/share/aclocal/pkg.m4. If your macros - are in a different location, try setting the environment variable - ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])]) -PKG_PROG_PKG_CONFIG() - -dnl LIB_DIR - library basename -LIB_DIR=`echo $libdir | $SED 's%.*/%%'` -AC_SUBST([LIB_DIR]) - -dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later -_SAVE_LDFLAGS="$LDFLAGS" -AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker]) -AC_SUBST([EXTRA_LIB_PATH]) - -dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later -_SAVE_CPPFLAGS="$CPPFLAGS" -AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers]) -AC_SUBST([X11_INCLUDES]) - -dnl Compiler macros -DEFINES="" -AC_SUBST([DEFINES]) -case "$host_os" in -linux*|*-gnu*|gnu*) - DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS" - ;; -solaris*) - DEFINES="$DEFINES -DPTHREADS -DSVR4" - ;; -cygwin*) - DEFINES="$DEFINES -DPTHREADS" - ;; -esac - -dnl Add flags for gcc and g++ -if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99" - if test "x$CLANG" = "xno"; then - CFLAGS="$CFLAGS -ffast-math" - fi - - # Enable -fvisibility=hidden if using a gcc that supports it - save_CFLAGS="$CFLAGS" - AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden]) - VISIBILITY_CFLAGS="-fvisibility=hidden" - CFLAGS="$CFLAGS $VISIBILITY_CFLAGS" - AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), - [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]); - - # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed. - CFLAGS=$save_CFLAGS - - # Work around aliasing bugs - developers should comment this out - CFLAGS="$CFLAGS -fno-strict-aliasing" -fi -if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -Wall" - - # Enable -fvisibility=hidden if using a gcc that supports it - save_CXXFLAGS="$CXXFLAGS" - AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden]) - VISIBILITY_CXXFLAGS="-fvisibility=hidden" - CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS" - AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), - [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]); - - # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed. - CXXFLAGS=$save_CXXFLAGS - - # Work around aliasing bugs - developers should comment this out - CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" -fi - -AC_SUBST([VISIBILITY_CFLAGS]) -AC_SUBST([VISIBILITY_CXXFLAGS]) - -dnl These should be unnecessary, but let the user set them if they want -AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler. - Default is to use CFLAGS.]) -AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the - compiler. Default is to use CFLAGS.]) -AC_SUBST([OPT_FLAGS]) -AC_SUBST([ARCH_FLAGS]) - -dnl -dnl Hacks to enable 32 or 64 bit build -dnl -AC_ARG_ENABLE([32-bit], - [AS_HELP_STRING([--enable-32-bit], - [build 32-bit libraries @<:@default=auto@:>@])], - [enable_32bit="$enableval"], - [enable_32bit=auto] -) -if test "x$enable_32bit" = xyes; then - if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -m32" - ARCH_FLAGS="$ARCH_FLAGS -m32" - fi - if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -m32" - fi -fi -AC_ARG_ENABLE([64-bit], - [AS_HELP_STRING([--enable-64-bit], - [build 64-bit libraries @<:@default=auto@:>@])], - [enable_64bit="$enableval"], - [enable_64bit=auto] -) -if test "x$enable_64bit" = xyes; then - if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -m64" - fi - if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -m64" - fi -fi - -dnl -dnl shared/static libraries, mimic libtool options -dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static], - [build static libraries @<:@default=disabled@:>@])], - [enable_static="$enableval"], - [enable_static=no] -) -case "x$enable_static" in -xyes|xno ) ;; -x ) enable_static=no ;; -* ) - AC_MSG_ERROR([Static library option '$enable_static' is not a valid]) - ;; -esac -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--disable-shared], - [build shared libraries @<:@default=enabled@:>@])], - [enable_shared="$enableval"], - [enable_shared=yes] -) -case "x$enable_shared" in -xyes|xno ) ;; -x ) enable_shared=yes ;; -* ) - AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid]) - ;; -esac - -dnl Can't have static and shared libraries, default to static if user -dnl explicitly requested. If both disabled, set to static since shared -dnl was explicitly requirested. -case "x$enable_static$enable_shared" in -xyesyes ) - AC_MSG_WARN([Can't build static and shared libraries, disabling shared]) - enable_shared=no - ;; -xnono ) - AC_MSG_WARN([Can't disable both static and shared libraries, enabling static]) - enable_static=yes - ;; -esac - -dnl -dnl mklib options -dnl -AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib]) -if test "$enable_static" = yes; then - MKLIB_OPTIONS="$MKLIB_OPTIONS -static" -fi -AC_SUBST([MKLIB_OPTIONS]) - -dnl -dnl other compiler options -dnl -AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug], - [use debug compiler flags and macros @<:@default=disabled@:>@])], - [enable_debug="$enableval"], - [enable_debug=no] -) -if test "x$enable_debug" = xyes; then - DEFINES="$DEFINES -DDEBUG" - if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -g" - fi - if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -g" - fi -fi - -dnl -dnl library names -dnl -LIB_PREFIX_GLOB='lib' -LIB_VERSION_SEPARATOR='.' -if test "$enable_static" = yes; then - LIB_EXTENSION='a' -else - case "$host_os" in - darwin* ) - LIB_EXTENSION='dylib' ;; - cygwin* ) - dnl prefix can be 'cyg' or 'lib' - LIB_PREFIX_GLOB='???' - LIB_VERSION_SEPARATOR='-' - LIB_EXTENSION='dll' ;; - aix* ) - LIB_EXTENSION='a' ;; - * ) - LIB_EXTENSION='so' ;; - esac -fi - -GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION} -GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION} -GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION} -GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION} -OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION} -EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION} -GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION} -GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION} -VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION} -GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION} -WAYLAND_EGL_LIB_NAME='lib$(WAYLAND_EGL_LIB).'${LIB_EXTENSION} - -GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLUT_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLUT_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLW_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLW_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -WAYLAND_EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(WAYLAND_EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' - -AC_SUBST([GL_LIB_NAME]) -AC_SUBST([GLU_LIB_NAME]) -AC_SUBST([GLUT_LIB_NAME]) -AC_SUBST([GLW_LIB_NAME]) -AC_SUBST([OSMESA_LIB_NAME]) -AC_SUBST([EGL_LIB_NAME]) -AC_SUBST([GLESv1_CM_LIB_NAME]) -AC_SUBST([GLESv2_LIB_NAME]) -AC_SUBST([VG_LIB_NAME]) -AC_SUBST([GLAPI_LIB_NAME]) -AC_SUBST([WAYLAND_EGL_LIB_NAME]) - -AC_SUBST([GL_LIB_GLOB]) -AC_SUBST([GLU_LIB_GLOB]) -AC_SUBST([GLUT_LIB_GLOB]) -AC_SUBST([GLW_LIB_GLOB]) -AC_SUBST([OSMESA_LIB_GLOB]) -AC_SUBST([EGL_LIB_GLOB]) -AC_SUBST([GLESv1_CM_LIB_GLOB]) -AC_SUBST([GLESv2_LIB_GLOB]) -AC_SUBST([VG_LIB_GLOB]) -AC_SUBST([GLAPI_LIB_GLOB]) -AC_SUBST([WAYLAND_EGL_LIB_GLOB]) - -dnl -dnl Arch/platform-specific settings -dnl -AC_ARG_ENABLE([asm], - [AS_HELP_STRING([--disable-asm], - [disable assembly usage @<:@default=enabled on supported plaforms@:>@])], - [enable_asm="$enableval"], - [enable_asm=yes] -) -asm_arch="" -ASM_FLAGS="" -MESA_ASM_SOURCES="" -GLAPI_ASM_SOURCES="" -AC_MSG_CHECKING([whether to enable assembly]) -test "x$enable_asm" = xno && AC_MSG_RESULT([no]) -# disable if cross compiling on x86/x86_64 since we must run gen_matypes -if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then - case "$host_cpu" in - i?86 | x86_64) - enable_asm=no - AC_MSG_RESULT([no, cross compiling]) - ;; - esac -fi -# check for supported arches -if test "x$enable_asm" = xyes; then - case "$host_cpu" in - i?86) - case "$host_os" in - linux* | *freebsd* | dragonfly* | *netbsd*) - test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86 - ;; - esac - ;; - x86_64) - case "$host_os" in - linux* | *freebsd* | dragonfly* | *netbsd*) - test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64 - ;; - esac - ;; - powerpc) - case "$host_os" in - linux*) - asm_arch=ppc - ;; - esac - ;; - sparc*) - case "$host_os" in - linux*) - asm_arch=sparc - ;; - esac - ;; - esac - - case "$asm_arch" in - x86) - ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM" - MESA_ASM_SOURCES='$(X86_SOURCES)' - GLAPI_ASM_SOURCES='$(X86_API)' - AC_MSG_RESULT([yes, x86]) - ;; - x86_64) - ASM_FLAGS="-DUSE_X86_64_ASM" - MESA_ASM_SOURCES='$(X86-64_SOURCES)' - GLAPI_ASM_SOURCES='$(X86-64_API)' - AC_MSG_RESULT([yes, x86_64]) - ;; - ppc) - ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM" - MESA_ASM_SOURCES='$(PPC_SOURCES)' - AC_MSG_RESULT([yes, ppc]) - ;; - sparc) - ASM_FLAGS="-DUSE_SPARC_ASM" - MESA_ASM_SOURCES='$(SPARC_SOURCES)' - GLAPI_ASM_SOURCES='$(SPARC_API)' - AC_MSG_RESULT([yes, sparc]) - ;; - *) - AC_MSG_RESULT([no, platform not supported]) - ;; - esac -fi -AC_SUBST([ASM_FLAGS]) -AC_SUBST([MESA_ASM_SOURCES]) -AC_SUBST([GLAPI_ASM_SOURCES]) - -dnl PIC code macro -MESA_PIC_FLAGS - -dnl Check to see if dlopen is in default libraries (like Solaris, which -dnl has it in libc), or if libdl is needed to get it. -AC_CHECK_FUNC([dlopen], [], - [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])]) -AC_SUBST([DLOPEN_LIBS]) - -dnl See if posix_memalign is available -AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"]) - -dnl SELinux awareness. -AC_ARG_ENABLE([selinux], - [AS_HELP_STRING([--enable-selinux], - [Build SELinux-aware Mesa @<:@default=disabled@:>@])], - [MESA_SELINUX="$enableval"], - [MESA_SELINUX=no]) -if test "x$enable_selinux" = "xyes"; then - AC_CHECK_HEADER([selinux/selinux.h],[], - [AC_MSG_ERROR([SELinux headers not found])]) - AC_CHECK_LIB([selinux],[is_selinux_enabled],[], - [AC_MSG_ERROR([SELinux library not found])]) - SELINUX_LIBS="-lselinux" - DEFINES="$DEFINES -DMESA_SELINUX" -fi - -dnl Determine which APIs to support -AC_ARG_ENABLE([opengl], - [AS_HELP_STRING([--disable-opengl], - [disable support for standard OpenGL API @<:@default=no@:>@])], - [enable_opengl="$enableval"], - [enable_opengl=yes]) -AC_ARG_ENABLE([gles1], - [AS_HELP_STRING([--enable-gles1], - [enable support for OpenGL ES 1.x API @<:@default=no@:>@])], - [enable_gles1="$enableval"], - [enable_gles1=no]) -AC_ARG_ENABLE([gles2], - [AS_HELP_STRING([--enable-gles2], - [enable support for OpenGL ES 2.x API @<:@default=no@:>@])], - [enable_gles2="$enableval"], - [enable_gles2=no]) -AC_ARG_ENABLE([gles-overlay], - [AS_HELP_STRING([--enable-gles-overlay], - [DEPRECATED. Same as --enable-gles1 and --enable-gles2])], - [enable_gles1="$enableval"; enable_gles2="$enableval"], - []) - -AC_ARG_ENABLE([openvg], - [AS_HELP_STRING([--enable-openvg], - [enable support for OpenVG API @<:@default=no@:>@])], - [enable_openvg="$enableval"], - [enable_openvg=no]) - -dnl smooth the transition; should be removed eventually -if test "x$enable_openvg" = xno; then - case "x$with_state_trackers" in - x*vega*) - AC_MSG_WARN([vega state tracker is enabled without --enable-openvg]) - enable_openvg=yes - ;; - esac -fi - -if test "x$enable_opengl" = xno -a \ - "x$enable_gles1" = xno -a \ - "x$enable_gles2" = xno -a \ - "x$enable_openvg" = xno; then - AC_MSG_ERROR([at least one API should be enabled]) -fi - -API_DEFINES="" -if test "x$enable_opengl" = xno; then - API_DEFINES="$API_DEFINES -DFEATURE_GL=0" -else - API_DEFINES="$API_DEFINES -DFEATURE_GL=1" -fi -if test "x$enable_gles1" = xyes; then - API_DEFINES="$API_DEFINES -DFEATURE_ES1=1" -fi -if test "x$enable_gles2" = xyes; then - API_DEFINES="$API_DEFINES -DFEATURE_ES2=1" -fi -AC_SUBST([API_DEFINES]) - -AC_ARG_ENABLE([shared-glapi], - [AS_HELP_STRING([--enable-shared-glapi], - [EXPERIMENTAL. Enable shared glapi for OpenGL @<:@default=no@:>@])], - [enable_shared_glapi="$enableval"], - [enable_shared_glapi=no]) - -SHARED_GLAPI="0" -if test "x$enable_shared_glapi" = xyes; then - SHARED_GLAPI="1" -fi -AC_SUBST([SHARED_GLAPI]) - -dnl -dnl Driver configuration. Options are xlib, dri and osmesa right now. -dnl More later: fbdev, ... -dnl -default_driver="xlib" - -case "$host_os" in -linux*) - case "$host_cpu" in - i*86|x86_64|powerpc*|sparc*) default_driver="dri";; - esac - ;; -*freebsd* | dragonfly* | *netbsd*) - case "$host_cpu" in - i*86|x86_64|powerpc*|sparc*) default_driver="dri";; - esac - ;; -esac - -if test "x$enable_opengl" = xno; then - default_driver="no" -fi - -AC_ARG_WITH([driver], - [AS_HELP_STRING([--with-driver=DRIVER], - [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])], - [mesa_driver="$withval"], - [mesa_driver="$default_driver"]) -dnl Check for valid option -case "x$mesa_driver" in -xxlib|xdri|xosmesa) - if test "x$enable_opengl" = xno; then - AC_MSG_ERROR([Driver '$mesa_driver' requires OpenGL enabled]) - fi - ;; -xno) - ;; -*) - AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option]) - ;; -esac - -dnl -dnl Driver specific build directories -dnl - -dnl this variable will be prepended to SRC_DIRS and is not exported -CORE_DIRS="" - -SRC_DIRS="" -GLU_DIRS="sgi" -GALLIUM_DIRS="auxiliary drivers state_trackers" -GALLIUM_TARGET_DIRS="" -GALLIUM_WINSYS_DIRS="sw" -GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity" -GALLIUM_STATE_TRACKERS_DIRS="" - -# build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled -case "x$enable_shared_glapi$enable_gles1$enable_gles2" in -x*yes*) - CORE_DIRS="$CORE_DIRS mapi/shared-glapi" - ;; -esac - -# build glapi if OpenGL is enabled -if test "x$enable_opengl" = xyes; then - CORE_DIRS="$CORE_DIRS mapi/glapi" -fi - -# build es1api if OpenGL ES 1.x is enabled -if test "x$enable_gles1" = xyes; then - CORE_DIRS="$CORE_DIRS mapi/es1api" -fi - -# build es2api if OpenGL ES 2.x is enabled -if test "x$enable_gles2" = xyes; then - CORE_DIRS="$CORE_DIRS mapi/es2api" -fi - -# build vgapi if OpenVG is enabled -if test "x$enable_openvg" = xyes; then - CORE_DIRS="$CORE_DIRS mapi/vgapi" -fi - -# build glsl and mesa if OpenGL or OpenGL ES is enabled -case "x$enable_opengl$enable_gles1$enable_gles2" in -x*yes*) - CORE_DIRS="$CORE_DIRS glsl mesa" - ;; -esac - -case "$mesa_driver" in -xlib) - DRIVER_DIRS="x11" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib" - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib" - ;; -dri) - SRC_DIRS="$SRC_DIRS glx" - DRIVER_DIRS="dri" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri" - ;; -osmesa) - DRIVER_DIRS="osmesa" - ;; -no) - DRIVER_DRIS="" - ;; -esac -AC_SUBST([SRC_DIRS]) -AC_SUBST([GLU_DIRS]) -AC_SUBST([DRIVER_DIRS]) -AC_SUBST([GALLIUM_DIRS]) -AC_SUBST([GALLIUM_TARGET_DIRS]) -AC_SUBST([GALLIUM_WINSYS_DIRS]) -AC_SUBST([GALLIUM_DRIVERS_DIRS]) -AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS]) -AC_SUBST([MESA_LLVM]) - -dnl -dnl Find out if X is available. The variable have_x is set if libX11 is -dnl found to mimic AC_PATH_XTRA. -dnl -if test -n "$PKG_CONFIG"; then - AC_MSG_CHECKING([pkg-config files for X11 are available]) - PKG_CHECK_EXISTS([x11],[ - x11_pkgconfig=yes - have_x=yes - ],[ - x11_pkgconfig=no - ]) - AC_MSG_RESULT([$x11_pkgconfig]) -else - x11_pkgconfig=no -fi -dnl Use the autoconf macro if no pkg-config files -if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([X11], [x11]) -else - AC_PATH_XTRA - test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS" - test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11" - AC_SUBST([X11_CFLAGS]) - AC_SUBST([X11_LIBS]) -fi - -dnl Try to tell the user that the --x-* options are only used when -dnl pkg-config is not available. This must be right after AC_PATH_XTRA. -m4_divert_once([HELP_BEGIN], -[These options are only used when the X libraries cannot be found by the -pkg-config utility.]) - -dnl We need X for xlib and dri, so bomb now if it's not found -case "$mesa_driver" in -xlib|dri) - if test "$no_x" = yes; then - AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver]) - fi - ;; -esac - -dnl XCB - this is only used for GLX right now -AC_ARG_ENABLE([xcb], - [AS_HELP_STRING([--enable-xcb], - [use XCB for GLX @<:@default=disabled@:>@])], - [enable_xcb="$enableval"], - [enable_xcb=no]) -if test "x$enable_xcb" = xyes; then - DEFINES="$DEFINES -DUSE_XCB" -else - enable_xcb=no -fi - -dnl -dnl libGL configuration per driver -dnl -case "$mesa_driver" in -xlib) - if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([XLIBGL], [x11 xext]) - GL_PC_REQ_PRIV="x11 xext" - X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS" - GL_LIB_DEPS="$XLIBGL_LIBS" - else - # should check these... - X11_INCLUDES="$X11_INCLUDES $X_CFLAGS" - GL_LIB_DEPS="$X_LIBS -lX11 -lXext" - GL_PC_LIB_PRIV="$GL_LIB_DEPS" - GL_PC_CFLAGS="$X11_INCLUDES" - fi - GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread" - GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread" - - # if static, move the external libraries to the programs - # and empty the libraries for libGL - if test "$enable_static" = yes; then - APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS" - GL_LIB_DEPS="" - fi - ;; -dri|no) # these checks are still desired when there is no mesa_driver - # DRI must be shared, I think - if test "$enable_static" = yes; then - AC_MSG_ERROR([Can't use static libraries for DRI drivers]) - fi - - # Check for libdrm - PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED]) - PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED]) - PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED]) - GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED" - DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" - - # find the DRI deps for libGL - if test "$x11_pkgconfig" = yes; then - dri_modules="x11 xext xdamage xfixes" - - # add xf86vidmode if available - PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no) - if test "$HAVE_XF86VIDMODE" = yes ; then - dri_modules="$dri_modules xxf86vm" - fi - - # add xcb modules if necessary - if test "$enable_xcb" = yes; then - dri_modules="$dri_modules x11-xcb xcb-glx" - fi - - PKG_CHECK_MODULES([DRIGL], [$dri_modules]) - GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules" - X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS" - GL_LIB_DEPS="$DRIGL_LIBS" - else - # should check these... - X11_INCLUDES="$X11_INCLUDES $X_CFLAGS" - GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes" - GL_PC_LIB_PRIV="$GL_LIB_DEPS" - GL_PC_CFLAGS="$X11_INCLUDES" - - # XCB can only be used from pkg-config - if test "$enable_xcb" = yes; then - PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx]) - GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx" - X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS" - GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS" - fi - fi - - # need DRM libs, -lpthread, etc. - GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS" - GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS" - GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS" - GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS" - GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS" - GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS" - ;; -osmesa) - # No libGL for osmesa - GL_LIB_DEPS="" - ;; -esac -AC_SUBST([GL_LIB_DEPS]) -AC_SUBST([GL_PC_REQ_PRIV]) -AC_SUBST([GL_PC_LIB_PRIV]) -AC_SUBST([GL_PC_CFLAGS]) -AC_SUBST([DRI_PC_REQ_PRIV]) -AC_SUBST([GLESv1_CM_LIB_DEPS]) -AC_SUBST([GLESv1_CM_PC_LIB_PRIV]) -AC_SUBST([GLESv2_LIB_DEPS]) -AC_SUBST([GLESv2_PC_LIB_PRIV]) - -GLAPI_LIB_DEPS="-lpthread" -AC_SUBST([GLAPI_LIB_DEPS]) - - -dnl Setup default DRI CFLAGS -DRI_CFLAGS='$(CFLAGS)' -DRI_CXXFLAGS='$(CXXFLAGS)' -DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a' -MESA_MODULES='$(TOP)/src/mesa/libmesa.a' - -AC_ARG_ENABLE([shared-dricore], - [AS_HELP_STRING([--enable-shared-dricore], - [link DRI modules with shared core DRI routines @<:@default=disabled@:>@])], - [enable_dricore="$enableval"], - [enable_dricore=no]) -if test "$mesa_driver" = dri ; then - if test "$enable_dricore" = yes ; then - if test "$GCC$GXX" != yesyes ; then - AC_MSG_WARN([Shared dricore requires GCC-compatible rpath handling. Disabling shared dricore]) - enable_dricore=no - else - DRICORE_GLSL_LIBS='$(TOP)/$(LIB_DIR)/libglsl.so' - DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so' - DRICORE_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -lglsl' - DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore -lglsl' - DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE' - DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE' - MESA_MODULES='$(DRICORE_LIBS) $(DRICORE_GLSL_LIBS)' - fi - fi -fi -AC_SUBST([DRICORE_LIBS]) -AC_SUBST([DRICORE_GLSL_LIBS]) -AC_SUBST([DRICORE_LIB_DEPS]) -AC_SUBST([DRI_CXXFLAGS]) -AC_SUBST([DRI_CFLAGS]) -AC_SUBST([MESA_MODULES]) - -AC_SUBST([HAVE_XF86VIDMODE]) - -PKG_CHECK_MODULES([LIBDRM_RADEON], - [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED], - HAVE_LIBDRM_RADEON=yes, - HAVE_LIBDRM_RADEON=no) - -dnl -dnl More X11 setup -dnl -if test "$mesa_driver" = xlib; then - DEFINES="$DEFINES -DUSE_XSHM" -fi - -dnl -dnl TLS detection -dnl - -AC_ARG_ENABLE([glx-tls], - [AS_HELP_STRING([--enable-glx-tls], - [enable TLS support in GLX @<:@default=disabled@:>@])], - [GLX_USE_TLS="$enableval"], - [GLX_USE_TLS=no]) -AC_SUBST(GLX_TLS, ${GLX_USE_TLS}) - -AS_IF([test "x$GLX_USE_TLS" = xyes], - [DEFINES="${DEFINES} -DGLX_USE_TLS -DPTHREADS"]) - -dnl -dnl More DRI setup -dnl -dnl Directory for DRI drivers -AC_ARG_WITH([dri-driverdir], - [AS_HELP_STRING([--with-dri-driverdir=DIR], - [directory for the DRI drivers @<:@${libdir}/dri@:>@])], - [DRI_DRIVER_INSTALL_DIR="$withval"], - [DRI_DRIVER_INSTALL_DIR='${libdir}/dri']) -AC_SUBST([DRI_DRIVER_INSTALL_DIR]) -dnl Extra search path for DRI drivers -AC_ARG_WITH([dri-searchpath], - [AS_HELP_STRING([--with-dri-searchpath=DIRS...], - [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])], - [DRI_DRIVER_SEARCH_DIR="$withval"], - [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}']) -AC_SUBST([DRI_DRIVER_SEARCH_DIR]) -dnl Direct rendering or just indirect rendering -AC_ARG_ENABLE([driglx-direct], - [AS_HELP_STRING([--disable-driglx-direct], - [enable direct rendering in GLX and EGL for DRI @<:@default=enabled@:>@])], - [driglx_direct="$enableval"], - [driglx_direct="yes"]) -dnl Which drivers to build - default is chosen by platform -AC_ARG_WITH([dri-drivers], - [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@], - [comma delimited DRI drivers list, e.g. - "swrast,i965,radeon" @<:@default=auto@:>@])], - [with_dri_drivers="$withval"], - [with_dri_drivers=yes]) -if test "x$with_dri_drivers" = x; then - with_dri_drivers=no -fi - -dnl If $with_dri_drivers is yes, directories will be added through -dnl platform checks -DRI_DIRS="" -case "$with_dri_drivers" in -no) ;; -yes) - DRI_DIRS="yes" - ;; -*) - # verify the requested driver directories exist - dri_drivers=`IFS=', '; echo $with_dri_drivers` - for driver in $dri_drivers; do - test -d "$srcdir/src/mesa/drivers/dri/$driver" || \ - AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist]) - done - DRI_DIRS="$dri_drivers" - ;; -esac - -dnl Set DRI_DIRS, DEFINES and LIB_DEPS -if test "$mesa_driver" = dri -o "$mesa_driver" = no; then - # Platform specific settings and drivers to build - case "$host_os" in - linux*) - DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER" - if test "x$driglx_direct" = xyes; then - DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" - fi - DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS" - - case "$host_cpu" in - x86_64) - # sis is missing because they have not be converted to use - # the new interface. i810 are missing because there is no - # x86-64 system where they could *ever* be used. - if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \ - savage tdfx unichrome swrast" - fi - ;; - powerpc*) - # Build only the drivers for cards that exist on PowerPC. - # At some point MGA will be added, but not yet. - if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="mach64 r128 r200 r300 r600 radeon tdfx swrast" - fi - ;; - sparc*) - # Build only the drivers for cards that exist on sparc` - if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast" - fi - ;; - esac - ;; - freebsd* | dragonfly* | *netbsd*) - DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1" - DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS" - DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING" - if test "x$driglx_direct" = xyes; then - DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" - fi - - if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \ - unichrome savage sis swrast" - fi - ;; - gnu*) - DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER" - DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS" - ;; - solaris*) - DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER" - DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING" - if test "x$driglx_direct" = xyes; then - DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" - fi - ;; - esac - - # default drivers - if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \ - savage sis tdfx unichrome swrast" - fi - - DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'` - - # Check for expat - if test "$mesa_driver" = dri; then - EXPAT_INCLUDES="" - EXPAT_LIB=-lexpat - AC_ARG_WITH([expat], - [AS_HELP_STRING([--with-expat=DIR], - [expat install directory])],[ - EXPAT_INCLUDES="-I$withval/include" - CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES" - LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR" - EXPAT_LIB="-L$withval/$LIB_DIR -lexpat" - ]) - AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])]) - AC_CHECK_LIB([expat],[XML_ParserCreate],[], - [AC_MSG_ERROR([Expat required for DRI.])]) - fi - - # put all the necessary libs together, including possibly libdricore - DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS" -fi -AC_SUBST([DRI_DIRS]) -AC_SUBST([EXPAT_INCLUDES]) -AC_SUBST([DRI_LIB_DEPS]) - -case $DRI_DIRS in -*i915*|*i965*) - PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED]) - ;; -esac - -case $DRI_DIRS in -*radeon*|*r200*|*r300*|*r600*) - if test "x$HAVE_LIBDRM_RADEON" = xyes; then - RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS" - RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS - fi - ;; -esac -AC_SUBST([RADEON_CFLAGS]) -AC_SUBST([RADEON_LDFLAGS]) - - -dnl -dnl OSMesa configuration -dnl -if test "$mesa_driver" = xlib; then - default_gl_osmesa=yes -else - default_gl_osmesa=no -fi -AC_ARG_ENABLE([gl-osmesa], - [AS_HELP_STRING([--enable-gl-osmesa], - [enable OSMesa with libGL @<:@default=enabled for xlib driver@:>@])], - [gl_osmesa="$enableval"], - [gl_osmesa="$default_gl_osmesa"]) -if test "x$gl_osmesa" = xyes; then - if test "x$enable_opengl" = xno; then - AC_MSG_ERROR([OpenGL is not available for OSMesa driver]) - fi - if test "$mesa_driver" = osmesa; then - AC_MSG_ERROR([libGL is not available for OSMesa driver]) - else - DRIVER_DIRS="$DRIVER_DIRS osmesa" - fi -fi - -dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...) -AC_ARG_WITH([osmesa-bits], - [AS_HELP_STRING([--with-osmesa-bits=BITS], - [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])], - [osmesa_bits="$withval"], - [osmesa_bits=8]) -if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then - AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver]) - osmesa_bits=8 -fi -case "x$osmesa_bits" in -x8) - OSMESA_LIB=OSMesa - ;; -x16|x32) - OSMESA_LIB="OSMesa$osmesa_bits" - DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31" - ;; -*) - AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option]) - ;; -esac -AC_SUBST([OSMESA_LIB]) - -case "$DRIVER_DIRS" in -*osmesa*) - # only link libraries with osmesa if shared - if test "$enable_static" = no; then - OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" - else - OSMESA_LIB_DEPS="" - fi - OSMESA_MESA_DEPS="" - OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" - ;; -esac -AC_SUBST([OSMESA_LIB_DEPS]) -AC_SUBST([OSMESA_MESA_DEPS]) -AC_SUBST([OSMESA_PC_REQ]) -AC_SUBST([OSMESA_PC_LIB_PRIV]) - -dnl -dnl EGL configuration -dnl -AC_ARG_ENABLE([egl], - [AS_HELP_STRING([--disable-egl], - [disable EGL library @<:@default=enabled@:>@])], - [enable_egl="$enableval"], - [enable_egl=yes]) -if test "x$enable_egl" = xno; then - if test "x$mesa_driver" = xno; then - AC_MSG_ERROR([cannot disable EGL when there is no mesa driver]) - fi - if test "x$enable_openvg" = xyes; then - AC_MSG_ERROR([cannot enable OpenVG without EGL]) - fi -fi -if test "x$enable_egl" = xyes; then - SRC_DIRS="$SRC_DIRS egl" - EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread" - EGL_DRIVERS_DIRS="" - if test "$enable_static" != yes; then - # build egl_glx when libGL is built - if test "$mesa_driver" = xlib -o "$mesa_driver" = dri; then - EGL_DRIVERS_DIRS="glx" - fi - - if test "$mesa_driver" = dri; then - # build egl_dri2 when xcb-dri2 is available - PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes], - [have_xcb_dri2=yes],[have_xcb_dri2=no]) - PKG_CHECK_MODULES([LIBUDEV], [libudev > 150], - [have_libudev=yes],[have_libudev=no]) - - if test "$have_xcb_dri2" = yes; then - EGL_DRIVER_DRI2=dri2 - DEFINES="$DEFINES -DHAVE_XCB_DRI2" - if test "$have_libudev" = yes; then - DEFINES="$DEFINES -DHAVE_LIBUDEV" - fi - # workaround a bug in xcb-dri2 generated by xcb-proto 1.6 - AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [], - [DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"]) - fi - fi - - EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS $EGL_DRIVER_DRI2" - fi -fi -AC_SUBST([EGL_LIB_DEPS]) -AC_SUBST([EGL_DRIVERS_DIRS]) - -dnl -dnl GLU configuration -dnl -AC_ARG_ENABLE([glu], - [AS_HELP_STRING([--disable-glu], - [enable OpenGL Utility library @<:@default=enabled@:>@])], - [enable_glu="$enableval"], - [enable_glu=yes]) - -if test "x$enable_glu" = xyes -a "x$mesa_driver" = xno; then - AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver]) - enable_glu=no -fi - -if test "x$enable_glu" = xyes; then - SRC_DIRS="$SRC_DIRS glu" - - case "$mesa_driver" in - osmesa) - # Link libGLU to libOSMesa instead of libGL - GLU_LIB_DEPS="" - GLU_PC_REQ="osmesa" - if test "$enable_static" = no; then - GLU_MESA_DEPS='-l$(OSMESA_LIB)' - else - GLU_MESA_DEPS="" - fi - ;; - *) - # If static, empty GLU_LIB_DEPS and add libs for programs to link - GLU_PC_REQ="gl" - GLU_PC_LIB_PRIV="-lm" - if test "$enable_static" = no; then - GLU_LIB_DEPS="-lm" - GLU_MESA_DEPS='-l$(GL_LIB)' - else - GLU_LIB_DEPS="" - GLU_MESA_DEPS="" - APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++" - fi - ;; - esac -fi -if test "$enable_static" = no; then - GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS" -fi -GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS" -AC_SUBST([GLU_LIB_DEPS]) -AC_SUBST([GLU_MESA_DEPS]) -AC_SUBST([GLU_PC_REQ]) -AC_SUBST([GLU_PC_REQ_PRIV]) -AC_SUBST([GLU_PC_LIB_PRIV]) -AC_SUBST([GLU_PC_CFLAGS]) - -dnl -dnl GLw configuration -dnl -AC_ARG_ENABLE([glw], - [AS_HELP_STRING([--disable-glw], - [enable Xt/Motif widget library @<:@default=enabled@:>@])], - [enable_glw="$enableval"], - [enable_glw=yes]) -dnl Don't build GLw on osmesa -if test "x$enable_glw" = xyes; then - case "$mesa_driver" in - osmesa|no) - AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver]) - enable_glw=no - ;; - esac -fi -AC_ARG_ENABLE([motif], - [AS_HELP_STRING([--enable-motif], - [use Motif widgets in GLw @<:@default=disabled@:>@])], - [enable_motif="$enableval"], - [enable_motif=no]) - -if test "x$enable_glw" = xyes; then - SRC_DIRS="$SRC_DIRS glw" - if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([GLW],[x11 xt]) - GLW_PC_REQ_PRIV="x11 xt" - GLW_LIB_DEPS="$GLW_LIBS" - else - # should check these... - GLW_LIB_DEPS="$X_LIBS -lXt -lX11" - GLW_PC_LIB_PRIV="$GLW_LIB_DEPS" - GLW_PC_CFLAGS="$X11_INCLUDES" - fi - - GLW_SOURCES="GLwDrawA.c" - MOTIF_CFLAGS= - if test "x$enable_motif" = xyes; then - GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c" - AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no]) - if test "x$MOTIF_CONFIG" != xno; then - MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags` - MOTIF_LIBS=`$MOTIF_CONFIG --libs` - else - AC_CHECK_HEADER([Xm/PrimitiveP.h], [], - [AC_MSG_ERROR([Can't locate Motif headers])]) - AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"], - [AC_MSG_ERROR([Can't locate Motif Xm library])]) - fi - # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11 - GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS" - GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV" - GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS" - fi - - # If static, empty GLW_LIB_DEPS and add libs for programs to link - GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV" - if test "$enable_static" = no; then - GLW_MESA_DEPS='-l$(GL_LIB)' - GLW_LIB_DEPS="$GLW_LIB_DEPS" - else - APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS" - GLW_LIB_DEPS="" - GLW_MESA_DEPS="" - fi -fi -AC_SUBST([GLW_LIB_DEPS]) -AC_SUBST([GLW_MESA_DEPS]) -AC_SUBST([GLW_SOURCES]) -AC_SUBST([MOTIF_CFLAGS]) -AC_SUBST([GLW_PC_REQ_PRIV]) -AC_SUBST([GLW_PC_LIB_PRIV]) -AC_SUBST([GLW_PC_CFLAGS]) - -dnl -dnl GLUT configuration -dnl -if test -f "$srcdir/include/GL/glut.h"; then - default_glut=yes -else - default_glut=no -fi -AC_ARG_ENABLE([glut], - [AS_HELP_STRING([--disable-glut], - [enable GLUT library @<:@default=enabled if source available@:>@])], - [enable_glut="$enableval"], - [enable_glut="$default_glut"]) - -dnl Don't build glut on osmesa -if test "x$enable_glut" = xyes; then - case "$mesa_driver" in - osmesa|no) - AC_MSG_NOTICE([Disabling glut since there is no OpenGL driver]) - enable_glut=no - ;; - esac -fi -dnl Can't build glut if GLU not available -if test "x$enable_glu$enable_glut" = xnoyes; then - AC_MSG_WARN([Disabling glut since GLU is disabled]) - enable_glut=no -fi - -if test "x$enable_glut" = xyes; then - SRC_DIRS="$SRC_DIRS glut/glx" - if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([GLUT],[x11 xmu xi]) - GLUT_PC_REQ_PRIV="x11 xmu xi" - GLUT_LIB_DEPS="$GLUT_LIBS" - else - # should check these... - GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi" - GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS" - GLUT_PC_CFLAGS="$X11_INCLUDES" - fi - if test "x$GCC" = xyes; then - GLUT_CFLAGS="$GLUT_CFLAGS -fexceptions" - fi - GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm" - GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm" - - # If static, empty GLUT_LIB_DEPS and add libs for programs to link - if test "$enable_static" = no; then - GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)' - else - APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS" - GLUT_LIB_DEPS="" - GLUT_MESA_DEPS="" - fi -fi -AC_SUBST([GLUT_LIB_DEPS]) -AC_SUBST([GLUT_MESA_DEPS]) -AC_SUBST([GLUT_CFLAGS]) -AC_SUBST([GLUT_PC_REQ_PRIV]) -AC_SUBST([GLUT_PC_LIB_PRIV]) -AC_SUBST([GLUT_PC_CFLAGS]) - -dnl -dnl Program library dependencies -dnl Only libm is added here if necessary as the libraries should -dnl be pulled in by the linker -dnl -if test "x$APP_LIB_DEPS" = x; then - case "$host_os" in - solaris*) - APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm" - ;; - cygwin*) - APP_LIB_DEPS="-lX11" - ;; - *) - APP_LIB_DEPS="-lm" - ;; - esac -fi -AC_SUBST([APP_LIB_DEPS]) -AC_SUBST([PROGRAM_DIRS]) - -dnl -dnl Gallium configuration -dnl -AC_ARG_ENABLE([gallium], - [AS_HELP_STRING([--disable-gallium], - [build gallium @<:@default=enabled@:>@])], - [enable_gallium="$enableval"], - [enable_gallium=yes]) -if test "x$enable_gallium" = xno -a "x$enable_openvg" = xyes; then - AC_MSG_ERROR([cannot enable OpenVG without Gallium]) -fi -if test "x$enable_gallium" = xyes; then - SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets" - AC_CHECK_HEADER([udis86.h], [HAS_UDIS86="yes"], - [HAS_UDIS86="no"]) - AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no]) -fi - -AC_SUBST([LLVM_CFLAGS]) -AC_SUBST([LLVM_LIBS]) -AC_SUBST([LLVM_LDFLAGS]) -AC_SUBST([LLVM_VERSION]) - -dnl -dnl Gallium state trackers configuration -dnl - -AC_ARG_ENABLE([gallium-egl], - [AS_HELP_STRING([--enable-gallium-egl], - [enable gallium EGL state tracker @<:@default=auto@:>@])], - [enable_gallium_egl="$enableval"], - [enable_gallium_egl=auto]) -if test "x$enable_gallium_egl" = xauto; then - case "$mesa_driver" in - dri|no) - enable_gallium_egl=$enable_egl - ;; - *) - enable_gallium_egl=$enable_openvg - ;; - esac -fi -case "x$enable_egl$enable_gallium_egl" in -xnoyes) - AC_MSG_ERROR([cannot build Gallium EGL state tracker without EGL]) -esac - -AC_ARG_WITH([state-trackers], - [AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@], - [comma delimited state_trackers list, e.g. - "egl,glx" @<:@default=auto@:>@])], - [with_state_trackers="$withval"], - [with_state_trackers=yes]) - -case "$with_state_trackers" in -no) - GALLIUM_STATE_TRACKERS_DIRS="" - ;; -yes) - # look at what else is built - case "$mesa_driver" in - xlib) - GALLIUM_STATE_TRACKERS_DIRS=glx - ;; - dri) - GALLIUM_STATE_TRACKERS_DIRS="dri" - HAVE_ST_DRI="yes" - # Have only tested st/xorg on 1.6.0 servers - PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED], - HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg", - HAVE_ST_XORG="no") - ;; - esac - - if test "x$enable_egl" = xyes; then - if test "$enable_openvg" = yes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vega" - st_egl="yes" - fi - - if test "$enable_gallium_egl" = yes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" - HAVE_ST_EGL="yes" - fi - fi - ;; -*) - # verify the requested state tracker exist - state_trackers="" - _state_trackers=`IFS=', '; echo $with_state_trackers` - for tracker in $_state_trackers; do - case "$tracker" in - dri) - if test "x$mesa_driver" != xdri; then - AC_MSG_ERROR([cannot build dri state tracker without mesa driver set to dri]) - fi - HAVE_ST_DRI="yes" - ;; - egl) - if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) - fi - HAVE_ST_EGL="yes" - ;; - xorg) - PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0]) - PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED]) - PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED]) - HAVE_ST_XORG="yes" - ;; - vega) - if test "x$enable_openvg" != xyes; then - AC_MSG_ERROR([cannot build vega state tracker without --enable-openvg]) - fi - have_st_vega="yes" - ;; - esac - - if test -n "$tracker"; then - test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ - AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) - if test -n "$state_trackers"; then - state_trackers="$state_trackers $tracker" - else - state_trackers="$tracker" - fi - fi - done - GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" - - # append --enable-openvg/--enable-gallium-egl to --with-state-trackers - if test "x$have_st_vega" != xyes -a "x$enable_openvg" = xyes; then - AC_MSG_ERROR([--with-state-trackers specified but vega is missing]) - fi - if test "x$HAVE_ST_EGL" != xyes -a "x$enable_gallium_egl" = xyes; then - AC_MSG_ERROR([--with-state-trackers specified but egl is missing]) - fi - ;; -esac - - -EGL_CLIENT_APIS="" -VG_LIB_DEPS="" - -case "x$enable_opengl$enable_gles1$enable_gles2" in -x*yes*) - EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)' - ;; -esac -if test "x$enable_openvg" = xyes; then - EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)' - VG_LIB_DEPS="$VG_LIB_DEPS -lpthread" -fi - -AC_SUBST([VG_LIB_DEPS]) -AC_SUBST([EGL_CLIENT_APIS]) - -if test "x$HAVE_ST_EGL" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl" -fi - -if test "x$HAVE_ST_XORG" = xyes; then - PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], - HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", - HAVE_XEXTPROTO_71="no") -fi - -AC_ARG_WITH([egl-platforms], - [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@], - [comma delimited native platforms libEGL supports, e.g. - "x11,drm" @<:@default=auto@:>@])], - [with_egl_platforms="$withval"], - [with_egl_platforms=yes]) -AC_ARG_WITH([egl-displays], - [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@], - [DEPRECATED. Use --with-egl-platforms instead])], - [with_egl_platforms="$withval"]) - -EGL_PLATFORMS="" -WAYLAND_EGL_LIB_DEPS="" - -case "$with_egl_platforms" in -yes) - if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then - EGL_PLATFORMS="x11" - if test "$mesa_driver" = dri; then - EGL_PLATFORMS="$EGL_PLATFORMS drm" - fi - fi - ;; -*) - if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) - fi - # verify the requested driver directories exist - egl_platforms=`IFS=', '; echo $with_egl_platforms` - for plat in $egl_platforms; do - test -d "$srcdir/src/gallium/state_trackers/egl/$plat" || \ - AC_MSG_ERROR([EGL platform '$plat' doesn't exist]) - if test "$plat" = "fbdev"; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev" - fi - if test "$plat" = "wayland"; then - PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \ - [AC_MSG_ERROR([cannot find libwayland-client])]) - WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS" - fi - done - EGL_PLATFORMS="$egl_platforms" - ;; -esac -AC_SUBST([EGL_PLATFORMS]) - -AC_SUBST([WAYLAND_EGL_LIB_DEPS]) -WAYLAND_EGL_PC_REQ_PRIV="wayland-client libdrm" -WAYLAND_EGL_PC_LIB_PRIV= -WAYLAND_EGL_PC_CFLAGS= - -AC_SUBST([WAYLAND_EGL_PC_REQ_PRIV]) -AC_SUBST([WAYLAND_EGL_PC_LIB_PRIV]) -AC_SUBST([WAYLAND_EGL_PC_CFLAGS]) - - -AC_ARG_WITH([egl-driver-dir], - [AS_HELP_STRING([--with-egl-driver-dir=DIR], - [directory for EGL drivers [[default=${libdir}/egl]]])], - [EGL_DRIVER_INSTALL_DIR="$withval"], - [EGL_DRIVER_INSTALL_DIR='${libdir}/egl']) -AC_SUBST([EGL_DRIVER_INSTALL_DIR]) - -AC_ARG_WITH([xorg-driver-dir], - [AS_HELP_STRING([--with-xorg-driver-dir=DIR], - [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])], - [XORG_DRIVER_INSTALL_DIR="$withval"], - [XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"]) -AC_SUBST([XORG_DRIVER_INSTALL_DIR]) - -AC_ARG_WITH([max-width], - [AS_HELP_STRING([--with-max-width=N], - [Maximum framebuffer width (4096)])], - [DEFINES="${DEFINES} -DMAX_WIDTH=${withval}"; - AS_IF([test "${withval}" -gt "4096"], - [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])] -) -AC_ARG_WITH([max-height], - [AS_HELP_STRING([--with-max-height=N], - [Maximum framebuffer height (4096)])], - [DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}"; - AS_IF([test "${withval}" -gt "4096"], - [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])] -) - -dnl -dnl Gallium LLVM -dnl -AC_ARG_ENABLE([gallium-llvm], - [AS_HELP_STRING([--enable-gallium-llvm], - [build gallium LLVM support @<:@default=disabled@:>@])], - [enable_gallium_llvm="$enableval"], - [enable_gallium_llvm=auto]) -if test "x$enable_gallium_llvm" = xyes; then - if test "x$LLVM_CONFIG" != xno; then - LLVM_VERSION=`$LLVM_CONFIG --version` - LLVM_CFLAGS=`$LLVM_CONFIG --cppflags` - LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++" - - if test "x$HAS_UDIS86" != xno; then - LLVM_LIBS="$LLVM_LIBS -ludis86" - DEFINES="$DEFINES -DHAVE_UDIS86" - fi - LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" - DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS" - MESA_LLVM=1 - else - MESA_LLVM=0 - fi -else - MESA_LLVM=0 -fi - -dnl -dnl Gallium helper functions -dnl -gallium_check_st() { - if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1" - fi - if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2" - fi - if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3" - fi -} - - -dnl -dnl Gallium SVGA configuration -dnl -AC_ARG_ENABLE([gallium-svga], - [AS_HELP_STRING([--enable-gallium-svga], - [build gallium SVGA @<:@default=disabled@:>@])], - [enable_gallium_svga="$enableval"], - [enable_gallium_svga=auto]) -if test "x$enable_gallium_svga" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" - gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx" -elif test "x$enable_gallium_svga" = xauto; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" -fi - -dnl -dnl Gallium i915 configuration -dnl -AC_ARG_ENABLE([gallium-i915], - [AS_HELP_STRING([--enable-gallium-i915], - [build gallium i915 @<:@default=disabled@:>@])], - [enable_gallium_i915="$enableval"], - [enable_gallium_i915=auto]) -if test "x$enable_gallium_i915" = xyes; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw" - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915" - gallium_check_st "i915/drm" "dri-i915" "xorg-i915" -elif test "x$enable_gallium_i915" = xauto; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw" - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915" -fi - -dnl -dnl Gallium i965 configuration -dnl -AC_ARG_ENABLE([gallium-i965], - [AS_HELP_STRING([--enable-gallium-i965], - [build gallium i965 @<:@default=disabled@:>@])], - [enable_gallium_i965="$enableval"], - [enable_gallium_i965=auto]) -if test "x$enable_gallium_i965" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965" - gallium_check_st "i965/drm" "dri-i965" "xorg-i965" -elif test "x$enable_gallium_i965" = xauto; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965" -fi - -dnl -dnl Gallium Radeon r300g configuration -dnl -AC_ARG_ENABLE([gallium-radeon], - [AS_HELP_STRING([--enable-gallium-radeon], - [build gallium radeon @<:@default=disabled@:>@])], - [enable_gallium_radeon="$enableval"], - [enable_gallium_radeon=auto]) -if test "x$enable_gallium_radeon" = xauto; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" - gallium_check_st "radeon/drm" "dri-r300" -fi -if test "x$enable_gallium_radeon" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" - gallium_check_st "radeon/drm" "dri-r300" "xorg-radeon" -fi - -dnl -dnl Gallium Radeon r600g configuration -dnl -AC_ARG_ENABLE([gallium-r600], - [AS_HELP_STRING([--enable-gallium-r600], - [build gallium radeon @<:@default=disabled@:>@])], - [enable_gallium_r600="$enableval"], - [enable_gallium_r600=auto]) -if test "x$enable_gallium_r600" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600" - gallium_check_st "r600/drm" "dri-r600" -fi - -dnl -dnl Gallium Nouveau configuration -dnl -AC_ARG_ENABLE([gallium-nouveau], - [AS_HELP_STRING([--enable-gallium-nouveau], - [build gallium nouveau @<:@default=disabled@:>@])], - [enable_gallium_nouveau="$enableval"], - [enable_gallium_nouveau=no]) -if test "x$enable_gallium_nouveau" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0" - gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" -fi - -dnl -dnl Gallium swrast configuration -dnl -AC_ARG_ENABLE([gallium-swrast], - [AS_HELP_STRING([--enable-gallium-swrast], - [build gallium swrast @<:@default=auto@:>@])], - [enable_gallium_swrast="$enableval"], - [enable_gallium_swrast=auto]) -if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then - if test "x$HAVE_ST_DRI" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast" - fi -fi - -dnl prepend CORE_DIRS to SRC_DIRS -SRC_DIRS="$CORE_DIRS $SRC_DIRS" - -dnl Restore LDFLAGS and CPPFLAGS -LDFLAGS="$_SAVE_LDFLAGS" -CPPFLAGS="$_SAVE_CPPFLAGS" - -dnl Substitute the config -AC_CONFIG_FILES([configs/autoconf]) - -dnl Replace the configs/current symlink -AC_CONFIG_COMMANDS([configs],[ -if test -f configs/current || test -L configs/current; then - rm -f configs/current -fi -ln -s autoconf configs/current -]) - -AC_OUTPUT - -dnl -dnl Output some configuration info for the user -dnl -echo "" -echo " prefix: $prefix" -echo " exec_prefix: $exec_prefix" -echo " libdir: $libdir" -echo " includedir: $includedir" - -dnl API info -echo "" -echo " OpenGL: $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)" -echo " OpenVG: $enable_openvg" - -dnl Driver info -echo "" -echo " Driver: $mesa_driver" -if test "$mesa_driver" != no; then - if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then - echo " OSMesa: lib$OSMESA_LIB" - else - echo " OSMesa: no" - fi - if test "$mesa_driver" = dri; then - # cleanup the drivers var - dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'` - if test "x$DRI_DIRS" = x; then - echo " DRI drivers: no" - else - echo " DRI drivers: $dri_dirs" - fi - echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR" - echo " Use XCB: $enable_xcb" - echo " Shared dricore: $enable_dricore" - fi -fi -echo "" -echo " GLU: $enable_glu" -echo " GLw: $enable_glw (Motif: $enable_motif)" -echo " glut: $enable_glut" - -dnl EGL -echo "" -echo " EGL: $enable_egl" -if test "$enable_egl" = yes; then - echo " EGL platforms: $EGL_PLATFORMS" - - egl_drivers="" - for d in $EGL_DRIVERS_DIRS; do - egl_drivers="$egl_drivers builtin:egl_$d" - done - - if test "$enable_gallium" = yes -a "$HAVE_ST_EGL" = yes; then - echo " EGL drivers: ${egl_drivers} egl_gallium" - echo " EGL Gallium STs:$EGL_CLIENT_APIS" - else - echo " EGL drivers: $egl_drivers" - fi -fi - -echo "" -if test "x$MESA_LLVM" = x1; then - echo " llvm: yes" - echo " llvm-config: $LLVM_CONFIG" - echo " llvm-version: $LLVM_VERSION" -else - echo " llvm: no" -fi - -echo "" -if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then - echo " Gallium: yes" - echo " Gallium dirs: $GALLIUM_DIRS" - echo " Target dirs: $GALLIUM_TARGET_DIRS" - echo " Winsys dirs: $GALLIUM_WINSYS_DIRS" - echo " Driver dirs: $GALLIUM_DRIVERS_DIRS" - echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS" -else - echo " Gallium: no" -fi - -dnl Libraries -echo "" -echo " Shared libs: $enable_shared" -echo " Static libs: $enable_static" - -dnl Compiler options -# cleanup the CFLAGS/CXXFLAGS/DEFINES vars -cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \ - $SED 's/^ *//;s/ */ /;s/ *$//'` -cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \ - $SED 's/^ *//;s/ */ /;s/ *$//'` -defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'` -echo "" -echo " CFLAGS: $cflags" -echo " CXXFLAGS: $cxxflags" -echo " Macros: $defines" -echo "" -echo " PYTHON2: $PYTHON2" - -echo "" -echo " Run '${MAKE-make}' to build Mesa" -echo "" +dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.59])
+
+dnl Versioning - scrape the version from configs/default
+m4_define([mesa_version],
+ [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n' | tr -d '\r'])])
+m4_ifval(mesa_version,,
+ [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])])
+
+dnl Tell the user about autoconf.html in the --help output
+m4_divert_once([HELP_END], [
+See docs/autoconf.html for more details on the options for Mesa.])
+
+AC_INIT([Mesa],[mesa_version],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
+AC_CONFIG_AUX_DIR([bin])
+AC_CANONICAL_HOST
+
+dnl Versions for external dependencies
+LIBDRM_REQUIRED=2.4.24
+LIBDRM_RADEON_REQUIRED=2.4.24
+LIBDRM_INTEL_REQUIRED=2.4.24
+DRI2PROTO_REQUIRED=2.1
+GLPROTO_REQUIRED=1.4.11
+LIBDRM_XORG_REQUIRED=2.4.24
+LIBKMS_XORG_REQUIRED=1.0.0
+
+dnl Check for progs
+AC_PROG_CPP
+AC_PROG_CC
+AC_PROG_CXX
+AC_CHECK_PROGS([MAKE], [gmake make])
+AC_CHECK_PROGS([PYTHON2], [python2 python])
+AC_PATH_PROG([MKDEP], [makedepend])
+AC_PATH_PROG([SED], [sed])
+
+if test "x$MKDEP" = "x"; then
+ AC_MSG_ERROR([makedepend is required to build Mesa])
+fi
+
+dnl Our fallback install-sh is a symlink to minstall. Use the existing
+dnl configuration in that case.
+AC_PROG_INSTALL
+test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)'
+
+dnl We need a POSIX shell for parts of the build. Assume we have one
+dnl in most cases.
+case "$host_os" in
+solaris*)
+ # Solaris /bin/sh is too old/non-POSIX compliant
+ AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
+ SHELL="$POSIX_SHELL"
+ ;;
+esac
+
+dnl clang is mostly GCC-compatible, but its version is much lower,
+dnl so we have to check for it.
+AC_MSG_CHECKING([if compiling with clang])
+
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([], [[
+#ifndef __clang__
+ not clang
+#endif
+]])],
+[CLANG=yes], [CLANG=no])
+
+AC_MSG_RESULT([$CLANG])
+
+dnl If we're using GCC, make sure that it is at least version 3.3.0. Older
+dnl versions are explictly not supported.
+if test "x$GCC" = xyes -a "x$CLANG" = xno; then
+ AC_MSG_CHECKING([whether gcc version is sufficient])
+ major=0
+ minor=0
+
+ GCC_VERSION=`$CC -dumpversion`
+ if test $? -eq 0; then
+ major=`echo $GCC_VERSION | cut -d. -f1`
+ minor=`echo $GCC_VERSION | cut -d. -f1`
+ fi
+
+ if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+fi
+
+
+MKDEP_OPTIONS=-fdepend
+dnl Ask gcc where it's keeping its secret headers
+if test "x$GCC" = xyes; then
+ for dir in include include-fixed; do
+ GCC_INCLUDES=`$CC -print-file-name=$dir`
+ if test "x$GCC_INCLUDES" != x && \
+ test "$GCC_INCLUDES" != "$dir" && \
+ test -d "$GCC_INCLUDES"; then
+ MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
+ fi
+ done
+fi
+AC_SUBST([MKDEP_OPTIONS])
+
+dnl Make sure the pkg-config macros are defined
+m4_ifndef([PKG_PROG_PKG_CONFIG],
+ [m4_fatal([Could not locate the pkg-config autoconf macros.
+ These are usually located in /usr/share/aclocal/pkg.m4. If your macros
+ are in a different location, try setting the environment variable
+ ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
+PKG_PROG_PKG_CONFIG()
+
+dnl LIB_DIR - library basename
+LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
+AC_SUBST([LIB_DIR])
+
+dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
+_SAVE_LDFLAGS="$LDFLAGS"
+AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
+AC_SUBST([EXTRA_LIB_PATH])
+
+dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
+_SAVE_CPPFLAGS="$CPPFLAGS"
+AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
+AC_SUBST([X11_INCLUDES])
+
+dnl Compiler macros
+DEFINES=""
+AC_SUBST([DEFINES])
+case "$host_os" in
+linux*|*-gnu*|gnu*)
+ DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
+ ;;
+solaris*)
+ DEFINES="$DEFINES -DPTHREADS -DSVR4"
+ ;;
+cygwin*)
+ DEFINES="$DEFINES -DPTHREADS"
+ ;;
+esac
+
+dnl Add flags for gcc and g++
+if test "x$GCC" = xyes; then
+ CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99"
+ if test "x$CLANG" = "xno"; then
+ CFLAGS="$CFLAGS -ffast-math"
+ fi
+
+ # Enable -fvisibility=hidden if using a gcc that supports it
+ save_CFLAGS="$CFLAGS"
+ AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+ CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
+ [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
+
+ # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
+ CFLAGS=$save_CFLAGS
+
+ # Work around aliasing bugs - developers should comment this out
+ CFLAGS="$CFLAGS -fno-strict-aliasing"
+fi
+if test "x$GXX" = xyes; then
+ CXXFLAGS="$CXXFLAGS -Wall"
+
+ # Enable -fvisibility=hidden if using a gcc that supports it
+ save_CXXFLAGS="$CXXFLAGS"
+ AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
+ VISIBILITY_CXXFLAGS="-fvisibility=hidden"
+ CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
+ [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
+
+ # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
+ CXXFLAGS=$save_CXXFLAGS
+
+ # Work around aliasing bugs - developers should comment this out
+ CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+fi
+
+AC_SUBST([VISIBILITY_CFLAGS])
+AC_SUBST([VISIBILITY_CXXFLAGS])
+
+dnl These should be unnecessary, but let the user set them if they want
+AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
+ Default is to use CFLAGS.])
+AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
+ compiler. Default is to use CFLAGS.])
+AC_SUBST([OPT_FLAGS])
+AC_SUBST([ARCH_FLAGS])
+
+dnl
+dnl Hacks to enable 32 or 64 bit build
+dnl
+AC_ARG_ENABLE([32-bit],
+ [AS_HELP_STRING([--enable-32-bit],
+ [build 32-bit libraries @<:@default=auto@:>@])],
+ [enable_32bit="$enableval"],
+ [enable_32bit=auto]
+)
+if test "x$enable_32bit" = xyes; then
+ if test "x$GCC" = xyes; then
+ CFLAGS="$CFLAGS -m32"
+ ARCH_FLAGS="$ARCH_FLAGS -m32"
+ fi
+ if test "x$GXX" = xyes; then
+ CXXFLAGS="$CXXFLAGS -m32"
+ fi
+fi
+AC_ARG_ENABLE([64-bit],
+ [AS_HELP_STRING([--enable-64-bit],
+ [build 64-bit libraries @<:@default=auto@:>@])],
+ [enable_64bit="$enableval"],
+ [enable_64bit=auto]
+)
+if test "x$enable_64bit" = xyes; then
+ if test "x$GCC" = xyes; then
+ CFLAGS="$CFLAGS -m64"
+ fi
+ if test "x$GXX" = xyes; then
+ CXXFLAGS="$CXXFLAGS -m64"
+ fi
+fi
+
+dnl
+dnl shared/static libraries, mimic libtool options
+dnl
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static],
+ [build static libraries @<:@default=disabled@:>@])],
+ [enable_static="$enableval"],
+ [enable_static=no]
+)
+case "x$enable_static" in
+xyes|xno ) ;;
+x ) enable_static=no ;;
+* )
+ AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
+ ;;
+esac
+AC_ARG_ENABLE([shared],
+ [AS_HELP_STRING([--disable-shared],
+ [build shared libraries @<:@default=enabled@:>@])],
+ [enable_shared="$enableval"],
+ [enable_shared=yes]
+)
+case "x$enable_shared" in
+xyes|xno ) ;;
+x ) enable_shared=yes ;;
+* )
+ AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
+ ;;
+esac
+
+dnl Can't have static and shared libraries, default to static if user
+dnl explicitly requested. If both disabled, set to static since shared
+dnl was explicitly requirested.
+case "x$enable_static$enable_shared" in
+xyesyes )
+ AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
+ enable_shared=no
+ ;;
+xnono )
+ AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
+ enable_static=yes
+ ;;
+esac
+
+dnl
+dnl mklib options
+dnl
+AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
+if test "$enable_static" = yes; then
+ MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
+fi
+AC_SUBST([MKLIB_OPTIONS])
+
+dnl
+dnl other compiler options
+dnl
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug],
+ [use debug compiler flags and macros @<:@default=disabled@:>@])],
+ [enable_debug="$enableval"],
+ [enable_debug=no]
+)
+if test "x$enable_debug" = xyes; then
+ DEFINES="$DEFINES -DDEBUG"
+ if test "x$GCC" = xyes; then
+ CFLAGS="$CFLAGS -g"
+ fi
+ if test "x$GXX" = xyes; then
+ CXXFLAGS="$CXXFLAGS -g"
+ fi
+fi
+
+dnl
+dnl library names
+dnl
+LIB_PREFIX_GLOB='lib'
+LIB_VERSION_SEPARATOR='.'
+if test "$enable_static" = yes; then
+ LIB_EXTENSION='a'
+else
+ case "$host_os" in
+ darwin* )
+ LIB_EXTENSION='dylib' ;;
+ cygwin* )
+ dnl prefix can be 'cyg' or 'lib'
+ LIB_PREFIX_GLOB='???'
+ LIB_VERSION_SEPARATOR='-'
+ LIB_EXTENSION='dll' ;;
+ aix* )
+ LIB_EXTENSION='a' ;;
+ * )
+ LIB_EXTENSION='so' ;;
+ esac
+fi
+
+GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
+GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
+GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
+GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
+OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
+EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
+GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION}
+GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION}
+VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION}
+GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
+WAYLAND_EGL_LIB_NAME='lib$(WAYLAND_EGL_LIB).'${LIB_EXTENSION}
+
+GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLUT_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLUT_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLW_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLW_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+WAYLAND_EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(WAYLAND_EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+
+AC_SUBST([GL_LIB_NAME])
+AC_SUBST([GLU_LIB_NAME])
+AC_SUBST([GLUT_LIB_NAME])
+AC_SUBST([GLW_LIB_NAME])
+AC_SUBST([OSMESA_LIB_NAME])
+AC_SUBST([EGL_LIB_NAME])
+AC_SUBST([GLESv1_CM_LIB_NAME])
+AC_SUBST([GLESv2_LIB_NAME])
+AC_SUBST([VG_LIB_NAME])
+AC_SUBST([GLAPI_LIB_NAME])
+AC_SUBST([WAYLAND_EGL_LIB_NAME])
+
+AC_SUBST([GL_LIB_GLOB])
+AC_SUBST([GLU_LIB_GLOB])
+AC_SUBST([GLUT_LIB_GLOB])
+AC_SUBST([GLW_LIB_GLOB])
+AC_SUBST([OSMESA_LIB_GLOB])
+AC_SUBST([EGL_LIB_GLOB])
+AC_SUBST([GLESv1_CM_LIB_GLOB])
+AC_SUBST([GLESv2_LIB_GLOB])
+AC_SUBST([VG_LIB_GLOB])
+AC_SUBST([GLAPI_LIB_GLOB])
+AC_SUBST([WAYLAND_EGL_LIB_GLOB])
+
+dnl
+dnl Arch/platform-specific settings
+dnl
+AC_ARG_ENABLE([asm],
+ [AS_HELP_STRING([--disable-asm],
+ [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
+ [enable_asm="$enableval"],
+ [enable_asm=yes]
+)
+asm_arch=""
+ASM_FLAGS=""
+MESA_ASM_SOURCES=""
+GLAPI_ASM_SOURCES=""
+AC_MSG_CHECKING([whether to enable assembly])
+test "x$enable_asm" = xno && AC_MSG_RESULT([no])
+# disable if cross compiling on x86/x86_64 since we must run gen_matypes
+if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
+ case "$host_cpu" in
+ i?86 | x86_64)
+ enable_asm=no
+ AC_MSG_RESULT([no, cross compiling])
+ ;;
+ esac
+fi
+# check for supported arches
+if test "x$enable_asm" = xyes; then
+ case "$host_cpu" in
+ i?86)
+ case "$host_os" in
+ linux* | *freebsd* | dragonfly* | *netbsd*)
+ test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
+ ;;
+ esac
+ ;;
+ x86_64)
+ case "$host_os" in
+ linux* | *freebsd* | dragonfly* | *netbsd*)
+ test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
+ ;;
+ esac
+ ;;
+ powerpc)
+ case "$host_os" in
+ linux*)
+ asm_arch=ppc
+ ;;
+ esac
+ ;;
+ sparc*)
+ case "$host_os" in
+ linux*)
+ asm_arch=sparc
+ ;;
+ esac
+ ;;
+ esac
+
+ case "$asm_arch" in
+ x86)
+ ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
+ MESA_ASM_SOURCES='$(X86_SOURCES)'
+ GLAPI_ASM_SOURCES='$(X86_API)'
+ AC_MSG_RESULT([yes, x86])
+ ;;
+ x86_64)
+ ASM_FLAGS="-DUSE_X86_64_ASM"
+ MESA_ASM_SOURCES='$(X86-64_SOURCES)'
+ GLAPI_ASM_SOURCES='$(X86-64_API)'
+ AC_MSG_RESULT([yes, x86_64])
+ ;;
+ ppc)
+ ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
+ MESA_ASM_SOURCES='$(PPC_SOURCES)'
+ AC_MSG_RESULT([yes, ppc])
+ ;;
+ sparc)
+ ASM_FLAGS="-DUSE_SPARC_ASM"
+ MESA_ASM_SOURCES='$(SPARC_SOURCES)'
+ GLAPI_ASM_SOURCES='$(SPARC_API)'
+ AC_MSG_RESULT([yes, sparc])
+ ;;
+ *)
+ AC_MSG_RESULT([no, platform not supported])
+ ;;
+ esac
+fi
+AC_SUBST([ASM_FLAGS])
+AC_SUBST([MESA_ASM_SOURCES])
+AC_SUBST([GLAPI_ASM_SOURCES])
+
+dnl PIC code macro
+MESA_PIC_FLAGS
+
+dnl Check to see if dlopen is in default libraries (like Solaris, which
+dnl has it in libc), or if libdl is needed to get it.
+AC_CHECK_FUNC([dlopen], [],
+ [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
+AC_SUBST([DLOPEN_LIBS])
+
+dnl See if posix_memalign is available
+AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
+
+dnl SELinux awareness.
+AC_ARG_ENABLE([selinux],
+ [AS_HELP_STRING([--enable-selinux],
+ [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
+ [MESA_SELINUX="$enableval"],
+ [MESA_SELINUX=no])
+if test "x$enable_selinux" = "xyes"; then
+ AC_CHECK_HEADER([selinux/selinux.h],[],
+ [AC_MSG_ERROR([SELinux headers not found])])
+ AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
+ [AC_MSG_ERROR([SELinux library not found])])
+ SELINUX_LIBS="-lselinux"
+ DEFINES="$DEFINES -DMESA_SELINUX"
+fi
+
+dnl Determine which APIs to support
+AC_ARG_ENABLE([opengl],
+ [AS_HELP_STRING([--disable-opengl],
+ [disable support for standard OpenGL API @<:@default=no@:>@])],
+ [enable_opengl="$enableval"],
+ [enable_opengl=yes])
+AC_ARG_ENABLE([gles1],
+ [AS_HELP_STRING([--enable-gles1],
+ [enable support for OpenGL ES 1.x API @<:@default=no@:>@])],
+ [enable_gles1="$enableval"],
+ [enable_gles1=no])
+AC_ARG_ENABLE([gles2],
+ [AS_HELP_STRING([--enable-gles2],
+ [enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
+ [enable_gles2="$enableval"],
+ [enable_gles2=no])
+AC_ARG_ENABLE([gles-overlay],
+ [AS_HELP_STRING([--enable-gles-overlay],
+ [DEPRECATED. Same as --enable-gles1 and --enable-gles2])],
+ [enable_gles1="$enableval"; enable_gles2="$enableval"],
+ [])
+
+AC_ARG_ENABLE([openvg],
+ [AS_HELP_STRING([--enable-openvg],
+ [enable support for OpenVG API @<:@default=no@:>@])],
+ [enable_openvg="$enableval"],
+ [enable_openvg=no])
+
+dnl smooth the transition; should be removed eventually
+if test "x$enable_openvg" = xno; then
+ case "x$with_state_trackers" in
+ x*vega*)
+ AC_MSG_WARN([vega state tracker is enabled without --enable-openvg])
+ enable_openvg=yes
+ ;;
+ esac
+fi
+
+if test "x$enable_opengl" = xno -a \
+ "x$enable_gles1" = xno -a \
+ "x$enable_gles2" = xno -a \
+ "x$enable_openvg" = xno; then
+ AC_MSG_ERROR([at least one API should be enabled])
+fi
+
+API_DEFINES=""
+if test "x$enable_opengl" = xno; then
+ API_DEFINES="$API_DEFINES -DFEATURE_GL=0"
+else
+ API_DEFINES="$API_DEFINES -DFEATURE_GL=1"
+fi
+if test "x$enable_gles1" = xyes; then
+ API_DEFINES="$API_DEFINES -DFEATURE_ES1=1"
+fi
+if test "x$enable_gles2" = xyes; then
+ API_DEFINES="$API_DEFINES -DFEATURE_ES2=1"
+fi
+AC_SUBST([API_DEFINES])
+
+AC_ARG_ENABLE([shared-glapi],
+ [AS_HELP_STRING([--enable-shared-glapi],
+ [EXPERIMENTAL. Enable shared glapi for OpenGL @<:@default=no@:>@])],
+ [enable_shared_glapi="$enableval"],
+ [enable_shared_glapi=no])
+
+SHARED_GLAPI="0"
+if test "x$enable_shared_glapi" = xyes; then
+ SHARED_GLAPI="1"
+fi
+AC_SUBST([SHARED_GLAPI])
+
+dnl
+dnl Driver configuration. Options are xlib, dri and osmesa right now.
+dnl More later: fbdev, ...
+dnl
+default_driver="xlib"
+
+case "$host_os" in
+linux*)
+ case "$host_cpu" in
+ i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
+ esac
+ ;;
+*freebsd* | dragonfly* | *netbsd*)
+ case "$host_cpu" in
+ i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
+ esac
+ ;;
+esac
+
+if test "x$enable_opengl" = xno; then
+ default_driver="no"
+fi
+
+AC_ARG_WITH([driver],
+ [AS_HELP_STRING([--with-driver=DRIVER],
+ [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
+ [mesa_driver="$withval"],
+ [mesa_driver="$default_driver"])
+dnl Check for valid option
+case "x$mesa_driver" in
+xxlib|xdri|xosmesa)
+ if test "x$enable_opengl" = xno; then
+ AC_MSG_ERROR([Driver '$mesa_driver' requires OpenGL enabled])
+ fi
+ ;;
+xno)
+ ;;
+*)
+ AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
+ ;;
+esac
+
+dnl
+dnl Driver specific build directories
+dnl
+
+dnl this variable will be prepended to SRC_DIRS and is not exported
+CORE_DIRS=""
+
+SRC_DIRS=""
+GLU_DIRS="sgi"
+GALLIUM_DIRS="auxiliary drivers state_trackers"
+GALLIUM_TARGET_DIRS=""
+GALLIUM_WINSYS_DIRS="sw"
+GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity"
+GALLIUM_STATE_TRACKERS_DIRS=""
+
+# build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
+case "x$enable_shared_glapi$enable_gles1$enable_gles2" in
+x*yes*)
+ CORE_DIRS="$CORE_DIRS mapi/shared-glapi"
+ ;;
+esac
+
+# build glapi if OpenGL is enabled
+if test "x$enable_opengl" = xyes; then
+ CORE_DIRS="$CORE_DIRS mapi/glapi"
+fi
+
+# build es1api if OpenGL ES 1.x is enabled
+if test "x$enable_gles1" = xyes; then
+ CORE_DIRS="$CORE_DIRS mapi/es1api"
+fi
+
+# build es2api if OpenGL ES 2.x is enabled
+if test "x$enable_gles2" = xyes; then
+ CORE_DIRS="$CORE_DIRS mapi/es2api"
+fi
+
+# build vgapi if OpenVG is enabled
+if test "x$enable_openvg" = xyes; then
+ CORE_DIRS="$CORE_DIRS mapi/vgapi"
+fi
+
+# build glsl and mesa if OpenGL or OpenGL ES is enabled
+case "x$enable_opengl$enable_gles1$enable_gles2" in
+x*yes*)
+ CORE_DIRS="$CORE_DIRS glsl mesa"
+ ;;
+esac
+
+case "$mesa_driver" in
+xlib)
+ DRIVER_DIRS="x11"
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
+ ;;
+dri)
+ SRC_DIRS="$SRC_DIRS glx"
+ DRIVER_DIRS="dri"
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri"
+ ;;
+osmesa)
+ DRIVER_DIRS="osmesa"
+ ;;
+no)
+ DRIVER_DRIS=""
+ ;;
+esac
+AC_SUBST([SRC_DIRS])
+AC_SUBST([GLU_DIRS])
+AC_SUBST([DRIVER_DIRS])
+AC_SUBST([GALLIUM_DIRS])
+AC_SUBST([GALLIUM_TARGET_DIRS])
+AC_SUBST([GALLIUM_WINSYS_DIRS])
+AC_SUBST([GALLIUM_DRIVERS_DIRS])
+AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
+AC_SUBST([MESA_LLVM])
+
+dnl
+dnl Find out if X is available. The variable have_x is set if libX11 is
+dnl found to mimic AC_PATH_XTRA.
+dnl
+if test -n "$PKG_CONFIG"; then
+ AC_MSG_CHECKING([pkg-config files for X11 are available])
+ PKG_CHECK_EXISTS([x11],[
+ x11_pkgconfig=yes
+ have_x=yes
+ ],[
+ x11_pkgconfig=no
+ ])
+ AC_MSG_RESULT([$x11_pkgconfig])
+else
+ x11_pkgconfig=no
+fi
+dnl Use the autoconf macro if no pkg-config files
+if test "$x11_pkgconfig" = yes; then
+ PKG_CHECK_MODULES([X11], [x11])
+else
+ AC_PATH_XTRA
+ test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS"
+ test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11"
+ AC_SUBST([X11_CFLAGS])
+ AC_SUBST([X11_LIBS])
+fi
+
+dnl Try to tell the user that the --x-* options are only used when
+dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
+m4_divert_once([HELP_BEGIN],
+[These options are only used when the X libraries cannot be found by the
+pkg-config utility.])
+
+dnl We need X for xlib and dri, so bomb now if it's not found
+case "$mesa_driver" in
+xlib|dri)
+ if test "$no_x" = yes; then
+ AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
+ fi
+ ;;
+esac
+
+dnl XCB - this is only used for GLX right now
+AC_ARG_ENABLE([xcb],
+ [AS_HELP_STRING([--enable-xcb],
+ [use XCB for GLX @<:@default=disabled@:>@])],
+ [enable_xcb="$enableval"],
+ [enable_xcb=no])
+if test "x$enable_xcb" = xyes; then
+ DEFINES="$DEFINES -DUSE_XCB"
+else
+ enable_xcb=no
+fi
+
+dnl
+dnl libGL configuration per driver
+dnl
+case "$mesa_driver" in
+xlib)
+ if test "$x11_pkgconfig" = yes; then
+ PKG_CHECK_MODULES([XLIBGL], [x11 xext])
+ GL_PC_REQ_PRIV="x11 xext"
+ X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
+ GL_LIB_DEPS="$XLIBGL_LIBS"
+ else
+ # should check these...
+ X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
+ GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
+ GL_PC_LIB_PRIV="$GL_LIB_DEPS"
+ GL_PC_CFLAGS="$X11_INCLUDES"
+ fi
+ GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
+ GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
+
+ # if static, move the external libraries to the programs
+ # and empty the libraries for libGL
+ if test "$enable_static" = yes; then
+ APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
+ GL_LIB_DEPS=""
+ fi
+ ;;
+dri|no) # these checks are still desired when there is no mesa_driver
+ # DRI must be shared, I think
+ if test "$enable_static" = yes; then
+ AC_MSG_ERROR([Can't use static libraries for DRI drivers])
+ fi
+
+ # Check for libdrm
+ PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
+ PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
+ PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
+ GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED"
+ DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
+
+ # find the DRI deps for libGL
+ if test "$x11_pkgconfig" = yes; then
+ dri_modules="x11 xext xdamage xfixes"
+
+ # add xf86vidmode if available
+ PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
+ if test "$HAVE_XF86VIDMODE" = yes ; then
+ dri_modules="$dri_modules xxf86vm"
+ fi
+
+ # add xcb modules if necessary
+ if test "$enable_xcb" = yes; then
+ dri_modules="$dri_modules x11-xcb xcb-glx"
+ fi
+
+ PKG_CHECK_MODULES([DRIGL], [$dri_modules])
+ GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
+ X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
+ GL_LIB_DEPS="$DRIGL_LIBS"
+ else
+ # should check these...
+ X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
+ GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
+ GL_PC_LIB_PRIV="$GL_LIB_DEPS"
+ GL_PC_CFLAGS="$X11_INCLUDES"
+
+ # XCB can only be used from pkg-config
+ if test "$enable_xcb" = yes; then
+ PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
+ GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
+ X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
+ GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
+ fi
+ fi
+
+ # need DRM libs, -lpthread, etc.
+ GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+ GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
+ GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+ GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
+ GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+ GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
+ ;;
+osmesa)
+ # No libGL for osmesa
+ GL_LIB_DEPS=""
+ ;;
+esac
+AC_SUBST([GL_LIB_DEPS])
+AC_SUBST([GL_PC_REQ_PRIV])
+AC_SUBST([GL_PC_LIB_PRIV])
+AC_SUBST([GL_PC_CFLAGS])
+AC_SUBST([DRI_PC_REQ_PRIV])
+AC_SUBST([GLESv1_CM_LIB_DEPS])
+AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
+AC_SUBST([GLESv2_LIB_DEPS])
+AC_SUBST([GLESv2_PC_LIB_PRIV])
+
+GLAPI_LIB_DEPS="-lpthread"
+AC_SUBST([GLAPI_LIB_DEPS])
+
+
+dnl Setup default DRI CFLAGS
+DRI_CFLAGS='$(CFLAGS)'
+DRI_CXXFLAGS='$(CXXFLAGS)'
+DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
+MESA_MODULES='$(TOP)/src/mesa/libmesa.a'
+
+AC_ARG_ENABLE([shared-dricore],
+ [AS_HELP_STRING([--enable-shared-dricore],
+ [link DRI modules with shared core DRI routines @<:@default=disabled@:>@])],
+ [enable_dricore="$enableval"],
+ [enable_dricore=no])
+if test "$mesa_driver" = dri ; then
+ if test "$enable_dricore" = yes ; then
+ if test "$GCC$GXX" != yesyes ; then
+ AC_MSG_WARN([Shared dricore requires GCC-compatible rpath handling. Disabling shared dricore])
+ enable_dricore=no
+ else
+ DRICORE_GLSL_LIBS='$(TOP)/$(LIB_DIR)/libglsl.so'
+ DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so'
+ DRICORE_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -lglsl'
+ DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore -lglsl'
+ DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE'
+ DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE'
+ MESA_MODULES='$(DRICORE_LIBS) $(DRICORE_GLSL_LIBS)'
+ fi
+ fi
+fi
+AC_SUBST([DRICORE_LIBS])
+AC_SUBST([DRICORE_GLSL_LIBS])
+AC_SUBST([DRICORE_LIB_DEPS])
+AC_SUBST([DRI_CXXFLAGS])
+AC_SUBST([DRI_CFLAGS])
+AC_SUBST([MESA_MODULES])
+
+AC_SUBST([HAVE_XF86VIDMODE])
+
+PKG_CHECK_MODULES([LIBDRM_RADEON],
+ [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
+ HAVE_LIBDRM_RADEON=yes,
+ HAVE_LIBDRM_RADEON=no)
+
+dnl
+dnl More X11 setup
+dnl
+if test "$mesa_driver" = xlib; then
+ DEFINES="$DEFINES -DUSE_XSHM"
+fi
+
+dnl
+dnl TLS detection
+dnl
+
+AC_ARG_ENABLE([glx-tls],
+ [AS_HELP_STRING([--enable-glx-tls],
+ [enable TLS support in GLX @<:@default=disabled@:>@])],
+ [GLX_USE_TLS="$enableval"],
+ [GLX_USE_TLS=no])
+AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
+
+AS_IF([test "x$GLX_USE_TLS" = xyes],
+ [DEFINES="${DEFINES} -DGLX_USE_TLS -DPTHREADS"])
+
+dnl
+dnl More DRI setup
+dnl
+dnl Directory for DRI drivers
+AC_ARG_WITH([dri-driverdir],
+ [AS_HELP_STRING([--with-dri-driverdir=DIR],
+ [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
+ [DRI_DRIVER_INSTALL_DIR="$withval"],
+ [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
+AC_SUBST([DRI_DRIVER_INSTALL_DIR])
+dnl Extra search path for DRI drivers
+AC_ARG_WITH([dri-searchpath],
+ [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
+ [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
+ [DRI_DRIVER_SEARCH_DIR="$withval"],
+ [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
+AC_SUBST([DRI_DRIVER_SEARCH_DIR])
+dnl Direct rendering or just indirect rendering
+AC_ARG_ENABLE([driglx-direct],
+ [AS_HELP_STRING([--disable-driglx-direct],
+ [enable direct rendering in GLX and EGL for DRI @<:@default=enabled@:>@])],
+ [driglx_direct="$enableval"],
+ [driglx_direct="yes"])
+dnl Which drivers to build - default is chosen by platform
+AC_ARG_WITH([dri-drivers],
+ [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
+ [comma delimited DRI drivers list, e.g.
+ "swrast,i965,radeon" @<:@default=auto@:>@])],
+ [with_dri_drivers="$withval"],
+ [with_dri_drivers=yes])
+if test "x$with_dri_drivers" = x; then
+ with_dri_drivers=no
+fi
+
+dnl If $with_dri_drivers is yes, directories will be added through
+dnl platform checks
+DRI_DIRS=""
+case "$with_dri_drivers" in
+no) ;;
+yes)
+ DRI_DIRS="yes"
+ ;;
+*)
+ # verify the requested driver directories exist
+ dri_drivers=`IFS=', '; echo $with_dri_drivers`
+ for driver in $dri_drivers; do
+ test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
+ AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
+ done
+ DRI_DIRS="$dri_drivers"
+ ;;
+esac
+
+dnl Set DRI_DIRS, DEFINES and LIB_DEPS
+if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
+ # Platform specific settings and drivers to build
+ case "$host_os" in
+ linux*)
+ DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+ if test "x$driglx_direct" = xyes; then
+ DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+ fi
+ DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
+
+ case "$host_cpu" in
+ x86_64)
+ # sis is missing because they have not be converted to use
+ # the new interface. i810 are missing because there is no
+ # x86-64 system where they could *ever* be used.
+ if test "x$DRI_DIRS" = "xyes"; then
+ DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \
+ savage tdfx unichrome swrast"
+ fi
+ ;;
+ powerpc*)
+ # Build only the drivers for cards that exist on PowerPC.
+ # At some point MGA will be added, but not yet.
+ if test "x$DRI_DIRS" = "xyes"; then
+ DRI_DIRS="mach64 r128 r200 r300 r600 radeon tdfx swrast"
+ fi
+ ;;
+ sparc*)
+ # Build only the drivers for cards that exist on sparc`
+ if test "x$DRI_DIRS" = "xyes"; then
+ DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast"
+ fi
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly* | *netbsd*)
+ DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
+ DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
+ DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+ if test "x$driglx_direct" = xyes; then
+ DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+ fi
+
+ if test "x$DRI_DIRS" = "xyes"; then
+ DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \
+ unichrome savage sis swrast"
+ fi
+ ;;
+ gnu*)
+ DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+ DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
+ ;;
+ solaris*)
+ DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+ DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+ if test "x$driglx_direct" = xyes; then
+ DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+ fi
+ ;;
+ esac
+
+ # default drivers
+ if test "x$DRI_DIRS" = "xyes"; then
+ DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
+ savage sis tdfx unichrome swrast"
+ fi
+
+ DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
+
+ # Check for expat
+ if test "$mesa_driver" = dri; then
+ EXPAT_INCLUDES=""
+ EXPAT_LIB=-lexpat
+ AC_ARG_WITH([expat],
+ [AS_HELP_STRING([--with-expat=DIR],
+ [expat install directory])],[
+ EXPAT_INCLUDES="-I$withval/include"
+ CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
+ LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
+ EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
+ ])
+ AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
+ AC_CHECK_LIB([expat],[XML_ParserCreate],[],
+ [AC_MSG_ERROR([Expat required for DRI.])])
+ fi
+
+ # put all the necessary libs together, including possibly libdricore
+ DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
+fi
+AC_SUBST([DRI_DIRS])
+AC_SUBST([EXPAT_INCLUDES])
+AC_SUBST([DRI_LIB_DEPS])
+
+case $DRI_DIRS in
+*i915*|*i965*)
+ PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
+ ;;
+esac
+
+case $DRI_DIRS in
+*radeon*|*r200*|*r300*|*r600*)
+ if test "x$HAVE_LIBDRM_RADEON" = xyes; then
+ RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
+ RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
+ fi
+ ;;
+esac
+AC_SUBST([RADEON_CFLAGS])
+AC_SUBST([RADEON_LDFLAGS])
+
+
+dnl
+dnl OSMesa configuration
+dnl
+if test "$mesa_driver" = xlib; then
+ default_gl_osmesa=yes
+else
+ default_gl_osmesa=no
+fi
+AC_ARG_ENABLE([gl-osmesa],
+ [AS_HELP_STRING([--enable-gl-osmesa],
+ [enable OSMesa with libGL @<:@default=enabled for xlib driver@:>@])],
+ [gl_osmesa="$enableval"],
+ [gl_osmesa="$default_gl_osmesa"])
+if test "x$gl_osmesa" = xyes; then
+ if test "x$enable_opengl" = xno; then
+ AC_MSG_ERROR([OpenGL is not available for OSMesa driver])
+ fi
+ if test "$mesa_driver" = osmesa; then
+ AC_MSG_ERROR([libGL is not available for OSMesa driver])
+ else
+ DRIVER_DIRS="$DRIVER_DIRS osmesa"
+ fi
+fi
+
+dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
+AC_ARG_WITH([osmesa-bits],
+ [AS_HELP_STRING([--with-osmesa-bits=BITS],
+ [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
+ [osmesa_bits="$withval"],
+ [osmesa_bits=8])
+if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
+ AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
+ osmesa_bits=8
+fi
+case "x$osmesa_bits" in
+x8)
+ OSMESA_LIB=OSMesa
+ ;;
+x16|x32)
+ OSMESA_LIB="OSMesa$osmesa_bits"
+ DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
+ ;;
+*)
+ AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
+ ;;
+esac
+AC_SUBST([OSMESA_LIB])
+
+case "$DRIVER_DIRS" in
+*osmesa*)
+ # only link libraries with osmesa if shared
+ if test "$enable_static" = no; then
+ OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
+ else
+ OSMESA_LIB_DEPS=""
+ fi
+ OSMESA_MESA_DEPS=""
+ OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
+ ;;
+esac
+AC_SUBST([OSMESA_LIB_DEPS])
+AC_SUBST([OSMESA_MESA_DEPS])
+AC_SUBST([OSMESA_PC_REQ])
+AC_SUBST([OSMESA_PC_LIB_PRIV])
+
+dnl
+dnl EGL configuration
+dnl
+AC_ARG_ENABLE([egl],
+ [AS_HELP_STRING([--disable-egl],
+ [disable EGL library @<:@default=enabled@:>@])],
+ [enable_egl="$enableval"],
+ [enable_egl=yes])
+if test "x$enable_egl" = xno; then
+ if test "x$mesa_driver" = xno; then
+ AC_MSG_ERROR([cannot disable EGL when there is no mesa driver])
+ fi
+ if test "x$enable_openvg" = xyes; then
+ AC_MSG_ERROR([cannot enable OpenVG without EGL])
+ fi
+fi
+if test "x$enable_egl" = xyes; then
+ SRC_DIRS="$SRC_DIRS egl"
+ EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread"
+ EGL_DRIVERS_DIRS=""
+ if test "$enable_static" != yes; then
+ # build egl_glx when libGL is built
+ if test "$mesa_driver" = xlib -o "$mesa_driver" = dri; then
+ EGL_DRIVERS_DIRS="glx"
+ fi
+
+ if test "$mesa_driver" = dri; then
+ # build egl_dri2 when xcb-dri2 is available
+ PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
+ [have_xcb_dri2=yes],[have_xcb_dri2=no])
+ PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
+ [have_libudev=yes],[have_libudev=no])
+
+ if test "$have_xcb_dri2" = yes; then
+ EGL_DRIVER_DRI2=dri2
+ DEFINES="$DEFINES -DHAVE_XCB_DRI2"
+ if test "$have_libudev" = yes; then
+ DEFINES="$DEFINES -DHAVE_LIBUDEV"
+ fi
+ # workaround a bug in xcb-dri2 generated by xcb-proto 1.6
+ AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
+ [DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"])
+ fi
+ fi
+
+ EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS $EGL_DRIVER_DRI2"
+ fi
+fi
+AC_SUBST([EGL_LIB_DEPS])
+AC_SUBST([EGL_DRIVERS_DIRS])
+
+dnl
+dnl GLU configuration
+dnl
+AC_ARG_ENABLE([glu],
+ [AS_HELP_STRING([--disable-glu],
+ [enable OpenGL Utility library @<:@default=enabled@:>@])],
+ [enable_glu="$enableval"],
+ [enable_glu=yes])
+
+if test "x$enable_glu" = xyes -a "x$mesa_driver" = xno; then
+ AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
+ enable_glu=no
+fi
+
+if test "x$enable_glu" = xyes; then
+ SRC_DIRS="$SRC_DIRS glu"
+
+ case "$mesa_driver" in
+ osmesa)
+ # Link libGLU to libOSMesa instead of libGL
+ GLU_LIB_DEPS=""
+ GLU_PC_REQ="osmesa"
+ if test "$enable_static" = no; then
+ GLU_MESA_DEPS='-l$(OSMESA_LIB)'
+ else
+ GLU_MESA_DEPS=""
+ fi
+ ;;
+ *)
+ # If static, empty GLU_LIB_DEPS and add libs for programs to link
+ GLU_PC_REQ="gl"
+ GLU_PC_LIB_PRIV="-lm"
+ if test "$enable_static" = no; then
+ GLU_LIB_DEPS="-lm"
+ GLU_MESA_DEPS='-l$(GL_LIB)'
+ else
+ GLU_LIB_DEPS=""
+ GLU_MESA_DEPS=""
+ APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
+ fi
+ ;;
+ esac
+fi
+if test "$enable_static" = no; then
+ GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
+fi
+GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
+AC_SUBST([GLU_LIB_DEPS])
+AC_SUBST([GLU_MESA_DEPS])
+AC_SUBST([GLU_PC_REQ])
+AC_SUBST([GLU_PC_REQ_PRIV])
+AC_SUBST([GLU_PC_LIB_PRIV])
+AC_SUBST([GLU_PC_CFLAGS])
+
+dnl
+dnl GLw configuration
+dnl
+AC_ARG_ENABLE([glw],
+ [AS_HELP_STRING([--disable-glw],
+ [enable Xt/Motif widget library @<:@default=enabled@:>@])],
+ [enable_glw="$enableval"],
+ [enable_glw=yes])
+dnl Don't build GLw on osmesa
+if test "x$enable_glw" = xyes; then
+ case "$mesa_driver" in
+ osmesa|no)
+ AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver])
+ enable_glw=no
+ ;;
+ esac
+fi
+AC_ARG_ENABLE([motif],
+ [AS_HELP_STRING([--enable-motif],
+ [use Motif widgets in GLw @<:@default=disabled@:>@])],
+ [enable_motif="$enableval"],
+ [enable_motif=no])
+
+if test "x$enable_glw" = xyes; then
+ SRC_DIRS="$SRC_DIRS glw"
+ if test "$x11_pkgconfig" = yes; then
+ PKG_CHECK_MODULES([GLW],[x11 xt])
+ GLW_PC_REQ_PRIV="x11 xt"
+ GLW_LIB_DEPS="$GLW_LIBS"
+ else
+ # should check these...
+ GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
+ GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
+ GLW_PC_CFLAGS="$X11_INCLUDES"
+ fi
+
+ GLW_SOURCES="GLwDrawA.c"
+ MOTIF_CFLAGS=
+ if test "x$enable_motif" = xyes; then
+ GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
+ AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
+ if test "x$MOTIF_CONFIG" != xno; then
+ MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
+ MOTIF_LIBS=`$MOTIF_CONFIG --libs`
+ else
+ AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
+ [AC_MSG_ERROR([Can't locate Motif headers])])
+ AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
+ [AC_MSG_ERROR([Can't locate Motif Xm library])])
+ fi
+ # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
+ GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
+ GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
+ GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
+ fi
+
+ # If static, empty GLW_LIB_DEPS and add libs for programs to link
+ GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV"
+ if test "$enable_static" = no; then
+ GLW_MESA_DEPS='-l$(GL_LIB)'
+ GLW_LIB_DEPS="$GLW_LIB_DEPS"
+ else
+ APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
+ GLW_LIB_DEPS=""
+ GLW_MESA_DEPS=""
+ fi
+fi
+AC_SUBST([GLW_LIB_DEPS])
+AC_SUBST([GLW_MESA_DEPS])
+AC_SUBST([GLW_SOURCES])
+AC_SUBST([MOTIF_CFLAGS])
+AC_SUBST([GLW_PC_REQ_PRIV])
+AC_SUBST([GLW_PC_LIB_PRIV])
+AC_SUBST([GLW_PC_CFLAGS])
+
+dnl
+dnl GLUT configuration
+dnl
+if test -f "$srcdir/include/GL/glut.h"; then
+ default_glut=yes
+else
+ default_glut=no
+fi
+AC_ARG_ENABLE([glut],
+ [AS_HELP_STRING([--disable-glut],
+ [enable GLUT library @<:@default=enabled if source available@:>@])],
+ [enable_glut="$enableval"],
+ [enable_glut="$default_glut"])
+
+dnl Don't build glut on osmesa
+if test "x$enable_glut" = xyes; then
+ case "$mesa_driver" in
+ osmesa|no)
+ AC_MSG_NOTICE([Disabling glut since there is no OpenGL driver])
+ enable_glut=no
+ ;;
+ esac
+fi
+dnl Can't build glut if GLU not available
+if test "x$enable_glu$enable_glut" = xnoyes; then
+ AC_MSG_WARN([Disabling glut since GLU is disabled])
+ enable_glut=no
+fi
+
+if test "x$enable_glut" = xyes; then
+ SRC_DIRS="$SRC_DIRS glut/glx"
+ if test "$x11_pkgconfig" = yes; then
+ PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
+ GLUT_PC_REQ_PRIV="x11 xmu xi"
+ GLUT_LIB_DEPS="$GLUT_LIBS"
+ else
+ # should check these...
+ GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
+ GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
+ GLUT_PC_CFLAGS="$X11_INCLUDES"
+ fi
+ if test "x$GCC" = xyes; then
+ GLUT_CFLAGS="$GLUT_CFLAGS -fexceptions"
+ fi
+ GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
+ GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm"
+
+ # If static, empty GLUT_LIB_DEPS and add libs for programs to link
+ if test "$enable_static" = no; then
+ GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
+ else
+ APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
+ GLUT_LIB_DEPS=""
+ GLUT_MESA_DEPS=""
+ fi
+fi
+AC_SUBST([GLUT_LIB_DEPS])
+AC_SUBST([GLUT_MESA_DEPS])
+AC_SUBST([GLUT_CFLAGS])
+AC_SUBST([GLUT_PC_REQ_PRIV])
+AC_SUBST([GLUT_PC_LIB_PRIV])
+AC_SUBST([GLUT_PC_CFLAGS])
+
+dnl
+dnl Program library dependencies
+dnl Only libm is added here if necessary as the libraries should
+dnl be pulled in by the linker
+dnl
+if test "x$APP_LIB_DEPS" = x; then
+ case "$host_os" in
+ solaris*)
+ APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
+ ;;
+ cygwin*)
+ APP_LIB_DEPS="-lX11"
+ ;;
+ *)
+ APP_LIB_DEPS="-lm"
+ ;;
+ esac
+fi
+AC_SUBST([APP_LIB_DEPS])
+AC_SUBST([PROGRAM_DIRS])
+
+dnl
+dnl Gallium configuration
+dnl
+AC_ARG_ENABLE([gallium],
+ [AS_HELP_STRING([--disable-gallium],
+ [build gallium @<:@default=enabled@:>@])],
+ [enable_gallium="$enableval"],
+ [enable_gallium=yes])
+if test "x$enable_gallium" = xno -a "x$enable_openvg" = xyes; then
+ AC_MSG_ERROR([cannot enable OpenVG without Gallium])
+fi
+if test "x$enable_gallium" = xyes; then
+ SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
+ AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
+fi
+
+AC_SUBST([LLVM_CFLAGS])
+AC_SUBST([LLVM_LIBS])
+AC_SUBST([LLVM_LDFLAGS])
+AC_SUBST([LLVM_VERSION])
+
+dnl
+dnl Gallium state trackers configuration
+dnl
+
+AC_ARG_ENABLE([gallium-egl],
+ [AS_HELP_STRING([--enable-gallium-egl],
+ [enable gallium EGL state tracker @<:@default=auto@:>@])],
+ [enable_gallium_egl="$enableval"],
+ [enable_gallium_egl=auto])
+if test "x$enable_gallium_egl" = xauto; then
+ case "$mesa_driver" in
+ dri|no)
+ enable_gallium_egl=$enable_egl
+ ;;
+ *)
+ enable_gallium_egl=$enable_openvg
+ ;;
+ esac
+fi
+case "x$enable_egl$enable_gallium_egl" in
+xnoyes)
+ AC_MSG_ERROR([cannot build Gallium EGL state tracker without EGL])
+esac
+
+AC_ARG_WITH([state-trackers],
+ [AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
+ [comma delimited state_trackers list, e.g.
+ "egl,glx" @<:@default=auto@:>@])],
+ [with_state_trackers="$withval"],
+ [with_state_trackers=yes])
+
+case "$with_state_trackers" in
+no)
+ GALLIUM_STATE_TRACKERS_DIRS=""
+ ;;
+yes)
+ # look at what else is built
+ case "$mesa_driver" in
+ xlib)
+ GALLIUM_STATE_TRACKERS_DIRS=glx
+ ;;
+ dri)
+ GALLIUM_STATE_TRACKERS_DIRS="dri"
+ HAVE_ST_DRI="yes"
+ # Have only tested st/xorg on 1.6.0 servers
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED],
+ HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
+ HAVE_ST_XORG="no")
+ ;;
+ esac
+
+ if test "x$enable_egl" = xyes; then
+ if test "$enable_openvg" = yes; then
+ GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vega"
+ st_egl="yes"
+ fi
+
+ if test "$enable_gallium_egl" = yes; then
+ GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
+ HAVE_ST_EGL="yes"
+ fi
+ fi
+ ;;
+*)
+ # verify the requested state tracker exist
+ state_trackers=""
+ _state_trackers=`IFS=', '; echo $with_state_trackers`
+ for tracker in $_state_trackers; do
+ case "$tracker" in
+ dri)
+ if test "x$mesa_driver" != xdri; then
+ AC_MSG_ERROR([cannot build dri state tracker without mesa driver set to dri])
+ fi
+ HAVE_ST_DRI="yes"
+ ;;
+ egl)
+ if test "x$enable_egl" != xyes; then
+ AC_MSG_ERROR([cannot build egl state tracker without EGL library])
+ fi
+ HAVE_ST_EGL="yes"
+ ;;
+ xorg)
+ PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0])
+ PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
+ PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
+ HAVE_ST_XORG="yes"
+ ;;
+ vega)
+ if test "x$enable_openvg" != xyes; then
+ AC_MSG_ERROR([cannot build vega state tracker without --enable-openvg])
+ fi
+ have_st_vega="yes"
+ ;;
+ esac
+
+ if test -n "$tracker"; then
+ test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
+ AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
+ if test -n "$state_trackers"; then
+ state_trackers="$state_trackers $tracker"
+ else
+ state_trackers="$tracker"
+ fi
+ fi
+ done
+ GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
+
+ # append --enable-openvg/--enable-gallium-egl to --with-state-trackers
+ if test "x$have_st_vega" != xyes -a "x$enable_openvg" = xyes; then
+ AC_MSG_ERROR([--with-state-trackers specified but vega is missing])
+ fi
+ if test "x$HAVE_ST_EGL" != xyes -a "x$enable_gallium_egl" = xyes; then
+ AC_MSG_ERROR([--with-state-trackers specified but egl is missing])
+ fi
+ ;;
+esac
+
+
+EGL_CLIENT_APIS=""
+VG_LIB_DEPS=""
+
+case "x$enable_opengl$enable_gles1$enable_gles2" in
+x*yes*)
+ EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)'
+ ;;
+esac
+if test "x$enable_openvg" = xyes; then
+ EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
+ VG_LIB_DEPS="$VG_LIB_DEPS -lpthread"
+fi
+
+AC_SUBST([VG_LIB_DEPS])
+AC_SUBST([EGL_CLIENT_APIS])
+
+if test "x$HAVE_ST_EGL" = xyes; then
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl"
+fi
+
+if test "x$HAVE_ST_XORG" = xyes; then
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
+ HAVE_XEXTPROTO_71="no")
+fi
+
+AC_ARG_WITH([egl-platforms],
+ [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
+ [comma delimited native platforms libEGL supports, e.g.
+ "x11,drm" @<:@default=auto@:>@])],
+ [with_egl_platforms="$withval"],
+ [with_egl_platforms=yes])
+AC_ARG_WITH([egl-displays],
+ [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@],
+ [DEPRECATED. Use --with-egl-platforms instead])],
+ [with_egl_platforms="$withval"])
+
+EGL_PLATFORMS=""
+WAYLAND_EGL_LIB_DEPS=""
+
+case "$with_egl_platforms" in
+yes)
+ if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then
+ EGL_PLATFORMS="x11"
+ if test "$mesa_driver" = dri; then
+ EGL_PLATFORMS="$EGL_PLATFORMS drm"
+ fi
+ fi
+ ;;
+*)
+ if test "x$enable_egl" != xyes; then
+ AC_MSG_ERROR([cannot build egl state tracker without EGL library])
+ fi
+ # verify the requested driver directories exist
+ egl_platforms=`IFS=', '; echo $with_egl_platforms`
+ for plat in $egl_platforms; do
+ test -d "$srcdir/src/gallium/state_trackers/egl/$plat" || \
+ AC_MSG_ERROR([EGL platform '$plat' doesn't exist])
+ if test "$plat" = "fbdev"; then
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev"
+ fi
+ if test "$plat" = "wayland"; then
+ PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \
+ [AC_MSG_ERROR([cannot find libwayland-client])])
+ WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS"
+ fi
+ done
+ EGL_PLATFORMS="$egl_platforms"
+ ;;
+esac
+AC_SUBST([EGL_PLATFORMS])
+
+AC_SUBST([WAYLAND_EGL_LIB_DEPS])
+WAYLAND_EGL_PC_REQ_PRIV="wayland-client libdrm"
+WAYLAND_EGL_PC_LIB_PRIV=
+WAYLAND_EGL_PC_CFLAGS=
+
+AC_SUBST([WAYLAND_EGL_PC_REQ_PRIV])
+AC_SUBST([WAYLAND_EGL_PC_LIB_PRIV])
+AC_SUBST([WAYLAND_EGL_PC_CFLAGS])
+
+
+AC_ARG_WITH([egl-driver-dir],
+ [AS_HELP_STRING([--with-egl-driver-dir=DIR],
+ [directory for EGL drivers [[default=${libdir}/egl]]])],
+ [EGL_DRIVER_INSTALL_DIR="$withval"],
+ [EGL_DRIVER_INSTALL_DIR='${libdir}/egl'])
+AC_SUBST([EGL_DRIVER_INSTALL_DIR])
+
+AC_ARG_WITH([xorg-driver-dir],
+ [AS_HELP_STRING([--with-xorg-driver-dir=DIR],
+ [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
+ [XORG_DRIVER_INSTALL_DIR="$withval"],
+ [XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"])
+AC_SUBST([XORG_DRIVER_INSTALL_DIR])
+
+AC_ARG_WITH([max-width],
+ [AS_HELP_STRING([--with-max-width=N],
+ [Maximum framebuffer width (4096)])],
+ [DEFINES="${DEFINES} -DMAX_WIDTH=${withval}";
+ AS_IF([test "${withval}" -gt "4096"],
+ [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
+)
+AC_ARG_WITH([max-height],
+ [AS_HELP_STRING([--with-max-height=N],
+ [Maximum framebuffer height (4096)])],
+ [DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}";
+ AS_IF([test "${withval}" -gt "4096"],
+ [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
+)
+
+dnl
+dnl Gallium LLVM
+dnl
+AC_ARG_ENABLE([gallium-llvm],
+ [AS_HELP_STRING([--enable-gallium-llvm],
+ [build gallium LLVM support @<:@default=disabled@:>@])],
+ [enable_gallium_llvm="$enableval"],
+ [enable_gallium_llvm=auto])
+if test "x$enable_gallium_llvm" = xyes; then
+ if test "x$LLVM_CONFIG" != xno; then
+ LLVM_VERSION=`$LLVM_CONFIG --version`
+ LLVM_CFLAGS=`$LLVM_CONFIG --cppflags`
+ LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++"
+
+ LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+ DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS"
+ MESA_LLVM=1
+ else
+ MESA_LLVM=0
+ fi
+else
+ MESA_LLVM=0
+fi
+
+dnl
+dnl Gallium helper functions
+dnl
+gallium_check_st() {
+ if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes; then
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1"
+ fi
+ if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
+ fi
+ if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
+ fi
+}
+
+
+dnl
+dnl Gallium SVGA configuration
+dnl
+AC_ARG_ENABLE([gallium-svga],
+ [AS_HELP_STRING([--enable-gallium-svga],
+ [build gallium SVGA @<:@default=disabled@:>@])],
+ [enable_gallium_svga="$enableval"],
+ [enable_gallium_svga=auto])
+if test "x$enable_gallium_svga" = xyes; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
+ gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx"
+elif test "x$enable_gallium_svga" = xauto; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
+fi
+
+dnl
+dnl Gallium i915 configuration
+dnl
+AC_ARG_ENABLE([gallium-i915],
+ [AS_HELP_STRING([--enable-gallium-i915],
+ [build gallium i915 @<:@default=disabled@:>@])],
+ [enable_gallium_i915="$enableval"],
+ [enable_gallium_i915=auto])
+if test "x$enable_gallium_i915" = xyes; then
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
+ gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
+elif test "x$enable_gallium_i915" = xauto; then
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
+fi
+
+dnl
+dnl Gallium i965 configuration
+dnl
+AC_ARG_ENABLE([gallium-i965],
+ [AS_HELP_STRING([--enable-gallium-i965],
+ [build gallium i965 @<:@default=disabled@:>@])],
+ [enable_gallium_i965="$enableval"],
+ [enable_gallium_i965=auto])
+if test "x$enable_gallium_i965" = xyes; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
+ gallium_check_st "i965/drm" "dri-i965" "xorg-i965"
+elif test "x$enable_gallium_i965" = xauto; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
+fi
+
+dnl
+dnl Gallium Radeon r300g configuration
+dnl
+AC_ARG_ENABLE([gallium-radeon],
+ [AS_HELP_STRING([--enable-gallium-radeon],
+ [build gallium radeon @<:@default=disabled@:>@])],
+ [enable_gallium_radeon="$enableval"],
+ [enable_gallium_radeon=auto])
+if test "x$enable_gallium_radeon" = xauto; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
+ gallium_check_st "radeon/drm" "dri-r300"
+fi
+if test "x$enable_gallium_radeon" = xyes; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
+ gallium_check_st "radeon/drm" "dri-r300" "xorg-radeon"
+fi
+
+dnl
+dnl Gallium Radeon r600g configuration
+dnl
+AC_ARG_ENABLE([gallium-r600],
+ [AS_HELP_STRING([--enable-gallium-r600],
+ [build gallium radeon @<:@default=disabled@:>@])],
+ [enable_gallium_r600="$enableval"],
+ [enable_gallium_r600=auto])
+if test "x$enable_gallium_r600" = xyes; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
+ gallium_check_st "r600/drm" "dri-r600"
+fi
+
+dnl
+dnl Gallium Nouveau configuration
+dnl
+AC_ARG_ENABLE([gallium-nouveau],
+ [AS_HELP_STRING([--enable-gallium-nouveau],
+ [build gallium nouveau @<:@default=disabled@:>@])],
+ [enable_gallium_nouveau="$enableval"],
+ [enable_gallium_nouveau=no])
+if test "x$enable_gallium_nouveau" = xyes; then
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
+ gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau"
+fi
+
+dnl
+dnl Gallium swrast configuration
+dnl
+AC_ARG_ENABLE([gallium-swrast],
+ [AS_HELP_STRING([--enable-gallium-swrast],
+ [build gallium swrast @<:@default=auto@:>@])],
+ [enable_gallium_swrast="$enableval"],
+ [enable_gallium_swrast=auto])
+if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then
+ if test "x$HAVE_ST_DRI" = xyes; then
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
+ fi
+fi
+
+dnl prepend CORE_DIRS to SRC_DIRS
+SRC_DIRS="$CORE_DIRS $SRC_DIRS"
+
+dnl Restore LDFLAGS and CPPFLAGS
+LDFLAGS="$_SAVE_LDFLAGS"
+CPPFLAGS="$_SAVE_CPPFLAGS"
+
+dnl Substitute the config
+AC_CONFIG_FILES([configs/autoconf])
+
+dnl Replace the configs/current symlink
+AC_CONFIG_COMMANDS([configs],[
+if test -f configs/current || test -L configs/current; then
+ rm -f configs/current
+fi
+ln -s autoconf configs/current
+])
+
+AC_OUTPUT
+
+dnl
+dnl Output some configuration info for the user
+dnl
+echo ""
+echo " prefix: $prefix"
+echo " exec_prefix: $exec_prefix"
+echo " libdir: $libdir"
+echo " includedir: $includedir"
+
+dnl API info
+echo ""
+echo " OpenGL: $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)"
+echo " OpenVG: $enable_openvg"
+
+dnl Driver info
+echo ""
+echo " Driver: $mesa_driver"
+if test "$mesa_driver" != no; then
+ if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
+ echo " OSMesa: lib$OSMESA_LIB"
+ else
+ echo " OSMesa: no"
+ fi
+ if test "$mesa_driver" = dri; then
+ # cleanup the drivers var
+ dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
+ if test "x$DRI_DIRS" = x; then
+ echo " DRI drivers: no"
+ else
+ echo " DRI drivers: $dri_dirs"
+ fi
+ echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
+ echo " Use XCB: $enable_xcb"
+ echo " Shared dricore: $enable_dricore"
+ fi
+fi
+echo ""
+echo " GLU: $enable_glu"
+echo " GLw: $enable_glw (Motif: $enable_motif)"
+echo " glut: $enable_glut"
+
+dnl EGL
+echo ""
+echo " EGL: $enable_egl"
+if test "$enable_egl" = yes; then
+ echo " EGL platforms: $EGL_PLATFORMS"
+
+ egl_drivers=""
+ for d in $EGL_DRIVERS_DIRS; do
+ egl_drivers="$egl_drivers builtin:egl_$d"
+ done
+
+ if test "$enable_gallium" = yes -a "$HAVE_ST_EGL" = yes; then
+ echo " EGL drivers: ${egl_drivers} egl_gallium"
+ echo " EGL Gallium STs:$EGL_CLIENT_APIS"
+ else
+ echo " EGL drivers: $egl_drivers"
+ fi
+fi
+
+echo ""
+if test "x$MESA_LLVM" = x1; then
+ echo " llvm: yes"
+ echo " llvm-config: $LLVM_CONFIG"
+ echo " llvm-version: $LLVM_VERSION"
+else
+ echo " llvm: no"
+fi
+
+echo ""
+if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
+ echo " Gallium: yes"
+ echo " Gallium dirs: $GALLIUM_DIRS"
+ echo " Target dirs: $GALLIUM_TARGET_DIRS"
+ echo " Winsys dirs: $GALLIUM_WINSYS_DIRS"
+ echo " Driver dirs: $GALLIUM_DRIVERS_DIRS"
+ echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS"
+else
+ echo " Gallium: no"
+fi
+
+dnl Libraries
+echo ""
+echo " Shared libs: $enable_shared"
+echo " Static libs: $enable_static"
+
+dnl Compiler options
+# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
+cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+ $SED 's/^ *//;s/ */ /;s/ *$//'`
+cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+ $SED 's/^ *//;s/ */ /;s/ *$//'`
+defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
+echo ""
+echo " CFLAGS: $cflags"
+echo " CXXFLAGS: $cxxflags"
+echo " Macros: $defines"
+echo ""
+echo " PYTHON2: $PYTHON2"
+
+echo ""
+echo " Run '${MAKE-make}' to build Mesa"
+echo ""
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index 34523d589..a61a9af8c 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -1,625 +1,624 @@ -"""gallium - -Frontend-tool for Gallium3D architecture. - -""" - -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - - -import distutils.version -import os -import os.path -import re -import subprocess -import platform as _platform - -import SCons.Action -import SCons.Builder -import SCons.Scanner - - -def symlink(target, source, env): - target = str(target[0]) - source = str(source[0]) - if os.path.islink(target) or os.path.exists(target): - os.remove(target) - os.symlink(os.path.basename(source), target) - -def install(env, source, subdir): - target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) - return env.Install(target_dir, source) - -def install_program(env, source): - return install(env, source, 'bin') - -def install_shared_library(env, sources, version = ()): - targets = [] - install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir']) - version = tuple(map(str, version)) - if env['SHLIBSUFFIX'] == '.dll': - dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') - targets += install(env, dlls, 'bin') - libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') - targets += install(env, libs, 'lib') - else: - for source in sources: - target_dir = os.path.join(install_dir, 'lib') - target_name = '.'.join((str(source),) + version) - last = env.InstallAs(os.path.join(target_dir, target_name), source) - targets += last - while len(version): - version = version[:-1] - target_name = '.'.join((str(source),) + version) - action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") - last = env.Command(os.path.join(target_dir, target_name), last, action) - targets += last - return targets - - -def createInstallMethods(env): - env.AddMethod(install_program, 'InstallProgram') - env.AddMethod(install_shared_library, 'InstallSharedLibrary') - - -def num_jobs(): - try: - return int(os.environ['NUMBER_OF_PROCESSORS']) - except (ValueError, KeyError): - pass - - try: - return os.sysconf('SC_NPROCESSORS_ONLN') - except (ValueError, OSError, AttributeError): - pass - - try: - return int(os.popen2("sysctl -n hw.ncpu")[1].read()) - except ValueError: - pass - - 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 - - if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0: - 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""" - - # Tell tools which machine to compile for - env['TARGET_ARCH'] = env['machine'] - env['MSVS_ARCH'] = env['machine'] - - # Toolchain - platform = env['platform'] - if env['toolchain'] == 'default': - if platform == 'winddk': - env['toolchain'] = 'winddk' - elif platform == 'wince': - env['toolchain'] = 'wcesdk' - env.Tool(env['toolchain']) - - # 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' - - if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': - # MSVC x64 support is broken in earlier versions of scons - env.EnsurePythonVersion(2, 0) - - # shortcuts - machine = env['machine'] - platform = env['platform'] - x86 = env['machine'] == 'x86' - ppc = env['machine'] == 'ppc' - gcc = env['gcc'] - msvc = env['msvc'] - - # Determine whether we are cross compiling; in particular, whether we need - # to compile code generators with a different compiler as the target code. - host_platform = _platform.system().lower() - if host_platform.startswith('cygwin'): - host_platform = 'cygwin' - host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine())) - host_machine = { - 'x86': 'x86', - 'i386': 'x86', - 'i486': 'x86', - 'i586': 'x86', - 'i686': 'x86', - 'ppc' : 'ppc', - 'AMD64': 'x86_64', - 'x86_64': 'x86_64', - }.get(host_machine, 'generic') - env['crosscompile'] = platform != host_platform - if machine == 'x86_64' and host_machine != 'x86_64': - env['crosscompile'] = True - env['hostonly'] = False - - # Backwards compatability with the debug= profile= options - if env['build'] == 'debug': - if not env['debug']: - 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: 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 - env.popitem('debug') - env.popitem('profile') - else: - # Backwards portability with older sconscripts - if env['build'] in ('debug', 'checked'): - env['debug'] = True - env['profile'] = False - if env['build'] == 'profile': - env['debug'] = False - env['profile'] = True - if env['build'] == 'release': - env['debug'] = False - env['profile'] = False - - # Put build output in a separate dir, which depends on the current - # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample - build_topdir = 'build' - build_subdir = env['platform'] - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['build'] != 'release': - build_subdir += '-' + env['build'] - build_dir = os.path.join(build_topdir, build_subdir) - # Place the .sconsign file in the build dir too, to avoid issues with - # different scons versions building the same source file - env['build_dir'] = build_dir - env.SConsignFile(os.path.join(build_dir, '.sconsign')) - if 'SCONS_CACHE_DIR' in os.environ: - print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],) - env.CacheDir(os.environ['SCONS_CACHE_DIR']) - env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf') - env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log') - - # Parallel build - 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'): - cppdefines += ['DEBUG'] - else: - cppdefines += ['NDEBUG'] - if env['build'] == 'profile': - cppdefines += ['PROFILE'] - if platform == 'windows': - cppdefines += [ - 'WIN32', - '_WINDOWS', - #'_UNICODE', - #'UNICODE', - # http://msdn.microsoft.com/en-us/library/aa383745.aspx - ('_WIN32_WINNT', '0x0601'), - ('WINVER', '0x0601'), - ] - if msvc and env['toolchain'] != 'winddk': - cppdefines += [ - 'VC_EXTRALEAN', - '_USE_MATH_DEFINES', - '_CRT_SECURE_NO_WARNINGS', - '_CRT_SECURE_NO_DEPRECATE', - '_SCL_SECURE_NO_WARNINGS', - '_SCL_SECURE_NO_DEPRECATE', - ] - if env['build'] in ('debug', 'checked'): - cppdefines += ['_DEBUG'] - if env['toolchain'] == 'winddk': - # Mimic WINDDK's builtin flags. See also: - # - WINDDK's bin/makefile.new i386mk.inc for more info. - # - buildchk_wxp_x86.log files, generated by the WINDDK's build - # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ - if machine == 'x86': - cppdefines += ['_X86_', 'i386'] - if machine == 'x86_64': - cppdefines += ['_AMD64_', 'AMD64'] - if platform == 'winddk': - cppdefines += [ - 'STD_CALL', - ('CONDITION_HANDLING', '1'), - ('NT_INST', '0'), - ('WIN32', '100'), - ('_NT1X_', '100'), - ('WINNT', '1'), - ('_WIN32_WINNT', '0x0501'), # minimum required OS version - ('WINVER', '0x0501'), - ('_WIN32_IE', '0x0603'), - ('WIN32_LEAN_AND_MEAN', '1'), - ('DEVL', '1'), - ('__BUILDMACHINE__', 'WinDDK'), - ('FPO', '0'), - ] - if env['build'] in ('debug', 'checked'): - cppdefines += [('DBG', 1)] - if platform == 'wince': - cppdefines += [ - '_CRT_SECURE_NO_DEPRECATE', - '_USE_32BIT_TIME_T', - 'UNICODE', - '_UNICODE', - ('UNDER_CE', '600'), - ('_WIN32_WCE', '0x600'), - 'WINCEOEM', - 'WINCEINTERNAL', - 'WIN32', - 'STRICT', - 'x86', - '_X86_', - 'INTERNATIONAL', - ('INTLMSG_CODEPAGE', '1252'), - ] - if platform == 'windows': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] - if platform == 'winddk': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] - if platform == 'wince': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] - if platform == 'embedded': - cppdefines += ['PIPE_OS_EMBEDDED'] - env.Append(CPPDEFINES = cppdefines) - - # C compiler options - cflags = [] # C - cxxflags = [] # C++ - ccflags = [] # C & C++ - if gcc: - ccversion = env['CCVERSION'] - if env['build'] == 'debug': - ccflags += ['-O0'] - elif ccversion.startswith('4.2.'): - # gcc 4.2.x optimizer is broken - print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" - ccflags += ['-O0'] - else: - ccflags += ['-O3'] - ccflags += ['-g3'] - if env['build'] in ('checked', 'profile'): - # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? - ccflags += [ - '-fno-omit-frame-pointer', - '-fno-optimize-sibling-calls', - ] - if env['machine'] == 'x86': - ccflags += [ - '-m32', - #'-march=pentium4', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \ - and (platform != 'windows' or env['build'] == 'debug' or True): - # NOTE: We need to ensure stack is realigned given that we - # produce shared objects, and have no control over the stack - # alignment policy of the application. Therefore we need - # -mstackrealign ore -mincoming-stack-boundary=2. - # - # XXX: -O and -mstackrealign causes stack corruption on MinGW - # - # XXX: We could have SSE without -mstackrealign if we always used - # __attribute__((force_align_arg_pointer)), but that's not - # always the case. - ccflags += [ - '-mstackrealign', # ensure stack is aligned - '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics - #'-mfpmath=sse', - ] - if platform in ['windows', 'darwin']: - # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 - ccflags += ['-fno-common'] - if env['machine'] == 'x86_64': - ccflags += ['-m64'] - if platform == 'darwin': - ccflags += ['-fno-common'] - # See also: - # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - ccflags += [ - '-Wall', - '-Wno-long-long', - '-ffast-math', - '-fmessage-length=0', # be nice to Eclipse - ] - cflags += [ - '-Wmissing-prototypes', - '-std=gnu99', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'): - ccflags += [ - '-Wmissing-field-initializers', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): - ccflags += [ - '-Werror=pointer-arith', - ] - cflags += [ - '-Werror=declaration-after-statement', - ] - if msvc: - # See also: - # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx - # - cl /? - if env['build'] == 'debug': - ccflags += [ - '/Od', # disable optimizations - '/Oi', # enable intrinsic functions - '/Oy-', # disable frame pointer omission - ] - else: - ccflags += [ - '/O2', # optimize for speed - ] - if env['build'] == 'release': - ccflags += [ - '/GL', # enable whole program optimization - ] - else: - ccflags += [ - '/GL-', # disable whole program optimization - ] - ccflags += [ - '/fp:fast', # fast floating point - '/W3', # warning level - #'/Wp64', # enable 64 bit porting warnings - ] - if env['machine'] == 'x86': - ccflags += [ - #'/arch:SSE2', # use the SSE2 instructions - ] - if platform == 'windows': - ccflags += [ - # TODO - ] - if platform == 'winddk': - ccflags += [ - '/Zl', # omit default library name in .OBJ - '/Zp8', # 8bytes struct member alignment - '/Gy', # separate functions for linker - '/Gm-', # disable minimal rebuild - '/WX', # treat warnings as errors - '/Gz', # __stdcall Calling convention - '/GX-', # disable C++ EH - '/GR-', # disable C++ RTTI - '/GF', # enable read-only string pooling - '/G6', # optimize for PPro, P-II, P-III - '/Ze', # enable extensions - '/Gi-', # disable incremental compilation - '/QIfdiv-', # disable Pentium FDIV fix - '/hotpatch', # prepares an image for hotpatching. - #'/Z7', #enable old-style debug info - ] - if platform == 'wince': - # See also C:\WINCE600\public\common\oak\misc\makefile.def - ccflags += [ - '/Zl', # omit default library name in .OBJ - '/GF', # enable read-only string pooling - '/GR-', # disable C++ RTTI - '/GS', # enable security checks - # Allow disabling language conformance to maintain backward compat - #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef - #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules - #'/wd4867', - #'/wd4430', - #'/MT', - #'/U_MT', - ] - # Automatic pdb generation - # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 - env.EnsureSConsVersion(0, 98, 0) - env['PDB'] = '${TARGET.base}.pdb' - env.Append(CCFLAGS = ccflags) - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cxxflags) - - if env['platform'] == 'windows' and msvc: - # Choose the appropriate MSVC CRT - # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - if env['build'] in ('debug', 'checked'): - env.Append(CCFLAGS = ['/MTd']) - env.Append(SHCCFLAGS = ['/LDd']) - else: - env.Append(CCFLAGS = ['/MT']) - env.Append(SHCCFLAGS = ['/LD']) - - # Assembler options - if gcc: - if env['machine'] == 'x86': - env.Append(ASFLAGS = ['-m32']) - if env['machine'] == 'x86_64': - env.Append(ASFLAGS = ['-m64']) - - # Linker options - linkflags = [] - shlinkflags = [] - if gcc: - if env['machine'] == 'x86': - linkflags += ['-m32'] - if env['machine'] == 'x86_64': - linkflags += ['-m64'] - if env['platform'] not in ('darwin'): - shlinkflags += [ - '-Wl,-Bsymbolic', - ] - # Handle circular dependencies in the libraries - if env['platform'] in ('darwin'): - pass - else: - env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' - if msvc: - if env['build'] == 'release': - # enable Link-time Code Generation - linkflags += ['/LTCG'] - env.Append(ARFLAGS = ['/LTCG']) - if platform == 'windows' and msvc: - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - linkflags += [ - '/fixed:no', - '/incremental:no', - ] - if platform == 'winddk': - linkflags += [ - '/merge:_PAGE=PAGE', - '/merge:_TEXT=.text', - '/section:INIT,d', - '/opt:ref', - '/opt:icf', - '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', - '/incremental:no', - '/fullbuild', - '/release', - '/nodefaultlib', - '/wx', - '/debug', - '/debugtype:cv', - '/version:5.1', - '/osversion:5.1', - '/functionpadmin:5', - '/safeseh', - '/pdbcompress', - '/stack:0x40000,0x1000', - '/driver', - '/align:0x80', - '/subsystem:native,5.01', - '/base:0x10000', - - '/entry:DrvEnableDriver', - ] - if env['build'] != 'release': - linkflags += [ - '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx - ] - if platform == 'wince': - linkflags += [ - '/nodefaultlib', - #'/incremental:no', - #'/fullbuild', - '/entry:_DllMainCRTStartup', - ] - env.Append(LINKFLAGS = linkflags) - env.Append(SHLINKFLAGS = shlinkflags) - - # We have C++ in several libraries, so always link with the C++ compiler - if env['gcc']: - env['LINK'] = env['CXX'] - - # Default libs - env.Append(LIBS = []) - - # Load tools - env.Tool('lex') - env.Tool('yacc') - if env['llvm']: - env.Tool('llvm') - env.Tool('udis86') - - pkg_config_modules(env, 'x11', ['x11', 'xext']) - pkg_config_modules(env, 'drm', ['libdrm']) - pkg_config_modules(env, 'drm_intel', ['libdrm_intel']) - pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon']) - pkg_config_modules(env, 'xorg', ['xorg-server']) - pkg_config_modules(env, 'kms', ['libkms']) - - env['dri'] = env['x11'] and env['drm'] - - # Custom builders and methods - env.Tool('custom') - createInstallMethods(env) - - # for debugging - #print env.Dump() - - -def exists(env): - return 1 +"""gallium
+
+Frontend-tool for Gallium3D architecture.
+
+"""
+
+#
+# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+import distutils.version
+import os
+import os.path
+import re
+import subprocess
+import platform as _platform
+
+import SCons.Action
+import SCons.Builder
+import SCons.Scanner
+
+
+def symlink(target, source, env):
+ target = str(target[0])
+ source = str(source[0])
+ if os.path.islink(target) or os.path.exists(target):
+ os.remove(target)
+ os.symlink(os.path.basename(source), target)
+
+def install(env, source, subdir):
+ target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir)
+ return env.Install(target_dir, source)
+
+def install_program(env, source):
+ return install(env, source, 'bin')
+
+def install_shared_library(env, sources, version = ()):
+ targets = []
+ install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'])
+ version = tuple(map(str, version))
+ if env['SHLIBSUFFIX'] == '.dll':
+ dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ targets += install(env, dlls, 'bin')
+ libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX')
+ targets += install(env, libs, 'lib')
+ else:
+ for source in sources:
+ target_dir = os.path.join(install_dir, 'lib')
+ target_name = '.'.join((str(source),) + version)
+ last = env.InstallAs(os.path.join(target_dir, target_name), source)
+ targets += last
+ while len(version):
+ version = version[:-1]
+ target_name = '.'.join((str(source),) + version)
+ action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+ last = env.Command(os.path.join(target_dir, target_name), last, action)
+ targets += last
+ return targets
+
+
+def createInstallMethods(env):
+ env.AddMethod(install_program, 'InstallProgram')
+ env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
+def num_jobs():
+ try:
+ return int(os.environ['NUMBER_OF_PROCESSORS'])
+ except (ValueError, KeyError):
+ pass
+
+ try:
+ return os.sysconf('SC_NPROCESSORS_ONLN')
+ except (ValueError, OSError, AttributeError):
+ pass
+
+ try:
+ return int(os.popen2("sysctl -n hw.ncpu")[1].read())
+ except ValueError:
+ pass
+
+ 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
+
+ if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
+ 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"""
+
+ # Tell tools which machine to compile for
+ env['TARGET_ARCH'] = env['machine']
+ env['MSVS_ARCH'] = env['machine']
+
+ # Toolchain
+ platform = env['platform']
+ if env['toolchain'] == 'default':
+ if platform == 'winddk':
+ env['toolchain'] = 'winddk'
+ elif platform == 'wince':
+ env['toolchain'] = 'wcesdk'
+ env.Tool(env['toolchain'])
+
+ # 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'
+
+ if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64':
+ # MSVC x64 support is broken in earlier versions of scons
+ env.EnsurePythonVersion(2, 0)
+
+ # shortcuts
+ machine = env['machine']
+ platform = env['platform']
+ x86 = env['machine'] == 'x86'
+ ppc = env['machine'] == 'ppc'
+ gcc = env['gcc']
+ msvc = env['msvc']
+
+ # Determine whether we are cross compiling; in particular, whether we need
+ # to compile code generators with a different compiler as the target code.
+ host_platform = _platform.system().lower()
+ if host_platform.startswith('cygwin'):
+ host_platform = 'cygwin'
+ host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()))
+ host_machine = {
+ 'x86': 'x86',
+ 'i386': 'x86',
+ 'i486': 'x86',
+ 'i586': 'x86',
+ 'i686': 'x86',
+ 'ppc' : 'ppc',
+ 'AMD64': 'x86_64',
+ 'x86_64': 'x86_64',
+ }.get(host_machine, 'generic')
+ env['crosscompile'] = platform != host_platform
+ if machine == 'x86_64' and host_machine != 'x86_64':
+ env['crosscompile'] = True
+ env['hostonly'] = False
+
+ # Backwards compatability with the debug= profile= options
+ if env['build'] == 'debug':
+ if not env['debug']:
+ 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: 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
+ env.popitem('debug')
+ env.popitem('profile')
+ else:
+ # Backwards portability with older sconscripts
+ if env['build'] in ('debug', 'checked'):
+ env['debug'] = True
+ env['profile'] = False
+ if env['build'] == 'profile':
+ env['debug'] = False
+ env['profile'] = True
+ if env['build'] == 'release':
+ env['debug'] = False
+ env['profile'] = False
+
+ # Put build output in a separate dir, which depends on the current
+ # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
+ build_topdir = 'build'
+ build_subdir = env['platform']
+ if env['machine'] != 'generic':
+ build_subdir += '-' + env['machine']
+ if env['build'] != 'release':
+ build_subdir += '-' + env['build']
+ build_dir = os.path.join(build_topdir, build_subdir)
+ # Place the .sconsign file in the build dir too, to avoid issues with
+ # different scons versions building the same source file
+ env['build_dir'] = build_dir
+ env.SConsignFile(os.path.join(build_dir, '.sconsign'))
+ if 'SCONS_CACHE_DIR' in os.environ:
+ print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
+ env.CacheDir(os.environ['SCONS_CACHE_DIR'])
+ env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
+ env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
+
+ # Parallel build
+ 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'):
+ cppdefines += ['DEBUG']
+ else:
+ cppdefines += ['NDEBUG']
+ if env['build'] == 'profile':
+ cppdefines += ['PROFILE']
+ if platform == 'windows':
+ cppdefines += [
+ 'WIN32',
+ '_WINDOWS',
+ #'_UNICODE',
+ #'UNICODE',
+ # http://msdn.microsoft.com/en-us/library/aa383745.aspx
+ ('_WIN32_WINNT', '0x0601'),
+ ('WINVER', '0x0601'),
+ ]
+ if msvc and env['toolchain'] != 'winddk':
+ cppdefines += [
+ 'VC_EXTRALEAN',
+ '_USE_MATH_DEFINES',
+ '_CRT_SECURE_NO_WARNINGS',
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_SCL_SECURE_NO_WARNINGS',
+ '_SCL_SECURE_NO_DEPRECATE',
+ ]
+ if env['build'] in ('debug', 'checked'):
+ cppdefines += ['_DEBUG']
+ if env['toolchain'] == 'winddk':
+ # Mimic WINDDK's builtin flags. See also:
+ # - WINDDK's bin/makefile.new i386mk.inc for more info.
+ # - buildchk_wxp_x86.log files, generated by the WINDDK's build
+ # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
+ if machine == 'x86':
+ cppdefines += ['_X86_', 'i386']
+ if machine == 'x86_64':
+ cppdefines += ['_AMD64_', 'AMD64']
+ if platform == 'winddk':
+ cppdefines += [
+ 'STD_CALL',
+ ('CONDITION_HANDLING', '1'),
+ ('NT_INST', '0'),
+ ('WIN32', '100'),
+ ('_NT1X_', '100'),
+ ('WINNT', '1'),
+ ('_WIN32_WINNT', '0x0501'), # minimum required OS version
+ ('WINVER', '0x0501'),
+ ('_WIN32_IE', '0x0603'),
+ ('WIN32_LEAN_AND_MEAN', '1'),
+ ('DEVL', '1'),
+ ('__BUILDMACHINE__', 'WinDDK'),
+ ('FPO', '0'),
+ ]
+ if env['build'] in ('debug', 'checked'):
+ cppdefines += [('DBG', 1)]
+ if platform == 'wince':
+ cppdefines += [
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_USE_32BIT_TIME_T',
+ 'UNICODE',
+ '_UNICODE',
+ ('UNDER_CE', '600'),
+ ('_WIN32_WCE', '0x600'),
+ 'WINCEOEM',
+ 'WINCEINTERNAL',
+ 'WIN32',
+ 'STRICT',
+ 'x86',
+ '_X86_',
+ 'INTERNATIONAL',
+ ('INTLMSG_CODEPAGE', '1252'),
+ ]
+ if platform == 'windows':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
+ if platform == 'winddk':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
+ if platform == 'wince':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
+ if platform == 'embedded':
+ cppdefines += ['PIPE_OS_EMBEDDED']
+ env.Append(CPPDEFINES = cppdefines)
+
+ # C compiler options
+ cflags = [] # C
+ cxxflags = [] # C++
+ ccflags = [] # C & C++
+ if gcc:
+ ccversion = env['CCVERSION']
+ if env['build'] == 'debug':
+ ccflags += ['-O0']
+ elif ccversion.startswith('4.2.'):
+ # gcc 4.2.x optimizer is broken
+ print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
+ ccflags += ['-O0']
+ else:
+ ccflags += ['-O3']
+ ccflags += ['-g3']
+ if env['build'] in ('checked', 'profile'):
+ # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
+ ccflags += [
+ '-fno-omit-frame-pointer',
+ '-fno-optimize-sibling-calls',
+ ]
+ if env['machine'] == 'x86':
+ ccflags += [
+ '-m32',
+ #'-march=pentium4',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
+ and (platform != 'windows' or env['build'] == 'debug' or True):
+ # NOTE: We need to ensure stack is realigned given that we
+ # produce shared objects, and have no control over the stack
+ # alignment policy of the application. Therefore we need
+ # -mstackrealign ore -mincoming-stack-boundary=2.
+ #
+ # XXX: -O and -mstackrealign causes stack corruption on MinGW
+ #
+ # XXX: We could have SSE without -mstackrealign if we always used
+ # __attribute__((force_align_arg_pointer)), but that's not
+ # always the case.
+ ccflags += [
+ '-mstackrealign', # ensure stack is aligned
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ #'-mfpmath=sse',
+ ]
+ if platform in ['windows', 'darwin']:
+ # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
+ ccflags += ['-fno-common']
+ if env['machine'] == 'x86_64':
+ ccflags += ['-m64']
+ if platform == 'darwin':
+ ccflags += ['-fno-common']
+ # See also:
+ # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+ ccflags += [
+ '-Wall',
+ '-Wno-long-long',
+ '-ffast-math',
+ '-fmessage-length=0', # be nice to Eclipse
+ ]
+ cflags += [
+ '-Wmissing-prototypes',
+ '-std=gnu99',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
+ ccflags += [
+ '-Wmissing-field-initializers',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
+ ccflags += [
+ '-Werror=pointer-arith',
+ ]
+ cflags += [
+ '-Werror=declaration-after-statement',
+ ]
+ if msvc:
+ # See also:
+ # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
+ # - cl /?
+ if env['build'] == 'debug':
+ ccflags += [
+ '/Od', # disable optimizations
+ '/Oi', # enable intrinsic functions
+ '/Oy-', # disable frame pointer omission
+ ]
+ else:
+ ccflags += [
+ '/O2', # optimize for speed
+ ]
+ if env['build'] == 'release':
+ ccflags += [
+ '/GL', # enable whole program optimization
+ ]
+ else:
+ ccflags += [
+ '/GL-', # disable whole program optimization
+ ]
+ ccflags += [
+ '/fp:fast', # fast floating point
+ '/W3', # warning level
+ #'/Wp64', # enable 64 bit porting warnings
+ ]
+ if env['machine'] == 'x86':
+ ccflags += [
+ #'/arch:SSE2', # use the SSE2 instructions
+ ]
+ if platform == 'windows':
+ ccflags += [
+ # TODO
+ ]
+ if platform == 'winddk':
+ ccflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/Zp8', # 8bytes struct member alignment
+ '/Gy', # separate functions for linker
+ '/Gm-', # disable minimal rebuild
+ '/WX', # treat warnings as errors
+ '/Gz', # __stdcall Calling convention
+ '/GX-', # disable C++ EH
+ '/GR-', # disable C++ RTTI
+ '/GF', # enable read-only string pooling
+ '/G6', # optimize for PPro, P-II, P-III
+ '/Ze', # enable extensions
+ '/Gi-', # disable incremental compilation
+ '/QIfdiv-', # disable Pentium FDIV fix
+ '/hotpatch', # prepares an image for hotpatching.
+ #'/Z7', #enable old-style debug info
+ ]
+ if platform == 'wince':
+ # See also C:\WINCE600\public\common\oak\misc\makefile.def
+ ccflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/GF', # enable read-only string pooling
+ '/GR-', # disable C++ RTTI
+ '/GS', # enable security checks
+ # Allow disabling language conformance to maintain backward compat
+ #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
+ #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
+ #'/wd4867',
+ #'/wd4430',
+ #'/MT',
+ #'/U_MT',
+ ]
+ # Automatic pdb generation
+ # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
+ env.EnsureSConsVersion(0, 98, 0)
+ env['PDB'] = '${TARGET.base}.pdb'
+ env.Append(CCFLAGS = ccflags)
+ env.Append(CFLAGS = cflags)
+ env.Append(CXXFLAGS = cxxflags)
+
+ if env['platform'] == 'windows' and msvc:
+ # Choose the appropriate MSVC CRT
+ # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
+ if env['build'] in ('debug', 'checked'):
+ env.Append(CCFLAGS = ['/MTd'])
+ env.Append(SHCCFLAGS = ['/LDd'])
+ else:
+ env.Append(CCFLAGS = ['/MT'])
+ env.Append(SHCCFLAGS = ['/LD'])
+
+ # Assembler options
+ if gcc:
+ if env['machine'] == 'x86':
+ env.Append(ASFLAGS = ['-m32'])
+ if env['machine'] == 'x86_64':
+ env.Append(ASFLAGS = ['-m64'])
+
+ # Linker options
+ linkflags = []
+ shlinkflags = []
+ if gcc:
+ if env['machine'] == 'x86':
+ linkflags += ['-m32']
+ if env['machine'] == 'x86_64':
+ linkflags += ['-m64']
+ if env['platform'] not in ('darwin'):
+ shlinkflags += [
+ '-Wl,-Bsymbolic',
+ ]
+ # Handle circular dependencies in the libraries
+ if env['platform'] in ('darwin'):
+ pass
+ else:
+ env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
+ if msvc:
+ if env['build'] == 'release':
+ # enable Link-time Code Generation
+ linkflags += ['/LTCG']
+ env.Append(ARFLAGS = ['/LTCG'])
+ if platform == 'windows' and msvc:
+ # See also:
+ # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+ linkflags += [
+ '/fixed:no',
+ '/incremental:no',
+ ]
+ if platform == 'winddk':
+ linkflags += [
+ '/merge:_PAGE=PAGE',
+ '/merge:_TEXT=.text',
+ '/section:INIT,d',
+ '/opt:ref',
+ '/opt:icf',
+ '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
+ '/incremental:no',
+ '/fullbuild',
+ '/release',
+ '/nodefaultlib',
+ '/wx',
+ '/debug',
+ '/debugtype:cv',
+ '/version:5.1',
+ '/osversion:5.1',
+ '/functionpadmin:5',
+ '/safeseh',
+ '/pdbcompress',
+ '/stack:0x40000,0x1000',
+ '/driver',
+ '/align:0x80',
+ '/subsystem:native,5.01',
+ '/base:0x10000',
+
+ '/entry:DrvEnableDriver',
+ ]
+ if env['build'] != 'release':
+ linkflags += [
+ '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
+ ]
+ if platform == 'wince':
+ linkflags += [
+ '/nodefaultlib',
+ #'/incremental:no',
+ #'/fullbuild',
+ '/entry:_DllMainCRTStartup',
+ ]
+ env.Append(LINKFLAGS = linkflags)
+ env.Append(SHLINKFLAGS = shlinkflags)
+
+ # We have C++ in several libraries, so always link with the C++ compiler
+ if env['gcc']:
+ env['LINK'] = env['CXX']
+
+ # Default libs
+ env.Append(LIBS = [])
+
+ # Load tools
+ env.Tool('lex')
+ env.Tool('yacc')
+ if env['llvm']:
+ env.Tool('llvm')
+
+ pkg_config_modules(env, 'x11', ['x11', 'xext'])
+ pkg_config_modules(env, 'drm', ['libdrm'])
+ pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
+ pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
+ pkg_config_modules(env, 'xorg', ['xorg-server'])
+ pkg_config_modules(env, 'kms', ['libkms'])
+
+ env['dri'] = env['x11'] and env['drm']
+
+ # Custom builders and methods
+ env.Tool('custom')
+ createInstallMethods(env)
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/mesalib/scons/llvm.py b/mesalib/scons/llvm.py index 3fef9e090..364cfe366 100644 --- a/mesalib/scons/llvm.py +++ b/mesalib/scons/llvm.py @@ -1,166 +1,166 @@ -"""llvm - -Tool-specific initialization for LLVM - -""" - -# -# Copyright (c) 2009 VMware, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -import os -import os.path -import re -import sys -import distutils.version - -import SCons.Errors -import SCons.Util - - -def generate(env): - env['llvm'] = False - - try: - llvm_dir = os.environ['LLVM'] - except KeyError: - # Do nothing -- use the system headers/libs - llvm_dir = None - else: - if not os.path.isdir(llvm_dir): - raise SCons.Errors.InternalError, "Specified LLVM directory not found" - - if env['debug']: - llvm_subdir = 'Debug' - else: - llvm_subdir = 'Release' - - llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin') - if not os.path.isdir(llvm_bin_dir): - llvm_bin_dir = os.path.join(llvm_dir, 'bin') - if not os.path.isdir(llvm_bin_dir): - raise SCons.Errors.InternalError, "LLVM binary directory not found" - - env.PrependENVPath('PATH', llvm_bin_dir) - - if env['platform'] == 'windows': - # 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' - 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 - return - llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"') - llvm_version = None - for line in open(llvm_config, 'rt'): - mo = llvm_version_re.match(line) - if mo: - llvm_version = mo.group(1) - llvm_version = distutils.version.LooseVersion(llvm_version) - break - if llvm_version is None: - print 'scons: could not determine the LLVM version from %s' % llvm_config - return - - env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) - env.AppendUnique(CPPDEFINES = [ - '__STDC_LIMIT_MACROS', - '__STDC_CONSTANT_MACROS', - 'HAVE_STDINT_H', - ]) - env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) - if llvm_version >= distutils.version.LooseVersion('2.7'): - # 2.7 - env.Prepend(LIBS = [ - 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter', - 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine', - 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen', - 'LLVMSelectionDAG', 'LLVMX86Info', 'LLVMAsmPrinter', - 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser', - 'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget', - 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMSystem', - ]) - else: - # 2.6 - env.Prepend(LIBS = [ - 'LLVMX86AsmParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen', - 'LLVMX86Info', 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter', - 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine', - 'LLVMDebugger', 'LLVMBitWriter', 'LLVMAsmParser', - 'LLVMArchive', 'LLVMBitReader', 'LLVMSelectionDAG', - 'LLVMAsmPrinter', 'LLVMCodeGen', 'LLVMScalarOpts', - 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis', - 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport', - 'LLVMSystem', - ]) - env.Append(LIBS = [ - 'imagehlp', - 'psapi', - ]) - if env['msvc']: - # Some of the LLVM C headers use the inline keyword without - # defining it. - env.Append(CPPDEFINES = [('inline', '__inline')]) - if env['build'] in ('debug', 'checked'): - # LLVM libraries are static, build with /MT, and they - # automatically link agains LIBCMT. When we're doing a - # debug build we'll be linking against LIBCMTD, so disable - # that. - env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT']) - else: - if not env.Detect('llvm-config'): - print 'scons: llvm-config script not found' % llvm_version - return - - llvm_version = env.backtick('llvm-config --version').rstrip() - llvm_version = distutils.version.LooseVersion(llvm_version) - - try: - env.ParseConfig('llvm-config --cppflags') - env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') - env.ParseConfig('llvm-config --ldflags') - except OSError: - print 'scons: llvm-config version %s failed' % llvm_version - return - - assert llvm_version is not None - env['llvm'] = True - - print 'scons: Found LLVM version %s' % llvm_version - env['LLVM_VERSION'] = llvm_version - - # Define HAVE_LLVM macro with the major/minor version number (e.g., 0x0206 for 2.6) - llvm_version_major = int(llvm_version.version[0]) - llvm_version_minor = int(llvm_version.version[1]) - llvm_version_hex = '0x%02x%02x' % (llvm_version_major, llvm_version_minor) - env.Prepend(CPPDEFINES = [('HAVE_LLVM', llvm_version_hex)]) - -def exists(env): - return True - -# vim:set ts=4 sw=4 et: +"""llvm
+
+Tool-specific initialization for LLVM
+
+"""
+
+#
+# Copyright (c) 2009 VMware, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os
+import os.path
+import re
+import sys
+import distutils.version
+
+import SCons.Errors
+import SCons.Util
+
+
+def generate(env):
+ env['llvm'] = False
+
+ try:
+ llvm_dir = os.environ['LLVM']
+ except KeyError:
+ # Do nothing -- use the system headers/libs
+ llvm_dir = None
+ else:
+ if not os.path.isdir(llvm_dir):
+ raise SCons.Errors.InternalError, "Specified LLVM directory not found"
+
+ if env['debug']:
+ llvm_subdir = 'Debug'
+ else:
+ llvm_subdir = 'Release'
+
+ llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin')
+ if not os.path.isdir(llvm_bin_dir):
+ llvm_bin_dir = os.path.join(llvm_dir, 'bin')
+ if not os.path.isdir(llvm_bin_dir):
+ raise SCons.Errors.InternalError, "LLVM binary directory not found"
+
+ env.PrependENVPath('PATH', llvm_bin_dir)
+
+ if env['platform'] == 'windows':
+ # 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'
+ 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
+ return
+ llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"')
+ llvm_version = None
+ for line in open(llvm_config, 'rt'):
+ mo = llvm_version_re.match(line)
+ if mo:
+ llvm_version = mo.group(1)
+ llvm_version = distutils.version.LooseVersion(llvm_version)
+ break
+ if llvm_version is None:
+ print 'scons: could not determine the LLVM version from %s' % llvm_config
+ return
+
+ env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
+ env.AppendUnique(CPPDEFINES = [
+ '__STDC_LIMIT_MACROS',
+ '__STDC_CONSTANT_MACROS',
+ 'HAVE_STDINT_H',
+ ])
+ env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
+ if llvm_version >= distutils.version.LooseVersion('2.7'):
+ # 2.7
+ env.Prepend(LIBS = [
+ 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
+ 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
+ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
+ 'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
+ 'LLVMSelectionDAG', 'LLVMX86Info', 'LLVMAsmPrinter',
+ 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine',
+ 'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser',
+ 'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget',
+ 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMSystem',
+ ])
+ else:
+ # 2.6
+ env.Prepend(LIBS = [
+ 'LLVMX86AsmParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
+ 'LLVMX86Info', 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
+ 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
+ 'LLVMDebugger', 'LLVMBitWriter', 'LLVMAsmParser',
+ 'LLVMArchive', 'LLVMBitReader', 'LLVMSelectionDAG',
+ 'LLVMAsmPrinter', 'LLVMCodeGen', 'LLVMScalarOpts',
+ 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis',
+ 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport',
+ 'LLVMSystem',
+ ])
+ env.Append(LIBS = [
+ 'imagehlp',
+ 'psapi',
+ ])
+ if env['msvc']:
+ # Some of the LLVM C headers use the inline keyword without
+ # defining it.
+ env.Append(CPPDEFINES = [('inline', '__inline')])
+ if env['build'] in ('debug', 'checked'):
+ # LLVM libraries are static, build with /MT, and they
+ # automatically link agains LIBCMT. When we're doing a
+ # debug build we'll be linking against LIBCMTD, so disable
+ # that.
+ env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
+ else:
+ if not env.Detect('llvm-config'):
+ print 'scons: llvm-config script not found' % llvm_version
+ return
+
+ llvm_version = env.backtick('llvm-config --version').rstrip()
+ llvm_version = distutils.version.LooseVersion(llvm_version)
+
+ try:
+ env.ParseConfig('llvm-config --cppflags')
+ env.ParseConfig('llvm-config --libs')
+ env.ParseConfig('llvm-config --ldflags')
+ except OSError:
+ print 'scons: llvm-config version %s failed' % llvm_version
+ return
+
+ assert llvm_version is not None
+ env['llvm'] = True
+
+ print 'scons: Found LLVM version %s' % llvm_version
+ env['LLVM_VERSION'] = llvm_version
+
+ # Define HAVE_LLVM macro with the major/minor version number (e.g., 0x0206 for 2.6)
+ llvm_version_major = int(llvm_version.version[0])
+ llvm_version_minor = int(llvm_version.version[1])
+ llvm_version_hex = '0x%02x%02x' % (llvm_version_major, llvm_version_minor)
+ env.Prepend(CPPDEFINES = [('HAVE_LLVM', llvm_version_hex)])
+
+def exists(env):
+ return True
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/udis86.py b/mesalib/scons/udis86.py deleted file mode 100644 index 82dd01a8f..000000000 --- a/mesalib/scons/udis86.py +++ /dev/null @@ -1,44 +0,0 @@ -"""udis86
-
-Tool-specific initialization for udis86
-
-"""
-
-#
-# Copyright (c) 2009 VMware, Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-def generate(env):
- conf = env.Configure()
-
- if conf.CheckHeader('udis86.h'): # and conf.CheckLib('udis86'):
- env['UDIS86'] = True
- env.Prepend(LIBS = ['udis86'])
- else:
- env['UDIS86'] = False
-
- conf.Finish()
-
-def exists(env):
- return True
-
-# vim:set ts=4 sw=4 et:
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h index 3c2672c01..e4c84c953 100644 --- a/mesalib/src/glsl/glsl_types.h +++ b/mesalib/src/glsl/glsl_types.h @@ -1,478 +1,478 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef GLSL_TYPES_H -#define GLSL_TYPES_H - -#include <string.h> -#include <assert.h> - -extern "C" { -#include "GL/gl.h" -} - -#include "ralloc.h" - -struct _mesa_glsl_parse_state; -struct glsl_symbol_table; - -extern "C" void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); - -extern "C" void -_mesa_glsl_release_types(void); - -enum glsl_base_type { - GLSL_TYPE_UINT = 0, - GLSL_TYPE_INT, - GLSL_TYPE_FLOAT, - GLSL_TYPE_BOOL, - GLSL_TYPE_SAMPLER, - GLSL_TYPE_STRUCT, - GLSL_TYPE_ARRAY, - GLSL_TYPE_VOID, - GLSL_TYPE_ERROR -}; - -enum glsl_sampler_dim { - GLSL_SAMPLER_DIM_1D = 0, - GLSL_SAMPLER_DIM_2D, - GLSL_SAMPLER_DIM_3D, - GLSL_SAMPLER_DIM_CUBE, - GLSL_SAMPLER_DIM_RECT, - GLSL_SAMPLER_DIM_BUF -}; - - -struct glsl_type { - GLenum gl_type; - glsl_base_type base_type; - - unsigned sampler_dimensionality:3; - unsigned sampler_shadow:1; - unsigned sampler_array:1; - unsigned sampler_type:2; /**< Type of data returned using this sampler. - * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, - * and \c GLSL_TYPE_UINT are valid. - */ - - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */ - static void* operator new(size_t size) - { - if (glsl_type::mem_ctx == NULL) { - glsl_type::mem_ctx = ralloc_context(NULL); - assert(glsl_type::mem_ctx != NULL); - } - - void *type; - - type = ralloc_size(glsl_type::mem_ctx, size); - assert(type != NULL); - - return type; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *type) - { - ralloc_free(type); - } - - /** - * \name Vector and matrix element counts - * - * For scalars, each of these values will be 1. For non-numeric types - * these will be 0. - */ - /*@{*/ - unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ - unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ - /*@}*/ - - /** - * Name of the data type - * - * This may be \c NULL for anonymous structures, for arrays, or for - * function types. - */ - const char *name; - - /** - * For \c GLSL_TYPE_ARRAY, this is the length of the array. For - * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and - * the number of values pointed to by \c fields.structure (below). - */ - unsigned length; - - /** - * Subtype of composite data types. - */ - union { - const struct glsl_type *array; /**< Type of array elements. */ - const struct glsl_type *parameters; /**< Parameters to function. */ - struct glsl_struct_field *structure; /**< List of struct fields. */ - } fields; - - - /** - * \name Pointers to various public type singletons - */ - /*@{*/ - static const glsl_type *const error_type; - static const glsl_type *const void_type; - static const glsl_type *const int_type; - static const glsl_type *const ivec4_type; - static const glsl_type *const uint_type; - static const glsl_type *const uvec2_type; - static const glsl_type *const uvec3_type; - static const glsl_type *const uvec4_type; - static const glsl_type *const float_type; - static const glsl_type *const vec2_type; - static const glsl_type *const vec3_type; - static const glsl_type *const vec4_type; - static const glsl_type *const bool_type; - static const glsl_type *const mat2_type; - static const glsl_type *const mat2x3_type; - static const glsl_type *const mat2x4_type; - static const glsl_type *const mat3x2_type; - static const glsl_type *const mat3_type; - static const glsl_type *const mat3x4_type; - static const glsl_type *const mat4x2_type; - static const glsl_type *const mat4x3_type; - static const glsl_type *const mat4_type; - /*@}*/ - - - /** - * For numeric and boolean derrived types returns the basic scalar type - * - * If the type is a numeric or boolean scalar, vector, or matrix type, - * this function gets the scalar type of the individual components. For - * all other types, including arrays of numeric or boolean types, the - * error type is returned. - */ - const glsl_type *get_base_type() const; - - /** - * Query the type of elements in an array - * - * \return - * Pointer to the type of elements in the array for array types, or \c NULL - * for non-array types. - */ - const glsl_type *element_type() const - { - return is_array() ? fields.array : NULL; - } - - /** - * Get the instance of a built-in scalar, vector, or matrix type - */ - static const glsl_type *get_instance(unsigned base_type, unsigned rows, - unsigned columns); - - /** - * Get the instance of an array type - */ - static const glsl_type *get_array_instance(const glsl_type *base, - unsigned elements); - - /** - * Get the instance of a record type - */ - static const glsl_type *get_record_instance(const glsl_struct_field *fields, - unsigned num_fields, - const char *name); - - /** - * Query the total number of scalars that make up a scalar, vector or matrix - */ - unsigned components() const - { - return vector_elements * matrix_columns; - } - - /** - * Calculate the number of components slots required to hold this type - * - * This is used to determine how many uniform or varying locations a type - * might occupy. - */ - unsigned component_slots() const; - - - /** - * Query whether or not a type is a scalar (non-vector and non-matrix). - */ - bool is_scalar() const - { - return (vector_elements == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a vector - */ - bool is_vector() const - { - return (vector_elements > 1) - && (matrix_columns == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a matrix - */ - bool is_matrix() const - { - /* GLSL only has float matrices. */ - return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is a non-array numeric type - */ - bool is_numeric() const - { - return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is an integral type - */ - bool is_integer() const - { - return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); - } - - /** - * Query whether or not a type is a float type - */ - bool is_float() const - { - return base_type == GLSL_TYPE_FLOAT; - } - - /** - * Query whether or not a type is a non-array boolean type - */ - bool is_boolean() const - { - return base_type == GLSL_TYPE_BOOL; - } - - /** - * Query whether or not a type is a sampler - */ - bool is_sampler() const - { - return base_type == GLSL_TYPE_SAMPLER; - } - - /** - * Query whether or not a type is an array - */ - bool is_array() const - { - return base_type == GLSL_TYPE_ARRAY; - } - - /** - * Query whether or not a type is a record - */ - bool is_record() const - { - return base_type == GLSL_TYPE_STRUCT; - } - - /** - * Query whether or not a type is the void type singleton. - */ - bool is_void() const - { - return base_type == GLSL_TYPE_VOID; - } - - /** - * Query whether or not a type is the error type singleton. - */ - bool is_error() const - { - return base_type == GLSL_TYPE_ERROR; - } - - /** - * Query the full type of a matrix row - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the rows of the matrix is returned. - */ - const glsl_type *row_type() const - { - return is_matrix() - ? get_instance(base_type, matrix_columns, 1) - : error_type; - } - - /** - * Query the full type of a matrix column - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the columns of the matrix is returned. - */ - const glsl_type *column_type() const - { - return is_matrix() - ? get_instance(base_type, vector_elements, 1) - : error_type; - } - - - /** - * Get the type of a structure field - * - * \return - * Pointer to the type of the named field. If the type is not a structure - * or the named field does not exist, \c glsl_type::error_type is returned. - */ - const glsl_type *field_type(const char *name) const; - - - /** - * Get the location of a filed within a record type - */ - int field_index(const char *name) const; - - - /** - * Query the number of elements in an array type - * - * \return - * The number of elements in the array for array types or -1 for non-array - * types. If the number of elements in the array has not yet been declared, - * zero is returned. - */ - int array_size() const - { - return is_array() ? length : -1; - } - -private: - /** - * ralloc context for all glsl_type allocations - * - * Set on the first call to \c glsl_type::new. - */ - static void *mem_ctx; - - void init_ralloc_type_ctx(void); - - /** Constructor for vector and matrix types */ - glsl_type(GLenum gl_type, - glsl_base_type base_type, unsigned vector_elements, - unsigned matrix_columns, const char *name); - - /** Constructor for sampler types */ - glsl_type(GLenum gl_type, - enum glsl_sampler_dim dim, bool shadow, bool array, - unsigned type, const char *name); - - /** Constructor for record types */ - glsl_type(const glsl_struct_field *fields, unsigned num_fields, - const char *name); - - /** Constructor for array types */ - glsl_type(const glsl_type *array, unsigned length); - - /** Hash table containing the known array types. */ - static struct hash_table *array_types; - - /** Hash table containing the known record types. */ - static struct hash_table *record_types; - - static int record_key_compare(const void *a, const void *b); - static unsigned record_key_hash(const void *key); - - /** - * \name Pointers to various type singletons - */ - /*@{*/ - static const glsl_type _error_type; - static const glsl_type _void_type; - static const glsl_type _sampler3D_type; - static const glsl_type builtin_core_types[]; - static const glsl_type builtin_structure_types[]; - static const glsl_type builtin_110_deprecated_structure_types[]; - static const glsl_type builtin_110_types[]; - static const glsl_type builtin_120_types[]; - static const glsl_type builtin_130_types[]; - static const glsl_type builtin_ARB_texture_rectangle_types[]; - static const glsl_type builtin_EXT_texture_array_types[]; - static const glsl_type builtin_EXT_texture_buffer_object_types[]; - /*@}*/ - - /** - * \name Methods to populate a symbol table with built-in types. - * - * \internal - * This is one of the truely annoying things about C++. Methods that are - * completely internal and private to a type still have to be advertised to - * the world in a public header file. - */ - /*@{*/ - static void generate_100ES_types(glsl_symbol_table *); - static void generate_110_types(glsl_symbol_table *); - static void generate_120_types(glsl_symbol_table *); - static void generate_130_types(glsl_symbol_table *); - static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool); - static void generate_EXT_texture_array_types(glsl_symbol_table *, bool); - static void generate_OES_texture_3D_types(glsl_symbol_table *, bool); - /*@}*/ - - /** - * \name Friend functions. - * - * These functions are friends because they must have C linkage and the - * need to call various private methods or access various private static - * data. - */ - /*@{*/ - friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); - friend void _mesa_glsl_release_types(void); - /*@}*/ -}; - -struct glsl_struct_field { - const struct glsl_type *type; - const char *name; -}; - -#endif /* GLSL_TYPES_H */ +/* -*- c++ -*- */
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#pragma once
+#ifndef GLSL_TYPES_H
+#define GLSL_TYPES_H
+
+#include <string.h>
+#include <assert.h>
+
+extern "C" {
+#include "GL/gl.h"
+}
+
+#include "ralloc.h"
+
+struct _mesa_glsl_parse_state;
+struct glsl_symbol_table;
+
+extern "C" void
+_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
+
+extern "C" void
+_mesa_glsl_release_types(void);
+
+enum glsl_base_type {
+ GLSL_TYPE_UINT = 0,
+ GLSL_TYPE_INT,
+ GLSL_TYPE_FLOAT,
+ GLSL_TYPE_BOOL,
+ GLSL_TYPE_SAMPLER,
+ GLSL_TYPE_STRUCT,
+ GLSL_TYPE_ARRAY,
+ GLSL_TYPE_VOID,
+ GLSL_TYPE_ERROR
+};
+
+enum glsl_sampler_dim {
+ GLSL_SAMPLER_DIM_1D = 0,
+ GLSL_SAMPLER_DIM_2D,
+ GLSL_SAMPLER_DIM_3D,
+ GLSL_SAMPLER_DIM_CUBE,
+ GLSL_SAMPLER_DIM_RECT,
+ GLSL_SAMPLER_DIM_BUF
+};
+
+
+struct glsl_type {
+ GLenum gl_type;
+ glsl_base_type base_type;
+
+ unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */
+ unsigned sampler_shadow:1;
+ unsigned sampler_array:1;
+ unsigned sampler_type:2; /**< Type of data returned using this sampler.
+ * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
+ * and \c GLSL_TYPE_UINT are valid.
+ */
+
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
+ static void* operator new(size_t size)
+ {
+ if (glsl_type::mem_ctx == NULL) {
+ glsl_type::mem_ctx = ralloc_context(NULL);
+ assert(glsl_type::mem_ctx != NULL);
+ }
+
+ void *type;
+
+ type = ralloc_size(glsl_type::mem_ctx, size);
+ assert(type != NULL);
+
+ return type;
+ }
+
+ /* If the user *does* call delete, that's OK, we will just
+ * ralloc_free in that case. */
+ static void operator delete(void *type)
+ {
+ ralloc_free(type);
+ }
+
+ /**
+ * \name Vector and matrix element counts
+ *
+ * For scalars, each of these values will be 1. For non-numeric types
+ * these will be 0.
+ */
+ /*@{*/
+ unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
+ unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
+ /*@}*/
+
+ /**
+ * Name of the data type
+ *
+ * This may be \c NULL for anonymous structures, for arrays, or for
+ * function types.
+ */
+ const char *name;
+
+ /**
+ * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
+ * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and
+ * the number of values pointed to by \c fields.structure (below).
+ */
+ unsigned length;
+
+ /**
+ * Subtype of composite data types.
+ */
+ union {
+ const struct glsl_type *array; /**< Type of array elements. */
+ const struct glsl_type *parameters; /**< Parameters to function. */
+ struct glsl_struct_field *structure; /**< List of struct fields. */
+ } fields;
+
+
+ /**
+ * \name Pointers to various public type singletons
+ */
+ /*@{*/
+ static const glsl_type *const error_type;
+ static const glsl_type *const void_type;
+ static const glsl_type *const int_type;
+ static const glsl_type *const ivec4_type;
+ static const glsl_type *const uint_type;
+ static const glsl_type *const uvec2_type;
+ static const glsl_type *const uvec3_type;
+ static const glsl_type *const uvec4_type;
+ static const glsl_type *const float_type;
+ static const glsl_type *const vec2_type;
+ static const glsl_type *const vec3_type;
+ static const glsl_type *const vec4_type;
+ static const glsl_type *const bool_type;
+ static const glsl_type *const mat2_type;
+ static const glsl_type *const mat2x3_type;
+ static const glsl_type *const mat2x4_type;
+ static const glsl_type *const mat3x2_type;
+ static const glsl_type *const mat3_type;
+ static const glsl_type *const mat3x4_type;
+ static const glsl_type *const mat4x2_type;
+ static const glsl_type *const mat4x3_type;
+ static const glsl_type *const mat4_type;
+ /*@}*/
+
+
+ /**
+ * For numeric and boolean derrived types returns the basic scalar type
+ *
+ * If the type is a numeric or boolean scalar, vector, or matrix type,
+ * this function gets the scalar type of the individual components. For
+ * all other types, including arrays of numeric or boolean types, the
+ * error type is returned.
+ */
+ const glsl_type *get_base_type() const;
+
+ /**
+ * Query the type of elements in an array
+ *
+ * \return
+ * Pointer to the type of elements in the array for array types, or \c NULL
+ * for non-array types.
+ */
+ const glsl_type *element_type() const
+ {
+ return is_array() ? fields.array : NULL;
+ }
+
+ /**
+ * Get the instance of a built-in scalar, vector, or matrix type
+ */
+ static const glsl_type *get_instance(unsigned base_type, unsigned rows,
+ unsigned columns);
+
+ /**
+ * Get the instance of an array type
+ */
+ static const glsl_type *get_array_instance(const glsl_type *base,
+ unsigned elements);
+
+ /**
+ * Get the instance of a record type
+ */
+ static const glsl_type *get_record_instance(const glsl_struct_field *fields,
+ unsigned num_fields,
+ const char *name);
+
+ /**
+ * Query the total number of scalars that make up a scalar, vector or matrix
+ */
+ unsigned components() const
+ {
+ return vector_elements * matrix_columns;
+ }
+
+ /**
+ * Calculate the number of components slots required to hold this type
+ *
+ * This is used to determine how many uniform or varying locations a type
+ * might occupy.
+ */
+ unsigned component_slots() const;
+
+
+ /**
+ * Query whether or not a type is a scalar (non-vector and non-matrix).
+ */
+ bool is_scalar() const
+ {
+ return (vector_elements == 1)
+ && (base_type >= GLSL_TYPE_UINT)
+ && (base_type <= GLSL_TYPE_BOOL);
+ }
+
+ /**
+ * Query whether or not a type is a vector
+ */
+ bool is_vector() const
+ {
+ return (vector_elements > 1)
+ && (matrix_columns == 1)
+ && (base_type >= GLSL_TYPE_UINT)
+ && (base_type <= GLSL_TYPE_BOOL);
+ }
+
+ /**
+ * Query whether or not a type is a matrix
+ */
+ bool is_matrix() const
+ {
+ /* GLSL only has float matrices. */
+ return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT);
+ }
+
+ /**
+ * Query whether or not a type is a non-array numeric type
+ */
+ bool is_numeric() const
+ {
+ return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT);
+ }
+
+ /**
+ * Query whether or not a type is an integral type
+ */
+ bool is_integer() const
+ {
+ return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT);
+ }
+
+ /**
+ * Query whether or not a type is a float type
+ */
+ bool is_float() const
+ {
+ return base_type == GLSL_TYPE_FLOAT;
+ }
+
+ /**
+ * Query whether or not a type is a non-array boolean type
+ */
+ bool is_boolean() const
+ {
+ return base_type == GLSL_TYPE_BOOL;
+ }
+
+ /**
+ * Query whether or not a type is a sampler
+ */
+ bool is_sampler() const
+ {
+ return base_type == GLSL_TYPE_SAMPLER;
+ }
+
+ /**
+ * Query whether or not a type is an array
+ */
+ bool is_array() const
+ {
+ return base_type == GLSL_TYPE_ARRAY;
+ }
+
+ /**
+ * Query whether or not a type is a record
+ */
+ bool is_record() const
+ {
+ return base_type == GLSL_TYPE_STRUCT;
+ }
+
+ /**
+ * Query whether or not a type is the void type singleton.
+ */
+ bool is_void() const
+ {
+ return base_type == GLSL_TYPE_VOID;
+ }
+
+ /**
+ * Query whether or not a type is the error type singleton.
+ */
+ bool is_error() const
+ {
+ return base_type == GLSL_TYPE_ERROR;
+ }
+
+ /**
+ * Query the full type of a matrix row
+ *
+ * \return
+ * If the type is not a matrix, \c glsl_type::error_type is returned.
+ * Otherwise a type matching the rows of the matrix is returned.
+ */
+ const glsl_type *row_type() const
+ {
+ return is_matrix()
+ ? get_instance(base_type, matrix_columns, 1)
+ : error_type;
+ }
+
+ /**
+ * Query the full type of a matrix column
+ *
+ * \return
+ * If the type is not a matrix, \c glsl_type::error_type is returned.
+ * Otherwise a type matching the columns of the matrix is returned.
+ */
+ const glsl_type *column_type() const
+ {
+ return is_matrix()
+ ? get_instance(base_type, vector_elements, 1)
+ : error_type;
+ }
+
+
+ /**
+ * Get the type of a structure field
+ *
+ * \return
+ * Pointer to the type of the named field. If the type is not a structure
+ * or the named field does not exist, \c glsl_type::error_type is returned.
+ */
+ const glsl_type *field_type(const char *name) const;
+
+
+ /**
+ * Get the location of a filed within a record type
+ */
+ int field_index(const char *name) const;
+
+
+ /**
+ * Query the number of elements in an array type
+ *
+ * \return
+ * The number of elements in the array for array types or -1 for non-array
+ * types. If the number of elements in the array has not yet been declared,
+ * zero is returned.
+ */
+ int array_size() const
+ {
+ return is_array() ? length : -1;
+ }
+
+private:
+ /**
+ * ralloc context for all glsl_type allocations
+ *
+ * Set on the first call to \c glsl_type::new.
+ */
+ static void *mem_ctx;
+
+ void init_ralloc_type_ctx(void);
+
+ /** Constructor for vector and matrix types */
+ glsl_type(GLenum gl_type,
+ glsl_base_type base_type, unsigned vector_elements,
+ unsigned matrix_columns, const char *name);
+
+ /** Constructor for sampler types */
+ glsl_type(GLenum gl_type,
+ enum glsl_sampler_dim dim, bool shadow, bool array,
+ unsigned type, const char *name);
+
+ /** Constructor for record types */
+ glsl_type(const glsl_struct_field *fields, unsigned num_fields,
+ const char *name);
+
+ /** Constructor for array types */
+ glsl_type(const glsl_type *array, unsigned length);
+
+ /** Hash table containing the known array types. */
+ static struct hash_table *array_types;
+
+ /** Hash table containing the known record types. */
+ static struct hash_table *record_types;
+
+ static int record_key_compare(const void *a, const void *b);
+ static unsigned record_key_hash(const void *key);
+
+ /**
+ * \name Pointers to various type singletons
+ */
+ /*@{*/
+ static const glsl_type _error_type;
+ static const glsl_type _void_type;
+ static const glsl_type _sampler3D_type;
+ static const glsl_type builtin_core_types[];
+ static const glsl_type builtin_structure_types[];
+ static const glsl_type builtin_110_deprecated_structure_types[];
+ static const glsl_type builtin_110_types[];
+ static const glsl_type builtin_120_types[];
+ static const glsl_type builtin_130_types[];
+ static const glsl_type builtin_ARB_texture_rectangle_types[];
+ static const glsl_type builtin_EXT_texture_array_types[];
+ static const glsl_type builtin_EXT_texture_buffer_object_types[];
+ /*@}*/
+
+ /**
+ * \name Methods to populate a symbol table with built-in types.
+ *
+ * \internal
+ * This is one of the truely annoying things about C++. Methods that are
+ * completely internal and private to a type still have to be advertised to
+ * the world in a public header file.
+ */
+ /*@{*/
+ static void generate_100ES_types(glsl_symbol_table *);
+ static void generate_110_types(glsl_symbol_table *);
+ static void generate_120_types(glsl_symbol_table *);
+ static void generate_130_types(glsl_symbol_table *);
+ static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
+ static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
+ static void generate_OES_texture_3D_types(glsl_symbol_table *, bool);
+ /*@}*/
+
+ /**
+ * \name Friend functions.
+ *
+ * These functions are friends because they must have C linkage and the
+ * need to call various private methods or access various private static
+ * data.
+ */
+ /*@{*/
+ friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *);
+ friend void _mesa_glsl_release_types(void);
+ /*@}*/
+};
+
+struct glsl_struct_field {
+ const struct glsl_type *type;
+ const char *name;
+};
+
+#endif /* GLSL_TYPES_H */
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index ed513397a..0bc534df5 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -3,7 +3,6 @@ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
* Copyright 2009 VMware, Inc. All Rights Reserved.
- * Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -31,8 +30,6 @@ extern "C" { #include "glheader.h"
#include "imports.h"
#include "mtypes.h"
-#include "main/uniforms.h"
-#include "main/macros.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_cache.h"
@@ -42,13 +39,6 @@ extern "C" { #include "program/programopt.h"
#include "texenvprogram.h"
}
-#include "../glsl/glsl_types.h"
-#include "../glsl/ir.h"
-#include "../glsl/glsl_symbol_table.h"
-#include "../glsl/glsl_parser_extras.h"
-#include "../glsl/ir_optimization.h"
-#include "../glsl/ir_print_visitor.h"
-#include "../program/ir_to_mesa.h"
/*
* Note on texture units:
@@ -69,7 +59,7 @@ struct texenvprog_cache_item {
GLuint hash;
void *key;
- struct gl_shader_program *data;
+ struct gl_fragment_program *data;
struct texenvprog_cache_item *next;
};
@@ -86,6 +76,13 @@ texenv_doing_secondary_color(struct gl_context *ctx) return GL_FALSE;
}
+/**
+ * Up to nine instructions per tex unit, plus fog, specular color.
+ */
+#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12)
+
+#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
+
struct mode_opt {
#ifdef __GNUC__
__extension__ GLubyte Source:4; /**< SRC_x */
@@ -119,6 +116,8 @@ struct state_key { GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */
GLuint ModeA:5; /**< MODE_x */
+ GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */
+
struct mode_opt OptRGB[MAX_COMBINER_TERMS];
struct mode_opt OptA[MAX_COMBINER_TERMS];
} unit[MAX_TEXTURE_UNITS];
@@ -471,6 +470,10 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR;
key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0;
}
+
+ /* this is a back-door for enabling cylindrical texture wrap mode */
+ if (texObj->Priority == 0.125)
+ key->unit[i].texture_cyl_wrap = 1;
}
/* _NEW_LIGHT | _NEW_FOG */
@@ -499,15 +502,40 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) }
+/**
+ * Use uregs to represent registers internally, translate to Mesa's
+ * expected formats on emit.
+ *
+ * NOTE: These are passed by value extensively in this file rather
+ * than as usual by pointer reference. If this disturbs you, try
+ * remembering they are just 32bits in size.
+ *
+ * GCC is smart enough to deal with these dword-sized structures in
+ * much the same way as if I had defined them as dwords and was using
+ * macros to access and set the fields. This is much nicer and easier
+ * to evolve.
+ */
+struct ureg {
+ GLuint file:4;
+ GLuint idx:8;
+ GLuint negatebase:1;
+ GLuint swz:12;
+ GLuint pad:7;
+};
+
+static const struct ureg undef = {
+ PROGRAM_UNDEFINED,
+ 255,
+ 0,
+ 0,
+ 0
+};
+
+
/** State used to build the fragment program:
*/
struct texenv_fragment_program {
- struct gl_shader_program *shader_program;
- struct gl_shader *shader;
struct gl_fragment_program *program;
- exec_list *instructions;
- exec_list *top_instructions;
- void *mem_ctx;
struct state_key *state;
GLbitfield alu_temps; /**< Track texture indirections, see spec. */
@@ -515,35 +543,385 @@ struct texenv_fragment_program { GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */
GLboolean error;
- ir_variable *src_texture[MAX_TEXTURE_COORD_UNITS];
+ struct ureg src_texture[MAX_TEXTURE_COORD_UNITS];
/* Reg containing each texture unit's sampled texture color,
* else undef.
*/
- /* Texcoord override from bumpmapping. */
- struct ir_variable *texcoord_tex[MAX_TEXTURE_COORD_UNITS];
-
+ struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS];
/* Reg containing texcoord for a texture unit,
* needed for bump mapping, else undef.
*/
- ir_rvalue *src_previous; /**< Reg containing color from previous
+ struct ureg src_previous; /**< Reg containing color from previous
* stage. May need to be decl'd.
*/
GLuint last_tex_stage; /**< Number of last enabled texture unit */
+
+ struct ureg half;
+ struct ureg one;
+ struct ureg zero;
};
-static ir_rvalue *
-get_source(struct texenv_fragment_program *p,
- GLuint src, GLuint unit)
+
+
+static struct ureg make_ureg(GLuint file, GLuint idx)
+{
+ struct ureg reg;
+ reg.file = file;
+ reg.idx = idx;
+ reg.negatebase = 0;
+ reg.swz = SWIZZLE_NOOP;
+ reg.pad = 0;
+ return reg;
+}
+
+static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
+{
+ reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x),
+ GET_SWZ(reg.swz, y),
+ GET_SWZ(reg.swz, z),
+ GET_SWZ(reg.swz, w));
+
+ return reg;
+}
+
+static struct ureg swizzle1( struct ureg reg, int x )
+{
+ return swizzle(reg, x, x, x, x);
+}
+
+static struct ureg negate( struct ureg reg )
+{
+ reg.negatebase ^= 1;
+ return reg;
+}
+
+static GLboolean is_undef( struct ureg reg )
+{
+ return reg.file == PROGRAM_UNDEFINED;
+}
+
+
+static struct ureg get_temp( struct texenv_fragment_program *p )
+{
+ GLint bit;
+
+ /* First try and reuse temps which have been used already:
+ */
+ bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps );
+
+ /* Then any unused temporary:
+ */
+ if (!bit)
+ bit = _mesa_ffs( ~p->temp_in_use );
+
+ if (!bit) {
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ if ((GLuint) bit > p->program->Base.NumTemporaries)
+ p->program->Base.NumTemporaries = bit;
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, (bit-1));
+}
+
+static struct ureg get_tex_temp( struct texenv_fragment_program *p )
+{
+ int bit;
+
+ /* First try to find available temp not previously used (to avoid
+ * starting a new texture indirection). According to the spec, the
+ * ~p->temps_output isn't necessary, but will keep it there for
+ * now:
+ */
+ bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output );
+
+ /* Then any unused temporary:
+ */
+ if (!bit)
+ bit = _mesa_ffs( ~p->temp_in_use );
+
+ if (!bit) {
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ if ((GLuint) bit > p->program->Base.NumTemporaries)
+ p->program->Base.NumTemporaries = bit;
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, (bit-1));
+}
+
+
+/** Mark a temp reg as being no longer allocatable. */
+static void reserve_temp( struct texenv_fragment_program *p, struct ureg r )
+{
+ if (r.file == PROGRAM_TEMPORARY)
+ p->temps_output |= (1 << r.idx);
+}
+
+
+static void release_temps(struct gl_context *ctx, struct texenv_fragment_program *p )
+{
+ GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps;
+
+ /* KW: To support tex_env_crossbar, don't release the registers in
+ * temps_output.
+ */
+ if (max_temp >= sizeof(int) * 8)
+ p->temp_in_use = p->temps_output;
+ else
+ p->temp_in_use = ~((1<<max_temp)-1) | p->temps_output;
+}
+
+
+static struct ureg register_param5( struct texenv_fragment_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4)
+{
+ int tokens[STATE_LENGTH];
+ GLuint idx;
+ tokens[0] = s0;
+ tokens[1] = s1;
+ tokens[2] = s2;
+ tokens[3] = s3;
+ tokens[4] = s4;
+ idx = _mesa_add_state_reference(p->program->Base.Parameters,
+ (gl_state_index *)tokens);
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+
+#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
+
+static GLuint frag_to_vert_attrib( GLuint attrib )
+{
+ switch (attrib) {
+ case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0;
+ case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1;
+ default:
+ assert(attrib >= FRAG_ATTRIB_TEX0);
+ assert(attrib <= FRAG_ATTRIB_TEX7);
+ return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0;
+ }
+}
+
+
+static struct ureg register_input( struct texenv_fragment_program *p, GLuint input )
+{
+ if (p->state->inputs_available & (1<<input)) {
+ p->program->Base.InputsRead |= (1 << input);
+ return make_ureg(PROGRAM_INPUT, input);
+ }
+ else {
+ GLuint idx = frag_to_vert_attrib( input );
+ return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx );
+ }
+}
+
+
+static void emit_arg( struct prog_src_register *reg,
+ struct ureg ureg )
+{
+ reg->File = ureg.file;
+ reg->Index = ureg.idx;
+ reg->Swizzle = ureg.swz;
+ reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE;
+ reg->Abs = GL_FALSE;
+}
+
+static void emit_dst( struct prog_dst_register *dst,
+ struct ureg ureg, GLuint mask )
+{
+ dst->File = ureg.file;
+ dst->Index = ureg.idx;
+ dst->WriteMask = mask;
+ dst->CondMask = COND_TR; /* always pass cond test */
+ dst->CondSwizzle = SWIZZLE_NOOP;
+}
+
+static struct prog_instruction *
+emit_op(struct texenv_fragment_program *p,
+ enum prog_opcode op,
+ struct ureg dest,
+ GLuint mask,
+ GLboolean saturate,
+ struct ureg src0,
+ struct ureg src1,
+ struct ureg src2 )
+{
+ const GLuint nr = p->program->Base.NumInstructions++;
+ struct prog_instruction *inst = &p->program->Base.Instructions[nr];
+
+ assert(nr < MAX_INSTRUCTIONS);
+
+ _mesa_init_instructions(inst, 1);
+ inst->Opcode = op;
+
+ emit_arg( &inst->SrcReg[0], src0 );
+ emit_arg( &inst->SrcReg[1], src1 );
+ emit_arg( &inst->SrcReg[2], src2 );
+
+ inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF;
+
+ emit_dst( &inst->DstReg, dest, mask );
+
+#if 0
+ /* Accounting for indirection tracking:
+ */
+ if (dest.file == PROGRAM_TEMPORARY)
+ p->temps_output |= 1 << dest.idx;
+#endif
+
+ return inst;
+}
+
+
+static struct ureg emit_arith( struct texenv_fragment_program *p,
+ enum prog_opcode op,
+ struct ureg dest,
+ GLuint mask,
+ GLboolean saturate,
+ struct ureg src0,
+ struct ureg src1,
+ struct ureg src2 )
+{
+ emit_op(p, op, dest, mask, saturate, src0, src1, src2);
+
+ /* Accounting for indirection tracking:
+ */
+ if (src0.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src0.idx;
+
+ if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src1.idx;
+
+ if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src2.idx;
+
+ if (dest.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << dest.idx;
+
+ p->program->Base.NumAluInstructions++;
+ return dest;
+}
+
+static struct ureg emit_texld( struct texenv_fragment_program *p,
+ enum prog_opcode op,
+ struct ureg dest,
+ GLuint destmask,
+ GLuint tex_unit,
+ GLuint tex_idx,
+ GLuint tex_shadow,
+ struct ureg coord )
+{
+ struct prog_instruction *inst = emit_op( p, op,
+ dest, destmask,
+ GL_FALSE, /* don't saturate? */
+ coord, /* arg 0? */
+ undef,
+ undef);
+
+ inst->TexSrcTarget = tex_idx;
+ inst->TexSrcUnit = tex_unit;
+ inst->TexShadow = tex_shadow;
+
+ p->program->Base.NumTexInstructions++;
+
+ /* Accounting for indirection tracking:
+ */
+ reserve_temp(p, dest);
+
+#if 0
+ /* Is this a texture indirection?
+ */
+ if ((coord.file == PROGRAM_TEMPORARY &&
+ (p->temps_output & (1<<coord.idx))) ||
+ (dest.file == PROGRAM_TEMPORARY &&
+ (p->alu_temps & (1<<dest.idx)))) {
+ p->program->Base.NumTexIndirections++;
+ p->temps_output = 1<<coord.idx;
+ p->alu_temps = 0;
+ assert(0); /* KW: texture env crossbar */
+ }
+#endif
+
+ return dest;
+}
+
+
+static struct ureg register_const4f( struct texenv_fragment_program *p,
+ GLfloat s0,
+ GLfloat s1,
+ GLfloat s2,
+ GLfloat s3)
+{
+ GLfloat values[4];
+ GLuint idx, swizzle;
+ struct ureg r;
+ values[0] = s0;
+ values[1] = s1;
+ values[2] = s2;
+ values[3] = s3;
+ idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
+ &swizzle );
+ r = make_ureg(PROGRAM_CONSTANT, idx);
+ r.swz = swizzle;
+ return r;
+}
+
+#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
+#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1)
+#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1)
+#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1)
+
+
+static struct ureg get_one( struct texenv_fragment_program *p )
+{
+ if (is_undef(p->one))
+ p->one = register_scalar_const(p, 1.0);
+ return p->one;
+}
+
+static struct ureg get_half( struct texenv_fragment_program *p )
{
- ir_variable *var;
- ir_dereference *deref;
+ if (is_undef(p->half))
+ p->half = register_scalar_const(p, 0.5);
+ return p->half;
+}
+
+static struct ureg get_zero( struct texenv_fragment_program *p )
+{
+ if (is_undef(p->zero))
+ p->zero = register_scalar_const(p, 0.0);
+ return p->zero;
+}
+
+
+static void program_error( struct texenv_fragment_program *p, const char *msg )
+{
+ _mesa_problem(NULL, "%s", msg);
+ p->error = 1;
+}
+static struct ureg get_source( struct texenv_fragment_program *p,
+ GLuint src, GLuint unit )
+{
switch (src) {
case SRC_TEXTURE:
- return new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]);
+ assert(!is_undef(p->src_texture[unit]));
+ return p->src_texture[unit];
case SRC_TEXTURE0:
case SRC_TEXTURE1:
@@ -553,69 +931,66 @@ get_source(struct texenv_fragment_program *p, case SRC_TEXTURE5:
case SRC_TEXTURE6:
case SRC_TEXTURE7:
- return new(p->mem_ctx)
- ir_dereference_variable(p->src_texture[src - SRC_TEXTURE0]);
+ assert(!is_undef(p->src_texture[src - SRC_TEXTURE0]));
+ return p->src_texture[src - SRC_TEXTURE0];
case SRC_CONSTANT:
- var = p->shader->symbols->get_variable("gl_TextureEnvColor");
- assert(var);
- deref = new(p->mem_ctx) ir_dereference_variable(var);
- var->max_array_access = MAX2(var->max_array_access, unit);
- return new(p->mem_ctx) ir_dereference_array(deref,
- new(p->mem_ctx) ir_constant(unit));
+ return register_param2(p, STATE_TEXENV_COLOR, unit);
case SRC_PRIMARY_COLOR:
- var = p->shader->symbols->get_variable("gl_Color");
- assert(var);
- return new(p->mem_ctx) ir_dereference_variable(var);
+ return register_input(p, FRAG_ATTRIB_COL0);
case SRC_ZERO:
- return new(p->mem_ctx) ir_constant(0.0f);
+ return get_zero(p);
case SRC_PREVIOUS:
- if (!p->src_previous) {
- var = p->shader->symbols->get_variable("gl_Color");
- assert(var);
- return new(p->mem_ctx) ir_dereference_variable(var);
- } else {
- return p->src_previous->clone(p->mem_ctx, NULL);
- }
+ if (is_undef(p->src_previous))
+ return register_input(p, FRAG_ATTRIB_COL0);
+ else
+ return p->src_previous;
default:
assert(0);
- return NULL;
+ return undef;
}
}
-static ir_rvalue *
-emit_combine_source(struct texenv_fragment_program *p,
- GLuint unit,
- GLuint source,
- GLuint operand)
+static struct ureg emit_combine_source( struct texenv_fragment_program *p,
+ GLuint mask,
+ GLuint unit,
+ GLuint source,
+ GLuint operand )
{
- ir_rvalue *src;
+ struct ureg arg, src, one;
src = get_source(p, source, unit);
switch (operand) {
case OPR_ONE_MINUS_SRC_COLOR:
- return new(p->mem_ctx) ir_expression(ir_binop_sub,
- new(p->mem_ctx) ir_constant(1.0f),
- src);
+ /* Get unused tmp,
+ * Emit tmp = 1.0 - arg.xyzw
+ */
+ arg = get_temp( p );
+ one = get_one( p );
+ return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef);
case OPR_SRC_ALPHA:
- return new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1);
-
+ if (mask == WRITEMASK_W)
+ return src;
+ else
+ return swizzle1( src, SWIZZLE_W );
case OPR_ONE_MINUS_SRC_ALPHA:
- return new(p->mem_ctx) ir_expression(ir_binop_sub,
- new(p->mem_ctx) ir_constant(1.0f),
- new(p->mem_ctx) ir_swizzle(src,
- 3, 3,
- 3, 3, 1));
+ /* Get unused tmp,
+ * Emit tmp = 1.0 - arg.wwww
+ */
+ arg = get_temp(p);
+ one = get_one(p);
+ return emit_arith(p, OPCODE_SUB, arg, mask, 0,
+ one, swizzle1(src, SWIZZLE_W), undef);
case OPR_ZERO:
- return new(p->mem_ctx) ir_constant(0.0f);
+ return get_zero(p);
case OPR_ONE:
- return new(p->mem_ctx) ir_constant(1.0f);
+ return get_one(p);
case OPR_SRC_COLOR:
return src;
default:
@@ -664,104 +1039,112 @@ static GLboolean args_match( const struct state_key *key, GLuint unit ) return GL_TRUE;
}
-static ir_rvalue *
-smear(struct texenv_fragment_program *p, ir_rvalue *val)
-{
- if (!val->type->is_scalar())
- return val;
-
- return new(p->mem_ctx) ir_swizzle(val, 0, 0, 0, 0, 4);
-}
-
-static ir_rvalue *
-emit_combine(struct texenv_fragment_program *p,
- GLuint unit,
- GLuint nr,
- GLuint mode,
- const struct mode_opt *opt)
+static struct ureg emit_combine( struct texenv_fragment_program *p,
+ struct ureg dest,
+ GLuint mask,
+ GLboolean saturate,
+ GLuint unit,
+ GLuint nr,
+ GLuint mode,
+ const struct mode_opt *opt)
{
- ir_rvalue *src[MAX_COMBINER_TERMS];
- ir_rvalue *tmp0, *tmp1;
+ struct ureg src[MAX_COMBINER_TERMS];
+ struct ureg tmp, half;
GLuint i;
assert(nr <= MAX_COMBINER_TERMS);
for (i = 0; i < nr; i++)
- src[i] = emit_combine_source( p, unit, opt[i].Source, opt[i].Operand );
+ src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand );
switch (mode) {
case MODE_REPLACE:
- return src[0];
-
+ if (mask == WRITEMASK_XYZW && !saturate)
+ return src[0];
+ else
+ return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef );
case MODE_MODULATE:
- return new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]);
-
+ return emit_arith( p, OPCODE_MUL, dest, mask, saturate,
+ src[0], src[1], undef );
case MODE_ADD:
- return new(p->mem_ctx) ir_expression(ir_binop_add, src[0], src[1]);
-
+ return emit_arith( p, OPCODE_ADD, dest, mask, saturate,
+ src[0], src[1], undef );
case MODE_ADD_SIGNED:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, src[0], src[1]);
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0,
- new(p->mem_ctx) ir_constant(-0.5f));
-
+ /* tmp = arg0 + arg1
+ * result = tmp - .5
+ */
+ half = get_half(p);
+ tmp = get_temp( p );
+ emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef );
+ emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef );
+ return dest;
case MODE_INTERPOLATE:
- /* Arg0 * (Arg2) + Arg1 * (1-Arg2) */
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]);
-
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_sub,
- new(p->mem_ctx) ir_constant(1.0f),
- src[2]->clone(p->mem_ctx, NULL));
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[1], tmp1);
-
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1);
+ /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered:
+ */
+ return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] );
case MODE_SUBTRACT:
- return new(p->mem_ctx) ir_expression(ir_binop_sub, src[0], src[1]);
+ return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef );
case MODE_DOT3_RGBA:
case MODE_DOT3_RGBA_EXT:
case MODE_DOT3_RGB_EXT:
case MODE_DOT3_RGB: {
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0],
- new(p->mem_ctx) ir_constant(2.0f));
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0,
- new(p->mem_ctx) ir_constant(-1.0f));
- tmp0 = new(p->mem_ctx) ir_swizzle(smear(p, tmp0), 0, 1, 2, 3, 3);
-
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[1],
- new(p->mem_ctx) ir_constant(2.0f));
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp1,
- new(p->mem_ctx) ir_constant(-1.0f));
- tmp1 = new(p->mem_ctx) ir_swizzle(smear(p, tmp1), 0, 1, 2, 3, 3);
-
- return new(p->mem_ctx) ir_expression(ir_binop_dot, tmp0, tmp1);
- }
- case MODE_MODULATE_ADD_ATI:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]);
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, src[1]);
+ struct ureg tmp0 = get_temp( p );
+ struct ureg tmp1 = get_temp( p );
+ struct ureg neg1 = register_scalar_const(p, -1);
+ struct ureg two = register_scalar_const(p, 2);
- case MODE_MODULATE_SIGNED_ADD_ATI:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]);
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, src[1]);
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0,
- new(p->mem_ctx) ir_constant(-0.5f));
+ /* tmp0 = 2*src0 - 1
+ * tmp1 = 2*src1 - 1
+ *
+ * dst = tmp0 dot3 tmp1
+ */
+ emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0,
+ two, src[0], neg1);
+ if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0)
+ tmp1 = tmp0;
+ else
+ emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0,
+ two, src[1], neg1);
+ emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef);
+ return dest;
+ }
+ case MODE_MODULATE_ADD_ATI:
+ /* Arg0 * Arg2 + Arg1 */
+ return emit_arith( p, OPCODE_MAD, dest, mask, saturate,
+ src[0], src[2], src[1] );
+ case MODE_MODULATE_SIGNED_ADD_ATI: {
+ /* Arg0 * Arg2 + Arg1 - 0.5 */
+ struct ureg tmp0 = get_temp(p);
+ half = get_half(p);
+ emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] );
+ emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef );
+ return dest;
+ }
case MODE_MODULATE_SUBTRACT_ATI:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]);
- return new(p->mem_ctx) ir_expression(ir_binop_sub, tmp0, src[1]);
-
+ /* Arg0 * Arg2 - Arg1 */
+ emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) );
+ return dest;
case MODE_ADD_PRODUCTS:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]);
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[2], src[3]);
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1);
-
+ /* Arg0 * Arg1 + Arg2 * Arg3 */
+ {
+ struct ureg tmp0 = get_temp(p);
+ emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef );
+ emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 );
+ }
+ return dest;
case MODE_ADD_PRODUCTS_SIGNED:
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]);
- tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[2], src[3]);
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1);
- return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0,
- new(p->mem_ctx) ir_constant(-0.5f));
-
+ /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */
+ {
+ struct ureg tmp0 = get_temp(p);
+ half = get_half(p);
+ emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef );
+ emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 );
+ emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef );
+ }
+ return dest;
case MODE_BUMP_ENVMAP_ATI:
/* special - not handled here */
assert(0);
@@ -772,24 +1155,17 @@ emit_combine(struct texenv_fragment_program *p, }
}
-static ir_rvalue *
-saturate(struct texenv_fragment_program *p, ir_rvalue *val)
-{
- val = new(p->mem_ctx) ir_expression(ir_binop_min, val,
- new(p->mem_ctx) ir_constant(1.0f));
- return new(p->mem_ctx) ir_expression(ir_binop_max, val,
- new(p->mem_ctx) ir_constant(0.0f));
-}
/**
* Generate instructions for one texture unit's env/combiner mode.
*/
-static ir_rvalue *
+static struct ureg
emit_texenv(struct texenv_fragment_program *p, GLuint unit)
{
const struct state_key *key = p->state;
GLboolean rgb_saturate, alpha_saturate;
GLuint rgb_shift, alpha_shift;
+ struct ureg out, dest;
if (!key->unit[unit].enabled) {
return get_source(p, SRC_PREVIOUS, 0);
@@ -831,232 +1207,129 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit) else
alpha_saturate = GL_FALSE;
- ir_variable *temp_var = new(p->mem_ctx) ir_variable(glsl_type::vec4_type,
- "texenv_combine",
- ir_var_temporary);
- p->instructions->push_tail(temp_var);
-
- ir_dereference *deref;
- ir_assignment *assign;
- ir_rvalue *val;
+ /* If this is the very last calculation (and various other conditions
+ * are met), emit directly to the color output register. Otherwise,
+ * emit to a temporary register.
+ */
+ if (key->separate_specular ||
+ unit != p->last_tex_stage ||
+ alpha_shift ||
+ key->num_draw_buffers != 1 ||
+ rgb_shift)
+ dest = get_temp( p );
+ else
+ dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR);
/* Emit the RGB and A combine ops
*/
if (key->unit[unit].ModeRGB == key->unit[unit].ModeA &&
args_match(key, unit)) {
- val = emit_combine(p, unit,
- key->unit[unit].NumArgsRGB,
- key->unit[unit].ModeRGB,
- key->unit[unit].OptRGB);
- val = smear(p, val);
- if (rgb_saturate)
- val = saturate(p, val);
-
- deref = new(p->mem_ctx) ir_dereference_variable(temp_var);
- assign = new(p->mem_ctx) ir_assignment(deref, val, NULL);
- p->instructions->push_tail(assign);
+ out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
}
else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT ||
key->unit[unit].ModeRGB == MODE_DOT3_RGBA) {
- ir_rvalue *val = emit_combine(p, unit,
- key->unit[unit].NumArgsRGB,
- key->unit[unit].ModeRGB,
- key->unit[unit].OptRGB);
- val = smear(p, val);
- if (rgb_saturate)
- val = saturate(p, val);
- deref = new(p->mem_ctx) ir_dereference_variable(temp_var);
- assign = new(p->mem_ctx) ir_assignment(deref, val, NULL);
- p->instructions->push_tail(assign);
+ out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
}
else {
/* Need to do something to stop from re-emitting identical
* argument calculations here:
*/
- val = emit_combine(p, unit,
- key->unit[unit].NumArgsRGB,
- key->unit[unit].ModeRGB,
- key->unit[unit].OptRGB);
- val = smear(p, val);
- val = new(p->mem_ctx) ir_swizzle(val, 0, 1, 2, 3, 3);
- if (rgb_saturate)
- val = saturate(p, val);
- deref = new(p->mem_ctx) ir_dereference_variable(temp_var);
- assign = new(p->mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_XYZ);
- p->instructions->push_tail(assign);
-
- val = emit_combine(p, unit,
- key->unit[unit].NumArgsA,
- key->unit[unit].ModeA,
- key->unit[unit].OptA);
- val = smear(p, val);
- val = new(p->mem_ctx) ir_swizzle(val, 3, 3, 3, 3, 1);
- if (alpha_saturate)
- val = saturate(p, val);
- deref = new(p->mem_ctx) ir_dereference_variable(temp_var);
- assign = new(p->mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_W);
- p->instructions->push_tail(assign);
+ out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
+ out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate,
+ unit,
+ key->unit[unit].NumArgsA,
+ key->unit[unit].ModeA,
+ key->unit[unit].OptA);
}
- deref = new(p->mem_ctx) ir_dereference_variable(temp_var);
-
/* Deal with the final shift:
*/
if (alpha_shift || rgb_shift) {
- ir_constant *shift;
+ struct ureg shift;
+ GLboolean saturate = GL_TRUE; /* always saturate at this point */
if (rgb_shift == alpha_shift) {
- shift = new(p->mem_ctx) ir_constant((float)(1 << rgb_shift));
+ shift = register_scalar_const(p, (GLfloat)(1<<rgb_shift));
}
else {
- float const_data[4] = {
- 1 << rgb_shift,
- 1 << rgb_shift,
- 1 << rgb_shift,
- 1 << alpha_shift
- };
- shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
- (ir_constant_data *)const_data);
+ shift = register_const4f(p,
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<alpha_shift));
}
-
- return saturate(p, new(p->mem_ctx) ir_expression(ir_binop_mul,
- deref, shift));
+ return emit_arith( p, OPCODE_MUL, dest, WRITEMASK_XYZW,
+ saturate, out, shift, undef );
}
else
- return deref;
+ return out;
}
/**
* Generate instruction for getting a texture source term.
*/
- static void load_texture( struct texenv_fragment_program *p, GLuint unit )
- {
- ir_dereference *deref;
- ir_assignment *assign;
-
- if (p->src_texture[unit])
- return;
-
- const GLuint texTarget = p->state->unit[unit].source_index;
- ir_rvalue *texcoord;
-
- if (p->texcoord_tex[unit]) {
- texcoord = new(p->mem_ctx) ir_dereference_variable(p->texcoord_tex[unit]);
- }
- else {
- ir_variable *tc_array = p->shader->symbols->get_variable("gl_TexCoord");
- assert(tc_array);
- texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
- ir_rvalue *index = new(p->mem_ctx) ir_constant(unit);
- texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
- tc_array->max_array_access = MAX2(tc_array->max_array_access, unit);
- }
-
- if (!p->state->unit[unit].enabled) {
- p->src_texture[unit] = new(p->mem_ctx) ir_variable(glsl_type::vec4_type,
- "dummy_tex",
- ir_var_temporary);
- p->instructions->push_tail(p->src_texture[unit]);
-
- deref = new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]);
- assign = new(p->mem_ctx) ir_assignment(deref,
- new(p->mem_ctx) ir_constant(0.0f),
- NULL);
- p->instructions->push_tail(assign);
- return ;
- }
-
- const glsl_type *sampler_type = NULL;
- int coords = 0;
-
- switch (texTarget) {
- case TEXTURE_1D_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("sampler1DShadow");
- else
- sampler_type = p->shader->symbols->get_type("sampler1D");
- coords = 1;
- break;
- case TEXTURE_1D_ARRAY_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("sampler1DArrayShadow");
- else
- sampler_type = p->shader->symbols->get_type("sampler1DArray");
- coords = 2;
- break;
- case TEXTURE_2D_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("sampler2DShadow");
- else
- sampler_type = p->shader->symbols->get_type("sampler2D");
- coords = 2;
- break;
- case TEXTURE_2D_ARRAY_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("sampler2DArrayShadow");
- else
- sampler_type = p->shader->symbols->get_type("sampler2DArray");
- coords = 3;
- break;
- case TEXTURE_RECT_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("sampler2DRectShadow");
- else
- sampler_type = p->shader->symbols->get_type("sampler2DRect");
- coords = 2;
- break;
- case TEXTURE_3D_INDEX:
- assert(!p->state->unit[unit].shadow);
- sampler_type = p->shader->symbols->get_type("sampler3D");
- coords = 3;
- break;
- case TEXTURE_CUBE_INDEX:
- if (p->state->unit[unit].shadow)
- sampler_type = p->shader->symbols->get_type("samplerCubeShadow");
- else
- sampler_type = p->shader->symbols->get_type("samplerCube");
- coords = 3;
- break;
- }
-
- p->src_texture[unit] = new(p->mem_ctx) ir_variable(glsl_type::vec4_type,
- "tex",
- ir_var_temporary);
- p->instructions->push_tail(p->src_texture[unit]);
-
- ir_texture *tex = new(p->mem_ctx) ir_texture(ir_tex);
-
-
- char *sampler_name = ralloc_asprintf(p->mem_ctx, "sampler_%d", unit);
- ir_variable *sampler = new(p->mem_ctx) ir_variable(sampler_type,
- sampler_name,
- ir_var_uniform);
- p->top_instructions->push_head(sampler);
- deref = new(p->mem_ctx) ir_dereference_variable(sampler);
- tex->set_sampler(deref);
-
- tex->coordinate = new(p->mem_ctx) ir_swizzle(texcoord, 0, 1, 2, 3, coords);
-
- if (p->state->unit[unit].shadow) {
- texcoord = texcoord->clone(p->mem_ctx, NULL);
- tex->shadow_comparitor = new(p->mem_ctx) ir_swizzle(texcoord,
- coords, 0, 0, 0,
- 1);
- coords++;
- }
-
- texcoord = texcoord->clone(p->mem_ctx, NULL);
- tex->projector = new(p->mem_ctx) ir_swizzle(texcoord, 3, 0, 0, 0, 1);
-
- deref = new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]);
- assign = new(p->mem_ctx) ir_assignment(deref, tex, NULL);
- p->instructions->push_tail(assign);
- }
+static void load_texture( struct texenv_fragment_program *p, GLuint unit )
+{
+ if (is_undef(p->src_texture[unit])) {
+ const GLuint texTarget = p->state->unit[unit].source_index;
+ struct ureg texcoord;
+ struct ureg tmp = get_tex_temp( p );
-static void
-load_texenv_source(struct texenv_fragment_program *p,
- GLuint src, GLuint unit)
+ if (is_undef(p->texcoord_tex[unit])) {
+ texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit);
+ }
+ else {
+ /* might want to reuse this reg for tex output actually */
+ texcoord = p->texcoord_tex[unit];
+ }
+
+ /* TODO: Use D0_MASK_XY where possible.
+ */
+ if (p->state->unit[unit].enabled) {
+ GLboolean shadow = GL_FALSE;
+
+ if (p->state->unit[unit].shadow) {
+ p->program->Base.ShadowSamplers |= 1 << unit;
+ shadow = GL_TRUE;
+ }
+
+ p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
+ tmp, WRITEMASK_XYZW,
+ unit, texTarget, shadow,
+ texcoord );
+
+ p->program->Base.SamplersUsed |= (1 << unit);
+ /* This identity mapping should already be in place
+ * (see _mesa_init_program_struct()) but let's be safe.
+ */
+ p->program->Base.SamplerUnits[unit] = unit;
+ }
+ else
+ p->src_texture[unit] = get_zero(p);
+
+ if (p->state->unit[unit].texture_cyl_wrap) {
+ /* set flag which is checked by Mesa->Gallium program translation */
+ p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP;
+ }
+
+ }
+}
+
+static GLboolean load_texenv_source( struct texenv_fragment_program *p,
+ GLuint src, GLuint unit )
{
switch (src) {
case SRC_TEXTURE:
@@ -1078,6 +1351,8 @@ load_texenv_source(struct texenv_fragment_program *p, /* not a texture src - do nothing */
break;
}
+
+ return GL_TRUE;
}
@@ -1104,214 +1379,108 @@ load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) /**
* Generate instructions for loading bump map textures.
*/
-static void
+static GLboolean
load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit )
{
const struct state_key *key = p->state;
GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0;
- ir_rvalue *bump;
- ir_rvalue *texcoord;
- ir_variable *rot_mat_0_var, *rot_mat_1_var;
- ir_dereference_variable *rot_mat_0, *rot_mat_1;
-
- rot_mat_0_var = p->shader->symbols->get_variable("gl_MESABumpRotMatrix0");
- rot_mat_1_var = p->shader->symbols->get_variable("gl_MESABumpRotMatrix1");
- rot_mat_0 = new(p->mem_ctx) ir_dereference_variable(rot_mat_0_var);
- rot_mat_1 = new(p->mem_ctx) ir_dereference_variable(rot_mat_1_var);
-
- ir_variable *tc_array = p->shader->symbols->get_variable("gl_TexCoord");
- assert(tc_array);
- texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
- ir_rvalue *index = new(p->mem_ctx) ir_constant(bumpedUnitNr);
- texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
- tc_array->max_array_access = MAX2(tc_array->max_array_access, unit);
+ struct ureg texcDst, bumpMapRes;
+ struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0);
+ struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr);
+ struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit );
+ struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit );
load_texenv_source( p, unit + SRC_TEXTURE0, unit );
+ bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit);
+ texcDst = get_tex_temp( p );
+ p->texcoord_tex[bumpedUnitNr] = texcDst;
+
/* Apply rot matrix and add coords to be available in next phase.
- * dest = Arg1 + (Arg0.xx * rotMat0) + (Arg0.yy * rotMat1)
+ * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1)
* note only 2 coords are affected the rest are left unchanged (mul by 0)
*/
- ir_dereference *deref;
- ir_assignment *assign;
- ir_rvalue *bump_x, *bump_y;
-
- texcoord = smear(p, texcoord);
-
- /* bump_texcoord = texcoord */
- ir_variable *bumped = new(p->mem_ctx) ir_variable(texcoord->type,
- "bump_texcoord",
- ir_var_temporary);
- p->instructions->push_tail(bumped);
-
- deref = new(p->mem_ctx) ir_dereference_variable(bumped);
- assign = new(p->mem_ctx) ir_assignment(deref, texcoord, NULL);
- p->instructions->push_tail(assign);
-
- /* bump_texcoord.xy += arg0.x * rotmat0 + arg0.y * rotmat1 */
- bump = get_source(p, key->unit[unit].OptRGB[0].Source, unit);
- bump_x = new(p->mem_ctx) ir_swizzle(bump, 0, 0, 0, 0, 1);
- bump = bump->clone(p->mem_ctx, NULL);
- bump_y = new(p->mem_ctx) ir_swizzle(bump, 1, 0, 0, 0, 1);
-
- bump_x = new(p->mem_ctx) ir_expression(ir_binop_mul, bump_x, rot_mat_0);
- bump_y = new(p->mem_ctx) ir_expression(ir_binop_mul, bump_y, rot_mat_1);
-
- ir_expression *expr;
- expr = new(p->mem_ctx) ir_expression(ir_binop_add, bump_x, bump_y);
-
- deref = new(p->mem_ctx) ir_dereference_variable(bumped);
- expr = new(p->mem_ctx) ir_expression(ir_binop_add,
- new(p->mem_ctx) ir_swizzle(deref,
- 0, 1, 1, 1,
- 2),
- expr);
-
- deref = new(p->mem_ctx) ir_dereference_variable(bumped);
- assign = new(p->mem_ctx) ir_assignment(deref, expr, NULL, WRITEMASK_XY);
- p->instructions->push_tail(assign);
-
- p->texcoord_tex[bumpedUnitNr] = bumped;
+ emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0,
+ swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc );
+ emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0,
+ swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst );
+
+ /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish
+ * enough to access this later, should optimize away.
+ */
+ emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0,
+ constdudvcolor, undef, undef );
+
+ return GL_TRUE;
}
/**
- * Applies the fog calculations.
- *
- * This is basically like the ARB_fragment_prorgam fog options. Note
- * that ffvertex_prog.c produces fogcoord for us when
- * GL_FOG_COORDINATE_EXT is set to GL_FRAGMENT_DEPTH_EXT.
+ * Generate a new fragment program which implements the context's
+ * current texture env/combine mode.
*/
-static ir_rvalue *
-emit_fog_instructions(struct texenv_fragment_program *p,
- ir_rvalue *fragcolor)
+static void
+create_new_program(struct gl_context *ctx, struct state_key *key,
+ struct gl_fragment_program *program)
{
- struct state_key *key = p->state;
- ir_rvalue *f, *temp;
- ir_variable *params, *oparams;
- ir_variable *fogcoord;
- ir_assignment *assign;
-
- /* Temporary storage for the whole fog result. Fog calculations
- * only affect rgb so we're hanging on to the .a value of fragcolor
- * this way.
- */
- ir_variable *fog_result = new(p->mem_ctx) ir_variable(glsl_type::vec4_type,
- "fog_result",
- ir_var_auto);
- p->instructions->push_tail(fog_result);
- temp = new(p->mem_ctx) ir_dereference_variable(fog_result);
- assign = new(p->mem_ctx) ir_assignment(temp, fragcolor, NULL);
- p->instructions->push_tail(assign);
-
- temp = new(p->mem_ctx) ir_dereference_variable(fog_result);
- fragcolor = new(p->mem_ctx) ir_swizzle(temp, 0, 1, 2, 3, 3);
-
- oparams = p->shader->symbols->get_variable("gl_MESAFogParamsOptimized");
- fogcoord = p->shader->symbols->get_variable("gl_FogFragCoord");
- params = p->shader->symbols->get_variable("gl_Fog");
- f = new(p->mem_ctx) ir_dereference_variable(fogcoord);
-
- ir_variable *f_var = new(p->mem_ctx) ir_variable(glsl_type::float_type,
- "fog_factor", ir_var_auto);
- p->instructions->push_tail(f_var);
-
- switch (key->fog_mode) {
- case FOG_LINEAR:
- /* f = (end - z) / (end - start)
- *
- * gl_MesaFogParamsOptimized gives us (-1 / (end - start)) and
- * (end / (end - start)) so we can generate a single MAD.
- */
- temp = new(p->mem_ctx) ir_dereference_variable(oparams);
- temp = new(p->mem_ctx) ir_swizzle(temp, 0, 0, 0, 0, 1);
- f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp);
-
- temp = new(p->mem_ctx) ir_dereference_variable(oparams);
- temp = new(p->mem_ctx) ir_swizzle(temp, 1, 0, 0, 0, 1);
- f = new(p->mem_ctx) ir_expression(ir_binop_add, f, temp);
- break;
- case FOG_EXP:
- /* f = e^(-(density * fogcoord))
- *
- * gl_MesaFogParamsOptimized gives us density/ln(2) so we can
- * use EXP2 which is generally the native instruction without
- * having to do any further math on the fog density uniform.
- */
- temp = new(p->mem_ctx) ir_dereference_variable(oparams);
- temp = new(p->mem_ctx) ir_swizzle(temp, 2, 0, 0, 0, 1);
- f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp);
- f = new(p->mem_ctx) ir_expression(ir_unop_neg, f);
- f = new(p->mem_ctx) ir_expression(ir_unop_exp2, f);
- break;
- case FOG_EXP2:
- /* f = e^(-(density * fogcoord)^2)
- *
- * gl_MesaFogParamsOptimized gives us density/sqrt(ln(2)) so we
- * can do this like FOG_EXP but with a squaring after the
- * multiply by density.
- */
- ir_variable *temp_var = new(p->mem_ctx) ir_variable(glsl_type::float_type,
- "fog_temp",
- ir_var_auto);
- p->instructions->push_tail(temp_var);
-
- temp = new(p->mem_ctx) ir_dereference_variable(oparams);
- temp = new(p->mem_ctx) ir_swizzle(temp, 3, 0, 0, 0, 1);
- f = new(p->mem_ctx) ir_expression(ir_binop_mul,
- f, temp);
-
- temp = new(p->mem_ctx) ir_dereference_variable(temp_var);
- ir_assignment *assign = new(p->mem_ctx) ir_assignment(temp, f, NULL);
- p->instructions->push_tail(assign);
-
- f = new(p->mem_ctx) ir_dereference_variable(temp_var);
- temp = new(p->mem_ctx) ir_dereference_variable(temp_var);
- f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp);
- f = new(p->mem_ctx) ir_expression(ir_unop_neg, f);
- f = new(p->mem_ctx) ir_expression(ir_unop_exp2, f);
- break;
- }
-
- f = saturate(p, f);
+ struct prog_instruction instBuffer[MAX_INSTRUCTIONS];
+ struct texenv_fragment_program p;
+ GLuint unit;
+ struct ureg cf, out;
+ int i;
- temp = new(p->mem_ctx) ir_dereference_variable(f_var);
- assign = new(p->mem_ctx) ir_assignment(temp, f, NULL);
- p->instructions->push_tail(assign);
+ memset(&p, 0, sizeof(p));
+ p.state = key;
+ p.program = program;
- f = new(p->mem_ctx) ir_dereference_variable(f_var);
- f = new(p->mem_ctx) ir_expression(ir_binop_sub,
- new(p->mem_ctx) ir_constant(1.0f),
- f);
- temp = new(p->mem_ctx) ir_dereference_variable(params);
- temp = new(p->mem_ctx) ir_dereference_record(temp, "color");
- temp = new(p->mem_ctx) ir_swizzle(temp, 0, 1, 2, 3, 3);
- temp = new(p->mem_ctx) ir_expression(ir_binop_mul, temp, f);
+ /* During code generation, use locally-allocated instruction buffer,
+ * then alloc dynamic storage below.
+ */
+ p.program->Base.Instructions = instBuffer;
+ p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB;
+ p.program->Base.String = NULL;
+ p.program->Base.NumTexIndirections = 1; /* is this right? */
+ p.program->Base.NumTexInstructions = 0;
+ p.program->Base.NumAluInstructions = 0;
+ p.program->Base.NumInstructions = 0;
+ p.program->Base.NumTemporaries = 0;
+ p.program->Base.NumParameters = 0;
+ p.program->Base.NumAttributes = 0;
+ p.program->Base.NumAddressRegs = 0;
+ p.program->Base.Parameters = _mesa_new_parameter_list();
+ p.program->Base.InputsRead = 0x0;
+
+ if (key->num_draw_buffers == 1)
+ p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR;
+ else {
+ for (i = 0; i < key->num_draw_buffers; i++)
+ p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i));
+ }
- f = new(p->mem_ctx) ir_dereference_variable(f_var);
- f = new(p->mem_ctx) ir_expression(ir_binop_mul, fragcolor, f);
- f = new(p->mem_ctx) ir_expression(ir_binop_add, temp, f);
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ p.src_texture[unit] = undef;
+ p.texcoord_tex[unit] = undef;
+ }
- ir_dereference *deref = new(p->mem_ctx) ir_dereference_variable(fog_result);
- assign = new(p->mem_ctx) ir_assignment(deref, f, NULL, WRITEMASK_XYZ);
- p->instructions->push_tail(assign);
+ p.src_previous = undef;
+ p.half = undef;
+ p.zero = undef;
+ p.one = undef;
- return new(p->mem_ctx) ir_dereference_variable(fog_result);
-}
+ p.last_tex_stage = 0;
+ release_temps(ctx, &p);
-static void
-emit_instructions(struct texenv_fragment_program *p)
-{
- struct state_key *key = p->state;
- GLuint unit;
+ if (key->enabled_units && key->num_draw_buffers) {
+ GLboolean needbumpstage = GL_FALSE;
- if (key->enabled_units) {
/* Zeroth pass - bump map textures first */
- for (unit = 0; unit < key->nr_enabled_units; unit++) {
+ for (unit = 0; unit < key->nr_enabled_units; unit++)
if (key->unit[unit].enabled &&
key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) {
- load_texunit_bumpmap(p, unit);
+ needbumpstage = GL_TRUE;
+ load_texunit_bumpmap( &p, unit );
}
- }
+ if (needbumpstage)
+ p.program->Base.NumTexIndirections++;
/* First pass - to support texture_env_crossbar, first identify
* all referenced texture sources and emit texld instructions
@@ -1319,157 +1488,104 @@ emit_instructions(struct texenv_fragment_program *p) */
for (unit = 0; unit < key->nr_enabled_units; unit++)
if (key->unit[unit].enabled) {
- load_texunit_sources(p, unit);
- p->last_tex_stage = unit;
+ load_texunit_sources( &p, unit );
+ p.last_tex_stage = unit;
}
/* Second pass - emit combine instructions to build final color:
*/
- for (unit = 0; unit < key->nr_enabled_units; unit++) {
+ for (unit = 0; unit < key->nr_enabled_units; unit++)
if (key->unit[unit].enabled) {
- p->src_previous = emit_texenv(p, unit);
+ p.src_previous = emit_texenv( &p, unit );
+ reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */
+ release_temps(ctx, &p); /* release all temps */
}
- }
}
- ir_rvalue *cf = get_source(p, SRC_PREVIOUS, 0);
- ir_dereference_variable *deref;
- ir_assignment *assign;
-
- if (key->separate_specular) {
- ir_rvalue *tmp0, *tmp1;
- ir_variable *spec_result = new(p->mem_ctx) ir_variable(glsl_type::vec4_type,
- "specular_add",
- ir_var_temporary);
-
- p->instructions->push_tail(spec_result);
-
- deref = new(p->mem_ctx) ir_dereference_variable(spec_result);
- assign = new(p->mem_ctx) ir_assignment(deref, cf, NULL);
- p->instructions->push_tail(assign);
-
- deref = new(p->mem_ctx) ir_dereference_variable(spec_result);
- tmp0 = new(p->mem_ctx) ir_swizzle(deref, 0, 1, 2, 3, 3);
+ cf = get_source( &p, SRC_PREVIOUS, 0 );
- ir_variable *secondary =
- p->shader->symbols->get_variable("gl_SecondaryColor");
- assert(secondary);
- deref = new(p->mem_ctx) ir_dereference_variable(secondary);
- tmp1 = new(p->mem_ctx) ir_swizzle(deref, 0, 1, 2, 3, 3);
-
- tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add,
- tmp0, tmp1);
-
- deref = new(p->mem_ctx) ir_dereference_variable(spec_result);
- assign = new(p->mem_ctx) ir_assignment(deref, tmp0, NULL, WRITEMASK_XYZ);
- p->instructions->push_tail(assign);
+ for (i = 0; i < key->num_draw_buffers; i++) {
+ if (key->num_draw_buffers == 1)
+ out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR );
+ else {
+ out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i );
+ }
- cf = new(p->mem_ctx) ir_dereference_variable(spec_result);
+ if (key->separate_specular) {
+ /* Emit specular add.
+ */
+ struct ureg s = register_input(&p, FRAG_ATTRIB_COL1);
+ emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef );
+ emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef );
+ }
+ else if (memcmp(&cf, &out, sizeof(cf)) != 0) {
+ /* Will wind up in here if no texture enabled or a couple of
+ * other scenarios (GL_REPLACE for instance).
+ */
+ emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef );
+ }
}
+ /* Finish up:
+ */
+ emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef);
if (key->fog_enabled) {
- cf = emit_fog_instructions(p, cf);
+ /* Pull fog mode from struct gl_context, the value in the state key is
+ * a reduced value and not what is expected in FogOption
+ */
+ p.program->FogOption = ctx->Fog.Mode;
+ p.program->Base.InputsRead |= FRAG_BIT_FOGC;
}
-
- ir_variable *frag_color = p->shader->symbols->get_variable("gl_FragColor");
- assert(frag_color);
- deref = new(p->mem_ctx) ir_dereference_variable(frag_color);
- assign = new(p->mem_ctx) ir_assignment(deref, cf, NULL);
- p->instructions->push_tail(assign);
-}
-
-/**
- * Generate a new fragment program which implements the context's
- * current texture env/combine mode.
- */
-static struct gl_shader_program *
-create_new_program(struct gl_context *ctx, struct state_key *key)
-{
- struct texenv_fragment_program p;
- unsigned int unit;
- _mesa_glsl_parse_state *state;
-
- memset(&p, 0, sizeof(p));
- p.mem_ctx = ralloc_context(NULL);
- p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER);
- p.shader->ir = new(p.shader) exec_list;
- state = new(p.shader) _mesa_glsl_parse_state(ctx, GL_FRAGMENT_SHADER,
- p.shader);
- p.shader->symbols = state->symbols;
- p.top_instructions = p.shader->ir;
- p.instructions = p.shader->ir;
- p.state = key;
- p.shader_program = ctx->Driver.NewShaderProgram(ctx, 0);
-
- state->language_version = 120;
- _mesa_glsl_initialize_types(state);
- _mesa_glsl_initialize_variables(p.instructions, state);
-
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- p.src_texture[unit] = NULL;
- p.texcoord_tex[unit] = NULL;
+ else {
+ p.program->FogOption = GL_NONE;
}
- p.src_previous = NULL;
+ if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections)
+ program_error(&p, "Exceeded max nr indirect texture lookups");
- p.last_tex_stage = 0;
+ if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions)
+ program_error(&p, "Exceeded max TEX instructions");
- ir_function *main_f = new(p.mem_ctx) ir_function("main");
- p.instructions->push_tail(main_f);
- state->symbols->add_function(main_f);
+ if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions)
+ program_error(&p, "Exceeded max ALU instructions");
- ir_function_signature *main_sig =
- new(p.mem_ctx) ir_function_signature(p.shader->symbols->get_type("void"));
- main_sig->is_defined = true;
- main_f->add_signature(main_sig);
+ ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS);
- p.instructions = &main_sig->body;
- if (key->num_draw_buffers)
- emit_instructions(&p);
-
- validate_ir_tree(p.shader->ir);
-
- while (do_common_optimization(p.shader->ir, false, 32))
- ;
- reparent_ir(p.shader->ir, p.shader->ir);
+ /* Allocate final instruction array */
+ p.program->Base.Instructions
+ = _mesa_alloc_instructions(p.program->Base.NumInstructions);
+ if (!p.program->Base.Instructions) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY,
+ "generating tex env program");
+ return;
+ }
+ _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
+ p.program->Base.NumInstructions);
- p.shader->CompileStatus = true;
- p.shader->Version = state->language_version;
- p.shader->num_builtins_to_link = state->num_builtins_to_link;
- p.shader_program->Shaders =
- (gl_shader **)malloc(sizeof(*p.shader_program->Shaders));
- p.shader_program->Shaders[0] = p.shader;
- p.shader_program->NumShaders = 1;
+ if (key->num_draw_buffers && p.program->FogOption) {
+ _mesa_append_fog_code(ctx, p.program);
+ p.program->FogOption = GL_NONE;
+ }
- _mesa_glsl_link_shader(ctx, p.shader_program);
- /* Set the sampler uniforms, and relink to get them into the linked
- * program.
+ /* Notify driver the fragment program has (actually) changed.
*/
- struct gl_fragment_program *fp = p.shader_program->FragmentProgram;
- for (unsigned int i = 0; i < MAX_TEXTURE_UNITS; i++) {
- char *name = ralloc_asprintf(p.mem_ctx, "sampler_%d", i);
- int loc = _mesa_get_uniform_location(ctx, p.shader_program, name);
- if (loc != -1) {
- /* Avoid using _mesa_uniform() because it flags state
- * updates, so if we're generating this shader_program in a
- * state update, we end up recursing. Instead, just set the
- * value, which is picked up at re-link.
- */
- loc = (loc & 0xffff) + (loc >> 16);
- int sampler = fp->Base.Parameters->ParameterValues[loc][0];
- fp->Base.SamplerUnits[sampler] = i;
- }
+ if (ctx->Driver.ProgramStringNotify) {
+ GLboolean ok = ctx->Driver.ProgramStringNotify(ctx,
+ GL_FRAGMENT_PROGRAM_ARB,
+ &p.program->Base);
+ /* Driver should be able to handle any texenv programs as long as
+ * the driver correctly reported max number of texture units correctly,
+ * etc.
+ */
+ ASSERT(ok);
+ (void) ok; /* silence unused var warning */
}
- _mesa_update_shader_textures_used(&fp->Base);
- (void) ctx->Driver.ProgramStringNotify(ctx, fp->Base.Target, &fp->Base);
- if (!p.shader_program->LinkStatus)
- _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",
- p.shader_program->InfoLog);
-
- ralloc_free(p.mem_ctx);
- return p.shader_program;
+ if (DISASSEM) {
+ _mesa_print_program(&p.program->Base);
+ printf("\n");
+ }
}
extern "C" {
@@ -1478,27 +1594,30 @@ extern "C" { * Return a fragment program which implements the current
* fixed-function texture, fog and color-sum operations.
*/
-struct gl_shader_program *
+struct gl_fragment_program *
_mesa_get_fixed_func_fragment_program(struct gl_context *ctx)
{
- struct gl_shader_program *shader_program;
+ struct gl_fragment_program *prog;
struct state_key key;
GLuint keySize;
-
+
keySize = make_state_key(ctx, &key);
-
- shader_program = (struct gl_shader_program *)
+
+ prog = (struct gl_fragment_program *)
_mesa_search_program_cache(ctx->FragmentProgram.Cache,
&key, keySize);
- if (!shader_program) {
- shader_program = create_new_program(ctx, &key);
+ if (!prog) {
+ prog = (struct gl_fragment_program *)
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+
+ create_new_program(ctx, &key, prog);
- _mesa_shader_cache_insert(ctx, ctx->FragmentProgram.Cache,
- &key, keySize, shader_program);
+ _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache,
+ &key, keySize, &prog->Base);
}
- return shader_program;
+ return prog;
}
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 520d96689..39b6f72cc 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2191,7 +2191,6 @@ struct gl_shader_state struct gl_shader_program *CurrentVertexProgram;
struct gl_shader_program *CurrentGeometryProgram;
struct gl_shader_program *CurrentFragmentProgram;
- struct gl_shader_program *_CurrentFragmentProgram;
/**
* Program used by glUniform calls.
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 5651e3263..f50f2af1e 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -43,7 +43,6 @@ #include "pixel.h"
#include "program/program.h"
#include "program/prog_parameter.h"
-#include "shaderobj.h"
#include "state.h"
#include "stencil.h"
#include "texenvprogram.h"
@@ -250,7 +249,7 @@ update_program(struct gl_context *ctx) {
const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram;
const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram;
- struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
+ const struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
@@ -276,31 +275,23 @@ update_program(struct gl_context *ctx) /* Use shader programs */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
fsProg->FragmentProgram);
- _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
- fsProg);
}
else if (ctx->FragmentProgram._Enabled) {
- /* use user-defined fragment program */
+ /* use user-defined vertex program */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
ctx->FragmentProgram.Current);
- _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
- NULL);
}
else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
/* Use fragment program generated from fixed-function state.
*/
- struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx);
- _mesa_reference_shader_program(ctx,
- &ctx->Shader._CurrentFragmentProgram, f);
-
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
- f->FragmentProgram);
+ _mesa_get_fixed_func_fragment_program(ctx));
+ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
+ ctx->FragmentProgram._Current);
}
else {
/* no fragment program */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
- _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
- NULL);
}
if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) {
diff --git a/mesalib/src/mesa/main/texenvprogram.h b/mesalib/src/mesa/main/texenvprogram.h index dba775feb..0895ebacb 100644 --- a/mesalib/src/mesa/main/texenvprogram.h +++ b/mesalib/src/mesa/main/texenvprogram.h @@ -29,7 +29,7 @@ struct gl_context;
-extern struct gl_shader_program *
+extern struct gl_fragment_program *
_mesa_get_fixed_func_fragment_program(struct gl_context *ctx);
#endif
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index 43f894a9b..6c97787e8 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -140,7 +140,7 @@ _mesa_free_program_data(struct gl_context *ctx) #endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
- _mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache);
+ _mesa_delete_program_cache(ctx, ctx->FragmentProgram.Cache);
#endif
#if FEATURE_ARB_geometry_shader4
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 0e0c4326e..0130c7a5a 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -1,579 +1,601 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - /* - * Authors: - * Keith Whitwell <keith@tungstengraphics.com> - * Brian Paul - * Michel Dänzer - */ - -#include "main/glheader.h" -#include "main/formats.h" -#include "main/macros.h" -#include "program/prog_instruction.h" -#include "st_context.h" -#include "st_atom.h" -#include "st_cb_accum.h" -#include "st_cb_clear.h" -#include "st_cb_fbo.h" -#include "st_format.h" -#include "st_program.h" - -#include "pipe/p_context.h" -#include "pipe/p_shader_tokens.h" -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "util/u_format.h" -#include "util/u_inlines.h" -#include "util/u_simple_shaders.h" -#include "util/u_draw_quad.h" - -#include "cso_cache/cso_context.h" - - -/** - * Do per-context initialization for glClear. - */ -void -st_init_clear(struct st_context *st) -{ - struct pipe_context *pipe = st->pipe; - struct pipe_screen *pscreen = st->pipe->screen; - - memset(&st->clear, 0, sizeof(st->clear)); - - st->clear.raster.gl_rasterization_rules = 1; - st->clear.enable_ds_separate = pscreen->get_param(pscreen, PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE); - - /* fragment shader state: color pass-through program */ - st->clear.fs = util_make_fragment_passthrough_shader(pipe); - - /* vertex shader state: color/position pass-through */ - { - const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, - TGSI_SEMANTIC_COLOR }; - const uint semantic_indexes[] = { 0, 0 }; - st->clear.vs = util_make_vertex_passthrough_shader(pipe, 2, - semantic_names, - semantic_indexes); - } -} - - -/** - * Free per-context state for glClear. - */ -void -st_destroy_clear(struct st_context *st) -{ - if (st->clear.fs) { - cso_delete_fragment_shader(st->cso_context, st->clear.fs); - st->clear.fs = NULL; - } - if (st->clear.vs) { - cso_delete_vertex_shader(st->cso_context, st->clear.vs); - st->clear.vs = NULL; - } - if (st->clear.vbuf) { - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf = NULL; - } -} - - -/** - * Draw a screen-aligned quadrilateral. - * Coords are clip coords with y=0=bottom. - */ -static void -draw_quad(struct st_context *st, - float x0, float y0, float x1, float y1, GLfloat z, - const GLfloat color[4]) -{ - struct pipe_context *pipe = st->pipe; - - /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as - * no_flush) updates to buffers where we know there is no conflict - * with previous data. Currently using max_slots > 1 will cause - * synchronous rendering if the driver flushes its command buffers - * between one bitmap and the next. Our flush hook below isn't - * sufficient to catch this as the driver doesn't tell us when it - * flushes its own command buffers. Until this gets fixed, pay the - * price of allocating a new buffer for each bitmap cache-flush to - * avoid synchronous rendering. - */ - const GLuint max_slots = 1; /* 1024 / sizeof(st->clear.vertices); */ - GLuint i; - - if (st->clear.vbuf_slot >= max_slots) { - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf_slot = 0; - } - - if (!st->clear.vbuf) { - st->clear.vbuf = pipe_buffer_create(pipe->screen, - PIPE_BIND_VERTEX_BUFFER, - PIPE_USAGE_STREAM, - max_slots * sizeof(st->clear.vertices)); - } - - /* positions */ - st->clear.vertices[0][0][0] = x0; - st->clear.vertices[0][0][1] = y0; - - st->clear.vertices[1][0][0] = x1; - st->clear.vertices[1][0][1] = y0; - - st->clear.vertices[2][0][0] = x1; - st->clear.vertices[2][0][1] = y1; - - st->clear.vertices[3][0][0] = x0; - st->clear.vertices[3][0][1] = y1; - - /* same for all verts: */ - for (i = 0; i < 4; i++) { - st->clear.vertices[i][0][2] = z; - st->clear.vertices[i][0][3] = 1.0; - st->clear.vertices[i][1][0] = color[0]; - st->clear.vertices[i][1][1] = color[1]; - st->clear.vertices[i][1][2] = color[2]; - st->clear.vertices[i][1][3] = color[3]; - } - - /* put vertex data into vbuf */ - pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf, - st->clear.vbuf_slot - * sizeof(st->clear.vertices), - sizeof(st->clear.vertices), - st->clear.vertices); - - /* draw */ - util_draw_vertex_buffer(pipe, - st->cso_context, - st->clear.vbuf, - st->clear.vbuf_slot * sizeof(st->clear.vertices), - PIPE_PRIM_TRIANGLE_FAN, - 4, /* verts */ - 2); /* attribs/vert */ - - /* Increment slot */ - st->clear.vbuf_slot++; -} - - - -/** - * Do glClear by drawing a quadrilateral. - * The vertices of the quad will be computed from the - * ctx->DrawBuffer->_X/Ymin/max fields. - */ -static void -clear_with_quad(struct gl_context *ctx, - GLboolean color, GLboolean depth, GLboolean stencil) -{ - struct st_context *st = st_context(ctx); - const struct gl_framebuffer *fb = ctx->DrawBuffer; - const GLfloat fb_width = (GLfloat) fb->Width; - const GLfloat fb_height = (GLfloat) fb->Height; - const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f; - const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f; - const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f; - const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f; - float clearColor[4]; - - /* - printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__, - color ? "color, " : "", - depth ? "depth, " : "", - stencil ? "stencil" : "", - x0, y0, - x1, y1); - */ - - cso_save_blend(st->cso_context); - cso_save_stencil_ref(st->cso_context); - cso_save_depth_stencil_alpha(st->cso_context); - cso_save_rasterizer(st->cso_context); - cso_save_viewport(st->cso_context); - cso_save_clip(st->cso_context); - cso_save_fragment_shader(st->cso_context); - cso_save_vertex_shader(st->cso_context); - cso_save_vertex_elements(st->cso_context); - cso_save_vertex_buffers(st->cso_context); - - /* blend state: RGBA masking */ - { - struct pipe_blend_state blend; - memset(&blend, 0, sizeof(blend)); - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - if (color) { - if (ctx->Color.ColorMask[0][0]) - blend.rt[0].colormask |= PIPE_MASK_R; - if (ctx->Color.ColorMask[0][1]) - blend.rt[0].colormask |= PIPE_MASK_G; - if (ctx->Color.ColorMask[0][2]) - blend.rt[0].colormask |= PIPE_MASK_B; - if (ctx->Color.ColorMask[0][3]) - blend.rt[0].colormask |= PIPE_MASK_A; - if (st->ctx->Color.DitherFlag) - blend.dither = 1; - } - cso_set_blend(st->cso_context, &blend); - } - - /* depth_stencil state: always pass/set to ref value */ - { - struct pipe_depth_stencil_alpha_state depth_stencil; - memset(&depth_stencil, 0, sizeof(depth_stencil)); - if (depth) { - depth_stencil.depth.enabled = 1; - depth_stencil.depth.writemask = 1; - depth_stencil.depth.func = PIPE_FUNC_ALWAYS; - } - - if (stencil) { - struct pipe_stencil_ref stencil_ref; - memset(&stencil_ref, 0, sizeof(stencil_ref)); - depth_stencil.stencil[0].enabled = 1; - depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS; - depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil[0].valuemask = 0xff; - depth_stencil.stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff; - stencil_ref.ref_value[0] = ctx->Stencil.Clear; - cso_set_stencil_ref(st->cso_context, &stencil_ref); - } - - cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil); - } - - cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw); - - cso_set_rasterizer(st->cso_context, &st->clear.raster); - - /* viewport state: viewport matching window dims */ - { - const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); - struct pipe_viewport_state vp; - vp.scale[0] = 0.5f * fb_width; - vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f); - vp.scale[2] = 1.0f; - vp.scale[3] = 1.0f; - vp.translate[0] = 0.5f * fb_width; - vp.translate[1] = 0.5f * fb_height; - vp.translate[2] = 0.0f; - vp.translate[3] = 0.0f; - cso_set_viewport(st->cso_context, &vp); - } - - cso_set_clip(st->cso_context, &st->clear.clip); - cso_set_fragment_shader_handle(st->cso_context, st->clear.fs); - cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); - - if (ctx->DrawBuffer->_ColorDrawBuffers[0]) { - st_translate_color(ctx->Color.ClearColor, - ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat, - clearColor); - } - - /* draw quad matching scissor rect */ - draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, clearColor); - - /* Restore pipe state */ - cso_restore_blend(st->cso_context); - cso_restore_stencil_ref(st->cso_context); - cso_restore_depth_stencil_alpha(st->cso_context); - cso_restore_rasterizer(st->cso_context); - cso_restore_viewport(st->cso_context); - cso_restore_clip(st->cso_context); - cso_restore_fragment_shader(st->cso_context); - cso_restore_vertex_shader(st->cso_context); - cso_restore_vertex_elements(st->cso_context); - cso_restore_vertex_buffers(st->cso_context); -} - - -/** - * Determine if we need to clear the depth buffer by drawing a quad. - */ -static INLINE GLboolean -check_clear_color_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - if (ctx->Scissor.Enabled && - (ctx->Scissor.X != 0 || - ctx->Scissor.Y != 0 || - ctx->Scissor.Width < rb->Width || - ctx->Scissor.Height < rb->Height)) - return GL_TRUE; - - if (!ctx->Color.ColorMask[0][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3]) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Determine if we need to clear the combiend depth/stencil buffer by - * drawing a quad. - */ -static INLINE GLboolean -check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - const GLuint stencilMax = 0xff; - GLboolean maskStencil - = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax; - - assert(rb->Format == MESA_FORMAT_S8 || - rb->Format == MESA_FORMAT_Z24_S8 || - rb->Format == MESA_FORMAT_S8_Z24); - - if (ctx->Scissor.Enabled && - (ctx->Scissor.X != 0 || - ctx->Scissor.Y != 0 || - ctx->Scissor.Width < rb->Width || - ctx->Scissor.Height < rb->Height)) - return GL_TRUE; - - if (maskStencil) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Determine if we need to clear the depth buffer by drawing a quad. - */ -static INLINE GLboolean -check_clear_depth_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb, - boolean ds_separate) -{ - const struct st_renderbuffer *strb = st_renderbuffer(rb); - const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format); - - if (ctx->Scissor.Enabled && - (ctx->Scissor.X != 0 || - ctx->Scissor.Y != 0 || - ctx->Scissor.Width < rb->Width || - ctx->Scissor.Height < rb->Height)) - return GL_TRUE; - - if (!ds_separate && isDS && ctx->DrawBuffer->Visual.stencilBits > 0) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Determine if we need to clear the stencil buffer by drawing a quad. - */ -static INLINE GLboolean -check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb, - boolean ds_separate) -{ - const struct st_renderbuffer *strb = st_renderbuffer(rb); - const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format); - const GLuint stencilMax = 0xff; - const GLboolean maskStencil - = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax; - - assert(rb->Format == MESA_FORMAT_S8 || - rb->Format == MESA_FORMAT_Z24_S8 || - rb->Format == MESA_FORMAT_S8_Z24); - - if (maskStencil) - return GL_TRUE; - - if (ctx->Scissor.Enabled && - (ctx->Scissor.X != 0 || - ctx->Scissor.Y != 0 || - ctx->Scissor.Width < rb->Width || - ctx->Scissor.Height < rb->Height)) - return GL_TRUE; - - /* This is correct, but it is necessary to look at the depth clear - * value held in the surface when it comes time to issue the clear, - * rather than taking depth and stencil clear values from the - * current state. - */ - if (!ds_separate && isDS && ctx->DrawBuffer->Visual.depthBits > 0) - return GL_TRUE; - - return GL_FALSE; -} - - - -/** - * Called when we need to flush. - */ -void -st_flush_clear(struct st_context *st) -{ - /* Release vertex buffer to avoid synchronous rendering if we were - * to map it in the next frame. - */ - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf_slot = 0; -} - - - -/** - * Called via ctx->Driver.Clear() - */ -static void -st_Clear(struct gl_context *ctx, GLbitfield mask) -{ - static const GLbitfield BUFFER_BITS_DS - = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - struct st_context *st = st_context(ctx); - struct gl_renderbuffer *depthRb - = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - struct gl_renderbuffer *stencilRb - = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - GLbitfield quad_buffers = 0x0; - GLbitfield clear_buffers = 0x0; - GLuint i; - - /* This makes sure the pipe has the latest scissor, etc values */ - st_validate_state( st ); - - if (mask & BUFFER_BITS_COLOR) { - for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { - GLuint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; - - if (mask & (1 << b)) { - struct gl_renderbuffer *rb - = ctx->DrawBuffer->Attachment[b].Renderbuffer; - struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (!strb || !strb->surface) - continue; - - if (check_clear_color_with_quad( ctx, rb )) - quad_buffers |= PIPE_CLEAR_COLOR; - else - clear_buffers |= PIPE_CLEAR_COLOR; - } - } - } - - if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depthRb == stencilRb) { - /* clearing combined depth + stencil */ - struct st_renderbuffer *strb = st_renderbuffer(depthRb); - - if (strb->surface) { - if (check_clear_depth_stencil_with_quad(ctx, depthRb)) - quad_buffers |= PIPE_CLEAR_DEPTHSTENCIL; - else - clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; - } - } - else { - /* separate depth/stencil clears */ - /* I don't think truly separate buffers are actually possible in gallium or hw? */ - if (mask & BUFFER_BIT_DEPTH) { - struct st_renderbuffer *strb = st_renderbuffer(depthRb); - - if (strb->surface) { - if (check_clear_depth_with_quad(ctx, depthRb, - st->clear.enable_ds_separate)) - quad_buffers |= PIPE_CLEAR_DEPTH; - else - clear_buffers |= PIPE_CLEAR_DEPTH; - } - } - if (mask & BUFFER_BIT_STENCIL) { - struct st_renderbuffer *strb = st_renderbuffer(stencilRb); - - if (strb->surface) { - if (check_clear_stencil_with_quad(ctx, stencilRb, - st->clear.enable_ds_separate)) - quad_buffers |= PIPE_CLEAR_STENCIL; - else - clear_buffers |= PIPE_CLEAR_STENCIL; - } - } - } - - /* - * If we're going to use clear_with_quad() for any reason, use it for - * everything possible. - */ - if (quad_buffers) { - quad_buffers |= clear_buffers; - clear_with_quad(ctx, - quad_buffers & PIPE_CLEAR_COLOR, - quad_buffers & PIPE_CLEAR_DEPTH, - quad_buffers & PIPE_CLEAR_STENCIL); - } else if (clear_buffers) { - /* driver cannot know it can clear everything if the buffer - * is a combined depth/stencil buffer but this wasn't actually - * required from the visual. Hence fix this up to avoid potential - * read-modify-write in the driver. - */ - float clearColor[4]; - - if ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) && - ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) && - (depthRb == stencilRb) && - (ctx->DrawBuffer->Visual.depthBits == 0 || - ctx->DrawBuffer->Visual.stencilBits == 0)) - clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; - - if (ctx->DrawBuffer->_ColorDrawBuffers[0]) { - st_translate_color(ctx->Color.ClearColor, - ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat, - clearColor); - } - - st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor, - ctx->Depth.Clear, ctx->Stencil.Clear); - } - if (mask & BUFFER_BIT_ACCUM) - st_clear_accum_buffer(ctx, - ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); -} - - -void -st_init_clear_functions(struct dd_function_table *functions) -{ - functions->Clear = st_Clear; -} +/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * Copyright 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Brian Paul
+ * Michel Dänzer
+ */
+
+#include "main/glheader.h"
+#include "main/formats.h"
+#include "main/macros.h"
+#include "program/prog_instruction.h"
+#include "st_context.h"
+#include "st_atom.h"
+#include "st_cb_accum.h"
+#include "st_cb_clear.h"
+#include "st_cb_fbo.h"
+#include "st_format.h"
+#include "st_program.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_format.h"
+#include "util/u_inlines.h"
+#include "util/u_simple_shaders.h"
+#include "util/u_draw_quad.h"
+
+#include "cso_cache/cso_context.h"
+
+
+/**
+ * Do per-context initialization for glClear.
+ */
+void
+st_init_clear(struct st_context *st)
+{
+ struct pipe_screen *pscreen = st->pipe->screen;
+
+ memset(&st->clear, 0, sizeof(st->clear));
+
+ st->clear.raster.gl_rasterization_rules = 1;
+ st->clear.enable_ds_separate = pscreen->get_param(pscreen, PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE);
+}
+
+
+/**
+ * Free per-context state for glClear.
+ */
+void
+st_destroy_clear(struct st_context *st)
+{
+ if (st->clear.fs) {
+ cso_delete_fragment_shader(st->cso_context, st->clear.fs);
+ st->clear.fs = NULL;
+ }
+ if (st->clear.vs) {
+ cso_delete_vertex_shader(st->cso_context, st->clear.vs);
+ st->clear.vs = NULL;
+ }
+ if (st->clear.vbuf) {
+ pipe_resource_reference(&st->clear.vbuf, NULL);
+ st->clear.vbuf = NULL;
+ }
+}
+
+
+/**
+ * Helper function to set the fragment shaders.
+ */
+static INLINE void
+set_fragment_shader(struct st_context *st)
+{
+ if (!st->clear.fs)
+ st->clear.fs = util_make_fragment_passthrough_shader(st->pipe);
+
+ cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
+}
+
+
+/**
+ * Helper function to set the vertex shader.
+ */
+static INLINE void
+set_vertex_shader(struct st_context *st)
+{
+ /* vertex shader - still required to provide the linkage between
+ * fragment shader input semantics and vertex_element/buffers.
+ */
+ if (!st->clear.vs)
+ {
+ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_COLOR };
+ const uint semantic_indexes[] = { 0, 0 };
+ st->clear.vs = util_make_vertex_passthrough_shader(st->pipe, 2,
+ semantic_names,
+ semantic_indexes);
+ }
+
+ cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
+}
+
+
+/**
+ * Draw a screen-aligned quadrilateral.
+ * Coords are clip coords with y=0=bottom.
+ */
+static void
+draw_quad(struct st_context *st,
+ float x0, float y0, float x1, float y1, GLfloat z,
+ const GLfloat color[4])
+{
+ struct pipe_context *pipe = st->pipe;
+
+ /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
+ * no_flush) updates to buffers where we know there is no conflict
+ * with previous data. Currently using max_slots > 1 will cause
+ * synchronous rendering if the driver flushes its command buffers
+ * between one bitmap and the next. Our flush hook below isn't
+ * sufficient to catch this as the driver doesn't tell us when it
+ * flushes its own command buffers. Until this gets fixed, pay the
+ * price of allocating a new buffer for each bitmap cache-flush to
+ * avoid synchronous rendering.
+ */
+ const GLuint max_slots = 1; /* 1024 / sizeof(st->clear.vertices); */
+ GLuint i;
+
+ if (st->clear.vbuf_slot >= max_slots) {
+ pipe_resource_reference(&st->clear.vbuf, NULL);
+ st->clear.vbuf_slot = 0;
+ }
+
+ if (!st->clear.vbuf) {
+ st->clear.vbuf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STREAM,
+ max_slots * sizeof(st->clear.vertices));
+ }
+
+ /* positions */
+ st->clear.vertices[0][0][0] = x0;
+ st->clear.vertices[0][0][1] = y0;
+
+ st->clear.vertices[1][0][0] = x1;
+ st->clear.vertices[1][0][1] = y0;
+
+ st->clear.vertices[2][0][0] = x1;
+ st->clear.vertices[2][0][1] = y1;
+
+ st->clear.vertices[3][0][0] = x0;
+ st->clear.vertices[3][0][1] = y1;
+
+ /* same for all verts: */
+ for (i = 0; i < 4; i++) {
+ st->clear.vertices[i][0][2] = z;
+ st->clear.vertices[i][0][3] = 1.0;
+ st->clear.vertices[i][1][0] = color[0];
+ st->clear.vertices[i][1][1] = color[1];
+ st->clear.vertices[i][1][2] = color[2];
+ st->clear.vertices[i][1][3] = color[3];
+ }
+
+ /* put vertex data into vbuf */
+ pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf,
+ st->clear.vbuf_slot
+ * sizeof(st->clear.vertices),
+ sizeof(st->clear.vertices),
+ st->clear.vertices);
+
+ /* draw */
+ util_draw_vertex_buffer(pipe,
+ st->cso_context,
+ st->clear.vbuf,
+ st->clear.vbuf_slot * sizeof(st->clear.vertices),
+ PIPE_PRIM_TRIANGLE_FAN,
+ 4, /* verts */
+ 2); /* attribs/vert */
+
+ /* Increment slot */
+ st->clear.vbuf_slot++;
+}
+
+
+
+/**
+ * Do glClear by drawing a quadrilateral.
+ * The vertices of the quad will be computed from the
+ * ctx->DrawBuffer->_X/Ymin/max fields.
+ */
+static void
+clear_with_quad(struct gl_context *ctx,
+ GLboolean color, GLboolean depth, GLboolean stencil)
+{
+ struct st_context *st = st_context(ctx);
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLfloat fb_width = (GLfloat) fb->Width;
+ const GLfloat fb_height = (GLfloat) fb->Height;
+ const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f;
+ const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
+ const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
+ const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
+ float clearColor[4];
+
+ /*
+ printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
+ color ? "color, " : "",
+ depth ? "depth, " : "",
+ stencil ? "stencil" : "",
+ x0, y0,
+ x1, y1);
+ */
+
+ cso_save_blend(st->cso_context);
+ cso_save_stencil_ref(st->cso_context);
+ cso_save_depth_stencil_alpha(st->cso_context);
+ cso_save_rasterizer(st->cso_context);
+ cso_save_viewport(st->cso_context);
+ cso_save_clip(st->cso_context);
+ cso_save_fragment_shader(st->cso_context);
+ cso_save_vertex_shader(st->cso_context);
+ cso_save_vertex_elements(st->cso_context);
+ cso_save_vertex_buffers(st->cso_context);
+
+ /* blend state: RGBA masking */
+ {
+ struct pipe_blend_state blend;
+ memset(&blend, 0, sizeof(blend));
+ blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+ blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+ blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ if (color) {
+ if (ctx->Color.ColorMask[0][0])
+ blend.rt[0].colormask |= PIPE_MASK_R;
+ if (ctx->Color.ColorMask[0][1])
+ blend.rt[0].colormask |= PIPE_MASK_G;
+ if (ctx->Color.ColorMask[0][2])
+ blend.rt[0].colormask |= PIPE_MASK_B;
+ if (ctx->Color.ColorMask[0][3])
+ blend.rt[0].colormask |= PIPE_MASK_A;
+ if (st->ctx->Color.DitherFlag)
+ blend.dither = 1;
+ }
+ cso_set_blend(st->cso_context, &blend);
+ }
+
+ /* depth_stencil state: always pass/set to ref value */
+ {
+ struct pipe_depth_stencil_alpha_state depth_stencil;
+ memset(&depth_stencil, 0, sizeof(depth_stencil));
+ if (depth) {
+ depth_stencil.depth.enabled = 1;
+ depth_stencil.depth.writemask = 1;
+ depth_stencil.depth.func = PIPE_FUNC_ALWAYS;
+ }
+
+ if (stencil) {
+ struct pipe_stencil_ref stencil_ref;
+ memset(&stencil_ref, 0, sizeof(stencil_ref));
+ depth_stencil.stencil[0].enabled = 1;
+ depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS;
+ depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].valuemask = 0xff;
+ depth_stencil.stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff;
+ stencil_ref.ref_value[0] = ctx->Stencil.Clear;
+ cso_set_stencil_ref(st->cso_context, &stencil_ref);
+ }
+
+ cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil);
+ }
+
+ cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw);
+
+ cso_set_rasterizer(st->cso_context, &st->clear.raster);
+
+ /* viewport state: viewport matching window dims */
+ {
+ const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
+ struct pipe_viewport_state vp;
+ vp.scale[0] = 0.5f * fb_width;
+ vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
+ vp.scale[2] = 1.0f;
+ vp.scale[3] = 1.0f;
+ vp.translate[0] = 0.5f * fb_width;
+ vp.translate[1] = 0.5f * fb_height;
+ vp.translate[2] = 0.0f;
+ vp.translate[3] = 0.0f;
+ cso_set_viewport(st->cso_context, &vp);
+ }
+
+ cso_set_clip(st->cso_context, &st->clear.clip);
+ set_fragment_shader(st);
+ set_vertex_shader(st);
+
+ if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+ st_translate_color(ctx->Color.ClearColor,
+ ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+ clearColor);
+ }
+
+ /* draw quad matching scissor rect */
+ draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, clearColor);
+
+ /* Restore pipe state */
+ cso_restore_blend(st->cso_context);
+ cso_restore_stencil_ref(st->cso_context);
+ cso_restore_depth_stencil_alpha(st->cso_context);
+ cso_restore_rasterizer(st->cso_context);
+ cso_restore_viewport(st->cso_context);
+ cso_restore_clip(st->cso_context);
+ cso_restore_fragment_shader(st->cso_context);
+ cso_restore_vertex_shader(st->cso_context);
+ cso_restore_vertex_elements(st->cso_context);
+ cso_restore_vertex_buffers(st->cso_context);
+}
+
+
+/**
+ * Determine if we need to clear the depth buffer by drawing a quad.
+ */
+static INLINE GLboolean
+check_clear_color_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ if (ctx->Scissor.Enabled &&
+ (ctx->Scissor.X != 0 ||
+ ctx->Scissor.Y != 0 ||
+ ctx->Scissor.Width < rb->Width ||
+ ctx->Scissor.Height < rb->Height))
+ return GL_TRUE;
+
+ if (!ctx->Color.ColorMask[0][0] ||
+ !ctx->Color.ColorMask[0][1] ||
+ !ctx->Color.ColorMask[0][2] ||
+ !ctx->Color.ColorMask[0][3])
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Determine if we need to clear the combiend depth/stencil buffer by
+ * drawing a quad.
+ */
+static INLINE GLboolean
+check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ const GLuint stencilMax = 0xff;
+ GLboolean maskStencil
+ = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
+ if (ctx->Scissor.Enabled &&
+ (ctx->Scissor.X != 0 ||
+ ctx->Scissor.Y != 0 ||
+ ctx->Scissor.Width < rb->Width ||
+ ctx->Scissor.Height < rb->Height))
+ return GL_TRUE;
+
+ if (maskStencil)
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Determine if we need to clear the depth buffer by drawing a quad.
+ */
+static INLINE GLboolean
+check_clear_depth_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ boolean ds_separate)
+{
+ const struct st_renderbuffer *strb = st_renderbuffer(rb);
+ const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
+
+ if (ctx->Scissor.Enabled &&
+ (ctx->Scissor.X != 0 ||
+ ctx->Scissor.Y != 0 ||
+ ctx->Scissor.Width < rb->Width ||
+ ctx->Scissor.Height < rb->Height))
+ return GL_TRUE;
+
+ if (!ds_separate && isDS && ctx->DrawBuffer->Visual.stencilBits > 0)
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Determine if we need to clear the stencil buffer by drawing a quad.
+ */
+static INLINE GLboolean
+check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ boolean ds_separate)
+{
+ const struct st_renderbuffer *strb = st_renderbuffer(rb);
+ const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
+ const GLuint stencilMax = 0xff;
+ const GLboolean maskStencil
+ = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
+ if (maskStencil)
+ return GL_TRUE;
+
+ if (ctx->Scissor.Enabled &&
+ (ctx->Scissor.X != 0 ||
+ ctx->Scissor.Y != 0 ||
+ ctx->Scissor.Width < rb->Width ||
+ ctx->Scissor.Height < rb->Height))
+ return GL_TRUE;
+
+ /* This is correct, but it is necessary to look at the depth clear
+ * value held in the surface when it comes time to issue the clear,
+ * rather than taking depth and stencil clear values from the
+ * current state.
+ */
+ if (!ds_separate && isDS && ctx->DrawBuffer->Visual.depthBits > 0)
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+
+/**
+ * Called when we need to flush.
+ */
+void
+st_flush_clear(struct st_context *st)
+{
+ /* Release vertex buffer to avoid synchronous rendering if we were
+ * to map it in the next frame.
+ */
+ pipe_resource_reference(&st->clear.vbuf, NULL);
+ st->clear.vbuf_slot = 0;
+}
+
+
+
+/**
+ * Called via ctx->Driver.Clear()
+ */
+static void
+st_Clear(struct gl_context *ctx, GLbitfield mask)
+{
+ static const GLbitfield BUFFER_BITS_DS
+ = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+ struct st_context *st = st_context(ctx);
+ struct gl_renderbuffer *depthRb
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ struct gl_renderbuffer *stencilRb
+ = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLbitfield quad_buffers = 0x0;
+ GLbitfield clear_buffers = 0x0;
+ GLuint i;
+
+ /* This makes sure the pipe has the latest scissor, etc values */
+ st_validate_state( st );
+
+ if (mask & BUFFER_BITS_COLOR) {
+ for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
+ GLuint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+
+ if (mask & (1 << b)) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[b].Renderbuffer;
+ struct st_renderbuffer *strb = st_renderbuffer(rb);
+
+ if (!strb || !strb->surface)
+ continue;
+
+ if (check_clear_color_with_quad( ctx, rb ))
+ quad_buffers |= PIPE_CLEAR_COLOR;
+ else
+ clear_buffers |= PIPE_CLEAR_COLOR;
+ }
+ }
+ }
+
+ if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depthRb == stencilRb) {
+ /* clearing combined depth + stencil */
+ struct st_renderbuffer *strb = st_renderbuffer(depthRb);
+
+ if (strb->surface) {
+ if (check_clear_depth_stencil_with_quad(ctx, depthRb))
+ quad_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
+ else
+ clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
+ }
+ }
+ else {
+ /* separate depth/stencil clears */
+ /* I don't think truly separate buffers are actually possible in gallium or hw? */
+ if (mask & BUFFER_BIT_DEPTH) {
+ struct st_renderbuffer *strb = st_renderbuffer(depthRb);
+
+ if (strb->surface) {
+ if (check_clear_depth_with_quad(ctx, depthRb,
+ st->clear.enable_ds_separate))
+ quad_buffers |= PIPE_CLEAR_DEPTH;
+ else
+ clear_buffers |= PIPE_CLEAR_DEPTH;
+ }
+ }
+ if (mask & BUFFER_BIT_STENCIL) {
+ struct st_renderbuffer *strb = st_renderbuffer(stencilRb);
+
+ if (strb->surface) {
+ if (check_clear_stencil_with_quad(ctx, stencilRb,
+ st->clear.enable_ds_separate))
+ quad_buffers |= PIPE_CLEAR_STENCIL;
+ else
+ clear_buffers |= PIPE_CLEAR_STENCIL;
+ }
+ }
+ }
+
+ /*
+ * If we're going to use clear_with_quad() for any reason, use it for
+ * everything possible.
+ */
+ if (quad_buffers) {
+ quad_buffers |= clear_buffers;
+ clear_with_quad(ctx,
+ quad_buffers & PIPE_CLEAR_COLOR,
+ quad_buffers & PIPE_CLEAR_DEPTH,
+ quad_buffers & PIPE_CLEAR_STENCIL);
+ } else if (clear_buffers) {
+ /* driver cannot know it can clear everything if the buffer
+ * is a combined depth/stencil buffer but this wasn't actually
+ * required from the visual. Hence fix this up to avoid potential
+ * read-modify-write in the driver.
+ */
+ float clearColor[4];
+
+ if ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) &&
+ ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
+ (depthRb == stencilRb) &&
+ (ctx->DrawBuffer->Visual.depthBits == 0 ||
+ ctx->DrawBuffer->Visual.stencilBits == 0))
+ clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
+
+ if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+ st_translate_color(ctx->Color.ClearColor,
+ ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+ clearColor);
+ }
+
+ st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor,
+ ctx->Depth.Clear, ctx->Stencil.Clear);
+ }
+ if (mask & BUFFER_BIT_ACCUM)
+ st_clear_accum_buffer(ctx,
+ ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
+}
+
+
+void
+st_init_clear_functions(struct dd_function_table *functions)
+{
+ functions->Clear = st_Clear;
+}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 8bdb3c801..1b824c0de 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -1530,7 +1530,7 @@ st_copy_texsubimage(struct gl_context *ctx, GLint srcY0, srcY1;
struct pipe_surface surf_tmpl;
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = stImage->pt->format;
+ surf_tmpl.format = util_format_linear(stImage->pt->format);
surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
surf_tmpl.u.tex.level = stImage->level;
surf_tmpl.u.tex.first_layer = stImage->face + destZ;
|