首页 > 解决方案 > 如何在 macOS 上使用 MTLTexture 和 MTLStorageModeShared 在 kCVPixelFormatType_422YpCbCr8 中渲染 CVPixelBuffer

问题描述

我不知道如何使用 MTLStorageModeShared 加速 CIImage 渲染到 drawable.texture:

目前的程序是(大约):

[ciContext startTaskToRender: ciImage toDestination: renderDestination error: &error];

这是代码中最慢的部分(大约每秒需要“更多”时间来渲染)。在带有集成 GPU 的 Mac 上运行时,它会在关键时间间隔下呈现。我猜这是因为在集成显卡上使用了共享内存 GPU 和 CPU。我的想法是使用 MTLStorageModeShared 创建 MTLTexture,然后将 kCVPixelFormatType_422YpCbCr8 pixelFormat 中的 cvBuffer 复制到纹理,使用着色器将 kCVPixelFormatType_422YpCbCr8 转换为 MTLPixelFormatRG8Unorm 纹理并blit 到目标纹理。

我的问题:

谢谢你。

标签: avfoundationmetalciimagecore-videocvpixelbuffer

解决方案


推荐阅读