Skip to content

Commit

Permalink
perf: release internal RT when disable bloom
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxudong committed Jul 9, 2024
1 parent 75c7013 commit c3c499b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/core/src/postProcess/effects/BloomEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class BloomEffect {
this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
} else {
this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
this._releaseRenderTargets();
}
}
}
Expand Down Expand Up @@ -387,6 +388,28 @@ export class BloomEffect {

shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
}

private _releaseRenderTargets(): void {
const length = this._mipDownRT.length;

for (let i = 0; i < length; i++) {
const downRT = this._mipDownRT[i];
const upRT = this._mipUpRT[i];

if (downRT) {
downRT.getColorTexture(0).destroy(true);
downRT.destroy(true);
}

if (upRT) {
upRT.getColorTexture(0).destroy(true);
upRT.destroy(true);
}
}

this._mipDownRT.length = 0;
this._mipUpRT.length = 0;
}
}

Shader.create(BloomEffect.SHADER_NAME, [
Expand Down

0 comments on commit c3c499b

Please sign in to comment.