I'm trying to figure out how the ownership works with the function CVMetalTextureGetTexture
:
CVMetalTextureRef textureRef;
// ... textureRef is created
id<MTLTexture> texture = CVMetalTextureGetTexture(_textureRef);
CVBufferRelease(textureRef); // Releasing the existing texture
// Is texture still valid here?
Is texture
still valid after releasing textureRef
? If not, can I somehow transfer ownership from textureRef
to texture
(ARC), so I don't have to call CVBufferRelease
later when texture
is released?
The same question for swift:
var texture: MTLTexture
do {
var textureRef: CVMetalTexture
// ... textureRef is created
texture = CVMetalTextureGetTexture(textureRef)!
// end of scope, textureRef is released
}
// Is texture still valid here?
MetalCameraSession.swift
of this GitHub Reporsitory. – Diversification