浏览代码

release resources when pluginunload

/main
Xingwei Zhu 3 年前
当前提交
ab09a1fa
共有 6 个文件被更改,包括 30 次插入9 次删除
  1. 2
      engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm
  2. 4
      engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.h
  3. 10
      engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.mm
  4. 2
      engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm
  5. 3
      engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.h
  6. 18
      engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.mm

2
engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm


unity_uiwidgets_->SetWakeUpCallback(nullptr);
unity_uiwidgets_ = nullptr;
UnitySurfaceManager::ReleaseResource();
unity_interfaces_ = nullptr;
}

4
engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.h


//openGL contexts pool
static std::vector<GLContextPair> gl_context_pool_;
static void ReleaseResource();
void* CreateRenderTexture(size_t width, size_t height);

uint32_t GetFbo();
private:
GLContextPair GetFreeOpenGLContext();
static GLContextPair GetFreeOpenGLContext();
void RecycleOpenGLContext(EAGLContext* gl, EAGLContext* gl_resource);
//pixel buffer handles
CVPixelBufferRef pixelbuffer_ref = nullptr;

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


{
EAGLContext* gl = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
EAGLContext* gl_resource = [[EAGLContext alloc] initWithAPI:[gl API] sharegroup: [gl sharegroup]];
gl_context_pool_.push_back(GLContextPair(gl, gl_resource));
return GLContextPair(gl, gl_resource);
}
auto context_pair = gl_context_pool_.back();
gl_context_pool_.pop_back();

ClearCurrentContext();
gl_context_pool_.push_back(GLContextPair(gl, gl_resource));
}
void UnitySurfaceManager::ReleaseResource()
{
while(gl_context_pool_.size() > 0)
{
gl_context_pool_.pop_back();
}
}
UnitySurfaceManager::UnitySurfaceManager(IUnityInterfaces* unity_interfaces)

2
engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm


unity_uiwidgets_->SetWakeUpCallback(nullptr);
unity_uiwidgets_ = nullptr;
UnitySurfaceManager::ReleaseResource();
unity_interfaces_ = nullptr;
}

3
engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.h


//openGL contexts pool
static std::vector<GLContextPair> gl_context_pool_;
static void ReleaseResource();
void* CreateRenderTexture(size_t width, size_t height);

uint32_t GetFbo();
private:
GLContextPair GetFreeOpenGLContext();
static GLContextPair GetFreeOpenGLContext();
void RecycleOpenGLContext(NSOpenGLContext* gl, NSOpenGLContext* gl_resource);
//pixel buffer handles
CVPixelBufferRef pixelbuffer_ref = nullptr;

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


gl_resource = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:gl];
if (gl_resource == nil) {
CGLReleaseContext(gl.CGLContextObj);
CGLReleaseContext([gl CGLContextObj]);
gl_context_pool_.push_back(GLContextPair(gl, gl_resource));
return GLContextPair(gl, gl_resource);
}
auto context_pair = gl_context_pool_.back();

ClearCurrentContext();
gl_context_pool_.push_back(GLContextPair(gl, gl_resource));
}
void UnitySurfaceManager::ReleaseResource()
{
while(gl_context_pool_.size() > 0)
{
auto context_pair = gl_context_pool_.back();
CGLReleaseContext([context_pair.gl_context_ CGLContextObj]);
CGLReleaseContext([context_pair.gl_resource_context_ CGLContextObj]);
gl_context_pool_.pop_back();
}
}
UnitySurfaceManager::UnitySurfaceManager(IUnityInterfaces* unity_interfaces)

正在加载...
取消
保存