Search code examples
iosmetal

How to retrieve MTLLanguageVersion in Metal


There is an MTLLanguageVersion enum documented at https://developer.apple.com/documentation/metal/mtllanguageversion?language=objc which, if I understand correctly, returns current Metal shading language version at runtime.

The problem is, I can't figure out where to retrieve it. I can't find any related property on MTLDevice or some global function for this, and documentation doesn't help either.


Solution

  • MTLLanguageVersion enum is used for configuring one of the compiler options, namely, languageVersion.

    You can configure the Metal compiler’s options by setting any or all of an MTLCompileOptions instance’s properties, including the following:

    You can compile a library with your compile options instance by calling a MTLDevice instance’s newLibraryWithSource:options:error: or newLibraryWithSource:options:completionHandler: method.