objective-c – CVMetalTextureGetTexture ownerhsip?

objective-c – CVMetalTextureGetTexture ownerhsip?,第1张

概述我试图弄清楚所有权如何与函数CVMetalTextureGetTexture一起使用: CVMetalTextureRef textureRef;// ... textureRef is createdid<MTLTexture> texture = CVMetalTextureGetTexture(_textureRef);CVBufferRelease(textureRef); // R 我试图弄清楚所有权如何与函数CVMetalTextureGetTexture一起使用:

CVMetalTextureRef textureRef;// ... textureRef is createdID<MTLTexture> texture = CVMetalTextureGetTexture(_textureRef);CVBufferRelease(textureRef); // Releasing the existing texture// Is texture still valID here?

释放textureRef后纹理是否仍然有效?如果没有,我可以以某种方式将所有权从textureRef转移到纹理(ARC),所以我不必在以后释放纹理时调用CVBufferRelease吗?

swift的同样问题:

var texture: MTLTexturedo {  var textureRef: CVMetalTexture  // ... textureRef is created  texture = CVMetalTextureGetTexture(textureRef)!  // end of scope,textureRef is released}// Is texture still valID here?
解决方法 在我看到你的问题之前,我们还做了另一个实验:

在循环中,从CVPixelBuffer创建的CVMetalTextureRef来自Camera.

static voID *texturePtr;  /** AVCaptureVIDeoDataOutputSampleBufferDelegate,as a loop */{CVMetalTextureRef textureRef;// ... textureRef is createdID<MTLTexture> texture = CVMetalTextureGetTexture(_textureRef);CVBufferRelease(textureRef); // Releasing the existing texturetexturePtr= (__brIDge_retained voID*)texture;// no releasing the texturePtr// (__brIDge_transfer ID<MTLTexture>)texturePtr;}

我发现我没有释放texturePtr,但仍然没有发生内存泄漏.更重要的是,texturePtr在某个时候和我们用新的var替换之前是有效的.所以我想也许这与你的问题有关.我的回答更像是一个不是答案的争论.

总结

以上是内存溢出为你收集整理的objective-c – CVMetalTextureGetTexture ownerhsip?全部内容,希望文章能够帮你解决objective-c – CVMetalTextureGetTexture ownerhsip?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1229018.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存