I am creating id<MTLTexture> object from CVPixelBufferRef the following way:
id CreateMTLTexrure(CVMetalTextureCacheRef texture_cache,
CVPixelBufferRef pixel_buffer,
MTLPixelFormat metal_pixel_format, size_t plane,
int height, int width) {
CVMetalTextureRef texture_ref;
CVReturn err = CVMetalTextureCacheCreateTextureFromImage(
kCFAllocatorDefault, texture_cache, pixel_buffer, NULL,
metal_pixel_format, width, height, plane, &texture_ref);
if (err != kCVReturnSuccess) {
// throw error
return nil;
}
id texture = CVMetalTextureGetTexture(texture_ref);
return texture;
}
When CVMetalTextureRef object should be released?
Is it safe to release it after MTLTexture is obtained?