1#!/usr/bin/env bash 2 3TARGETDIR=localResults 4BASEDIR=baseResults 5EXE=../build/install/bin/glslangValidator 6REMAPEXE=../build/install/bin/spirv-remap 7HASERROR=0 8mkdir -p localResults 9 10if [ -a localtestlist ] 11 then 12 while read t; do 13 echo Running $t... 14 b=`basename $t` 15 $EXE -i -l $t > $TARGETDIR/$b.out 16 diff -b $BASEDIR/$b.out $TARGETDIR/$b.out || HASERROR=1 17 done < localtestlist 18fi 19 20rm -f comp.spv frag.spv geom.spv tesc.spv tese.spv vert.spv 21 22# 23# special tests 24# 25 26$EXE badMacroArgs.frag > $TARGETDIR/badMacroArgs.frag.out 27diff -b $BASEDIR/badMacroArgs.frag.out $TARGETDIR/badMacroArgs.frag.out || HASERROR=1 28 29# 30# reflection tests 31# 32echo Running reflection... 33$EXE -l -q -C reflection.vert > $TARGETDIR/reflection.vert.out 34diff -b $BASEDIR/reflection.vert.out $TARGETDIR/reflection.vert.out || HASERROR=1 35$EXE -D -Od -e flizv -l -q -C -V -Od hlsl.reflection.vert > $TARGETDIR/hlsl.reflection.vert.out 36diff -b $BASEDIR/hlsl.reflection.vert.out $TARGETDIR/hlsl.reflection.vert.out || HASERROR=1 37$EXE -D -Od -e main -l -q -C -V -Od hlsl.reflection.binding.frag > $TARGETDIR/hlsl.reflection.binding.frag.out 38diff -b $BASEDIR/hlsl.reflection.binding.frag.out $TARGETDIR/hlsl.reflection.binding.frag.out || HASERROR=1 39$EXE -D -Od -e main -l -q --hlsl-iomap --auto-map-bindings --stb 10 --sbb 20 --ssb 30 --suavb 40 --scb 50 -D -V -e main -Od hlsl.automap.frag > $TARGETDIR/hlsl.automap.frag.out 40diff -b $BASEDIR/hlsl.automap.frag.out $TARGETDIR/hlsl.automap.frag.out || HASERROR=1 41 42# 43# multi-threaded test 44# 45echo Comparing single thread to multithread for all tests in current directory... 46$EXE -i -C *.vert *.geom *.frag *.tes* *.comp > singleThread.out 47$EXE -i -C *.vert *.geom *.frag *.tes* *.comp -t > multiThread.out 48diff singleThread.out multiThread.out || HASERROR=1 49if [ $HASERROR -eq 0 ] 50then 51 rm singleThread.out 52 rm multiThread.out 53fi 54 55# 56# entry point renaming tests 57# 58echo Running entry-point renaming tests 59$EXE -i -H -V -D -Od -e main_in_spv --ku --source-entrypoint main -Od hlsl.entry.rename.frag > $TARGETDIR/hlsl.entry.rename.frag.out 60diff -b $BASEDIR/hlsl.entry.rename.frag.out $TARGETDIR/hlsl.entry.rename.frag.out || HASERROR=1 61 62# 63# Testing ill-defined uncalled function 64# 65echo Running ill-defined uncalled function 66$EXE -D -Od -e main -H -Od hlsl.deadFunctionMissingBody.vert > $TARGETDIR/hlsl.deadFunctionMissingBody.vert.out 67diff -b $BASEDIR/hlsl.deadFunctionMissingBody.vert.out $TARGETDIR/hlsl.deadFunctionMissingBody.vert.out || HASERROR=1 68 69if [ $HASERROR -eq 0 ] 70then 71 echo Tests Succeeded. 72else 73 echo Tests Failed. 74fi 75 76# 77# Testing -S and compound suffixes 78# 79echo Running explicit stage test and compound suffix tests 80$EXE -Od -i -S vert nosuffix > $TARGETDIR/nosuffix.out 81diff -b $BASEDIR/nosuffix.out $TARGETDIR/nosuffix.out || HASERROR=1 82$EXE -Od -i compoundsuffix.vert.glsl > $TARGETDIR/compoundsuffix.vert.glsl 83diff -b $BASEDIR/compoundsuffix.vert.glsl $TARGETDIR/compoundsuffix.vert.glsl || HASERROR=1 84$EXE -Od -e main -H compoundsuffix.frag.hlsl > $TARGETDIR/compoundsuffix.frag.hlsl 85diff -b $BASEDIR/compoundsuffix.frag.hlsl $TARGETDIR/compoundsuffix.frag.hlsl || HASERROR=1 86 87# 88# Testing --hlsl-offsets 89# 90echo Running hlsl offsets 91$EXE -i --hlsl-offsets -H spv.hlslOffsets.vert > $TARGETDIR/spv.hlslOffsets.vert.out 92diff -b $BASEDIR/spv.hlslOffsets.vert.out $TARGETDIR/spv.hlslOffsets.vert.out || HASERROR=1 93 94echo Running hlsl offsets 95$EXE -i --hlsl-offsets -D -Od -e main -H -Od hlsl.hlslOffset.vert > $TARGETDIR/hlsl.hlslOffset.vert.out 96diff -b $BASEDIR/hlsl.hlslOffset.vert.out $TARGETDIR/hlsl.hlslOffset.vert.out || HASERROR=1 97 98# 99# Testing --resource-set-binding 100# 101echo Configuring HLSL descriptor set and binding number manually 102$EXE -V -D -Od -e main -H -Od hlsl.multiDescriptorSet.frag --rsb frag t0 0 0 t1 1 0 s0 0 1 s1 1 1 b0 2 0 b1 2 1 b2 2 2 > $TARGETDIR/hlsl.multiDescriptorSet.frag.out 103diff -b $BASEDIR/hlsl.multiDescriptorSet.frag.out $TARGETDIR/hlsl.multiDescriptorSet.frag.out || HASERROR=1 104 105$EXE -V -D -Od -e main -H -Od hlsl.explicitDescriptorSet.frag --hlsl-iomap --amb --ssb 10 --stb 20 --rsb 4 > $TARGETDIR/hlsl.explicitDescriptorSet.frag.out 106diff -b $BASEDIR/hlsl.explicitDescriptorSet.frag.out $TARGETDIR/hlsl.explicitDescriptorSet.frag.out || HASERROR=1 107 108$EXE -V -D -Od -e main -H -Od hlsl.explicitDescriptorSet.frag --hlsl-iomap --amb --ssb 10 --stb 20 --rsb frag 3 > $TARGETDIR/hlsl.explicitDescriptorSet-2.frag.out 109diff -b $BASEDIR/hlsl.explicitDescriptorSet-2.frag.out $TARGETDIR/hlsl.explicitDescriptorSet-2.frag.out || HASERROR=1 110 111# 112# Testing per-descriptor-set IO map shift 113# 114echo 'Testing per-descriptor-set IO map shift' 115$EXE -e main --hlsl-iomap --ssb 10 1 15 2 --stb 20 --stb 25 2 --suavb 30 --suavb 40 2 --sub 50 6 -i -q -D -Od -V hlsl.shift.per-set.frag > $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1 116diff -b $BASEDIR/hlsl.shift.per-set.frag.out $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1 117 118# 119# Testing location error 120# 121echo Testing SPV no location 122$EXE -V -C spv.noLocation.vert > $TARGETDIR/spv.noLocation.vert.out 123diff -b $BASEDIR/spv.noLocation.vert.out $TARGETDIR/spv.noLocation.vert.out || HASERROR=1 124$EXE -G -H --aml spv.noBuiltInLoc.vert > $TARGETDIR/spv.noBuiltInLoc.vert.out 125diff -b $BASEDIR/spv.noBuiltInLoc.vert.out $TARGETDIR/spv.noBuiltInLoc.vert.out || HASERROR=1 126$EXE -G spv.looseUniformNoLoc.vert > $TARGETDIR/spv.looseUniformNoLoc.vert.out 127diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc.vert.out || HASERROR=1 128 129# 130# Testing debug information 131# 132echo Testing SPV Debug Information 133$EXE -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf \ 134 -G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.frag.out 135diff -b $BASEDIR/spv.debugInfo.frag.out $TARGETDIR/spv.debugInfo.frag.out || HASERROR=1 136$EXE -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf \ 137 -G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.1.1.frag.out 138diff -b $BASEDIR/spv.debugInfo.1.1.frag.out $TARGETDIR/spv.debugInfo.1.1.frag.out || HASERROR=1 139$EXE -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \ 140 --sep origMain -H -Od spv.hlslDebugInfo.vert --rsb vert t0 0 0 > $TARGETDIR/spv.hlslDebugInfo.frag.out 141diff -b $BASEDIR/spv.hlslDebugInfo.frag.out $TARGETDIR/spv.hlslDebugInfo.frag.out || HASERROR=1 142 143# 144# Testing Includer 145# 146echo Testing Includer 147$EXE -D -Od -e main -H -Od ../Test/hlsl.include.vert > $TARGETDIR/hlsl.include.vert.out 148diff -b $BASEDIR/hlsl.include.vert.out $TARGETDIR/hlsl.include.vert.out || HASERROR=1 149$EXE -D -Od -e main -H -Od hlsl.includeNegative.vert > $TARGETDIR/hlsl.includeNegative.vert.out 150diff -b $BASEDIR/hlsl.includeNegative.vert.out $TARGETDIR/hlsl.includeNegative.vert.out || HASERROR=1 151$EXE -l -i include.vert > $TARGETDIR/include.vert.out 152diff -b $BASEDIR/include.vert.out $TARGETDIR/include.vert.out || HASERROR=1 153$EXE -D -Od -e main -H -Od -Iinc1/path1 -Iinc1/path2 hlsl.dashI.vert > $TARGETDIR/hlsl.dashI.vert.out 154diff -b $BASEDIR/hlsl.dashI.vert.out $TARGETDIR/hlsl.dashI.vert.out || HASERROR=1 155 156# 157# Testing -D and -U 158# 159echo "Testing -D and -U" 160$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l -UUNDEFED -DMUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out 161diff -b $BASEDIR/glsl.-D-U.frag.out $TARGETDIR/glsl.-D-U.frag.out || HASERROR=1 162$EXE -D -Od -e main -V -i -DUNDEFED -UIN_SHADER -DFOO=200 -UUNDEFED -Od hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out 163diff -b $BASEDIR/hlsl.-D-U.frag.out $TARGETDIR/hlsl.-D-U.frag.out || HASERROR=1 164 165# 166# Test --client and --target-env 167# 168echo "Testing --client and --target-env" 169$EXE --client vulkan100 spv.targetVulkan.vert || HASERROR=1 170$EXE --client opengl100 spv.targetOpenGL.vert || HASERROR=1 171$EXE --target-env vulkan1.0 spv.targetVulkan.vert || HASERROR=1 172$EXE --target-env vulkan1.1 spv.targetVulkan.vert || HASERROR=1 173$EXE --target-env opengl spv.targetOpenGL.vert || HASERROR=1 174$EXE -V100 spv.targetVulkan.vert || HASERROR=1 175$EXE -G100 spv.targetOpenGL.vert || HASERROR=1 176 177# 178# Testing GLSL entry point rename 179# 180echo "Testing GLSL entry point rename" 181$EXE -H -e foo --source-entrypoint main glsl.entryPointRename.vert > $TARGETDIR/glsl.entryPointRename.vert.out 182diff -b $BASEDIR/glsl.entryPointRename.vert.out $TARGETDIR/glsl.entryPointRename.vert.out || HASERROR=1 183$EXE -H -e foo --source-entrypoint bar glsl.entryPointRename.vert > $TARGETDIR/glsl.entryPointRename.vert.bad.out 184diff -b $BASEDIR/glsl.entryPointRename.vert.bad.out $TARGETDIR/glsl.entryPointRename.vert.bad.out || HASERROR=1 185$EXE -H -e foo --source-entrypoint main glsl.entryPointRename2.vert > $TARGETDIR/glsl.entryPointRename2.vert.out 186diff -b $BASEDIR/glsl.entryPointRename2.vert.out $TARGETDIR/glsl.entryPointRename2.vert.out || HASERROR=1 187 188# 189# Testing remapper error handling 190# 191echo "Testing remapper error handling" 192$REMAPEXE --do-everything -i remap.invalid-spirv-1.spv -o $TARGETDIR > $TARGETDIR/remap.invalid-spirv-1.out && HASERROR=1 193diff -b $BASEDIR/remap.invalid-spirv-1.out $TARGETDIR/remap.invalid-spirv-1.out || HASERROR=1 194$REMAPEXE --do-everything -i remap.invalid-spirv-2.spv -o $TARGETDIR > $TARGETDIR/remap.invalid-spirv-2.out && HASERROR=1 195diff -b $BASEDIR/remap.invalid-spirv-2.out $TARGETDIR/remap.invalid-spirv-2.out || HASERROR=1 196 197# 198# Testing position Y inversion 199# 200echo "Testing position Y inversion" 201$EXE -H -e main -V -D -Od -H -i --iy hlsl.y-negate-1.vert > $TARGETDIR/hlsl.y-negate-1.vert.out 202diff -b $BASEDIR/hlsl.y-negate-1.vert.out $TARGETDIR/hlsl.y-negate-1.vert.out || HASERROR=1 203$EXE -H -e main -V -D -Od -H -i --invert-y hlsl.y-negate-2.vert > $TARGETDIR/hlsl.y-negate-2.vert.out 204diff -b $BASEDIR/hlsl.y-negate-2.vert.out $TARGETDIR/hlsl.y-negate-2.vert.out || HASERROR=1 205$EXE -H -e main -V -D -Od -H -i --invert-y hlsl.y-negate-3.vert > $TARGETDIR/hlsl.y-negate-3.vert.out 206diff -b $BASEDIR/hlsl.y-negate-3.vert.out $TARGETDIR/hlsl.y-negate-3.vert.out || HASERROR=1 207 208# 209# Testing hlsl_functionality1 210# 211$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.structbuffer.incdec.frag > \ 212 $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out 213diff -b $BASEDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out || HASERROR=1 214$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.noSemantic.functionality1.comp > \ 215 $TARGETDIR/hlsl.noSemantic.functionality1.comp.out 216diff -b $BASEDIR/hlsl.noSemantic.functionality1.comp.out $TARGETDIR/hlsl.noSemantic.functionality1.comp.out || HASERROR=1 217 218# 219# Final checking 220# 221if [ $HASERROR -eq 0 ] 222then 223 echo Tests Succeeded. 224else 225 echo Tests Failed. 226fi 227 228rm -f comp.spv frag.spv geom.spv tesc.spv tese.spv vert.spv 229 230exit $HASERROR 231