diff options
Diffstat (limited to 'contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh')
| -rwxr-xr-x | contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh b/contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh new file mode 100755 index 0000000..0b8c33c --- /dev/null +++ b/contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | set -x | ||
| 4 | set -e | ||
| 5 | cd `dirname "$0"` | ||
| 6 | |||
| 7 | shadernames=(FullscreenVert BlitFrom2D BlitFrom2DArray BlitFrom3D BlitFromCube BlitFromCubeArray) | ||
| 8 | |||
| 9 | generate_shaders() | ||
| 10 | { | ||
| 11 | fileplatform=$1 | ||
| 12 | compileplatform=$2 | ||
| 13 | sdkplatform=$3 | ||
| 14 | minversion=$4 | ||
| 15 | |||
| 16 | for shadername in "${shadernames[@]}"; do | ||
| 17 | xcrun -sdk $sdkplatform metal -c -std=$compileplatform-metal2.0 -m$sdkplatform-version-min=$minversion -Wall -O3 -D COMPILE_$shadername -o ./$shadername.air ./Metal_Blit.metal || exit $? | ||
| 18 | xcrun -sdk $sdkplatform metallib -o $shadername.metallib $shadername.air || exit $? | ||
| 19 | xxd -i $shadername.metallib | perl -w -p -e 's/\Aunsigned /const unsigned /;' >./${shadername}_$fileplatform.h | ||
| 20 | rm -f $shadername.air $shadername.metallib | ||
| 21 | done | ||
| 22 | } | ||
| 23 | |||
| 24 | generate_shaders macos macos macosx 10.11 | ||
| 25 | generate_shaders ios ios iphoneos 11.0 | ||
| 26 | generate_shaders iphonesimulator ios iphonesimulator 11.0 | ||
| 27 | generate_shaders tvos ios appletvos 11.0 | ||
| 28 | generate_shaders tvsimulator ios appletvsimulator 11.0 | ||
| 29 | |||
| 30 | # Bundle together one mega-header | ||
| 31 | catShaders() | ||
| 32 | { | ||
| 33 | target=$1 | ||
| 34 | for shadername in "${shadernames[@]}"; do | ||
| 35 | cat ${shadername}_$target.h >> Metal_Blit.h | ||
| 36 | done | ||
| 37 | } | ||
| 38 | |||
| 39 | rm -f Metal_Blit.h | ||
| 40 | echo "#if defined(SDL_PLATFORM_IOS)" >> Metal_Blit.h | ||
| 41 | echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h | ||
| 42 | catShaders iphonesimulator | ||
| 43 | echo "#else" >> Metal_Blit.h | ||
| 44 | catShaders ios | ||
| 45 | echo "#endif" >> Metal_Blit.h | ||
| 46 | echo "#elif defined(SDL_PLATFORM_TVOS)" >> Metal_Blit.h | ||
| 47 | echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h | ||
| 48 | catShaders tvsimulator | ||
| 49 | echo "#else" >> Metal_Blit.h | ||
| 50 | catShaders tvos | ||
| 51 | echo "#endif" >> Metal_Blit.h | ||
| 52 | echo "#else" >> Metal_Blit.h | ||
| 53 | catShaders macos | ||
| 54 | echo "#endif" >> Metal_Blit.h | ||
| 55 | |||
| 56 | # Clean up | ||
| 57 | cleanupShaders() | ||
| 58 | { | ||
| 59 | target=$1 | ||
| 60 | for shadername in "${shadernames[@]}"; do | ||
| 61 | rm -f ${shadername}_$target.h | ||
| 62 | done | ||
| 63 | } | ||
| 64 | cleanupShaders iphonesimulator | ||
| 65 | cleanupShaders ios | ||
| 66 | cleanupShaders tvsimulator | ||
| 67 | cleanupShaders tvos | ||
| 68 | cleanupShaders macos \ No newline at end of file | ||
