Metal入门概念

Metal

Metal是ios系统的渲染/异构计算的框架
和OpenGL一样具有利用GPU加速渲染的功能 并且能和OpenCL一样利用GPU做异构计算

Metal的优势就在于整合了渲染和异构计算 在一个统一的框架上提供多种需求
Android上可能需要OpenGL+OpenCL来实现的功能 IOS只需要Metal就可以做到

Metal的使用也比OpenCL要便捷一些 在工程中创建的metal代码
都会被xcode整合到默认的metal库打包到app中 和android的res有异曲同工之妙
对比下OpenCL需要通过API引入cl代码就不那么便捷

Metal参考链接


 1. apple metal文档 https://developer.apple.com/library/content/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Introduction/Introduction.html
 2. apple sample code
https://developer.apple.com/library/content/samplecode/AVCamPhotoFilter/Introduction/Intro.html

Metal使用避坑

Metal使用中遇到的问题:

 1. metal的kennel代码执行中不可以在xcode中直接结束运行 否则app将卡死
    这应该是由于metal的机制导致的。 
    metal的kernel代码执行时 app会在线程中阻塞等待Metal kernel代码完成
    文档中也提到metal代码不允许后台执行 只能在主线程中完成。
 2. 

你可能感兴趣的:(Metal)