mirror of
https://github.com/galacean/engine.git
synced 2026-06-21 19:02:50 +08:00
Merge pull request #2410 from GuoLei1990/fix/shader-destroy
Fix shader destroy memory residual
This commit is contained in:
@@ -491,7 +491,7 @@ export class Engine extends EventDispatcher {
|
||||
if (length > shaderProgramPools.length) {
|
||||
shaderProgramPools.length = length;
|
||||
}
|
||||
shaderProgramPools[index] = pool = new ShaderProgramPool();
|
||||
shaderProgramPools[index] = pool = new ShaderProgramPool(this);
|
||||
shaderPass._shaderProgramPools.push(pool);
|
||||
}
|
||||
return pool;
|
||||
|
||||
@@ -146,8 +146,11 @@ export class ShaderPass extends ShaderPart {
|
||||
_destroy(): void {
|
||||
const shaderProgramPools = this._shaderProgramPools;
|
||||
for (let i = 0, n = shaderProgramPools.length; i < n; i++) {
|
||||
shaderProgramPools[i]._destroy();
|
||||
const shaderProgramPool = shaderProgramPools[i];
|
||||
shaderProgramPool._destroy();
|
||||
delete shaderProgramPool.engine._shaderProgramPools[this._shaderPassId];
|
||||
}
|
||||
// Clear array storing multiple engine shader program pools
|
||||
shaderProgramPools.length = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Engine } from "../Engine";
|
||||
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
||||
import { ShaderProgram } from "./ShaderProgram";
|
||||
|
||||
@@ -11,6 +12,8 @@ export class ShaderProgramPool {
|
||||
private _lastQueryMap: Record<number, ShaderProgram>;
|
||||
private _lastQueryKey: number;
|
||||
|
||||
constructor(public engine: Engine) {}
|
||||
|
||||
/**
|
||||
* Get shader program by macro collection.
|
||||
* @param macros - macro collection
|
||||
|
||||
Reference in New Issue
Block a user