Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/rendering/cubismoffscreenrendertarget_webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ export class CubismOffscreenRenderTarget_WebGL extends CubismRenderTarget_WebGL
}

public release(): void {
const borrowedFromManager = this._webGLOffscreenManager != null;

if (
this._webGLOffscreenManager != null &&
borrowedFromManager &&
this._gl != null &&
this._renderTexture != null
) {
Expand All @@ -215,13 +217,17 @@ export class CubismOffscreenRenderTarget_WebGL extends CubismRenderTarget_WebGL
);
}

if (this._colorBuffer && this._gl) {
this._gl.deleteTexture(this._colorBuffer);
if (borrowedFromManager) {
// Color buffer and framebuffer are borrowed from CubismWebGLOffscreenManager.
// The manager owns GPU lifetime (releaseStaleRenderTextures / context teardown).
// Deleting them here double-frees the pool slot and can delete previousFramebuffer
// when setOffscreenRenderTarget stored it as a fallback.
this._colorBuffer = null;
}
if (this._renderTexture && this._gl) {
this._gl.deleteFramebuffer(this._renderTexture);
this._renderTexture = null;
} else if (this._gl) {
// Inherited createRenderTarget() locally owns the texture/FBO
// (_modelRenderTargets). destroyRenderTarget() is the matching owner.
this.destroyRenderTarget();
}

if (this._webGLOffscreenManager != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/rendering/cubismrenderer_webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ export class CubismRenderer_WebGL extends CubismRenderer {

for (let i = 0; i < this._offscreenList.length; i++) {
if (this._offscreenList[i] != null && this._offscreenList[i].isValid()) {
this._offscreenList[i].destroyRenderTarget();
// プールから借用した GPU オブジェクトは destroy しない
this._offscreenList[i].release();
}
}
this._offscreenList.length = 0;
Expand Down