Skip to content

Commit ea0759f

Browse files
committed
Set the minimum required Metal version for compatibility when running in an environment where it is not set to the latest version (contrary to what the documentation says)
1 parent f06b27b commit ea0759f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

filament/backend/src/metal/MetalShaderCompiler.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ bool isReady() const noexcept {
111111
id<MTLLibrary> library = nil;
112112
switch (program.getShaderLanguage()) {
113113
case ShaderLanguage::MSL: {
114-
// By default, Metal uses the most recent language version.
115114
MTLCompileOptions* options = [MTLCompileOptions new];
116115
options.fastMathEnabled = YES;
116+
// The docs for MTLCompileOptions say that Metal uses the most
117+
// recent language version if it is not specified, but this is
118+
// not always true: it is possible for the environment to be set
119+
// up in a way where an older version is used by default. So we
120+
// explicitly set the minimum version we require.
121+
options.languageVersion = MTLLanguageVersion2_3;
117122

118123
assert_invariant(source[source.size() - 1] == '\0');
119124
// the shader string is null terminated and the length includes the null character

0 commit comments

Comments
 (0)