summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorskallweitNV <64953474+skallweitNV@users.noreply.github.com>2024-06-06 18:08:38 +0200
committerGitHub <noreply@github.com>2024-06-06 09:08:38 -0700
commit8ea3854d94eb1ff213be716a38493d601784810b (patch)
tree071be96574be4afa54afe0a1fe0d66f10eb2cd80 /source/compiler-core
parent40d48bf1742cf21cc1ad3dd00d11fb04f37e512f (diff)
work on gfx metal backend (#4287)
* implement sampler state * implement input layout * implement fence object * buffer implementation * texture implementation * cleanup * add adapter enumeration * supported formats and allocation info * work on device and implement readBufferResource * skeleton for transient resource heap * initial work on command queue / buffers / encoders * fix uploading initial buffer data * implement buffer resource view * string utility functions * wip query pool implementation * cleanup * swapchain * wip * remove plain buffer view * extend gfxGetDeviceTypeName with metal * basic support for resource binding with compute shaders * needed for metal bindings * replace assert(0) with SLANG_UNIMPLEMENTED_X
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-metal-compiler.cpp28
1 files changed, 25 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;
}