Skip to content

Commit

Permalink
use glslangValidator in Travis-CI to validate our shaders... hopefull…
Browse files Browse the repository at this point in the history
…y fixing OsnaCS#187
  • Loading branch information
vab9 committed Aug 9, 2016
1 parent de9a13d commit 0405a52
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
language: rust
rust: stable
cache: cargo
cache:
- cargo
- directories:
- validator
sudo: false
git:
depth: 1
before_script:
- |
export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH &&
ci/install-tools.sh
ci/install-tools.sh &&
ci/install-glslangValidator.sh
script:
- ci/run-all.sh
after_success:
Expand Down
15 changes: 15 additions & 0 deletions ci/install-glslangValidator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

# check for validator folder (travis caching)
if [ ! -d "validator/" ]; then
echo "need to install glslangValidator..."
mkdir validator/
cd validator/
wget "https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang/Install/Linux/glslangValidator"
chmod +x glslangValidator
cd ../
echo "installed glslangValidator to $PWD/validator/glslangValidator"
else
echo "using cached glslangValidator"
fi
7 changes: 7 additions & 0 deletions ci/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ $MY_PATH/check-basic-style.sh
# EDIT: we don't want to check it anymore...
# $MY_PATH/check-rustfmt.sh

# add validator to PATH
VALIDATOR_PATH=`find $PWD -name glslangValidator`
export PATH=$PATH:`dirname $VALIDATOR_PATH`

# validate shaders
$MY_PATH/validate-shaders.sh

# check that everything compiles and all tests pass
$MY_PATH/test-all.sh

Expand Down
42 changes: 42 additions & 0 deletions ci/validate-shaders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -o errexit -o nounset

echo ""
echo "=== Validating Shaders =============="

SHADER_DIR=`find $PWD -name shader`

ERROR_TMP=".shader_errors"
trap "rm $ERROR_TMP; exit" SIGHUP SIGINT SIGTERM

# Make sure only shaders are in client/shader/ for this to work
for shader in $SHADER_DIR/*; do
echo "Validating: `basename $shader` ..."
if ! glslangValidator -s $shader > /dev/null;
then
echo "=== ERRORS in `basename $shader` =============" >> $ERROR_TMP
glslangValidator $shader | grep "ERROR" >> $ERROR_TMP
echo "" >> $ERROR_TMP
fi
done

echo ""
echo "=== Validating Shaders Done! ============"

if [ -s $ERROR_TMP ]
then
echo ""
echo "=== FOUND ERRORS IN SOME SHADERS! =============="
echo ""
ERROR=1
# Print Errors & Cleanup
cat $ERROR_TMP
rm $ERROR_TMP
else
echo ""
echo "=== Shaders seem fine! =============="
ERROR=0
fi

test $ERROR == 0

0 comments on commit 0405a52

Please sign in to comment.