浏览代码

fix occasional crash on mac editor (apply the fix to ios too)

/siyaoH-1.17-PlatformMessage
Xingwei Zhu 4 年前
当前提交
f988e819
共有 2 个文件被更改,包括 28 次插入35 次删除
  1. 31
      engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.mm
  2. 32
      engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.mm

31
engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.mm


bool UnitySurfaceManager::ReleaseNativeRenderTexture()
{
//release gl resources
CFRelease(gl_tex_ref_);
CFRelease(gl_tex_cache_ref_);
//release metal resources
CFRelease(metal_tex_ref_);
CFRelease(metal_tex_cache_ref_);
//release cv pixelbuffer
CVPixelBufferRelease(pixelbuffer_ref);
FML_DCHECK(gl_tex_ != 0);
glDeleteTextures(1, &gl_tex_);
//gl_tex_ is released in CVOpenGLTextureRelease
CFRelease(gl_tex_cache_ref_);
CFRelease(gl_tex_ref_);
//release metal resources
metal_tex_ref_ = nullptr;
metal_tex_cache_ref_ = nullptr;
CFRelease(metal_tex_ref_);
metal_tex_ref_ = nullptr;
CFRelease(metal_tex_cache_ref_);
metal_tex_cache_ref_ = nullptr;
//release cv pixelbuffer
CVPixelBufferRelease(pixelbuffer_ref);
return true;
}
} // namespace uiwidgets

32
engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.mm


bool UnitySurfaceManager::ReleaseNativeRenderTexture()
{
//release gl resources
CVOpenGLTextureRelease(gl_tex_ref_);
CVOpenGLTextureCacheRelease(gl_tex_cache_ref_);
//release metal resources
CFRelease(metal_tex_ref_);
CFRelease(metal_tex_cache_ref_);
//release pixel buffer
CVPixelBufferRelease(pixelbuffer_ref);
FML_DCHECK(gl_tex_ != 0);
//gl_tex_ will be released in CVOpenGLTextureRelease
//glDeleteTextures(1, &gl_tex_);
//gl_tex_ is released in CVOpenGLTextureRelease
CVOpenGLTextureCacheRelease(gl_tex_cache_ref_);
CVOpenGLTextureRelease(gl_tex_ref_);
//release metal resources
//since ARC is enabled by default, no need to release the texture
metal_tex_ = nullptr;
CFRelease(metal_tex_ref_);
CFRelease(metal_tex_cache_ref_);
//since ARC is enabled by default, no need to release the texture
metal_tex_ = nullptr;
//release cv pixelbuffer
CVPixelBufferRelease(pixelbuffer_ref);
return true;
}
} // namespace uiwidgets
正在加载...
取消
保存