1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/bin/bash
glslang=$(PATH=./glslang/bin:$PATH which glslangValidator 2> /dev/null)
result=0
shaderdir=$1
if [ -z $glslang ]; then
echo "Error: glslangValidator not found, cannot validate shaders!"
exit 1
fi
function print_error
{
echo "While validating $1:"
echo "$2"
result=1
}
function validate_vert
{
output=$(cat "$shaderdir/header_desktop.glsl" "$shaderdir/$1" | $glslang --stdin -S vert -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_desktop_core.glsl" "$shaderdir/$1" | $glslang --stdin -S vert -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_es2.glsl" "$shaderdir/$1" | $glslang --stdin -S vert -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_es3.glsl" "$shaderdir/$1" | $glslang --stdin -S vert -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
}
function validate_frag
{
output=$(cat "$shaderdir/header_desktop.glsl" "$shaderdir/sdf.glsl" "$shaderdir/$1" | $glslang --stdin -S frag -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_desktop_core.glsl" "$shaderdir/sdf.glsl" "$shaderdir/$1" | $glslang --stdin -S frag -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_es2.glsl" "$shaderdir/sdf.glsl" "$shaderdir/$1" | $glslang --stdin -S frag -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
output=$(cat "$shaderdir/header_es3.glsl" "$shaderdir/sdf.glsl" "$shaderdir/$1" | $glslang --stdin -S frag -l -DVALIDATING)
if [ $? -ne 0 ]; then print_error "$1" "$output"; fi
}
validate_vert "piechart.vert"
validate_frag "piechart.frag"
validate_vert "linechart.vert"
validate_frag "linechart.frag"
if [ $result -eq 0 ]; then
echo "Successfully validated shaders, no errors found."
fi
exit $result
|