From 8ea3854d94eb1ff213be716a38493d601784810b Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:08:38 +0200 Subject: 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 --- source/compiler-core/slang-metal-compiler.cpp | 28 ++++++++++++++++++++++++--- source/slang/slang-reflection-api.cpp | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'source') 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 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 compiler = ComPtr( - 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; } -- cgit v1.2.3