Hi,
I'm trying to compile my .metal file into .metallib with:
xcrun -sdk iphoneos metal -std=ios-metal1.1 Shaders.metal -o CameraShader.air
xcrun -sdk iphoneos metallib CameraShader.air -o CameraShader.metallib
But when I call device.makeRenderPipelineState it throws with error:
Error Domain=AGXMetalA9 Code=1 "Function displayTexture has a deployment target which is incompatible with this OS." UserInfo={NSLocalizedDescription=Function displayTexture has a deployment target which is incompatible with this OS.}
If I use .metal file everything works fine.
What I'm doing wrong?
Since you're compiling your Metal code on the command-line (not using the Xcode project), the complier doesn't know the deployment target. So, by default, it uses the version of the SDK as the deployment target (I'm guessing you have an iOS 11 SDK since it works on a device with iOS11 but not iOS10).
You need to use the -mios-version-min option with the Metal compiler like the following:
xcrun -sdk iphoneos metal -std=ios-metal1.1 -mios-version-min=8.0 Shaders.metal -o CameraShader.air