Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@noppefoxwolf

Cocoapodsでmetalファイルを含めて配布する方法と、CoreImageで使う方法

More than 1 year has passed since last update.

cocoapodsでMetalファイルを含めて配布する場合は、podspecにmetalファイルを追加します。

LibraryName.podspec
s.source_files = 'LibraryName/Classes/**/*.{swift,metal}'

また、CoreImageのCIKernelとして呼ぶ場合は次のような設定を追加します。

LibraryName.podspec
s.pod_target_xcconfig = {
  'MTLLINKER_FLAGS' => '-cikernel',
  'MTL_COMPILER_FLAGS' => '-fcikernel'
}

これでMetalファイルに含まれる関数がCoreImage用としてコンパイルされます。

CIKernelをライブラリ内で生成するには、自身のバンドルを指定します。

private final class BundleToken {}

let url = Bundle(for: BundleToken.self).url(forResource: "default", withExtension: "metallib")!
let data = try! Data(contentsOf: url)
let kernel = try! CIColorKernel(functionName: "filterName", fromMetalLibraryData: data)
0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
noppefoxwolf
きつねすき、にんげんこわい

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?