also support ATI Compressonator via WINE for release building
authorRudolf Polzer <divverent@alientrap.org>
Sat, 26 Jun 2010 14:29:41 +0000 (16:29 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 26 Jun 2010 14:29:54 +0000 (16:29 +0200)
misc/tools/cached-converter.sh
misc/tools/compress-texture [new file with mode: 0755]

index fda5cac0f8e4cb4d08720e97ec15c2a41e62c5bd..e9a214b758880f0efb381cbd67c6997744d2de7c 100755 (executable)
@@ -7,10 +7,20 @@ set -e
 : ${jpeg_qual_rgb:=95}
 : ${jpeg_qual_a:=99}
 : ${do_dds:=true}
-: ${dds_flags:=}
+: ${dds_tool:=compressonator}
 : ${do_ogg:=false}
 : ${ogg_qual:=1}
 
+me=$0
+case "$me" in
+       */*)
+               meprefix=${me%/*}/
+               ;;
+       *)
+               meprefix=
+               ;;
+esac
+
 tmpdir=`mktemp -d -t cached-converter.XXXXXX`
 trap 'exit 1' INT
 trap 'rm -rf "$tmpdir"' EXIT
@@ -47,7 +57,7 @@ cached()
        else
                rm -f "$tempfile1"
                rm -f "$tempfile2"
-       exit 1
+               exit 1
        fi
 }
 
@@ -57,7 +67,7 @@ reduce_jpeg2_dds()
        ia=$1; shift
        o=$1; shift; shift 
        convert "$i" "$ia" -compose CopyOpacity -composite "$tmpdir/x.png" && \
-       nvcompress -alpha -bc3 $1 "$tmpdir/x.png" "$o"
+       "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.png" "$o" $1
 }
 
 reduce_jpeg2_jpeg2()
@@ -89,7 +99,7 @@ reduce_rgba_dds()
 {
        i=$1; shift; shift
        o=$1; shift; shift
-       nvcompress -alpha -bc3 $1 "$i" "$o"
+       "$meprefix"compress-texture "$dds_tool" dxt5 "$i" "$o" $1
 }
 
 reduce_rgba_jpeg2()
@@ -107,7 +117,7 @@ reduce_rgb_dds()
 {
        i=$1; shift; shift
        o=$1; shift; shift
-       nvcompress -bc1 $1 "$i" "$o"
+       "$meprefix"compress-texture "$dds_tool" dxt1 "$i" "$o" $1
 }
 
 reduce_rgb_jpeg()
diff --git a/misc/tools/compress-texture b/misc/tools/compress-texture
new file mode 100755 (executable)
index 0000000..d1ceecd
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# usage: compress-texture tool compression in.png out.dds
+# example: compress-texture compressonator dxt1 foo.jpg foo.dds
+
+tool=$1; shift
+format=$1; shift
+src=$1; shift
+dst=$1; shift
+
+f=
+case "$tool" in
+       compressonator)
+               case "$format" in
+                       dxt1) f="+fourCC DXT1" ;;
+                       dxt3) f="+fourCC DXT3" ;;
+                       dxt5) f="+fourCC DXT5" ;;
+               esac
+               echo ">> $f ($format)"
+               dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
+               dir_dos="C:/${dir##*/}"
+               ext=${src##*.}
+               cp "$src" "$dir/src.$ext"
+               wine "$HOME/.wine/drive_c/Program Files/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -mipmaps "$dir_dos/src.$ext" "$dir_dos/dst.dds" -codec DXTC.dll $f "$@"
+               mv "$dir/dst.dds" "$dst"
+               rm -rf "$dir"
+               ;;
+       nvcompress)
+               case "$format" in
+                       dxt1) f="-bc1" ;;
+                       dxt3) f="-alpha -bc3" ;;
+                       dxt5) f="-alpha -bc5" ;;
+               esac
+               nvcompress $f "$@" "$src" "$dst"
+               ;;
+esac