diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-metal-compiler.cpp | 28 | ||||
| -rw-r--r-- | source/slang/slang-reflection-api.cpp | 1 |
2 files changed, 26 insertions, 3 deletions
diff --git a/source/compiler-core/slang-metal-compiler.cpp b/source/compiler-core/slang-metal-compiler.cpp index d3bf92bf3..e235db23d 100644 --- a/source/compiler-core/slang-metal-compiler.cpp +++ b/source/compiler-core/slang-metal-compiler.cpp @@ -62,11 +62,33 @@ namespace Slang static SlangResult locateMetalCompiler(const String& path, DownstreamCompilerSet* set) { ComPtr<IDownstreamCompiler> innerCppCompiler; - ExecutableLocation exeLocation(path, "metal"); - SLANG_RETURN_ON_FAIL(GCCDownstreamCompilerUtil::createCompiler(exeLocation, innerCppCompiler)); + + ExecutableLocation metalcLocation = ExecutableLocation(path, "metal");; + + String metalSDKPath = path; + +#if defined (SLANG_APPLE_FAMILY) + // Use xcrun command to find the metal compiler. + CommandLine xcrunCmdLine; + ExecutableLocation xcrunLocation("xcrun"); + xcrunCmdLine.setExecutableLocation(xcrunLocation); + xcrunCmdLine.addArg("--sdk"); + xcrunCmdLine.addArg("macosx"); + xcrunCmdLine.addArg("--find"); + xcrunCmdLine.addArg("metal"); + ExecuteResult exeRes; + if (SLANG_SUCCEEDED(ProcessUtil::execute(xcrunCmdLine, exeRes))) + { + String metalPath = exeRes.standardOutput.trim(); + metalcLocation = ExecutableLocation(ExecutableLocation::Type::Path, metalPath); + metalSDKPath = Path::getParentDirectory(metalcLocation.m_pathOrName); + } +#endif + + SLANG_RETURN_ON_FAIL(GCCDownstreamCompilerUtil::createCompiler(metalcLocation, innerCppCompiler)); ComPtr<IDownstreamCompiler> compiler = ComPtr<IDownstreamCompiler>( - new MetalDownstreamCompiler(innerCppCompiler, path)); + new MetalDownstreamCompiler(innerCppCompiler, metalSDKPath)); set->addCompiler(compiler); return SLANG_OK; } diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index ab73ce7f4..e7f4b9bf3 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -1828,6 +1828,7 @@ namespace Slang case LayoutResourceKind::ShaderResource: case LayoutResourceKind::DescriptorTableSlot: case LayoutResourceKind::Uniform: + case LayoutResourceKind::ConstantBuffer: // for metal resInfo = info; break; } |
