Atlas - compile_shaders.sh
Home / ext / SDL / src / gpu / metal Lines: 1 | Size: 2025 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]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[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.