summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh')
-rwxr-xr-xcontrib/SDL-3.2.8/src/gpu/metal/compile_shaders.sh68
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
3set -x
4set -e
5cd `dirname "$0"`
6
7shadernames=(FullscreenVert BlitFrom2D BlitFrom2DArray BlitFrom3D BlitFromCube BlitFromCubeArray)
8
9generate_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
24generate_shaders macos macos macosx 10.11
25generate_shaders ios ios iphoneos 11.0
26generate_shaders iphonesimulator ios iphonesimulator 11.0
27generate_shaders tvos ios appletvos 11.0
28generate_shaders tvsimulator ios appletvsimulator 11.0
29
30# Bundle together one mega-header
31catShaders()
32{
33 target=$1
34 for shadername in "${shadernames[@]}"; do
35 cat ${shadername}_$target.h >> Metal_Blit.h
36 done
37}
38
39rm -f Metal_Blit.h
40echo "#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
46echo "#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
52echo "#else" >> Metal_Blit.h
53 catShaders macos
54echo "#endif" >> Metal_Blit.h
55
56# Clean up
57cleanupShaders()
58{
59 target=$1
60 for shadername in "${shadernames[@]}"; do
61 rm -f ${shadername}_$target.h
62 done
63}
64cleanupShaders iphonesimulator
65cleanupShaders ios
66cleanupShaders tvsimulator
67cleanupShaders tvos
68cleanupShaders macos \ No newline at end of file