Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CVOpenGLESTextureCache&;CVMetalTextureCache的正确用法_Ios_Opengl Es_Avfoundation_Core Video_Cvpixelbuffer - Fatal编程技术网

Ios CVOpenGLESTextureCache&;CVMetalTextureCache的正确用法

Ios CVOpenGLESTextureCache&;CVMetalTextureCache的正确用法,ios,opengl-es,avfoundation,core-video,cvpixelbuffer,Ios,Opengl Es,Avfoundation,Core Video,Cvpixelbuffer,关于CVOpenGLESTextureCache和CVMetalTextureCache的可用文档很少,更具体地说,关于它们的正确用法。为了将CVPixelBuffer映射到OpenGLES纹理,我们创建纹理缓存,如下所示: let err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nil, oglContext as CVEAGLContext, nil, &textureCache) if err !=

关于CVOpenGLESTextureCache和CVMetalTextureCache的可用文档很少,更具体地说,关于它们的正确用法。为了将CVPixelBuffer映射到OpenGLES纹理,我们创建纹理缓存,如下所示:

 let err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nil, oglContext as CVEAGLContext, nil, &textureCache)
        if err != 0 {
            NSLog("Error at CVOpenGLESTextureCacheCreate %d", err)
            success = false
            break bail
        }
然后我们使用CVOpenGLESTextureCacheCreateTextureFromImage(…)API从CVPixelBuffer创建OpenGLES纹理

金属流完全相同,首先创建CVMetalTextureCache

  if CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, device!, nil, &metalTextureCache) == kCVReturnSuccess {

  }
然后使用CVMetalTextureCacheCheCreateTextureFromImage(…)API从CVPixelBuffer创建金属纹理

我的问题是:

  • 我们可以创建多少个CVOpenGLESTextureCache/CVMetalTextureCache对象?在代码中使用多个纹理缓存对象是否存在隐藏的性能损失?我看到一些代码创建一个全局纹理缓存,一些代码创建多个纹理缓存对象

  • OpenGLES代码使用EAGLContext创建纹理缓存,这意味着我们不能在多个线程上重用相同的CVOpenGLESTextureCache。然而,我们似乎只有一个CVMetalTextureCache,可以跨所有线程重用。真的是这样吗

  • 我从IOSurface备份的相机中获取CVPixelBuffer对象。我正在用不同的方法多次为同一个CVPixelBuffer重新创建OpenGLES/Metal纹理,可能使用不同的纹理缓存对象,也可能在不同的线程上。从性能和内存管理的角度来看,这是正确的做法吗?或者我应该一次性创建OpenGLES/金属纹理对象,并将纹理提供给多种方法吗


  • 1。我认为你可以用“纹理”替换“纹理缓存”的所有实例,所以在你的应用程序中使用尽可能多的纹理。将具有类似使用模式的图像分组/映射到一个大纹理中可能会有性能优势。测量一下。也就是说,我曾经创建了数百个GLE纹理缓存纹理,得到的结果比预期的要慢,但那是几年前的事了,所以。。。测量它。我们如何准确地测量它,因为有这么多线程和渲染路径同时执行,视频帧不断出现?@DeepakSharma你对此有更好的理解吗?有什么线索或材料可以帮助你吗?我还试图了解更多关于CVMetalTextureCache和其他核心视频类和函数的工作原理,如CVPixelBufferPool等@Rohansap,但并不完全如此。我在上面贴了更多的问题,但它仍然是个谜