33 const auto found = _libraries.find(device);
34 if (found != _libraries.end()) {
38 if (_sourceCode.empty()) {
39 spdlog::error(
"MetalShader source is empty. Source-less metallib fallback was removed.");
43 auto* compileOptions = MTL::CompileOptions::alloc()->init();
44 compileOptions->setFastMathEnabled(
true);
45 MTL::Library* library = device->newLibrary(NS::String::string(_sourceCode.c_str(), NS::UTF8StringEncoding),
46 compileOptions, error);
47 compileOptions->release();
50 _libraries[device] = library;
52 const auto errorStr = (error && *error)
53 ? (*error)->localizedDescription()->utf8String()
55 spdlog::error(
"Metal shader compilation failed (VS={}, FS={}): {}",