简体   繁体   English

从另一个项目访问自定义 Metal 库

[英]Accessing a custom Metal library from another project

I am looking to create my own Metal library target in Xcode.我希望在 Xcode 中创建自己的金属库目标。 The makeLibrary(filepath:) described here requires a file with the.metallib extension. 这里描述的makeLibrary(filepath:)需要一个扩展名为 .metallib 的文件。 Do I have to create the.metallib file manually using each of the metal files in the Metal library target as described here and load it at runtime?我是否必须按照此处所述使用 Metal 库目标中的每个金属文件手动创建 .metallib 文件并在运行时加载它? Or can I embed it somehow in my app to allow the shaders to be compiled at compile time?或者我可以以某种方式将它嵌入到我的应用程序中以允许在编译时编译着色器? The first strategy seems inefficient, and there must be some use for the target.第一种策略似乎效率低下,目标肯定有一些用处。

I did not find a better way to tell Xcode to embed the metallib into my other target (in my case a framework), so I set up a custom build phase in my framework target to copy the library like this:我没有找到更好的方法来告诉 Xcode 将metallib嵌入到我的另一个目标(在我的情况下是一个框架)中,所以我在我的框架目标中设置了一个自定义构建阶段来复制库,如下所示:

在此处输入图像描述

I also added the Metal library target as a dependency to my framework target to ensure that it's always built first.我还添加了 Metal 库目标作为我的框架目标的依赖项,以确保它总是首先构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM