summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2008-12-07 19:06:58 -0500
committerZack Rusin <zack@tungstengraphics.com>2008-12-07 19:06:58 -0500
commit22c6e1a9128f3e5d0c686efe2994a26a1a482658 (patch)
tree70a5a7ef63b91cbc326544f105d8af5212cdc95c
Starting work on OpenCL
-rw-r--r--.emacs-dirvars10
-rw-r--r--Makefile111
-rwxr-xr-xbin/installmesa74
-rwxr-xr-xbin/minstall89
-rwxr-xr-xbin/mklib801
-rwxr-xr-xbin/raw2png.py366
-rwxr-xr-xbin/win32kprof.py309
-rw-r--r--configs/.gitignore1
-rw-r--r--configs/default98
-rw-r--r--configs/linux-dri68
-rw-r--r--configs/linux-dri-debug16
-rw-r--r--configs/linux-dri-x8610
-rw-r--r--configs/linux-dri-x86-6421
-rw-r--r--cpuwinsys/cpuwinsys.c273
-rw-r--r--cpuwinsys/cpuwinsys.h6
-rw-r--r--include/OpenCL/cl.h843
-rw-r--r--include/OpenCL/cl_gl.h103
-rw-r--r--include/OpenCL/cl_platform.h119
-rw-r--r--include/OpenCL/device.h10
-rw-r--r--src/Makefile0
-rw-r--r--src/api_command.c42
-rw-r--r--src/api_context.c47
-rw-r--r--src/api_device.c205
-rw-r--r--src/api_enqueue.c221
-rw-r--r--src/api_event.c31
-rw-r--r--src/api_flush.c14
-rw-r--r--src/api_kernel.c61
-rw-r--r--src/api_memory.c84
-rw-r--r--src/api_platform.c34
-rw-r--r--src/api_profiling.c13
-rw-r--r--src/api_program.c74
-rw-r--r--src/api_sampler.c34
-rw-r--r--src/cl_api.c0
-rw-r--r--src/context.h16
-rw-r--r--src/device.c10
-rw-r--r--src/device.h12
36 files changed, 4226 insertions, 0 deletions
diff --git a/.emacs-dirvars b/.emacs-dirvars
new file mode 100644
index 0000000..33945f9
--- /dev/null
+++ b/.emacs-dirvars
@@ -0,0 +1,10 @@
+;; -*- emacs-lisp -*-
+;;
+;; This file is processed by the dirvars emacs package. Each variable
+;; setting below is performed when this dirvars file is loaded.
+;;
+indent-tabs-mode: nil
+tab-width: 8
+c-basic-offset: 3
+kde-emacs-after-parent-string: ""
+evaluate: (c-set-offset 'inline-open '0)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3d29244
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,111 @@
+TOP = .
+include $(TOP)/configs/current
+
+
+CL_SOURCES = \
+ src/api_command.c \
+ src/api_context.c \
+ src/api_device.c \
+ src/api_enqueue.c \
+ src/api_event.c \
+ src/api_flush.c \
+ src/api_kernel.c \
+ src/api_memory.c \
+ src/api_platform.c \
+ src/api_profiling.c \
+ src/api_program.c \
+ src/api_sampler.c \
+ cpuwinsys/cpuwinsys.c
+
+
+### All the core C sources
+
+ALL_SOURCES = \
+ $(CL_SOURCES)
+
+
+### Object files
+CL_OBJECTS = \
+ $(CL_SOURCES:.c=.o)
+
+### Include directories
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include \
+ -I$(GALLIUM)/include \
+ -I$(GALLIUM)/src/gallium/include \
+ -I$(GALLIUM)/src/gallium/auxiliary
+
+CL_LIB = OpenCL
+CL_LIB_NAME = lib$(CL_LIB).so
+
+CL_MAJOR = 1
+CL_MINOR = 0
+CL_TINY = 0
+
+GALLIUM_LIBS = \
+ $(GALLIUM)/src/gallium/auxiliary/pipebuffer/libpipebuffer.a \
+ $(GALLIUM)/src/gallium/auxiliary/sct/libsct.a \
+ $(GALLIUM)/src/gallium/auxiliary/draw/libdraw.a \
+ $(GALLIUM)/src/gallium/auxiliary/rtasm/librtasm.a \
+ $(GALLIUM)/src/gallium/auxiliary/translate/libtranslate.a \
+ $(GALLIUM)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
+ $(GALLIUM)/src/gallium/auxiliary/tgsi/libtgsi.a \
+ $(GALLIUM)/src/gallium/auxiliary/util/libutil.a
+
+.SUFFIXES : .cpp
+
+.c.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+.cpp.o:
+ $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+
+default: depend subdirs $(TOP)/$(LIB_DIR)/$(CL_LIB_NAME)
+
+# Make the OpenCL library
+$(TOP)/$(LIB_DIR)/$(CL_LIB_NAME): $(CL_OBJECTS) $(GALLIUM_LIBS)
+ $(TOP)/bin/mklib -o $(CL_LIB) \
+ -major $(CL_MAJOR) \
+ -minor $(CL_MINOR) \
+ -patch $(CL_TINY) \
+ -install $(TOP)/$(LIB_DIR) \
+ $(CL_OBJECTS) $(GALLIUM_LIBS) \
+ -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive $(SYS_LIBS)
+
+######################################################################
+# Generic stuff
+
+depend: $(ALL_SOURCES)
+ @ echo "running $(MKDEP)"
+ @ rm -f depend # workaround oops on gutsy?!?
+ @ touch depend
+ @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
+ > /dev/null 2>/dev/null
+
+
+subdirs:
+
+install: default
+ $(INSTALL) -d $(INSTALL_DIR)/include/OpenCL
+ $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
+ $(INSTALL) -m 644 $(TOP)/include/OpenCL/*.h $(INSTALL_DIR)/include/OpenCL
+ @if [ -e $(TOP)/$(LIB_DIR)/$(CL_LIB_NAME) ]; then \
+ $(INSTALL) $(TOP)/$(LIB_DIR)/libOpenCL* $(INSTALL_DIR)/$(LIB_DIR); \
+ fi
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` $(TOP)/include/OpenCL/*.h
+
+clean:
+ -rm -f */*.o
+ -rm -f */*/*.o
+ -rm -f depend depend.bak
+
+include depend
+
diff --git a/bin/installmesa b/bin/installmesa
new file mode 100755
index 0000000..1e24c05
--- /dev/null
+++ b/bin/installmesa
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+#
+# Simple shell script for installing Mesa's header and library files.
+# If the copy commands below don't work on a particular system (i.e. the
+# -f or -d flags), we may need to branch on `uname` to do the right thing.
+#
+
+
+TOP=.
+
+INCLUDE_DIR="/usr/local/include"
+LIB_DIR="/usr/local/lib"
+
+if [ "x$#" = "x0" ] ; then
+echo
+echo "***** Mesa installation - You may need root privileges to do this *****"
+echo
+echo "Default directory for header files is:" ${INCLUDE_DIR}
+echo "Enter new directory or press <Enter> to accept this default."
+
+read INPUT
+if [ "x${INPUT}" != "x" ] ; then
+ INCLUDE_DIR=${INPUT}
+fi
+
+echo
+echo "Default directory for library files is:" ${LIB_DIR}
+echo "Enter new directory or press <Enter> to accept this default."
+
+read INPUT
+if [ "x${INPUT}" != "x" ] ; then
+ LIB_DIR=${INPUT}
+fi
+
+echo
+echo "About to install Mesa header files (GL/*.h) in: " ${INCLUDE_DIR}/GL
+echo "and Mesa library files (libGL.*, etc) in: " ${LIB_DIR}
+echo "Press <Enter> to continue, or <ctrl>-C to abort."
+
+read INPUT
+
+else
+INCLUDE_DIR=$1/include
+LIB_DIR=$1/lib
+fi
+
+# flags:
+# -f = force
+# -d = preserve symlinks (does not work on BSD)
+
+if [ `uname` = "FreeBSD" ] ; then
+ CP_FLAGS="-f"
+elif [ `uname` = "Darwin" ] ; then
+ CP_FLAGS="-f"
+elif [ `uname` = "AIX" ] ; then
+ CP_FLAGS="-fh"
+else
+ CP_FLAGS="-fd"
+fi
+
+
+set -v
+
+mkdir -p ${INCLUDE_DIR}
+mkdir -p ${INCLUDE_DIR}/GL
+# NOT YET: mkdir -p ${INCLUDE_DIR}/GLES
+mkdir -p ${LIB_DIR}
+cp -f ${TOP}/include/GL/*.h ${INCLUDE_DIR}/GL
+cp -f ${TOP}/src/glw/*.h ${INCLUDE_DIR}/GL
+# NOT YET: cp -f ${TOP}/include/GLES/*.h ${INCLUDE_DIR}/GLES
+cp ${CP_FLAGS} ${TOP}/lib*/lib* ${LIB_DIR}
+
+echo "Done."
diff --git a/bin/minstall b/bin/minstall
new file mode 100755
index 0000000..819b2bc
--- /dev/null
+++ b/bin/minstall
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+
+# A minimal replacement for 'install' that supports installing symbolic links.
+# Only a limited number of options are supported:
+# -d dir Create a directory
+# -m mode Sets a file's mode when installing
+
+
+# If these commands aren't portable, we'll need some "if (arch)" type stuff
+SYMLINK="ln -s"
+MKDIR="mkdir -p"
+RM="rm -f"
+
+MODE=""
+
+if [ "$1" = "-d" ] ; then
+ # make a directory path
+ $MKDIR "$2"
+ exit 0
+fi
+
+if [ "$1" = "-m" ] ; then
+ # set file mode
+ MODE=$2
+ shift 2
+fi
+
+# install file(s) into destination
+if [ $# -ge 2 ] ; then
+
+ # Last cmd line arg is the dest dir
+ for FILE in $@ ; do
+ DEST="$FILE"
+ done
+
+ # Loop over args, moving them to DEST directory
+ I=1
+ for FILE in $@ ; do
+ if [ $I = $# ] ; then
+ # stop, don't want to install $DEST into $DEST
+ exit 0
+ fi
+
+ # determine file's type
+ if [ -h "$FILE" ] ; then
+ #echo $FILE is a symlink
+ # Unfortunately, cp -d isn't universal so we have to
+ # use a work-around.
+
+ # Use ls -l to find the target that the link points to
+ LL=`ls -l "$FILE"`
+ for L in $LL ; do
+ TARGET=$L
+ done
+ #echo $FILE is a symlink pointing to $TARGET
+
+ FILE=`basename "$FILE"`
+ # Go to $DEST and make the link
+ PWDSAVE="$PWD"
+ cd "$DEST" # pushd
+ $RM "$FILE"
+ $SYMLINK "$TARGET" "$FILE"
+ cd "$PWDSAVE" # popd
+
+ elif [ -f "$FILE" ] ; then
+ #echo "$FILE" is a regular file
+ $RM "$DEST/`basename $FILE`"
+ cp "$FILE" "$DEST"
+ if [ $MODE ] ; then
+ FILE=`basename "$FILE"`
+ chmod $MODE "$DEST/$FILE"
+ fi
+ else
+ echo "Unknown type of argument: " "$FILE"
+ exit 1
+ fi
+
+ I=`expr $I + 1`
+ done
+
+ exit 0
+fi
+
+# If we get here, we didn't find anything to do
+echo "Usage:"
+echo " install -d dir Create named directory"
+echo " install [-m mode] file [...] dest Install files in destination"
+
diff --git a/bin/mklib b/bin/mklib
new file mode 100755
index 0000000..e17e2fe
--- /dev/null
+++ b/bin/mklib
@@ -0,0 +1,801 @@
+#!/bin/sh
+
+# Make a shared library.
+# This script should be useful for projects other than Mesa.
+# Improvements/fixes are welcome.
+
+
+# Copyright (C) 1999-2006 Brian Paul 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, 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
+# BRIAN PAUL 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.
+
+
+#
+# Option defaults
+#
+LIBNAME=""
+MAJOR=1
+MINOR=0
+PATCH=""
+DEPS=""
+LINK=""
+CPLUSPLUS=0
+STATIC=0
+DLOPEN=0
+INSTALLDIR="."
+ARCH="auto"
+ARCHOPT=""
+NOPREFIX=0
+EXPORTS=""
+
+
+#
+# Parse arguments
+#
+while true
+do
+ case $1 in
+ '-h' | '--help')
+ echo 'Usage: mklib [options] objects'
+ echo 'Create a shared library from object files.'
+ echo ' -o LIBRARY specifies the name of the resulting library, without'
+ echo ' the leading "lib" or any suffix.'
+ echo ' (eg: "-o GL" might result in "libGL.so" being made)'
+ echo ' -major N specifies major version number (default is 1)'
+ echo ' -minor N specifies minor version number (default is 0)'
+ echo ' -patch N specifies patch version number (default is 0)'
+ echo ' -lLIBRARY specifies a dependency on LIBRARY'
+ echo ' -LDIR search in DIR for library dependencies'
+ echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
+ echo ' Not observed on all systems at this time.'
+ echo ' -cplusplus link with C++ runtime'
+ echo ' -static make a static library (default is dynamic/shared)'
+ echo ' -dlopen make a shared library suitable for dynamic loading'
+ echo ' -install DIR put resulting library file(s) in DIR'
+ echo ' -arch ARCH override using `uname` to determine host system'
+ echo ' -archopt OPT specify an extra achitecture-specific option OPT'
+ echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
+ echo ' -exports FILE only export the symbols listed in FILE'
+ echo ' -h, --help display this information and exit'
+ exit 1
+ ;;
+ '-o')
+ shift 1;
+ LIBNAME=$1
+ ;;
+ '-major')
+ shift 1;
+ MAJOR=$1
+ ;;
+ '-minor')
+ shift 1;
+ MINOR=$1
+ ;;
+ '-patch')
+ shift 1;
+ PATCH=$1
+ ;;
+ '-linker')
+ shift 1;
+ LINK=$1
+ ;;
+ -l*)
+ DEPS="$DEPS $1"
+ ;;
+ -L*)
+ DEPS="$DEPS $1"
+ ;;
+ -pthread)
+ # this is a special case (see bugzilla 10876)
+ DEPS="$DEPS $1"
+ ;;
+ '-pthread')
+ DEPS="$DEPS -pthread"
+ ;;
+ '-cplusplus')
+ CPLUSPLUS=1
+ ;;
+ '-static')
+ STATIC=1
+ ;;
+ '-dlopen')
+ DLOPEN=1
+ ;;
+ '-install')
+ shift 1;
+ INSTALLDIR=$1
+ ;;
+ '-arch')
+ shift 1;
+ ARCH=$1
+ ;;
+ '-archopt')
+ shift 1;
+ ARCHOPT=$1
+ ;;
+ '-noprefix')
+ NOPREFIX=1
+ ;;
+ '-exports')
+ shift 1;
+ EXPORTS=$1
+ ;;
+ -*)
+ echo "mklib: Unknown option: " $1 ;
+ exit 1
+ ;;
+ *)
+ # This should be the first object file, stop parsing
+ break
+ esac
+ shift 1
+done
+OBJECTS=$@
+
+
+if [ ${ARCH} = "auto" ] ; then
+ ARCH=`uname`
+fi
+
+
+#
+# Error checking
+#
+if [ "x${LIBNAME}" = "x" ] ; then
+ echo "mklib: Error: no library name specified"
+ exit 1
+fi
+if [ "x${OBJECTS}" = "x" ] ; then
+ echo "mklib: Error: no object files specified"
+ exit 1
+fi
+
+
+#
+# Debugging info
+#
+if [ ] ; then
+ echo "-----------------"
+ echo ARCH is $ARCH
+ echo LIBNAME is $LIBNAME
+ echo MAJOR is $MAJOR
+ echo MINOR is $MINOR
+ echo PATCH is $PATCH
+ echo DEPS are $DEPS
+ echo "EXPORTS in" $EXPORTS
+ echo "-----------------"
+fi
+
+
+#
+# OK, make the library now
+#
+case $ARCH in
+
+ 'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
+ # we assume gcc
+
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified so set default link command now
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=g++
+ else
+ LINK=gcc
+ fi
+ fi
+
+ if [ $NOPREFIX = 1 ] ; then
+ # No "lib" or ".so" part
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
+ case $ARCH in 'Linux' | 'GNU' | GNU/*)
+ OPTS="-Xlinker -Bsymbolic -shared"
+ ;;
+ *)
+ OPTS="-shared"
+ ;;
+ esac
+
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
+ OPTS="-m32 ${OPTS}"
+ fi
+
+ rm -f ${LIBNAME}
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ # finish up
+ FINAL_LIBS="${LIBNAME}"
+ elif [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
+ echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
+ LINK="ar"
+ OPTS="-ru"
+ rm -f ${LIBNAME}
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
+ ranlib ${LIBNAME}
+ # finish up
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+ case $ARCH in 'Linux' | 'GNU' | GNU/*)
+ OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
+ ;;
+ *)
+ OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
+ ;;
+ esac
+ if [ $EXPORTS ] ; then
+ #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
+ # Make the 'exptmp' file for --version-script option
+ echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
+ echo "global:" >> exptmp
+ sed 's/$/;/' ${EXPORTS} >> exptmp
+ echo "local:" >> exptmp
+ echo "*;" >> exptmp
+ echo "};" >> exptmp
+ OPTS="${OPTS} -Xlinker --version-script=exptmp"
+ # exptmp is removed below
+ fi
+
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
+ OPTS="-m32 ${OPTS}"
+ fi
+
+ if [ x${PATCH} = "x" ] ; then
+ VERSION="${MAJOR}.${MINOR}"
+ else
+ VERSION="${MAJOR}.${MINOR}.${PATCH}"
+ fi
+
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
+
+ # rm any old libs
+ rm -f ${LIBNAME}.so.${VERSION}
+ rm -f ${LIBNAME}.so.${MAJOR}
+ rm -f ${LIBNAME}.so
+
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
+ ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
+ # finish up
+ FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
+# rm -f exptmp
+ fi
+ ;;
+
+ 'SunOS')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making SunOS static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ if [ $NOPREFIX = 0 ] ; then
+ LIBNAME="lib${LIBNAME}.so"
+ fi
+ echo "mklib: Making SunOS shared library: " ${LIBNAME}
+
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified, choose default linker now
+ if [ $CPLUSPLUS = 1 ] ; then
+ # determine linker and options for C++ code
+ if [ `which c++` ] ; then
+ # use Sun c++
+ LINK="c++"
+ elif [ `type g++` ] ; then
+ # use g++
+ LINK="g++"
+ else
+ echo "mklib: warning: can't find C++ comiler, trying CC."
+ LINK="CC"
+ fi
+ else
+ # use native Sun linker for C code
+ LINK="ld"
+ fi
+ fi
+
+ # linker options
+ if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
+ # SunOS tools, -G to make shared libs
+ OPTS="-G"
+ else
+ # gcc linker
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" ] ; then
+ OPTS="-m32 -shared -Wl,-Bdynamic"
+ else
+ OPTS="-m64 -shared -Wl,-Bdynamic"
+ fi
+ fi
+
+ # Check if objects are SPARC v9
+ # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
+ set ${OBJECTS}
+ SPARCV9=`file $1 | grep SPARCV9`
+ if [ "${SPARCV9}" ] ; then
+ OPTS="${OPTS} -xarch=v9"
+ fi
+
+ # for debug:
+ #echo "mklib: linker is" ${LINK} ${OPTS}
+ if [ $NOPREFIX = 1 ] ; then
+ rm -f ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ else
+ rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
+ ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
+ fi
+ FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
+ fi
+ ;;
+
+ 'FreeBSD')
+ # we assume gcc
+
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified so set default link command now
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=g++
+ else
+ LINK=gcc
+ fi
+ fi
+
+ if [ $NOPREFIX = 1 ] ; then
+ # No "lib" or ".so" part
+ echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
+ OPTS="-shared"
+ rm -f ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ elif [ $STATIC = 1 ] ; then
+ STLIB="lib${LIBNAME}.a"
+ echo "mklib: Making FreeBSD static library: " ${STLIB}
+ rm -f ${STLIB}
+ ar cq ${STLIB} ${OBJECTS}
+ ranlib ${STLIB}
+ FINAL_LIBS=${STLIB}
+ else
+ SHLIB="lib${LIBNAME}.so.${MAJOR}"
+ OPTS="-shared -Wl,-soname,${SHLIB}"
+ echo "mklib: Making FreeBSD shared library: " ${SHLIB}
+ rm -f ${SHLIB}
+ ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
+ ln -sf ${SHLIB} "lib${LIBNAME}.so"
+ FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
+ fi
+ ;;
+
+ 'NetBSD')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}_pic.a"
+ echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar cq ${LIBNAME} ${OBJECTS}
+ ranlib ${LIBNAME}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
+ echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'IRIX' | 'IRIX64')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ rm -f ${LIBNAME}
+ ar rc ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+
+ # examine first object to determine ABI
+ set ${OBJECTS}
+ ABI_O32=`file $1 | grep 'ELF 32-bit'`
+ ABI_N32=`file $1 | grep 'ELF N32'`
+ ABI_N64=`file $1 | grep 'ELF 64-bit'`
+ if [ "${ABI_O32}" ] ; then
+ OPTS="-32 -shared -all"
+ ABI="o32-bit"
+ elif [ "${ABI_N32}" ] ; then
+ OPTS="-n32 -shared -all"
+ ABI="n32-bit"
+ elif [ "${ABI_N64}" ] ; then
+ OPTS="-64 -shared -all"
+ ABI="64-bit"
+ else
+ echo "Error: Unexpected IRIX ABI!"
+ exit 1
+ fi
+
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="CC"
+ else
+ LINK="ld"
+ fi
+
+ echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'linux-cygwin')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making linux-cygwin library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'HP-UX')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making HP-UX static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ # HP uses a .2 for their current GL/GLU libraries
+ if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
+ MAJOR=2
+ fi
+ RUNLIB="lib${LIBNAME}.${MAJOR}"
+ DEVLIB="lib${LIBNAME}.sl"
+ echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
+ ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
+ ln -s ${RUNLIB} ${DEVLIB}
+ FINAL_LIBS="${RUNLIB} ${DEVLIB}"
+ fi
+ ;;
+
+ 'AIX' )
+ # examine first object to determine ABI
+ set ${OBJECTS}
+ ABI_64=`file $1 | grep '64-bit'`
+ if [ "${ABI_64}" ] ; then
+ X64="-X64"
+ Q64="-q64"
+ OFILE=shr_64.o
+ else
+ OFILE=shr.o #Want to be consistent with the IBM libGL.a
+ fi
+
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making AIX static library: " ${LIBNAME}
+ ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ EXPFILE="lib${LIBNAME}.exp"
+ LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
+ OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
+ rm -f ${EXPFILE} ${OFILE}
+ NM="/bin/nm -eC ${X64}"
+ echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
+ ${NM} ${OBJECTS} | awk '{
+ if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
+ && ( substr($1,1,1) != ".")) {
+ if (substr ($1, 1, 7) != "__sinit" &&
+ substr ($1, 1, 7) != "__sterm") {
+ if (substr ($1, 1, 5) == "__tf1")
+ print (substr ($1, 7))
+ else if (substr ($1, 1, 5) == "__tf9")
+ print (substr ($1, 15))
+ else
+ print $1
+ }
+ }
+ }' | sort -u >> ${EXPFILE}
+
+ # On AIX a shared library is linked differently when
+ # you want to dlopen the file
+ if [ $DLOPEN = "1" ] ; then
+ cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ else
+ cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
+ ar ${X64} -r ${LIBNAME} ${OFILE}
+ fi
+
+ FINAL_LIBS="${LIBNAME}"
+ fi
+ ;;
+
+ 'OpenSTEP')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
+ libtool -static -o ${LIBNAME} - ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'OSF1')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making OSF/1 static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ VERSION="${MAJOR}.${MINOR}"
+ LIBNAME="lib${LIBNAME}.so"
+ echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
+ if [ "x$LINK" = "x" ] ; then
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=cxx
+ else
+ LINK=cc
+ fi
+ fi
+ rm -f ${LIBNAME}.${VERSION}
+ ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
+ ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
+ FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
+ fi
+ ;;
+
+ 'Darwin')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making Darwin static library: " ${LIBNAME}
+ LINK="ar"
+ OPTS="-ruvs"
+ ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ # On Darwin a .bundle is used for a library that you want to dlopen
+ if [ $DLOPEN = "1" ] ; then
+ LIBSUFFIX="bundle"
+ OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
+ else
+ LIBSUFFIX="dylib"
+ OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+ fi
+ LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
+ LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+
+ # examine first object to determine ABI
+ set ${OBJECTS}
+ ABI_PPC=`file $1 | grep 'object ppc'`
+ ABI_I386=`file $1 | grep 'object i386'`
+ if [ "${ABI_PPC}" ] ; then
+ OPTS="${OPTS} -arch ppc"
+ fi
+ if [ "${ABI_I386}" ] ; then
+ OPTS="${OPTS} -arch i386"
+ fi
+
+ # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
+ # to OPTS here?
+
+ # determine linker
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="g++"
+ else
+ LINK="cc"
+ fi
+
+ echo "mklib: Making Darwin shared library: " ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ ln -s ${LIBNAME} ${LINKNAME}
+ FINAL_LIBS="${LIBNAME} ${LINKNAME}"
+ fi
+ ;;
+
+ 'LynxOS')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making LynxOS static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'BeOS')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making BeOS static library: " ${LIBNAME}
+ ar -cru "${LIBNAME}" ${OBJECTS}
+ else
+ LIBNAME="lib${LIBNAME}.so"
+ echo "mklib: Making BeOS shared library: " ${LIBNAME}
+ gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
+ mimeset -f "${LIBNAME}"
+ # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
+ setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
+ fi
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'QNX')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making QNX library: " ${LIBNAME}
+ wlib ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'MorphOS')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making MorphOS library: " ${LIBNAME}
+ ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ ;;
+
+ 'icc' | 'icc-istatic')
+ # Intel C compiler
+ # This should get merged into the Linux code, above, since this isn't
+ # really a different architecture.
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+
+ if [ $STATIC = 1 ] ; then
+ echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
+ LINK="ar"
+ OPTS="-ruv"
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
+ # finish up
+ FINAL_LIBS="${LIBNAME}.a"
+ else
+ if [ $ARCH = icc-istatic ] ; then
+ OPTS="-shared -i-static -cxxlib-icc"
+ else
+ OPTS="-shared"
+ fi
+ VERSION="${MAJOR}.${MINOR}.${PATCH}"
+ echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
+
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="icpc"
+ else
+ LINK="icc"
+ fi
+ # rm any old libs
+ rm -f ${LIBNAME}.so.${VERSION}
+ rm -f ${LIBNAME}.so.${MAJOR}
+ rm -f ${LIBNAME}.so
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
+ ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
+ # finish up
+ FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
+ fi
+ ;;
+
+ 'aix-gcc')
+ # AIX with gcc
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making AIX GCC static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
+ # remove old lib
+ rm -f ${LIBNAME}
+ # make the lib
+ gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
+ # NOTE: the application linking with this library must specify
+ # the -Wl,-brtl flags to gcc
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'ultrix')
+ # XXX untested
+ if [ $STATIC = 0 ] ; then
+ echo "mklib: Warning shared libs not supported on Ultrix"
+ fi
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making static library for Ultrix: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ ;;
+
+ CYGWIN*)
+ # GCC-based environment
+ CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+
+ if [ $STATIC = 1 ] ; then
+ echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
+ LINK="ar"
+ OPTS="-ru"
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
+ ranlib ${LIBNAME}.a
+ # finish up
+ FINAL_LIBS=${LIBNAME}.a
+ else
+ OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
+
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="g++"
+ else
+ LINK="gcc"
+ fi
+
+ # rm any old libs
+ rm -f ${LIBNAME}-${MAJOR}.dll
+ rm -f ${LIBNAME}.dll.a
+ rm -f ${LIBNAME}.a
+
+ # make lib
+ ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
+ # finish up
+ FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
+ # special case for installing in bin
+ FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
+ fi
+ ;;
+
+ 'example')
+ # If you're adding support for a new architecture, you can
+ # start with this:
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making static library for example arch: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar rv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ echo "mklib: Making shared library for example arch: " ${LIBNAME}
+ ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS="${LIBNAME}"
+ fi
+ ;;
+
+ *)
+ echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
+ echo "mklib: Please add necessary commands to mklib script."
+ ;;
+esac
+
+
+#
+# Put library files into installation directory if specified.
+#
+if [ ${INSTALLDIR} != "." ] ; then
+ echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
+ mv ${FINAL_LIBS} ${INSTALLDIR}/
+fi
diff --git a/bin/raw2png.py b/bin/raw2png.py
new file mode 100755
index 0000000..f01e799
--- /dev/null
+++ b/bin/raw2png.py
@@ -0,0 +1,366 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# 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 os.path
+import sys
+import struct
+import Image # http://www.pythonware.com/products/pil/
+
+PIPE_FORMAT_LAYOUT_RGBAZS = 0
+PIPE_FORMAT_LAYOUT_YCBCR = 1
+PIPE_FORMAT_LAYOUT_DXT = 2
+PIPE_FORMAT_LAYOUT_MIXED = 3
+
+PIPE_FORMAT_COMP_R = 0
+PIPE_FORMAT_COMP_G = 1
+PIPE_FORMAT_COMP_B = 2
+PIPE_FORMAT_COMP_A = 3
+PIPE_FORMAT_COMP_0 = 4
+PIPE_FORMAT_COMP_1 = 5
+PIPE_FORMAT_COMP_Z = 6
+PIPE_FORMAT_COMP_S = 7
+
+PIPE_FORMAT_TYPE_UNKNOWN = 0
+PIPE_FORMAT_TYPE_FLOAT = 1
+PIPE_FORMAT_TYPE_UNORM = 2
+PIPE_FORMAT_TYPE_SNORM = 3
+PIPE_FORMAT_TYPE_USCALED = 4
+PIPE_FORMAT_TYPE_SSCALED = 5
+PIPE_FORMAT_TYPE_SRGB = 6
+PIPE_FORMAT_TYPE_FIXED = 7
+
+def _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, EXP2, TYPE ):
+ return ((PIPE_FORMAT_LAYOUT_RGBAZS << 0) |\
+ ((SWZ) << 2) |\
+ ((SIZEX) << 14) |\
+ ((SIZEY) << 17) |\
+ ((SIZEZ) << 20) |\
+ ((SIZEW) << 23) |\
+ ((EXP2) << 26) |\
+ ((TYPE) << 29) )
+
+def _PIPE_FORMAT_SWZ( SWZX, SWZY, SWZZ, SWZW ):
+ return (((SWZX) << 0) | ((SWZY) << 3) | ((SWZZ) << 6) | ((SWZW) << 9))
+
+def _PIPE_FORMAT_RGBAZS_1( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE ):
+ return _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 0, TYPE )
+
+def _PIPE_FORMAT_RGBAZS_2( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE ):
+ _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 1, TYPE )
+
+def _PIPE_FORMAT_RGBAZS_8( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE ):
+ return _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 3, TYPE )
+
+def _PIPE_FORMAT_RGBAZS_64( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE ):
+ return _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 6, TYPE )
+
+def _PIPE_FORMAT_MIXED( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, SIGNX, SIGNY, SIGNZ, SIGNW, NORMALIZED, SCALE8 ):
+ return ((PIPE_FORMAT_LAYOUT_MIXED << 0) |\
+ ((SWZ) << 2) |\
+ ((SIZEX) << 14) |\
+ ((SIZEY) << 17) |\
+ ((SIZEZ) << 20) |\
+ ((SIZEW) << 23) |\
+ ((SIGNX) << 26) |\
+ ((SIGNY) << 27) |\
+ ((SIGNZ) << 28) |\
+ ((SIGNW) << 29) |\
+ ((NORMALIZED) << 30) |\
+ ((SCALE8) << 31) )
+
+
+_PIPE_FORMAT_R001 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_1 )
+_PIPE_FORMAT_RG01 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_1 )
+_PIPE_FORMAT_RGB1 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_1 )
+_PIPE_FORMAT_RGBA = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_A )
+_PIPE_FORMAT_ARGB = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B )
+_PIPE_FORMAT_ABGR = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R )
+_PIPE_FORMAT_BGRA = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_A )
+_PIPE_FORMAT_1RGB = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_1, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B )
+_PIPE_FORMAT_1BGR = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_1, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R )
+_PIPE_FORMAT_BGR1 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_1 )
+_PIPE_FORMAT_0000 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+_PIPE_FORMAT_000R = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_R )
+_PIPE_FORMAT_RRR1 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_1 )
+_PIPE_FORMAT_RRRR = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R )
+_PIPE_FORMAT_RRRG = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G )
+_PIPE_FORMAT_Z000 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+_PIPE_FORMAT_0Z00 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+_PIPE_FORMAT_SZ00 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+_PIPE_FORMAT_ZS00 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+_PIPE_FORMAT_S000 = _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
+
+def _PIPE_FORMAT_YCBCR( REV ):
+ return ((PIPE_FORMAT_LAYOUT_YCBCR << 0) |\
+ ((REV) << 2) )
+
+def _PIPE_FORMAT_DXT( LEVEL, RSIZE, GSIZE, BSIZE, ASIZE ):
+ return ((PIPE_FORMAT_LAYOUT_DXT << 0) | \
+ ((LEVEL) << 2) | \
+ ((RSIZE) << 5) | \
+ ((GSIZE) << 8) | \
+ ((BSIZE) << 11) | \
+ ((ASIZE) << 14) )
+
+PIPE_FORMAT_NONE = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_0000, 0, 0, 0, 0, PIPE_FORMAT_TYPE_UNKNOWN )
+PIPE_FORMAT_A8R8G8B8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ARGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_X8R8G8B8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_1RGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_B8G8R8A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_B8G8R8X8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_A1R5G5B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_A4R4G4B4_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R5G6B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_RGB1, 5, 6, 5, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_A2B10G10R10_UNORM = _PIPE_FORMAT_RGBAZS_2 ( _PIPE_FORMAT_ABGR, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_L8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_000R, 0, 0, 0, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_I8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRR, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_A8L8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_L16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_YCBCR = _PIPE_FORMAT_YCBCR( 0 )
+PIPE_FORMAT_YCBCR_REV = _PIPE_FORMAT_YCBCR( 1 )
+PIPE_FORMAT_Z16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_Z32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_Z32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_S8Z24_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_SZ00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_Z24S8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ZS00, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_X8Z24_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_0Z00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_Z24X8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_S8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_S000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R64G64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R64G64B64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R64G64B64A64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R32G32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R32G32B32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R32G32B32A32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FLOAT )
+PIPE_FORMAT_R32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R32G32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R32G32B32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R32G32B32A32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R32G32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R32G32B32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R32G32B32A32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R32G32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R32G32B32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R32G32B32A32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R32G32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R32G32B32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R32G32B32A32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R16G16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R16G16B16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R16G16B16A16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R16G16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R16G16B16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R16G16B16A16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R16G16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R16G16B16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R16G16B16A16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R16G16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R16G16B16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R16G16B16A16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R8G8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R8G8B8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R8G8B8A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R8G8B8X8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM )
+PIPE_FORMAT_R8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R8G8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R8G8B8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R8G8B8A8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R8G8B8X8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_USCALED )
+PIPE_FORMAT_R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R8G8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R8G8B8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R8G8B8A8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R8G8B8X8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_B6G5R5_SNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_BGR1, 6, 5, 5, 0, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_A8B8G8R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_X8B8G8R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM )
+PIPE_FORMAT_R8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R8G8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R8G8B8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R8G8B8A8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R8G8B8X8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED )
+PIPE_FORMAT_R32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FIXED )
+PIPE_FORMAT_R32G32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FIXED )
+PIPE_FORMAT_R32G32B32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FIXED )
+PIPE_FORMAT_R32G32B32A32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FIXED )
+PIPE_FORMAT_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB )
+PIPE_FORMAT_A8_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB )
+PIPE_FORMAT_R8G8B8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB )
+PIPE_FORMAT_R8G8B8A8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB )
+PIPE_FORMAT_R8G8B8X8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB )
+PIPE_FORMAT_X8UB8UG8SR8S_NORM = _PIPE_FORMAT_MIXED( _PIPE_FORMAT_1BGR, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 )
+PIPE_FORMAT_B6UG5SR5S_NORM = _PIPE_FORMAT_MIXED( _PIPE_FORMAT_BGR1, 6, 5, 5, 0, 0, 1, 1, 0, 1, 0 )
+PIPE_FORMAT_DXT1_RGB = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 0 )
+PIPE_FORMAT_DXT1_RGBA = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 8 )
+PIPE_FORMAT_DXT3_RGBA = _PIPE_FORMAT_DXT( 3, 8, 8, 8, 8 )
+PIPE_FORMAT_DXT5_RGBA = _PIPE_FORMAT_DXT( 5, 8, 8, 8, 8 )
+
+
+formats = {}
+for name, value in globals().items():
+ if name.startswith("PIPE_FORMAT_") and isinstance(value, int):
+ formats[value] = name
+
+
+def clip(g):
+ return min(max(g, 0), 255)
+
+
+def yuv2rgb(y, u, v):
+ C = y - 16
+ D = u - 128
+ E = v - 128
+
+ r = clip(( 298 * C + 409 * E + 128) >> 8)
+ g = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
+ b = clip(( 298 * C + 516 * D + 128) >> 8)
+
+ return r, g, b
+
+
+def translate_r5g6b5(data):
+ value, = struct.unpack_from("H", data)
+ r = ((value >> 11) & 0x1f)*0xff/0x1f
+ g = ((value >> 5) & 0x3f)*0xff/0x3f
+ b = ((value >> 0) & 0x1f)*0xff/0x1f
+ a = 255
+ return [[(r, g, b, a)]]
+
+def translate_a8r8g8b8(data):
+ b, g, r, a = struct.unpack_from("BBBB", data)
+ return [[(r, g, b, a)]]
+
+
+def translate_x8r8g8b8(data):
+ b, g, r, x = struct.unpack_from("BBBB", data)
+ a = 255
+ return [[(r, g, b, a)]]
+
+def translate_r8g8b8a8(data):
+ r, g, b, a = struct.unpack_from("BBBB", data)
+ return [[(r, g, b, a)]]
+
+def translate_ycbcr(data):
+ y1, u, y2, v = struct.unpack_from("BBBB", data)
+ r1, g1, b1 = yuv2rgb(y1, u, v)
+ r2, g2, b2 = yuv2rgb(y1, u, v)
+ return [[(r1, g1, b1, 255), (r2, g2, b2, 255)]]
+
+def translate_ycbcr_rev(data):
+ v, y2, u, y1 = struct.unpack_from("BBBB", data)
+ r1, g1, b1 = yuv2rgb(y1, u, v)
+ r2, g2, b2 = yuv2rgb(y1, u, v)
+ return [[(r1, g1, b1, 255), (r2, g2, b2, 255)]]
+
+def translate_x8z24(data):
+ value, = struct.unpack_from("I", data)
+ r = g = b = (value & 0xffffff)*0xff/0xffffff
+ a = 255
+ return [[(r, g, b, a)]]
+
+def translate_s8z24(data):
+ value, = struct.unpack_from("I", data)
+ r = (value & 0xffffff)*0xff/0xffffff
+ g = value >> 24
+ b = 0
+ a = 255
+ return [[(r, g, b, a)]]
+
+
+translate = {
+ PIPE_FORMAT_A8R8G8B8_UNORM: (4, 1, 1, translate_a8r8g8b8),
+ PIPE_FORMAT_X8R8G8B8_UNORM: (4, 1, 1, translate_x8r8g8b8),
+ PIPE_FORMAT_B8G8R8A8_UNORM: (4, 1, 1, translate_r8g8b8a8),
+ PIPE_FORMAT_B8G8R8X8_UNORM: (4, 1, 1, translate_r8g8b8a8),
+ PIPE_FORMAT_A8B8G8R8_SNORM: (4, 1, 1, translate_r8g8b8a8),
+ PIPE_FORMAT_R5G6B5_UNORM: (2, 1, 1, translate_r5g6b5),
+ PIPE_FORMAT_YCBCR: (4, 2, 1, translate_ycbcr),
+ PIPE_FORMAT_YCBCR_REV: (4, 2, 1, translate_ycbcr_rev),
+ PIPE_FORMAT_S8Z24_UNORM: (4, 1, 1, translate_s8z24),
+ PIPE_FORMAT_X8Z24_UNORM: (4, 1, 1, translate_x8z24),
+}
+
+def read_header(infile):
+ header_fmt = "IIII"
+ header = infile.read(struct.calcsize(header_fmt))
+ return struct.unpack_from(header_fmt, header)
+
+def process(infilename, outfilename):
+ sys.stderr.write("%s -> %s\n" % (infilename, outfilename))
+ infile = open(infilename, "rb")
+ format, cpp, width, height = read_header(infile)
+ sys.stderr.write(" %ux%ux%ubpp %s\n" % (width, height, cpp*8, formats[format]))
+ outimage = Image.new(
+ mode='RGB',
+ size=(width, height),
+ color=(0,0,0))
+ outpixels = outimage.load()
+ try:
+ bsize, bwidth, bheight, translate_func = translate[format]
+ except KeyError:
+ sys.stderr.write('error: unsupported format %s\n' % formats[format])
+ return
+ for y in range(0, height, bheight):
+ for x in range(0, width, bwidth):
+ indata = infile.read(bsize)
+ outdata = translate_func(indata)
+ for j in range(bheight):
+ for i in range(bwidth):
+ r, g, b, a = outdata[j][i]
+ outpixels[x+i, y+j] = r, g, b
+ outimage.save(outfilename, "PNG")
+
+
+def main():
+ if sys.platform == 'win32':
+ # wildcard expansion
+ from glob import glob
+ args = []
+ for arg in sys.argv[1:]:
+ args.extend(glob(arg))
+ else:
+ args = sys.argv[1:]
+ for infilename in args:
+ root, ext = os.path.splitext(infilename)
+ outfilename = root + ".png"
+ process(infilename, outfilename)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/bin/win32kprof.py b/bin/win32kprof.py
new file mode 100755
index 0000000..c36317d
--- /dev/null
+++ b/bin/win32kprof.py
@@ -0,0 +1,309 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# 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 sys
+import optparse
+import re
+import struct
+
+from gprof2dot import Call, Function, Profile
+from gprof2dot import CALLS, SAMPLES, TIME, TIME_RATIO, TOTAL_TIME, TOTAL_TIME_RATIO
+from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
+
+
+__version__ = '0.1'
+
+
+class ParseError(Exception):
+ pass
+
+
+class MsvcDemangler:
+ # http://www.kegel.com/mangle.html
+
+ def __init__(self, symbol):
+ self._symbol = symbol
+ self._pos = 0
+
+ def lookahead(self):
+ return self._symbol[self._pos]
+
+ def consume(self):
+ ret = self.lookahead()
+ self._pos += 1
+ return ret
+
+ def match(self, c):
+ if self.lookahead() != c:
+ raise ParseError
+ self.consume()
+
+ def parse(self):
+ self.match('?')
+ name = self.parse_name()
+ qualifications = self.parse_qualifications()
+ return '::'.join(qualifications + [name])
+
+ def parse_name(self):
+ if self.lookahead() == '?':
+ return self.consume() + self.consume()
+ else:
+ name = self.parse_id()
+ self.match('@')
+ return name
+
+ def parse_qualifications(self):
+ qualifications = []
+ while self.lookahead() != '@':
+ name = self.parse_id()
+ qualifications.append(name)
+ self.match('@')
+ return qualifications
+
+ def parse_id(self):
+ s = ''
+ while True:
+ c = self.lookahead()
+ if c.isalnum() or c in '_':
+ s += c
+ self.consume()
+ else:
+ break
+ return s
+
+
+def demangle(name):
+ if name.startswith('_'):
+ name = name[1:]
+ idx = name.rfind('@')
+ if idx != -1 and name[idx+1:].isdigit():
+ name = name[:idx]
+ return name
+ if name.startswith('?'):
+ demangler = MsvcDemangler(name)
+ return demangler.parse()
+ return name
+
+
+class Reader:
+
+ def __init__(self):
+ self.symbols = []
+ self.symbol_cache = {}
+ self.base_addr = None
+
+ def read_map(self, mapfile):
+ # See http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
+ last_addr = 0
+ last_name = 0
+ for line in file(mapfile, "rt"):
+ fields = line.split()
+ try:
+ section_offset, name, addr, type, lib_object = fields
+ except ValueError:
+ continue
+ if type != 'f':
+ continue
+ section, offset = section_offset.split(':')
+ addr = int(offset, 16)
+ self.symbols.append((addr, name))
+ last_addr = addr
+ last_name = name
+
+ # sort symbols
+ self.symbols.sort(key = lambda (addr, name): addr)
+
+ def lookup_addr(self, addr):
+ try:
+ return self.symbol_cache[addr]
+ except KeyError:
+ pass
+
+ tolerance = 4196
+ s, e = 0, len(self.symbols)
+ while s != e:
+ i = (s + e)//2
+ start_addr, name = self.symbols[i]
+ try:
+ end_addr, next_name = self.symbols[i + 1]
+ except IndexError:
+ end_addr = start_addr + tolerance
+ if addr < start_addr:
+ e = i
+ continue
+ if addr == end_addr:
+ return next_name, addr - start_addr
+ if addr > end_addr:
+ s = i
+ continue
+ return name, addr - start_addr
+ raise ValueError
+
+ def lookup_symbol(self, name):
+ for symbol_addr, symbol_name in self.symbols:
+ if name == symbol_name:
+ return symbol_addr
+ return 0
+
+ def read_data(self, data):
+ profile = Profile()
+
+ fp = file(data, "rb")
+ entry_format = "IIII"
+ entry_size = struct.calcsize(entry_format)
+ caller = None
+ caller_stack = []
+ while True:
+ entry = fp.read(entry_size)
+ if len(entry) < entry_size:
+ break
+ caller_addr, callee_addr, samples_lo, samples_hi = struct.unpack(entry_format, entry)
+ if caller_addr == 0 and callee_addr == 0:
+ continue
+
+ if self.base_addr is None:
+ ref_addr = self.lookup_symbol('___debug_profile_reference@0')
+ if ref_addr:
+ self.base_addr = (caller_addr - ref_addr) & ~(options.align - 1)
+ else:
+ self.base_addr = 0
+ sys.stderr.write('Base addr: %08x\n' % self.base_addr)
+
+ samples = (samples_hi << 32) | samples_lo
+
+ try:
+ caller_raddr = caller_addr - self.base_addr
+ caller_sym, caller_ofs = self.lookup_addr(caller_raddr)
+
+ try:
+ caller = profile.functions[caller_sym]
+ except KeyError:
+ caller_name = demangle(caller_sym)
+ caller = Function(caller_sym, caller_name)
+ profile.add_function(caller)
+ caller[CALLS] = 0
+ caller[SAMPLES] = 0
+ except ValueError:
+ caller = None
+
+ if not callee_addr:
+ if caller:
+ caller[SAMPLES] += samples
+ else:
+ callee_raddr = callee_addr - self.base_addr
+ callee_sym, callee_ofs = self.lookup_addr(callee_raddr)
+
+ try:
+ callee = profile.functions[callee_sym]
+ except KeyError:
+ callee_name = demangle(callee_sym)
+ callee = Function(callee_sym, callee_name)
+ profile.add_function(callee)
+ callee[CALLS] = samples
+ callee[SAMPLES] = 0
+ else:
+ callee[CALLS] += samples
+
+ if caller is not None:
+ try:
+ call = caller.calls[callee.id]
+ except KeyError:
+ call = Call(callee.id)
+ call[CALLS] = samples
+ caller.add_call(call)
+ else:
+ call[CALLS] += samples
+
+ if options.verbose:
+ if not callee_addr:
+ sys.stderr.write('%s+%u: %u\n' % (caller_sym, caller_ofs, samples))
+ else:
+ sys.stderr.write('%s+%u -> %s+%u: %u\n' % (caller_sym, caller_ofs, callee_sym, callee_ofs, samples))
+
+ # compute derived data
+ profile.validate()
+ profile.find_cycles()
+ profile.aggregate(SAMPLES)
+ profile.ratio(TIME_RATIO, SAMPLES)
+ profile.call_ratios(CALLS)
+ profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
+
+ return profile
+
+
+def main():
+ parser = optparse.OptionParser(
+ usage="\n\t%prog [options] [file] ...",
+ version="%%prog %s" % __version__)
+ parser.add_option(
+ '-a', '--align', metavar='NUMBER',
+ type="int", dest="align", default=16,
+ help="section alignment")
+ parser.add_option(
+ '-m', '--map', metavar='FILE',
+ type="string", dest="map",
+ help="map file")
+ parser.add_option(
+ '-b', '--base', metavar='FILE',
+ type="string", dest="base",
+ help="base addr")
+ parser.add_option(
+ '-n', '--node-thres', metavar='PERCENTAGE',
+ type="float", dest="node_thres", default=0.5,
+ help="eliminate nodes below this threshold [default: %default]")
+ parser.add_option(
+ '-e', '--edge-thres', metavar='PERCENTAGE',
+ type="float", dest="edge_thres", default=0.1,
+ help="eliminate edges below this threshold [default: %default]")
+ parser.add_option(
+ '-v', '--verbose',
+ action="count",
+ dest="verbose", default=0,
+ help="verbose output")
+
+ global options
+ (options, args) = parser.parse_args(sys.argv[1:])
+
+ reader = Reader()
+ if options.base is not None:
+ reader.base_addr = int(options.base, 16)
+ if options.map is not None:
+ reader.read_map(options.map)
+ for arg in args:
+ profile = reader.read_data(arg)
+ profile.prune(options.node_thres/100.0, options.edge_thres/100.0)
+ output = sys.stdout
+ dot = DotWriter(output)
+ colormap = TEMPERATURE_COLORMAP
+ dot.graph(profile, colormap)
+
+
+if __name__ == '__main__':
+ main()
+
diff --git a/configs/.gitignore b/configs/.gitignore
new file mode 100644
index 0000000..5b9023a
--- /dev/null
+++ b/configs/.gitignore
@@ -0,0 +1 @@
+current
diff --git a/configs/default b/configs/default
new file mode 100644
index 0000000..4e3b9aa
--- /dev/null
+++ b/configs/default
@@ -0,0 +1,98 @@
+# Default/template configuration
+
+# This is included by other config files which may override some
+# of these variables.
+# Think of this as a base class from which configs are derived.
+
+
+CONFIG_NAME = default
+
+# Version info
+MESA_MAJOR=7
+MESA_MINOR=1
+MESA_TINY=0
+
+# external projects. This should be useless now that we use libdrm.
+DRM_SOURCE_PATH=$(TOP)/../drm
+
+# Compiler and flags
+CC = cc
+CXX = CC
+HOST_CC = $(CC)
+CFLAGS = -O
+CXXFLAGS = -O
+GLU_CFLAGS =
+
+# Compiler for building demos/tests/etc
+APP_CC = $(CC)
+APP_CXX = $(CXX)
+
+# Misc tools and flags
+MKLIB_OPTIONS =
+MKDEP = makedepend
+MKDEP_OPTIONS = -fdepend
+MAKE = make
+INSTALL = $(TOP)/bin/minstall
+
+# Python and flags (generally only needed by the developers)
+PYTHON2 = python
+PYTHON_FLAGS = -t -O -O
+
+# Library names (base name)
+GL_LIB = GL
+GLU_LIB = GLU
+GLUT_LIB = glut
+GLW_LIB = GLw
+OSMESA_LIB = OSMesa
+
+
+# Library names (actual file names)
+GL_LIB_NAME = lib$(GL_LIB).so
+GLU_LIB_NAME = lib$(GLU_LIB).so
+GLUT_LIB_NAME = lib$(GLUT_LIB).so
+GLW_LIB_NAME = lib$(GLW_LIB).so
+OSMESA_LIB_NAME = lib$(OSMESA_LIB).so
+
+
+# Optional assembly language optimization files for libGL
+
+# GLw widget sources (Append "GLwMDrawA.c" here and add -lXm to GLW_LIB_DEPS in
+# order to build the Motif widget too)
+GLW_SOURCES = GLwDrawA.c
+
+
+# Directories to build
+LIB_DIR = lib
+SRC_DIRS = gallium mesa gallium/winsys
+GLU_DIRS = sgi
+DRIVER_DIRS =
+# Which subdirs under $(TOP)/progs/ to enter:
+PROGRAM_DIRS =
+
+
+# Gallium directories and
+GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi rtasm util
+GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(GALLIUM)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
+GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple failover
+GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(GALLIUM)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
+GALLIUM_WINSYS_DIRS = iegd
+
+
+# Library/program dependencies
+#EXTRA_LIB_PATH ?=
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
+OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
+GLU_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXi -lm
+GLW_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXt -lX11
+APP_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
+
+
+
+# Installation directories (for make install)
+INSTALL_DIR = /usr/local
+DRI_DRIVER_INSTALL_DIR = /usr/X11R6/lib/modules/dri
+
+# Where libGL will look for DRI hardware drivers
+DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
+
diff --git a/configs/linux-dri b/configs/linux-dri
new file mode 100644
index 0000000..e88c2cd
--- /dev/null
+++ b/configs/linux-dri
@@ -0,0 +1,68 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-dri
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+#MKDEP = /usr/X11R6/bin/makedepend
+#MKDEP = gcc -M
+#MKDEP_OPTIONS = -MF depend
+
+OPT_FLAGS = -O2 -g
+PIC_FLAGS = -fPIC
+
+# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
+ARCH_FLAGS ?=
+
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
+ -D_BSD_SOURCE -D_GNU_SOURCE \
+ -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
+ -DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \
+ -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
+
+X11_INCLUDES = -I/usr/X11R6/include
+
+CFLAGS = -Wall -Wmissing-prototypes -std=c99 -ffast-math \
+ $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) $(ASM_FLAGS)
+
+CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+
+
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/X11R6/lib
+
+LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
+LIBDRM_LIB = $(shell pkg-config --libs libdrm)
+DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
+ -lm -lpthread -ldl \
+ $(LIBDRM_LIB)
+
+
+# This is now 0 by default since it seems to confuse the hell out of people
+# and generate a lot of extra noise on bugzilla. If you need to build with
+# EGL, do 'make linux-dri USING_EGL=1'
+
+USING_EGL=0
+
+# Directories
+SRC_DIRS := glx/x11 $(SRC_DIRS)
+ifeq ($(USING_EGL), 1)
+SRC_DIRS := egl $(SRC_DIRS)
+PROGRAM_DIRS = egl
+endif
+
+DRIVER_DIRS = dri
+WINDOW_SYSTEM=dri
+GALLIUM_DRIVER_DIRS += psb
+GALLIUM_WINSYS_DIRS = dri
+
+# gamma are missing because they have not been converted to use the new
+# interface.
+DRI_DIRS = psb
diff --git a/configs/linux-dri-debug b/configs/linux-dri-debug
new file mode 100644
index 0000000..c3a4584
--- /dev/null
+++ b/configs/linux-dri-debug
@@ -0,0 +1,16 @@
+# -*-makefile-*-
+# Configuration for linux-dri-debug: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-debug
+OPT_FLAGS = -O0 -g
+ARCH_FLAGS = -DDEBUG
+
+# Helpful to reduce the amount of stuff that gets built sometimes:
+#DRI_DIRS = i915tex i915
+#DRI_DIRS = i965
+#DRI_DIRS = radeon r200 r300
+#DRI_DIRS = unichrome sis trident
+#DRI_DIRS = i810 mga r128 tdfx
+
diff --git a/configs/linux-dri-x86 b/configs/linux-dri-x86
new file mode 100644
index 0000000..96c42d7
--- /dev/null
+++ b/configs/linux-dri-x86
@@ -0,0 +1,10 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-x86
+
+ARCH_FLAGS = -m32 -mmmx -msse -msse2
+
+
diff --git a/configs/linux-dri-x86-64 b/configs/linux-dri-x86-64
new file mode 100644
index 0000000..e8e7f69
--- /dev/null
+++ b/configs/linux-dri-x86-64
@@ -0,0 +1,21 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-x86-64
+
+ARCH_FLAGS = -m64
+
+
+LIB_DIR = lib64
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/X11R6/lib64
+
+# ffb, gamma, and sis are 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.
+#
+DRI_DIRS = i915tex i915 i965 mach64 mga r128 r200 radeon tdfx unichrome savage r300
+
diff --git a/cpuwinsys/cpuwinsys.c b/cpuwinsys/cpuwinsys.c
new file mode 100644
index 0000000..04a8a05
--- /dev/null
+++ b/cpuwinsys/cpuwinsys.c
@@ -0,0 +1,273 @@
+#include "cpuwinsys.h"
+
+#include "pipe/p_winsys.h"
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#ifdef GALLIUM_CELL
+#include "cell/ppu/cell_context.h"
+#include "cell/ppu/cell_screen.h"
+#include "cell/ppu/cell_winsys.h"
+#else
+#define TILE_SIZE 32 /* avoid compilation errors */
+#endif
+
+
+/**
+ * Subclass of pipe_winsys for Xlib winsys
+ */
+struct cpu_winsys {
+ struct pipe_winsys base;
+};
+
+/**
+ * Subclass of pipe_buffer for CL winsys.
+ * Low-level OS/window system memory buffer
+ */
+struct cpu_buffer
+{
+ struct pipe_buffer base;
+ boolean userBuffer; /** Is this a user-space buffer? */
+ void *data;
+ void *mapped;
+};
+
+
+/** Cast wrapper */
+static INLINE struct cpu_buffer *
+cpu_buffer(struct pipe_buffer *buf)
+{
+ return (struct cpu_buffer *)buf;
+}
+
+
+/* Most callbacks map direcly onto dri_bufmgr operations:
+ */
+static void *
+cpu_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct cpu_buffer *cpu_buf = cpu_buffer(buf);
+ cpu_buf->mapped = cpu_buf->data;
+ return cpu_buf->mapped;
+}
+
+static void
+cpu_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
+{
+ struct cpu_buffer *cpu_buf = cpu_buffer(buf);
+ cpu_buf->mapped = NULL;
+}
+
+static void
+cpu_buffer_destroy(struct pipe_winsys *pws,
+ struct pipe_buffer *buf)
+{
+ struct cpu_buffer *oldBuf = cpu_buffer(buf);
+
+ if (oldBuf->data) {
+ if (!oldBuf->userBuffer) {
+ align_free(oldBuf->data);
+ }
+
+ oldBuf->data = NULL;
+ }
+
+ free(oldBuf);
+}
+
+
+static void
+cpu_flush_frontbuffer(struct pipe_winsys *pws,
+ struct pipe_surface *surf,
+ void *context_private)
+{
+ /*### do nothing? */
+}
+
+
+
+static const char *
+cpu_get_name(struct pipe_winsys *pws)
+{
+ return "OpenCL CPU";
+}
+
+
+static struct pipe_buffer *
+cpu_buffer_create(struct pipe_winsys *pws,
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
+{
+ struct cpu_buffer *buffer = CALLOC_STRUCT(cpu_buffer);
+
+ buffer->base.refcount = 1;
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
+
+ if (buffer->data == NULL) {
+ /* align to 16-byte multiple for Cell */
+ buffer->data = align_malloc(size, MAX2(alignment, 16));
+ }
+
+ return &buffer->base;
+}
+
+
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_buffer *
+cpu_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
+{
+ struct cpu_buffer *buffer = CALLOC_STRUCT(cpu_buffer);
+ buffer->base.refcount = 1;
+ buffer->base.size = bytes;
+ buffer->userBuffer = TRUE;
+ buffer->data = ptr;
+
+ return &buffer->base;
+}
+
+
+
+/**
+ * Round n up to next multiple.
+ */
+static INLINE unsigned
+round_up(unsigned n, unsigned multiple)
+{
+ return (n + multiple - 1) & ~(multiple - 1);
+}
+
+static int
+cpu_surface_alloc_storage(struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned flags,
+ unsigned tex_usage)
+{
+ const unsigned alignment = 64;
+
+ surf->width = width;
+ surf->height = height;
+ surf->format = format;
+ pf_get_block(format, &surf->block);
+ surf->nblocksx = pf_get_nblocksx(&surf->block, width);
+ surf->nblocksy = pf_get_nblocksy(&surf->block, height);
+ surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
+ surf->usage = flags;
+
+ assert(!surf->buffer);
+ surf->buffer = winsys->buffer_create(winsys, alignment,
+ PIPE_BUFFER_USAGE_PIXEL,
+#ifdef GALLIUM_CELL /* XXX a bit of a hack */
+ surf->stride *
+ round_up(surf->nblocksy, TILE_SIZE));
+#else
+ surf->stride * surf->nblocksy);
+#endif
+
+ if(!surf->buffer)
+ return -1;
+
+ return 0;
+}
+
+
+/**
+ * Called via winsys->surface_alloc() to create new surfaces.
+ */
+static struct pipe_surface *
+cpu_surface_alloc(struct pipe_winsys *ws)
+{
+ struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
+
+ assert(ws);
+
+ surface->refcount = 1;
+ surface->winsys = ws;
+
+ return surface;
+}
+
+
+
+static void
+cpu_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
+{
+ struct pipe_surface *surf = *s;
+ assert(!surf->texture);
+ surf->refcount--;
+ if (surf->refcount == 0) {
+ if (surf->buffer)
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
+ free(surf);
+ }
+ *s = NULL;
+}
+
+
+/*
+ * Fence functions - basically nothing to do, as we don't create any actual
+ * fence objects.
+ */
+
+static void
+cpu_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+}
+
+
+static int
+cpu_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
+
+static int
+cpu_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
+struct pipe_winsys * cpu_winsys(void)
+{
+ static struct cpu_winsys *ws = NULL;
+
+ if (!ws) {
+ ws = CALLOC_STRUCT(cpu_winsys);
+
+ /* Fill in this struct with callbacks that pipe will need to
+ * communicate with the buffer manager, etc.
+ */
+ ws->base.buffer_create = cpu_buffer_create;
+ ws->base.user_buffer_create = cpu_user_buffer_create;
+ ws->base.buffer_map = cpu_buffer_map;
+ ws->base.buffer_unmap = cpu_buffer_unmap;
+ ws->base.buffer_destroy = cpu_buffer_destroy;
+
+ ws->base.surface_alloc = cpu_surface_alloc;
+ ws->base.surface_alloc_storage = cpu_surface_alloc_storage;
+ ws->base.surface_release = cpu_surface_release;
+
+ ws->base.fence_reference = cpu_fence_reference;
+ ws->base.fence_signalled = cpu_fence_signalled;
+ ws->base.fence_finish = cpu_fence_finish;
+
+ ws->base.flush_frontbuffer = cpu_flush_frontbuffer;
+ ws->base.get_name = cpu_get_name;
+ }
+
+ return &ws->base;
+}
diff --git a/cpuwinsys/cpuwinsys.h b/cpuwinsys/cpuwinsys.h
new file mode 100644
index 0000000..b3a1a72
--- /dev/null
+++ b/cpuwinsys/cpuwinsys.h
@@ -0,0 +1,6 @@
+#ifndef CPUWINSYS_H
+#define CPUWINSYS_H
+
+struct pipe_winsys *cpu_winsys(void);
+
+#endif
diff --git a/include/OpenCL/cl.h b/include/OpenCL/cl.h
new file mode 100644
index 0000000..8ee5147
--- /dev/null
+++ b/include/OpenCL/cl.h
@@ -0,0 +1,843 @@
+/*******************************************************************************
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are 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 Materials.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+#ifndef __OPENCL_CL_H
+#define __OPENCL_CL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <OpenCL/cl_platform.h>
+
+/******************************************************************************/
+
+typedef struct _cl_device_id * cl_device_id;
+typedef struct _cl_context * cl_context;
+typedef struct _cl_command_queue * cl_command_queue;
+typedef struct _cl_mem * cl_mem;
+typedef struct _cl_program * cl_program;
+typedef struct _cl_kernel * cl_kernel;
+typedef struct _cl_event * cl_event;
+typedef struct _cl_sampler * cl_sampler;
+
+typedef cl_uint cl_bool;
+typedef cl_ulong cl_bitfield;
+typedef cl_bitfield cl_device_type;
+typedef cl_uint cl_platform_info;
+typedef cl_uint cl_device_info;
+typedef cl_bitfield cl_device_address_info;
+typedef cl_bitfield cl_device_fp_config;
+typedef cl_uint cl_device_mem_cache_type;
+typedef cl_uint cl_device_local_mem_type;
+typedef cl_bitfield cl_device_exec_capabilities;
+typedef cl_bitfield cl_command_queue_properties;
+
+typedef cl_bitfield cl_context_properties;
+typedef cl_uint cl_context_info;
+typedef cl_uint cl_command_queue_info;
+typedef cl_uint cl_channel_order;
+typedef cl_uint cl_channel_type;
+typedef cl_bitfield cl_mem_flags;
+typedef cl_uint cl_mem_object_type;
+typedef cl_uint cl_mem_info;
+typedef cl_uint cl_image_info;
+typedef cl_uint cl_addressing_mode;
+typedef cl_uint cl_filter_mode;
+typedef cl_uint cl_sampler_info;
+typedef cl_bitfield cl_map_flags;
+typedef cl_uint cl_program_info;
+typedef cl_uint cl_program_build_info;
+typedef cl_uint cl_build_status;
+typedef cl_uint cl_kernel_info;
+typedef cl_uint cl_kernel_work_group_info;
+typedef cl_uint cl_event_info;
+typedef cl_uint cl_command_type;
+typedef cl_uint cl_profiling_info;
+
+typedef struct _cl_image_format {
+ cl_channel_order image_channel_order;
+ cl_channel_type image_channel_data_type;
+} cl_image_format;
+
+/******************************************************************************/
+
+// Error Codes
+#define CL_SUCCESS 0
+#define CL_DEVICE_NOT_FOUND -1
+#define CL_DEVICE_NOT_AVAILABLE -2
+#define CL_DEVICE_COMPILER_NOT_AVAILABLE -3
+#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
+#define CL_OUT_OF_RESOURCES -5
+#define CL_OUT_OF_HOST_MEMORY -6
+#define CL_PROFILING_INFO_NOT_AVAILABLE -7
+#define CL_MEM_COPY_OVERLAP -8
+#define CL_IMAGE_FORMAT_MISMATCH -9
+#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
+
+#define CL_INVALID_VALUE -30
+#define CL_INVALID_DEVICE_TYPE -31
+#define CL_INVALID_DEVICE -32
+#define CL_INVALID_CONTEXT -33
+#define CL_INVALID_QUEUE_PROPERTIES -34
+#define CL_INVALID_COMMAND_QUEUE -35
+#define CL_INVALID_HOST_PTR -36
+#define CL_INVALID_MEM_OBJECT -37
+#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -38
+#define CL_INVALID_IMAGE_SIZE -39
+#define CL_INVALID_SAMPLER -40
+#define CL_INVALID_BINARY -41
+#define CL_INVALID_BUILD_OPTIONS -42
+#define CL_INVALID_PROGRAM -43
+#define CL_INVALID_PROGRAM_EXECUTABLE -44
+#define CL_INVALID_KERNEL_NAME -45
+#define CL_INVALID_KERNEL -46
+#define CL_INVALID_ARG_INDEX -47
+#define CL_INVALID_ARG_VALUE -48
+#define CL_INVALID_ARG_SIZE -49
+#define CL_INVALID_KERNEL_ARGS -50
+#define CL_INVALID_WORK_DIMENSION -51
+#define CL_INVALID_WORK_GROUP_SIZE -52
+#define CL_INVALID_WORK_ITEM_SIZE -53
+#define CL_INVALID_GLOBAL_OFFSET -54
+#define CL_INVALID_EVENT_WAIT_LIST -55
+#define CL_INVALID_EVENT -56
+#define CL_INVALID_OPERATION -57
+#define CL_INVALID_GL_OBJECT -58
+#define CL_INVALID_BUFFER_SIZE -59
+
+// OpenCL Version
+#define CL_VERSION_1_0 1
+
+// cl_bool
+#define CL_FALSE 0
+#define CL_TRUE 1
+
+// cl_platform_info
+#define CL_PLATFORM_PROFILE 0x0900
+#define CL_PLATFORM_VERSION 0x0901
+
+// cl_device_type - bitfield
+#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
+#define CL_DEVICE_TYPE_CPU (1 << 1)
+#define CL_DEVICE_TYPE_GPU (1 << 2)
+#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
+#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
+
+// cl_device_info
+#define CL_DEVICE_TYPE 0x1000
+#define CL_DEVICE_VENDOR_ID 0x1001
+#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
+#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
+#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
+#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
+#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
+#define CL_DEVICE_ADDRESS_BITS 0x100D
+#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
+#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
+#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
+#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
+#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
+#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
+#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
+#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
+#define CL_DEVICE_IMAGE_SUPPORT 0x1016
+#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
+#define CL_DEVICE_MAX_SAMPLERS 0x1018
+#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
+#define CL_DEVICE_MAX_DATA_TYPE_ALIGN_SIZE 0x101A
+#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
+#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
+#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
+#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
+#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
+#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
+#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
+#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
+#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
+#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
+#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
+#define CL_DEVICE_ENDIAN_LITTLE 0x1026
+#define CL_DEVICE_AVAILABLE 0x1027
+#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
+#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
+#define CL_DEVICE_QUEUE_PROPERTIES 0x102A
+#define CL_DEVICE_NAME 0x102B
+#define CL_DEVICE_VENDOR 0x102C
+#define CL_DRIVER_VERSION 0x102D
+#define CL_DEVICE_PROFILE 0x102E
+#define CL_DEVICE_VERSION 0x102F
+#define CL_DEVICE_EXTENSIONS 0x1030
+
+// cl_device_address_info - bitfield
+#define CL_DEVICE_ADDRESS_32_BITS (1 << 0)
+#define CL_DEVICE_ADDRESS_64_BITS (1 << 1)
+
+// cl_device_fp_config - bitfield
+#define CL_FP_DENORM (1 << 0)
+#define CL_FP_INF_NAN (1 << 1)
+#define CL_FP_ROUND_TO_NEAREST (1 << 2)
+#define CL_FP_ROUND_TO_ZERO (1 << 3)
+#define CL_FP_ROUND_TO_INF (1 << 4)
+#define CL_FP_FMA (1 << 5)
+
+// cl_device_mem_cache_type
+#define CL_NONE 0x0
+#define CL_READ_ONLY_CACHE 0x1
+#define CL_READ_WRITE_CACHE 0x2
+
+// cl_device_local_mem_type
+#define CL_LOCAL 0x1
+#define CL_GLOBAL 0x2
+
+// cl_device_exec_capabilities - bitfield
+#define CL_EXEC_KERNEL (1 << 0)
+#define CL_EXEC_NATIVE_FN_AS_KERNEL (1 << 1)
+
+// cl_command_queue_properties - bitfield
+#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
+#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
+
+// cl_context_info
+#define CL_CONTEXT_REFERENCE_COUNT 0x1080
+#define CL_CONTEXT_NUM_DEVICES 0x1081
+#define CL_CONTEXT_DEVICES 0x1082
+#define CL_CONTEXT_PROPERTIES 0x1083
+
+// cl_command_queue_info
+#define CL_QUEUE_CONTEXT 0x1090
+#define CL_QUEUE_DEVICE 0x1091
+#define CL_QUEUE_REFERENCE_COUNT 0x1092
+#define CL_QUEUE_PROPERTIES 0x1093
+
+// cl_mem_flags - bitfield
+#define CL_MEM_READ_WRITE (1 << 0)
+#define CL_MEM_WRITE_ONLY (1 << 1)
+#define CL_MEM_READ_ONLY (1 << 2)
+#define CL_MEM_USE_HOST_PTR (1 << 3)
+#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
+#define CL_MEM_COPY_HOST_PTR (1 << 5)
+
+// cl_channel_order
+#define CL_R 0x10B0
+#define CL_A 0x10B1
+#define CL_RG 0x10B2
+#define CL_RA 0x10B3
+#define CL_RGB 0x10B4
+#define CL_RGBA 0x10B5
+#define CL_BGRA 0x10B6
+#define CL_ARGB 0x10B7
+
+// cl_channel_type
+#define CL_SNORM_INT8 0x10D0
+#define CL_SNORM_INT16 0x10D1
+#define CL_UNORM_INT8 0x10D2
+#define CL_UNORM_INT16 0x10D3
+#define CL_UNORM_SHORT_565 0x10D4
+#define CL_UNORM_SHORT_555 0x10D5
+#define CL_UNORM_INT_101010 0x10D6
+#define CL_SIGNED_INT8 0x10D7
+#define CL_SIGNED_INT16 0x10D8
+#define CL_SIGNED_INT32 0x10D9
+#define CL_UNSIGNED_INT8 0x10DA
+#define CL_UNSIGNED_INT16 0x10DB
+#define CL_UNSIGNED_INT32 0x10DC
+#define CL_HALF_FLOAT 0x10DD
+#define CL_FLOAT 0x10DE
+
+// cl_mem_object_type
+#define CL_MEM_OBJECT_BUFFER 0x10F0
+#define CL_MEM_OBJECT_IMAGE2D 0x10F1
+#define CL_MEM_OBJECT_IMAGE3D 0x10F2
+
+// cl_mem_info
+#define CL_MEM_TYPE 0x1100
+#define CL_MEM_FLAGS 0x1101
+#define CL_MEM_SIZE 0x1102
+#define CL_MEM_HOST_PTR 0x1103
+#define CL_MEM_MAP_COUNT 0x1104
+#define CL_MEM_REFERENCE_COUNT 0x1105
+#define CL_MEM_CONTEXT 0x1106
+
+// cl_image_info
+#define CL_IMAGE_FORMAT 0x1110
+#define CL_IMAGE_ELEMENT_SIZE 0x1111
+#define CL_IMAGE_ROW_PITCH 0x1112
+#define CL_IMAGE_SLICE_PITCH 0x1113
+#define CL_IMAGE_WIDTH 0x1114
+#define CL_IMAGE_HEIGHT 0x1115
+#define CL_IMAGE_DEPTH 0x1116
+
+// cl_addressing_mode
+#define CL_ADDRESS_NONE 0x1130
+#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
+#define CL_ADDRESS_CLAMP 0x1132
+#define CL_ADDRESS_REPEAT 0x1133
+
+// cl_filter_mode
+#define CL_FILTER_NEAREST 0x1140
+#define CL_FILTER_LINEAR 0x1141
+
+// cl_sampler_info
+#define CL_SAMPLER_REFERENCE_COUNT 0x1150
+#define CL_SAMPLER_CONTEXT 0x1151
+#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
+#define CL_SAMPLER_ADDRESSING_MODE 0x1153
+#define CL_SAMPLER_FILTER_MODE 0x1154
+
+// cl_map_flags - bitfield
+#define CL_MAP_READ (1 << 0)
+#define CL_MAP_WRITE (1 << 1)
+
+// cl_program_info
+#define CL_PROGRAM_REFERENCE_COUNT 0x1160
+#define CL_PROGRAM_CONTEXT 0x1161
+#define CL_PROGRAM_NUM_DEVICES 0x1162
+#define CL_PROGRAM_DEVICES 0x1163
+#define CL_PROGRAM_SOURCE 0x1164
+#define CL_PROGRAM_BINARY_SIZES 0x1165
+#define CL_PROGRAM_BINARIES 0x1166
+
+// cl_program_build_info
+#define CL_PROGRAM_BUILD_STATUS 0x1181
+#define CL_PROGRAM_BUILD_OPTIONS 0x1182
+#define CL_PROGRAM_BUILD_LOG 0x1183
+
+// cl_build_status
+#define CL_BUILD_SUCCESS 0
+#define CL_BUILD_NONE -1
+#define CL_BUILD_ERROR -2
+#define CL_BUILD_IN_PROGRESS -3
+
+// cl_kernel_info
+#define CL_KERNEL_FUNCTION_NAME 0x1190
+#define CL_KERNEL_NUM_ARGS 0x1191
+#define CL_KERNEL_REFERENCE_COUNT 0x1192
+#define CL_KERNEL_CONTEXT 0x1193
+#define CL_KERNEL_PROGRAM 0x1194
+
+// cl_kernel_work_group_info
+#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
+#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
+
+// cl_event_info
+#define CL_EVENT_COMMAND_QUEUE 0x11D0
+#define CL_EVENT_COMMAND_TYPE 0x11D1
+#define CL_EVENT_REFERENCE_COUNT 0x11D2
+#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
+
+// cl_command_type
+#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
+#define CL_COMMAND_TASK 0x11F1
+#define CL_COMMAND_NATIVE_KERNEL 0x11F2
+#define CL_COMMAND_READ_BUFFER 0x11F3
+#define CL_COMMAND_WRITE_BUFFER 0x11F4
+#define CL_COMMAND_COPY_BUFFER 0x11F5
+#define CL_COMMAND_READ_IMAGE 0x11F6
+#define CL_COMMAND_WRITE_IMAGE 0x11F7
+#define CL_COMMAND_COPY_IMAGE 0x11F8
+#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
+#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
+#define CL_COMMAND_MAP_BUFFER 0x11FB
+#define CL_COMMAND_MAP_IMAGE 0x11FC
+#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
+#define CL_COMMAND_MARKER 0x11FE
+#define CL_COMMAND_WAIT_FOR_EVENTS 0x11FF
+#define CL_COMMAND_BARRIER 0x1200
+#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x1201
+#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1202
+
+// command execution status
+#define CL_COMPLETE 0x0
+#define CL_RUNNING 0x1
+#define CL_SUBMITTED 0x2
+#define CL_QUEUED 0x3
+
+// cl_profiling_info
+#define CL_PROFILING_COMMAND_QUEUED 0x1280
+#define CL_PROFILING_COMMAND_SUBMIT 0x1281
+#define CL_PROFILING_COMMAND_START 0x1282
+#define CL_PROFILING_COMMAND_END 0x1283
+
+/********************************************************************************************************/
+
+// Platform API
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPlatformInfo(cl_platform_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Device APIs
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceIDs(cl_device_type /* device_type */,
+ cl_uint /* num_entries */,
+ cl_device_id * /* devices */,
+ cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceInfo(cl_device_id /* device */,
+ cl_device_info /* opcode */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Context APIs
+
+typedef void (*logging_fn)(const char *, const void *, size_t, const void *);
+
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContext(cl_context_properties /* properties */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* devices */,
+ logging_fn /* pfn_notify */,
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContextFromType(cl_context_properties /* properties */,
+ cl_device_type /* device_type */,
+ logging_fn /* pfn_notify */,
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetContextInfo(cl_context /* context */,
+ cl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Command Queue APIs
+extern CL_API_ENTRY cl_command_queue CL_API_CALL
+clCreateCommandQueue(cl_context /* context */,
+ cl_device_id /* device */,
+ cl_command_queue_properties /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetCommandQueueInfo(cl_command_queue /* command_queue */,
+ cl_command_queue_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetCommandQueueProperty(cl_command_queue /* command_queue */,
+ cl_command_queue_properties /* properties */,
+ cl_int /* enable */,
+ cl_command_queue_properties * /* old_properties */) CL_API_SUFFIX__VERSION_1_0;
+
+// Memory Object APIs
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ size_t /* size */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateImage2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_row_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateImage3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_depth */,
+ size_t /* image_row_pitch */,
+ size_t /* image_slice_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSupportedImageFormats(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_mem_object_type /* image_type */,
+ cl_uint /* num_entries */,
+ cl_image_format * /* image_formats */,
+ cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetMemObjectInfo(cl_mem /* memobj */,
+ cl_mem_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetImageInfo(cl_mem /* image */,
+ cl_image_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Sampler APIs
+extern CL_API_ENTRY cl_sampler CL_API_CALL
+clCreateSampler(cl_context /* context */,
+ cl_bool /* normalized_coords */,
+ cl_addressing_mode /* addressing_mode */,
+ cl_filter_mode /* filter_mode */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSamplerInfo(cl_sampler /* sampler */,
+ cl_sampler_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Program Object APIs
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithSource(cl_context /* context */,
+ cl_uint /* count */,
+ const char ** /* strings */,
+ const size_t * /* lengths */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithBinary(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const size_t * /* lengths */,
+ const void ** /* binaries */,
+ cl_int * /* binary_status */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clBuildProgram(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ void (*pfn_notify)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramInfo(cl_program /* program */,
+ cl_program_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramBuildInfo(cl_program /* program */,
+ cl_device_id /* device */,
+ cl_program_build_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Kernel Object APIs
+extern CL_API_ENTRY cl_kernel CL_API_CALL
+clCreateKernel(cl_program /* program */,
+ const char * /* kernel_name */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCreateKernelsInProgram(cl_program /* program */,
+ cl_uint /* num_kernels */,
+ cl_kernel * /* kernels */,
+ cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetKernelArg(cl_kernel /* kernel */,
+ cl_uint /* arg_indx */,
+ size_t /* arg_size */,
+ const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelInfo(cl_kernel /* kernel */,
+ cl_kernel_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelWorkGroupInfo(cl_kernel /* kernel */,
+ cl_device_id /* device */,
+ cl_kernel_work_group_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Event Object APIs
+extern CL_API_ENTRY cl_int CL_API_CALL
+clWaitForEvents(cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventInfo(cl_event /* event */,
+ cl_event_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+// Profiling APIs
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventProfilingInfo(cl_event /* event */,
+ cl_profiling_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Flush and Finish APIs
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+// Enqueued Commands APIs
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ size_t /* offset */,
+ size_t /* cb */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ size_t /* offset */,
+ size_t /* cb */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ size_t /* src_offset */,
+ size_t /* dst_offset */,
+ size_t /* cb */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_read */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* row_pitch */,
+ size_t /* slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_write */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* row_pitch */,
+ size_t /* slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_image */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* dst_offset */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_image */,
+ size_t /* src_offset */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ size_t /* offset */,
+ size_t /* cb */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t * /* image_row_pitch */,
+ size_t * /* image_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueUnmapMemObject(cl_command_queue /* command_queue */,
+ cl_mem /* memobj */,
+ void * /* mapped_ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNDRangeKernel(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* work_dim */,
+ const size_t * /* global_work_offset */,
+ const size_t * /* global_work_size */,
+ const size_t * /* local_work_size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueTask(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNativeFnAsKernel(cl_command_queue /* command_queue */,
+ void (*user_func)(void *),
+ void * /* args */,
+ size_t /* cb_args */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_list */,
+ const void ** /* args_mem_loc */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueMarker(cl_command_queue /* command_queue */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWaitForEvents(cl_command_queue /* command_queue */,
+ cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueBarrier(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __OPENCL_CL_H
+
diff --git a/include/OpenCL/cl_gl.h b/include/OpenCL/cl_gl.h
new file mode 100644
index 0000000..8d28293
--- /dev/null
+++ b/include/OpenCL/cl_gl.h
@@ -0,0 +1,103 @@
+/**********************************************************************************
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are 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 Materials.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+#ifndef __OPENCL_CL_GL_H
+#define __OPENCL_CL_GL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// NOTE: Make sure that appropriate GL header file is included separately
+
+#include <OpenCL/cl_platform.h>
+
+typedef cl_uint cl_gl_object_type;
+typedef cl_uint cl_gl_texture_info;
+
+// cl_gl_object_type
+#define CL_GL_OBJECT_BUFFER 0x2000
+#define CL_GL_OBJECT_TEXTURE2D 0x2001
+#define CL_GL_OBJECT_TEXTURE_RECTANGLE 0x2002
+#define CL_GL_OBJECT_TEXTURE3D 0x2003
+#define CL_GL_OBJECT_RENDERBUFFER 0x2004
+
+// cl_gl_texture_info
+#define CL_GL_TEXTURE_TARGET 0x2005
+#define CL_GL_MIPMAP_LEVEL 0x2006
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ GLuint /* bufobj */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLTexture2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ GLenum /* target */,
+ GLint /* miplevel */,
+ GLuint /* texture */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLTexture3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ GLenum /* target */,
+ GLint /* miplevel */,
+ GLuint /* texture */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLRenderbuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ GLuint /* renderbuffer */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLObjectInfo(cl_mem /* memobj */,
+ cl_gl_object_type * /* gl_object_type */,
+ GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLTextureInfo(cl_mem /* memobj */,
+ cl_gl_texture_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clAcquireGLObjects(cl_command_queue /* queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /*mem_objects */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseGLObjects(cl_command_queue /* queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */) CL_API_SUFFIX__VERSION_1_0;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __OPENCL_CL_GL_H
diff --git a/include/OpenCL/cl_platform.h b/include/OpenCL/cl_platform.h
new file mode 100644
index 0000000..8611984
--- /dev/null
+++ b/include/OpenCL/cl_platform.h
@@ -0,0 +1,119 @@
+/**********************************************************************************
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are 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 Materials.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+#ifndef __CL_PLATFORM_H
+#define __CL_PLATFORM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CL_API_ENTRY
+#define CL_API_CALL
+#define CL_API_SUFFIX__VERSION_1_0
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* scalar types */
+typedef int8_t cl_char;
+typedef uint8_t cl_uchar;
+typedef int16_t cl_short __attribute__((aligned(2)));
+typedef uint16_t cl_ushort __attribute__((aligned(2)));
+typedef int32_t cl_int __attribute__((aligned(4)));
+typedef uint32_t cl_uint __attribute__((aligned(4)));
+typedef int64_t cl_long __attribute__((aligned(8)));
+typedef uint64_t cl_ulong __attribute__((aligned(8)));
+
+typedef uint16_t cl_half __attribute__((aligned(2)));
+typedef float cl_float __attribute__((aligned(4)));
+typedef double cl_double __attribute__((aligned(8)));
+
+/*
+ * Vector types
+ *
+ * Note: OpenCL requires that all types be naturally aligned.
+ * This means that vector types must be naturally aligned.
+ * For example, a vector of four floats must be aligned to
+ * a 16 byte boundary (calculated as 4 * the natural 4-byte
+ * alignment of the float). The alignment qualifiers here
+ * will only function properly if your compiler supports them
+ * and if you don't actively work to defeat them. For example,
+ * in order for a cl_float4 to be 16 byte aligned in a struct,
+ * the start of the struct must itself be 16-byte aligned.
+ *
+ * Maintaining proper alignment is the user's responsibility.
+ */
+typedef int8_t cl_char2[2] __attribute__((aligned(2)));
+typedef int8_t cl_char4[4] __attribute__((aligned(4)));
+typedef int8_t cl_char8[8] __attribute__((aligned(8)));
+typedef int8_t cl_char16[16] __attribute__((aligned(16)));
+typedef uint8_t cl_uchar2[2] __attribute__((aligned(2)));
+typedef uint8_t cl_uchar4[4] __attribute__((aligned(4)));
+typedef uint8_t cl_uchar8[8] __attribute__((aligned(8)));
+typedef uint8_t cl_uchar16[16] __attribute__((aligned(16)));
+
+typedef int16_t cl_short2[2] __attribute__((aligned(4)));
+typedef int16_t cl_short4[4] __attribute__((aligned(8)));
+typedef int16_t cl_short8[8] __attribute__((aligned(16)));
+typedef int16_t cl_short16[16] __attribute__((aligned(32)));
+typedef uint16_t cl_ushort2[2] __attribute__((aligned(4)));
+typedef uint16_t cl_ushort4[4] __attribute__((aligned(8)));
+typedef uint16_t cl_ushort8[8] __attribute__((aligned(16)));
+typedef uint16_t cl_ushort16[16] __attribute__((aligned(32)));
+
+typedef int32_t cl_int2[2] __attribute__((aligned(8)));
+typedef int32_t cl_int4[4] __attribute__((aligned(16)));
+typedef int32_t cl_int8[8] __attribute__((aligned(32)));
+typedef int32_t cl_int16[16] __attribute__((aligned(64)));
+typedef uint32_t cl_uint2[2] __attribute__((aligned(8)));
+typedef uint32_t cl_uint4[4] __attribute__((aligned(16)));
+typedef uint32_t cl_uint8[8] __attribute__((aligned(32)));
+typedef uint32_t cl_uint16[16] __attribute__((aligned(64)));
+
+typedef int64_t cl_long2[2] __attribute__((aligned(16)));
+typedef int64_t cl_long4[4] __attribute__((aligned(32)));
+typedef int64_t cl_long8[8] __attribute__((aligned(64)));
+typedef int64_t cl_long16[16] __attribute__((aligned(128)));
+typedef uint64_t cl_ulong2[2] __attribute__((aligned(16)));
+typedef uint64_t cl_ulong4[4] __attribute__((aligned(32)));
+typedef uint64_t cl_ulong8[8] __attribute__((aligned(64)));
+typedef uint64_t cl_ulong16[16] __attribute__((aligned(128)));
+
+typedef float cl_float2[2] __attribute__((aligned(8)));
+typedef float cl_float4[4] __attribute__((aligned(16)));
+typedef float cl_float8[8] __attribute__((aligned(32)));
+typedef float cl_float16[16] __attribute__((aligned(64)));
+
+typedef double cl_double2[2] __attribute__((aligned(16)));
+typedef double cl_double4[4] __attribute__((aligned(32)));
+typedef double cl_double8[8] __attribute__((aligned(64)));
+typedef double cl_double16[16] __attribute__((aligned(128)));
+
+/* There are no vector types for half */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __CL_PLATFORM_H
diff --git a/include/OpenCL/device.h b/include/OpenCL/device.h
new file mode 100644
index 0000000..b34a525
--- /dev/null
+++ b/include/OpenCL/device.h
@@ -0,0 +1,10 @@
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "OpenCL/cl.h"
+
+struct _cl_device_id {
+ struct pipe_screen *screen;
+};
+
+#endif
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/Makefile
diff --git a/src/api_command.c b/src/api_command.c
new file mode 100644
index 0000000..a4f2dcd
--- /dev/null
+++ b/src/api_command.c
@@ -0,0 +1,42 @@
+#include <OpenCL/cl.h>
+
+// Command Queue APIs
+cl_command_queue
+clCreateCommandQueue(cl_context context,
+ cl_device_id device,
+ cl_command_queue_properties properties,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainCommandQueue(cl_command_queue command_queue)
+{
+ return 0;
+}
+
+cl_int
+clReleaseCommandQueue(cl_command_queue command_queue)
+{
+ return 0;
+}
+
+cl_int
+clGetCommandQueueInfo(cl_command_queue command_queue,
+ cl_command_queue_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
+cl_int
+clSetCommandQueueProperty(cl_command_queue command_queue,
+ cl_command_queue_properties properties,
+ cl_int enable,
+ cl_command_queue_properties * old_properties)
+{
+ return 0;
+}
diff --git a/src/api_context.c b/src/api_context.c
new file mode 100644
index 0000000..fbf3af9
--- /dev/null
+++ b/src/api_context.c
@@ -0,0 +1,47 @@
+#include <OpenCL/cl.h>
+
+
+// Context APIs
+
+cl_context
+clCreateContext(cl_context_properties properties,
+ cl_uint num_devices,
+ const cl_device_id * devices,
+ logging_fn pfn_notify,
+ void * user_data,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_context
+clCreateContextFromType(cl_context_properties properties,
+ cl_device_type device_type,
+ logging_fn pfn_notify,
+ void * user_data,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainContext(cl_context context)
+{
+ return 0;
+}
+
+cl_int
+clReleaseContext(cl_context context)
+{
+ return 0;
+}
+
+cl_int
+clGetContextInfo(cl_context context,
+ cl_context_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
diff --git a/src/api_device.c b/src/api_device.c
new file mode 100644
index 0000000..2583f40
--- /dev/null
+++ b/src/api_device.c
@@ -0,0 +1,205 @@
+#include <OpenCL/cl.h>
+#include <OpenCL/cl_platform.h>
+
+#include "device.h"
+
+// Device APIs
+
+static void
+create_gpu_device(cl_device_id * devices,
+ cl_uint * num_devices,
+ cl_uint num_entries)
+{
+}
+
+static void
+create_cpu_device(cl_device_id * devices,
+ cl_uint * num_devices,
+ cl_uint num_entries)
+{
+}
+
+static void
+create_accel_device(cl_device_id * devices,
+ cl_uint * num_devices,
+ cl_uint num_entries)
+{
+#ifdef GALLIUM_CELL
+ if (!getenv("GALLIUM_NOCELL")) {
+ struct cell_winsys *cws = cell_get_winsys(pixelformat);
+ struct pipe_screen *screen = cell_create_screen(pws);
+
+ pipe = cell_create_context(screen, cws);
+ }
+#endif
+}
+
+
+cl_int
+clGetDeviceIDs(cl_device_type device_type,
+ cl_uint num_entries,
+ cl_device_id * devices,
+ cl_uint * num_devices)
+{
+ cl_bool gpu, cpu, accelerator;
+ cl_uint original_num_entries = num_entries;
+
+ gpu = (device_type & CL_DEVICE_TYPE_DEFAULT) ||
+ (device_type & CL_DEVICE_TYPE_GPU) ||
+ (device_type & CL_DEVICE_TYPE_ALL);
+
+ cpu = (device_type & CL_DEVICE_TYPE_CPU) ||
+ (device_type & CL_DEVICE_TYPE_ALL);
+
+ accelerator = (device_type & CL_DEVICE_TYPE_ACCELERATOR) ||
+ (device_type & CL_DEVICE_TYPE_ALL);
+
+ if (!gpu && !cpu && !accelerator)
+ return CL_INVALID_DEVICE_TYPE;
+
+ if ((!num_entries && devices) || (!num_devices && !devices))
+ return CL_INVALID_VALUE;
+
+ if (gpu && num_entries > 0) {
+ cl_uint num_gpus = 0;
+ create_gpu_device(devices, &num_gpus, num_entries);
+ num_entries -= num_gpus;
+ *num_devices += num_gpus;
+ }
+
+ if (cpu && num_entries > 0) {
+ cl_uint num_cpus = 0;
+ create_cpu_device(devices, &num_cpus, num_entries);
+ num_entries -= num_cpus;
+ *num_devices += num_cpus;
+ }
+
+ if (accelerator && num_entries) {
+ cl_uint num_accels = 0;
+ create_accel_device(devices, &num_accels, num_entries);
+ num_entries -= num_accels;
+ *num_devices += num_accels;
+ }
+
+ if (original_num_entries == num_entries)
+ return CL_DEVICE_NOT_FOUND;
+
+ return CL_SUCCESS;
+}
+
+cl_int
+clGetDeviceInfo(cl_device_id device,
+ cl_device_info opcode,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ if (!device)
+ return CL_INVALID_DEVICE;
+
+ switch(opcode) {
+ case CL_DEVICE_TYPE: {
+ ((cl_int*)param_value)[0] = device->type;
+ }
+ break;
+ case CL_DEVICE_VENDOR_ID:
+ break;
+ case CL_DEVICE_MAX_COMPUTE_UNITS:
+ break;
+ case CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:
+ break;
+ case CL_DEVICE_MAX_WORK_GROUP_SIZE:
+ break;
+ case CL_DEVICE_MAX_WORK_ITEM_SIZES:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT:
+ break;
+ case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
+ break;
+ case CL_DEVICE_MAX_CLOCK_FREQUENCY:
+ break;
+ case CL_DEVICE_ADDRESS_BITS:
+ break;
+ case CL_DEVICE_MAX_READ_IMAGE_ARGS:
+ break;
+ case CL_DEVICE_MAX_WRITE_IMAGE_ARGS:
+ break;
+ case CL_DEVICE_MAX_MEM_ALLOC_SIZE:
+ break;
+ case CL_DEVICE_IMAGE2D_MAX_WIDTH:
+ break;
+ case CL_DEVICE_IMAGE2D_MAX_HEIGHT:
+ break;
+ case CL_DEVICE_IMAGE3D_MAX_WIDTH:
+ break;
+ case CL_DEVICE_IMAGE3D_MAX_HEIGHT:
+ break;
+ case CL_DEVICE_IMAGE3D_MAX_DEPTH:
+ break;
+ case CL_DEVICE_IMAGE_SUPPORT:
+ break;
+ case CL_DEVICE_MAX_PARAMETER_SIZE:
+ break;
+ case CL_DEVICE_MAX_SAMPLERS:
+ break;
+ case CL_DEVICE_MEM_BASE_ADDR_ALIGN:
+ break;
+ case CL_DEVICE_MAX_DATA_TYPE_ALIGN_SIZE:
+ break;
+ case CL_DEVICE_SINGLE_FP_CONFIG:
+ break;
+ case CL_DEVICE_GLOBAL_MEM_CACHE_TYPE:
+ break;
+ case CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE:
+ break;
+ case CL_DEVICE_GLOBAL_MEM_CACHE_SIZE:
+ break;
+ case CL_DEVICE_GLOBAL_MEM_SIZE:
+ break;
+ case CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:
+ break;
+ case CL_DEVICE_MAX_CONSTANT_ARGS:
+ break;
+ case CL_DEVICE_LOCAL_MEM_TYPE:
+ break;
+ case CL_DEVICE_LOCAL_MEM_SIZE:
+ break;
+ case CL_DEVICE_ERROR_CORRECTION_SUPPORT:
+ break;
+ case CL_DEVICE_PROFILING_TIMER_RESOLUTION:
+ break;
+ case CL_DEVICE_ENDIAN_LITTLE:
+ break;
+ case CL_DEVICE_AVAILABLE:
+ break;
+ case CL_DEVICE_COMPILER_AVAILABLE:
+ break;
+ case CL_DEVICE_EXECUTION_CAPABILITIES:
+ break;
+ case CL_DEVICE_QUEUE_PROPERTIES:
+ break;
+ case CL_DEVICE_NAME:
+ break;
+ case CL_DEVICE_VENDOR:
+ break;
+ case CL_DRIVER_VERSION:
+ break;
+ case CL_DEVICE_PROFILE:
+ break;
+ case CL_DEVICE_VERSION:
+ break;
+ case CL_DEVICE_EXTENSIONS:
+ break;
+ default:
+ return CL_INVALID_VALUE;
+ }
+ return CL_SUCCESS;
+}
diff --git a/src/api_enqueue.c b/src/api_enqueue.c
new file mode 100644
index 0000000..15091b4
--- /dev/null
+++ b/src/api_enqueue.c
@@ -0,0 +1,221 @@
+#include <OpenCL/cl.h>
+
+// Enqueued Commands APIs
+cl_int
+clEnqueueReadBuffer(cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_read,
+ size_t offset,
+ size_t cb,
+ void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueWriteBuffer(cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_write,
+ size_t offset,
+ size_t cb,
+ const void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueCopyBuffer(cl_command_queue command_queue,
+ cl_mem src_buffer,
+ cl_mem dst_buffer,
+ size_t src_offset,
+ size_t dst_offset,
+ size_t cb,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueReadImage(cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_read,
+ const size_t * origin,
+ const size_t * region,
+ size_t row_pitch,
+ size_t slice_pitch,
+ void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueWriteImage(cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_write,
+ const size_t * origin,
+ const size_t * region,
+ size_t row_pitch,
+ size_t slice_pitch,
+ const void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueCopyImage(cl_command_queue command_queue,
+ cl_mem src_image,
+ cl_mem dst_image,
+ const size_t * src_origin,
+ const size_t * dst_origin,
+ const size_t * region,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
+ cl_mem src_image,
+ cl_mem dst_buffer,
+ const size_t * src_origin,
+ const size_t * region,
+ size_t dst_offset,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueCopyBufferToImage(cl_command_queue command_queue,
+ cl_mem src_buffer,
+ cl_mem dst_image,
+ size_t src_offset,
+ const size_t * dst_origin,
+ const size_t * region,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+void *
+clEnqueueMapBuffer(cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_map,
+ cl_map_flags map_flags,
+ size_t offset,
+ size_t cb,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+void *
+clEnqueueMapImage(cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_map,
+ cl_map_flags map_flags,
+ const size_t * origin,
+ const size_t * region,
+ size_t * image_row_pitch,
+ size_t * image_slice_pitch,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueUnmapMemObject(cl_command_queue command_queue,
+ cl_mem memobj,
+ void * mapped_ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueNDRangeKernel(cl_command_queue command_queue,
+ cl_kernel kernel,
+ cl_uint work_dim,
+ const size_t * global_work_offset,
+ const size_t * global_work_size,
+ const size_t * local_work_size,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueTask(cl_command_queue command_queue,
+ cl_kernel kernel,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueNativeFnAsKernel(cl_command_queue command_queue,
+ void (*user_func)(void *),
+ void * args,
+ size_t cb_args,
+ cl_uint num_mem_objects,
+ const cl_mem * mem_list,
+ const void ** args_mem_loc,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueMarker(cl_command_queue command_queue,
+ cl_event * event)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueWaitForEvents(cl_command_queue command_queue,
+ cl_uint num_events,
+ const cl_event * event_list)
+{
+ return 0;
+}
+
+cl_int
+clEnqueueBarrier(cl_command_queue command_queue)
+{
+ return 0;
+}
diff --git a/src/api_event.c b/src/api_event.c
new file mode 100644
index 0000000..9c08011
--- /dev/null
+++ b/src/api_event.c
@@ -0,0 +1,31 @@
+#include <OpenCL/cl.h>
+
+// Event Object APIs
+cl_int
+clWaitForEvents(cl_uint num_events,
+ const cl_event * event_list)
+{
+ return 0;
+}
+
+cl_int
+clGetEventInfo(cl_event event,
+ cl_event_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainEvent(cl_event event)
+{
+ return 0;
+}
+
+cl_int
+clReleaseEvent(cl_event event)
+{
+ return 0;
+}
diff --git a/src/api_flush.c b/src/api_flush.c
new file mode 100644
index 0000000..34afab0
--- /dev/null
+++ b/src/api_flush.c
@@ -0,0 +1,14 @@
+#include <OpenCL/cl.h>
+
+// Flush and Finish APIs
+cl_int
+clFlush(cl_command_queue command_queue)
+{
+ return 0;
+}
+
+cl_int
+clFinish(cl_command_queue command_queue)
+{
+ return 0;
+}
diff --git a/src/api_kernel.c b/src/api_kernel.c
new file mode 100644
index 0000000..27d7c81
--- /dev/null
+++ b/src/api_kernel.c
@@ -0,0 +1,61 @@
+#include <OpenCL/cl.h>
+
+// Kernel Object APIs
+cl_kernel
+clCreateKernel(cl_program program,
+ const char * kernel_name,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clCreateKernelsInProgram(cl_program program,
+ cl_uint num_kernels,
+ cl_kernel * kernels,
+ cl_uint * num_kernels_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainKernel(cl_kernel kernel)
+{
+ return 0;
+}
+
+cl_int
+clReleaseKernel(cl_kernel kernel)
+{
+ return 0;
+}
+
+cl_int
+clSetKernelArg(cl_kernel kernel,
+ cl_uint arg_indx,
+ size_t arg_size,
+ const void * arg_value)
+{
+ return 0;
+}
+
+cl_int
+clGetKernelInfo(cl_kernel kernel,
+ cl_kernel_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
+cl_int
+clGetKernelWorkGroupInfo(cl_kernel kernel,
+ cl_device_id device,
+ cl_kernel_work_group_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
diff --git a/src/api_memory.c b/src/api_memory.c
new file mode 100644
index 0000000..19d4095
--- /dev/null
+++ b/src/api_memory.c
@@ -0,0 +1,84 @@
+#include <OpenCL/cl.h>
+
+
+// Memory Object APIs
+cl_mem
+clCreateBuffer(cl_context context,
+ cl_mem_flags flags,
+ size_t size,
+ void * host_ptr,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_mem
+clCreateImage2D(cl_context context,
+ cl_mem_flags flags,
+ const cl_image_format * image_format,
+ size_t image_width,
+ size_t image_height,
+ size_t image_row_pitch,
+ void * host_ptr,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_mem
+clCreateImage3D(cl_context context,
+ cl_mem_flags flags,
+ const cl_image_format * image_format,
+ size_t image_width,
+ size_t image_height,
+ size_t image_depth,
+ size_t image_row_pitch,
+ size_t image_slice_pitch,
+ void * host_ptr,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainMemObject(cl_mem memobj)
+{
+ return 0;
+}
+
+cl_int
+clReleaseMemObject(cl_mem memobj)
+{
+ return 0;
+}
+
+cl_int
+clGetSupportedImageFormats(cl_context context,
+ cl_mem_flags flags,
+ cl_mem_object_type image_type,
+ cl_uint num_entries,
+ cl_image_format * image_formats,
+ cl_uint * num_image_formats)
+{
+ return 0;
+}
+
+cl_int
+clGetMemObjectInfo(cl_mem memobj,
+ cl_mem_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
+cl_int
+clGetImageInfo(cl_mem image,
+ cl_image_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
diff --git a/src/api_platform.c b/src/api_platform.c
new file mode 100644
index 0000000..28fdc3f
--- /dev/null
+++ b/src/api_platform.c
@@ -0,0 +1,34 @@
+#include <OpenCL/cl.h>
+
+#include <string.h>
+
+#define PROFILE_STR "FULL_PROFILE"
+#define PROFILE_STR_LEN 12
+
+#define VERSION_STR "OpenCL 1.0"
+#define VERSION_STR_LEN 10
+
+// Platform API
+cl_int
+clGetPlatformInfo(cl_platform_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ switch(param_name) {
+ case CL_PLATFORM_PROFILE:
+ strcpy(param_value, PROFILE_STR);
+ *param_value_size_ret = PROFILE_STR_LEN;
+ break;
+
+ case CL_PLATFORM_VERSION:
+ strcpy(param_value, VERSION_STR);
+ *param_value_size_ret = VERSION_STR_LEN;
+ break;
+
+ default:
+ return CL_INVALID_VALUE;
+ }
+
+ return CL_SUCCESS;
+}
diff --git a/src/api_profiling.c b/src/api_profiling.c
new file mode 100644
index 0000000..5980dee
--- /dev/null
+++ b/src/api_profiling.c
@@ -0,0 +1,13 @@
+#include <OpenCL/cl.h>
+
+// Profiling APIs
+cl_int
+clGetEventProfilingInfo(cl_event event,
+ cl_profiling_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
diff --git a/src/api_program.c b/src/api_program.c
new file mode 100644
index 0000000..98999fa
--- /dev/null
+++ b/src/api_program.c
@@ -0,0 +1,74 @@
+#include <OpenCL/cl.h>
+
+// Program Object APIs
+cl_program
+clCreateProgramWithSource(cl_context context,
+ cl_uint count,
+ const char ** strings,
+ const size_t * lengths,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_program
+clCreateProgramWithBinary(cl_context context,
+ cl_uint num_devices,
+ const cl_device_id * device_list,
+ const size_t * lengths,
+ const void ** binaries,
+ cl_int * binary_status,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainProgram(cl_program program)
+{
+ return 0;
+}
+
+cl_int
+clReleaseProgram(cl_program program)
+{
+ return 0;
+}
+
+cl_int
+clBuildProgram(cl_program program,
+ cl_uint num_devices,
+ const cl_device_id * device_list,
+ const char * options,
+ void (*pfn_notify)(cl_program program, void * user_data),
+ void * user_data)
+{
+ return 0;
+}
+
+cl_int
+clUnloadCompiler(void)
+{
+ return 0;
+}
+
+cl_int
+clGetProgramInfo(cl_program program,
+ cl_program_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
+
+cl_int
+clGetProgramBuildInfo(cl_program program,
+ cl_device_id device,
+ cl_program_build_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
diff --git a/src/api_sampler.c b/src/api_sampler.c
new file mode 100644
index 0000000..8c4d74a
--- /dev/null
+++ b/src/api_sampler.c
@@ -0,0 +1,34 @@
+#include <OpenCL/cl.h>
+
+// Sampler APIs
+cl_sampler
+clCreateSampler(cl_context context,
+ cl_bool normalized_coords,
+ cl_addressing_mode addressing_mode,
+ cl_filter_mode filter_mode,
+ cl_int * errcode_ret)
+{
+ return 0;
+}
+
+cl_int
+clRetainSampler(cl_sampler sampler)
+{
+ return 0;
+}
+
+cl_int
+clReleaseSampler(cl_sampler sampler)
+{
+ return 0;
+}
+
+cl_int
+clGetSamplerInfo(cl_sampler sampler,
+ cl_sampler_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret)
+{
+ return 0;
+}
diff --git a/src/cl_api.c b/src/cl_api.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/cl_api.c
diff --git a/src/context.h b/src/context.h
new file mode 100644
index 0000000..f74bcdb
--- /dev/null
+++ b/src/context.h
@@ -0,0 +1,16 @@
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+#include "OpenCL/cl.h"
+
+#include "pipe/p_context.h"
+
+struct _cl_context {
+ struct pipe_context *pipe;
+ cl_uint id;
+};
+
+void cl_set_current_context(struct _cl_context *ctx);
+struct _cl_context *cl_current_context(void);
+
+#endif
diff --git a/src/device.c b/src/device.c
new file mode 100644
index 0000000..b34a525
--- /dev/null
+++ b/src/device.c
@@ -0,0 +1,10 @@
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "OpenCL/cl.h"
+
+struct _cl_device_id {
+ struct pipe_screen *screen;
+};
+
+#endif
diff --git a/src/device.h b/src/device.h
new file mode 100644
index 0000000..c6f8f51
--- /dev/null
+++ b/src/device.h
@@ -0,0 +1,12 @@
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "OpenCL/cl.h"
+
+struct _cl_device_id {
+ struct pipe_screen *screen;
+
+ cl_uint type;
+};
+
+#endif