LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   [REQUEST] Enable 3D acceleration for Radeon HD7000 and HD8000 cards (https://www.linuxquestions.org/questions/slackware-14/%5Brequest%5D-enable-3d-acceleration-for-radeon-hd7000-and-hd8000-cards-4175470117/)

TobiSGD 07-18-2013 03:21 PM

[REQUEST] Enable 3D acceleration for Radeon HD7000 and HD8000 cards
 
As it seems Mesa in Slackware -current is compiled without the radeonsi Gallium3D driver, so Radeon HD7000 and HD8000 videochips don't get 3D acceleration. To change this radeonsi has to be added to the
Code:

--with-gallium-drivers=
line in the Mesa Slackbuild.
Unfortunately I have no card from those series available, so I can't test this.

Darth Vader 07-18-2013 05:49 PM

Quote:

Originally Posted by TobiSGD (Post 4992790)
As it seems Mesa in Slackware -current is compiled without the radeonsi Gallium3D driver, so Radeon HD7000 and HD8000 videochips don't get 3D acceleration. To change this radeonsi has to be added to the
Code:

--with-gallium-drivers=
line in the Mesa Slackbuild.
Unfortunately I have no card from those series available, so I can't test this.

For RadeonSI you need also R600 target support on LLVM-3.3 enabled with parameter
Code:

--enable-experimental-targets=R600
.

volkerdi 07-18-2013 05:59 PM

Quote:

Originally Posted by Darth Vader (Post 4992851)
For RadeonSI you need also R600 target support on LLVM-3.3 enabled with parameter
Code:

--enable-experimental-targets=R600
.

That's what the error message told me, too. But then it says that --enable-experimental-targets is an unrecognized option.

volkerdi 07-18-2013 06:32 PM

Also tried --enable-r600-llvm-compiler, but it still spits out the error about needing the option that doesn't work, and the resulting package is missing the drivers for VMware.

Looks like a no-go for now.

TobiSGD 07-18-2013 08:29 PM

Wow, there is more into it than I thought. Thanks for your effort.

EDIT: FWIW, I just tested if that option is recognized when using the latest git of LLVM/Clang and it worked indeed, so I think that this is something to look into after the 14.1 release.

ReaperX7 07-18-2013 08:49 PM

Try these flags in the configuration and see if they help. I used some of these a while back on my custom libMesa build and they seemed to work:

Code:

--enable-r600-llvm-compiler \
--enable-egl1 \
--enable-egl2 \
--enable-openvg \
--enable-xorg \
--enable-xa \
--enable-opencl \
--with-gallium-drivers="nouveau,r300,r600,radeonsi,svga" \
--with-dri-drivers="i915,i965,intel,radeon,r200,swrast"

BTW: you may want to check -current against the new 9.1.5 sources of libmesa: ftp://ftp.freedesktop.org/pub/mesa/9...-9.1.5.tar.bz2

And OpenCL might pester for these also:

http://slackbuilds.org/repository/14...pencl-headers/

volkerdi 07-18-2013 11:54 PM

Quote:

Originally Posted by ReaperX7 (Post 4992902)
BTW: you may want to check -current against the new 9.1.5 sources of libmesa: ftp://ftp.freedesktop.org/pub/mesa/9...-9.1.5.tar.bz2

I'm grabbing that now. But if radeonsi requires features that are labeled experimental, it's not time for that yet.

tuxbg 07-19-2013 12:07 AM

Also for OpenGL 3.0/3.1 Pat you need this
Code:

--enable-texture-float

ReaperX7 07-19-2013 12:34 AM

Quote:

Originally Posted by volkerdi (Post 4992977)
I'm grabbing that now. But if radeonsi requires features that are labeled experimental, it's not time for that yet.

Might be good to have a package with it for /Testing just in case anyone wants to give it a go, or has a card that can be tested with those chipsets, rather than excluding it.

Also, is the latest libdrm 2.4.26 incorporated?

http://dri.freedesktop.org/libdrm/libdrm-2.4.46.tar.bz2

BroX 07-19-2013 08:19 AM

I'd be happy to test packages to enable radeonsi with a HD7750 card.

BroX 07-19-2013 02:37 PM

Quote:

Originally Posted by volkerdi (Post 4992854)
That's what the error message told me, too. But then it says that --enable-experimental-targets is an unrecognized option.

I had no problems rebuilding llvm-3.3 with --enable-experimental-targets=R600. And after applying a patch from LFS I rebuilt mesa-9.1.4 including radeonsi.

Details in this post.

To cut to the chase: so far, radeonsi gets loaded, but X crashes with a segfault :(

ReaperX7 07-19-2013 03:36 PM

Maybe X needs to be rebuilt also...

Darth Vader 07-19-2013 03:58 PM

Quote:

Originally Posted by volkerdi (Post 4992854)
That's what the error message told me, too. But then it says that --enable-experimental-targets is an unrecognized option.

LLVM-3.3 is (re)compiled here just fine, on the latest current, using the following ./configure arguments.

Code:

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib$LIBDIRSUFFIX \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man \
  --enable-optimized \
  --disable-assertions \
  --enable-pic \
  --with-clang-resource-dir="../lib${LIBDIRSUFFIX}/clang/${VERSION}" \
  --enable-experimental-targets=R600 \
  --build=$ARCH-slackware-linux \
  --host=$ARCH-slackware-linux || exit 1

Well, in other words, the latest LLVM(-3.3) have an new (experimental) target, written right by AMD, called R600. That support is used by (the latest) MESA for enabling the bytecode support required to support RadeonSI.

volkerdi 07-19-2013 04:07 PM

Quote:

Originally Posted by Darth Vader (Post 4993467)
LLVM-3.3 is (re)compiled here just fine, on the latest current, using the following ./configure arguments.

Yeah, I recompiled it correctly here last night after someone pointed out in an email that the option was to be applied to the llvm configure, not the mesa one. D'oh!

I'm still not sure what we'll do about this yet, as I still have some concerns that these changes could make X less stable on these cards. It might be better to wait until these features aren't marked as experimental. There's always the fglrx driver in the meantime.

Thanks for all the hints about this, though.

ReaperX7 07-19-2013 04:25 PM

Maybe we need to add a directory named /experimental sometime for stuff like this?

Darth Vader 07-19-2013 04:36 PM

Quote:

Originally Posted by volkerdi (Post 4993472)
Yeah, I recompiled it correctly here last night after someone pointed out in an email that the option was to be applied to the llvm configure, not the mesa one. D'oh!

I'm still not sure what we'll do about this yet, as I still have some concerns that these changes could make X less stable on these cards. It might be better to wait until these features aren't marked as experimental. There's always the fglrx driver in the meantime.

Thanks for all the hints about this, though.

Well, because that LLVM's R600 support need to be enabled explicit (with --enable-r600-llvm-compiler,) on the MESA build, to obtain the required effect, I suggest you to enable the R600 target in LLVM, but to leave MESA as is.

That configuration simplifies the life of those adventurous who live on MESA-9.2 from GIT. That 9.2 GIT version performs just fine on few RadeonSI cards at that I have access...

Holering 08-27-2013 11:28 PM

SlackBuild for Mesa-9.2.0-rc2 and
 
HOW TO GET HARDWARE ACCELERATION FOR RADEON HD 7750! (see below)

After installing glamor-egl and updating Mesa, you may have to rebuild and reinstall xorg and the xf86-video-ati driver (see below on enabling --enable-glamor for the driver). Also, I can't confirm if you need llvm rebuilt with the --enable-r600-llvm-compiler option; you may or may not, so beware as I had my package of llvm built with that option.

Glamor egl slackbuild script (modified from some other slackbuild in l directory)
Link to required patch (right-click and save-as) http://www.linuxfromscratch.org/patc...-fixes-1.patch
Link to glamor-egl! http://anduin.linuxfromscratch.org/s...l-0.5.0.tar.xz
Code:

#!/bin/sh

# Copyright 2008, 2009, 2010, 2011  Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


PKGNAM=glamor-egl
VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
BUILD=${BUILD:-1}

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
      *) export ARCH=$( uname -m ) ;;
  esac
fi

NUMJOBS=${NUMJOBS:-" -j7 "}

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-glamor-egl

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
#  SLKCFLAGS="$CFLAGS"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -pipe -fPIC"
#  SLKCFLAGS="$CFLAGS"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf glamor-egl-$VERSION
tar xvf $CWD/glamor-egl-$VERSION.tar.xz
cd glamor-egl-$VERSION
chown -R root:root .
find . \
  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  -exec chmod 755 {} \; -o \
  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  -exec chmod 644 {} \;

# Patch from LFS
patch -Np1 -i $CWD/glamor-egl-0.5.0-fixes-1.patch
autoreconf -fi

sh autogen.sh

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --build=$ARCH-slackware-linux

make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

mv $PKG/usr/share/man $PKG/usr
gzip -9 $PKG/usr/man/man?/*.?

mv $PKG/usr/share/doc $PKG/usr
cp -a \
  AUTHORS COPYING* README* TODO \
  $PKG/usr/doc/glamor-egl-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/glamor-egl-$VERSION-$ARCH-$BUILD.txz

Now you can enable glamor in the slackware sources x/x11/configure/configure file after installing glamor (from above script) by adding:
Code:

--enable-glamor \
. (For some weird reason I couldn't build some xorg packages with the default script until I added --disable-xmlto in x/x11/configure/configure. Maybe you won't have that problem but who knows). You should probably rebuild xorg and the driver after you're done with Mesa (either in the next script or the last one were I managed to get 3D acceleration working on my cape verde GPU). Better yet, you should rebuild all packages dependent on Mesa (someone should write a script to check package dependencies and automate package rebuilding from slackware source directory).

Modified slackbuild for Mesa-9.2.0-rc2
Link to Mesa-9.2.0-rc2! ftp://ftp.freedesktop.org/pub/mesa/9...-9.2.0-rc2.zip
Code:

#!/bin/sh

# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PKGNAM=mesa
VERSION=9.2.0-rc2
DEMOVERS=8.1.0
BUILD=${BUILD:-1}

NUMJOBS=${NUMJOBS:--j7}

# Be sure this list is up-to-date:
#DRI_DRIVERS="i915,i965,intel,nouveau,r200,radeon,swrast"
DRI_DRIVERS="i915,i965,intel,nouveau,r200,radeon"

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
      *) export ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-mesa

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
#  SLKCFLAGS="$CFLAGS"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -pipe -fPIC"
#  SLKCFLAGS="$CFLAGS"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf Mesa-${VERSION}
#tar xvf $CWD/MesaLib-${VERSION}.tar.?z* || exit 1
unzip $CWD/MesaLib-${VERSION}.zip || exit 1
cd Mesa-$VERSION

# Let's kill the warning about operating on a dangling symlink:
rm -f src/gallium/state_trackers/d3d1x/w32api

# Make sure ownerships and permissions are sane:
chown -R root:root .
find . \
  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  -exec chmod 755 {} \; -o \
  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  -exec chmod 644 {} \;

# Apply patches from git (and maybe elsewhere):
# Patches obtained by:
  git checkout origin/8.0
  git format-patch 3d657b14b4cab98a2945904823e78cd8950944f4.. # 8.0.3 release
if /bin/ls $CWD/patches/*.patch 1> /dev/null 2> /dev/null ; then
  for patch in $CWD/patches/*.patch ; do
    patch -p1 < $patch || exit 1 ;
  done
fi

if [ ! -r configure ]; then
  autoreconf || exit 1
fi

# Fix llvm build problem with Mesa 9.1.6
#patch -Np1 -i $CWD/MesaLib-9.1.6-llvm_fixes-1.patch

# Ignore llvm r300 requirement
#patch -Np1 -i $CWD/mesa-9.2-dont-require-llvm-for-r300.patch

# Fix building with LLVM 3.3 (Courtesy of LFS)
sed -i "/LLVM_VERSION_INT/s:-ne:-lt:" configure.ac


# Running autogen to avoid problems if our autotools don't match upstream's:
./autogen.sh

# Optional configure options listed here:
# --enable-opencl \
# --enable-openvg \
# --enable-r600-llvm-compiler \

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --mandir=/usr/man \
  --docdir=/usr/doc/mesa-$VERSION \
  --disable-gallium-llvm \
  --with-gallium-drivers=nouveau,r300,r600,radeonsi,svga \
  --enable-gbm \
  --enable-gallium-gbm \
  --enable-xorg \
  --enable-xa \
  --enable-glx-tls \
  --enable-osmesa \
  --enable-texture-float \
  --enable-shared-glapi \
  --with-dri-drivers="$DRI_DRIVERS" \
  --with-dri-driverdir=/usr/lib${LIBDIRSUFFIX}/xorg/modules/dri \
  --build=$ARCH-slackware-linux


# r300 requires llvm
# Other gallium drivers:
# galahad,i915,identity,llvmpipe,noop,nv50,nvc0,nvfx,rbug,softpipe,svga,trace

make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1

# Now install the demos
( cd $TMP
  rm -rf mesa-demos-$DEMOVERS
  tar xvf $CWD/mesa-demos-$DEMOVERS.tar.?z* || exit 1
  cd mesa-demos-$DEMOVERS
  chown -R root:root .
  find . \
    \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
    -exec chmod 755 {} \; -o \
    \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
    -exec chmod 644 {} \; 
  CFLAGS="$SLKCFLAGS" \
  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --build=$ARCH-slackware-linux
  # Build and install gears and glinfo, as well as a few other demos
  make -C src/demos gears glinfo
  make -C src/xdemos \
    glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \
    glxheads glxinfo glxpbdemo glxpixmap
  mkdir -p $PKG/usr/bin
  cp -a src/demos/{gears,glinfo} $PKG/usr/bin
  for i in glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \
      glxheads glxinfo glxpbdemo glxpixmap ; do
        cp -a src/xdemos/$i $PKG/usr/bin ;
  done
)
 
# Strip binaries:
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

# Compress info files, if any:
if [ -d $PKG/usr/info ]; then
  rm -f $PKG/usr/info/dir
  gzip -9 $PKG/usr/info/*
fi

mkdir -p $PKG/usr/doc/Mesa-$VERSION/html
cp -a \
  docs/COPYING* docs/relnotes-${VERSION}*.html docs/README* docs/GL* \
  $PKG/usr/doc/Mesa-$VERSION
cp -a docs/*.html $PKG/usr/doc/Mesa-$VERSION/html
rm -f $PKG/usr/doc/Mesa-$VERSION/html/relnotes*.html

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz

Disabled swrast since I experienced problems with omp_get_thread_num using gcc-4.7.3. Could've been my CFLAGS but not quite sure. Also couldn't use llvm compiler for RadeonSI driver. You can remove radeonsi in the "with-gallium-drivers=" option and re-enable the llvm compiler option.


After further testing I got hardware acceleration working on my hd 7750 (cape verde)! Funnily enough, I was enabling all the options for llvm and proper cape verde support but got bad results (only software acceleration worked). Ended up using the most basic Mesa build options and it worked! Don't know if radeonsi driver is better but I only got software acceleration results trying to build it. This should work on all other new ati hd 7xxx gpus. Here's what the script looks like.

Code:

#!/bin/sh

# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PKGNAM=mesa
VERSION=9.2.0-rc2
DEMOVERS=8.1.0
BUILD=${BUILD:-1}

NUMJOBS=${NUMJOBS:--j7}

# Be sure this list is up-to-date:
#DRI_DRIVERS="i915,i965,intel,nouveau,r200,radeon,swrast"
DRI_DRIVERS="radeon"

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
      *) export ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-mesa

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
#  SLKCFLAGS="$CFLAGS"
  SLKCFLAGS="-O2 -pipe -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf Mesa-${VERSION}
#tar xvf $CWD/MesaLib-${VERSION}.tar.?z* || exit 1
unzip $CWD/MesaLib-${VERSION}.zip || exit 1
cd Mesa-$VERSION

# Let's kill the warning about operating on a dangling symlink:
rm -f src/gallium/state_trackers/d3d1x/w32api

# Make sure ownerships and permissions are sane:
chown -R root:root .
find . \
  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  -exec chmod 755 {} \; -o \
  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  -exec chmod 644 {} \;

# Apply patches from git (and maybe elsewhere):
# Patches obtained by:
  git checkout origin/8.0
  git format-patch 3d657b14b4cab98a2945904823e78cd8950944f4.. # 8.0.3 release
if /bin/ls $CWD/patches/*.patch 1> /dev/null 2> /dev/null ; then
  for patch in $CWD/patches/*.patch ; do
    patch -p1 < $patch || exit 1 ;
  done
fi

if [ ! -r configure ]; then
  autoreconf || exit 1
fi

# Fix llvm build problem with Mesa 9.1.6
#patch -Np1 -i $CWD/MesaLib-9.1.6-llvm_fixes-1.patch

# Ignore llvm r300 requirement
#patch -Np1 -i $CWD/mesa-9.2-dont-require-llvm-for-r300.patch

# Fix building with LLVM 3.3 (Courtesy of LFS)
sed -i "/LLVM_VERSION_INT/s:-ne:-lt:" configure.ac


# Running autogen to avoid problems if our autotools don't match upstream's:
./autogen.sh

# Optional configure options listed here:
# --enable-opencl

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --mandir=/usr/man \
  --docdir=/usr/doc/mesa-$VERSION \
  --with-dri-drivers="$DRI_DRIVERS" \
  --with-dri-driverdir=/usr/lib${LIBDIRSUFFIX}/xorg/modules/dri \
  --build=$ARCH-slackware-linux


# r300 requires llvm
# Other gallium drivers:
# galahad,i915,identity,llvmpipe,noop,nv50,nvc0,nvfx,rbug,softpipe,svga,trace

make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1

# Now install the demos
( cd $TMP
  rm -rf mesa-demos-$DEMOVERS
  tar xvf $CWD/mesa-demos-$DEMOVERS.tar.?z* || exit 1
  cd mesa-demos-$DEMOVERS
  sh autogen.sh
  chown -R root:root .
  find . \
    \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
    -exec chmod 755 {} \; -o \
    \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
    -exec chmod 644 {} \;
  CFLAGS="$SLKCFLAGS" \
  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --build=$ARCH-slackware-linux
  # Build and install gears and glinfo, as well as a few other demos
  make -C src/demos gears glinfo
  make -C src/xdemos \
    glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \
    glxheads glxinfo glxpbdemo glxpixmap
  mkdir -p $PKG/usr/bin
  cp -a src/demos/{gears,glinfo} $PKG/usr/bin
  for i in glthreads glxcontexts glxdemo glxgears glxgears_fbconfig \
      glxheads glxinfo glxpbdemo glxpixmap ; do
        cp -a src/xdemos/$i $PKG/usr/bin ;
  done
)
 
# Strip binaries:
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

# Compress info files, if any:
if [ -d $PKG/usr/info ]; then
  rm -f $PKG/usr/info/dir
  gzip -9 $PKG/usr/info/*
fi

mkdir -p $PKG/usr/doc/Mesa-$VERSION/html
cp -a \
  docs/COPYING* docs/relnotes-${VERSION}*.html docs/README* docs/GL* \
  $PKG/usr/doc/Mesa-$VERSION
cp -a docs/*.html $PKG/usr/doc/Mesa-$VERSION/html
rm -f $PKG/usr/doc/Mesa-$VERSION/html/relnotes*.html

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz

Now if only I could get opengl vsync to work...

Cheers! :beer:


All times are GMT -5. The time now is 06:15 AM.