简体   繁体   中英

Core Image shader language conversion to metal with simulator support

My app has a handful of Core Image shaders written in the Core Image Shader Language. I load them like CIColorKernel(source: <kernel string here>) . I just bumped the deployment target of my app from iOS 11.0 to 12.0. Now I get the following warnings.

'init(source:)' was deprecated in iOS 12.0: Core Image Kernel Language API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)

Because our app is built with treat warnings as errors I have to hide or fix this warning.

I could rewrite the shaders in the metal shader language so I can use CIColorKernel(functionName: <name>, fromMetalLibraryData: <data>) , however Metal isn't supported in the simulator. So if I do that, then we won't be able to get screenshots of all the devices we need from the simulator. I could rewrite the shaders in metal and only load the metal ones when running on the device, falling back to the current ones on the simulator. However this doesn't seem ideal as we then have 2 sets of functions to maintain. This also requires I get the deprecation warning hidden somehow.

So any suggestions of a non-deprecated way to write shaders you can run in the simulator? If not I may just try to silence the warnings until iOS 13 and hope the sim gets better support. I can't figure out how to Define CI_SILENCE_GL_DEPRECATION to silence these warnings . I've tried adding a CI_SILENCE_GL_DEPRECATION build setting.

Update Since it was end of the year I used one of our 2 DTS tickets to ask Apple how to silence it. Their response was to use #pragma GCC diagnostic ignored "-Wdeprecated-declarations” in an Objective-C file to disable all deprecated warnings, or file a bug about not being able to silence this one. :( I guess for now I'll just have to leave that framework's deployment target at iOS 11 for now, and hope I don't need to upgrade to 12 for some future feature/bug. The main app's deployment target can still be 12 though, so for now it won't effect users.

To silence the warning add to GCC_PREPROCESSOR_DEFINITIONS of your build configuration CI_SILENCE_GL_DEPRECATION CI_SILENCE_GL_DEPRECATION

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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