mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Destroy location wrappers when they're unused.
This commit is contained in:
parent
e920b1a961
commit
b9deef7e61
4 changed files with 59 additions and 4 deletions
|
@ -12,6 +12,7 @@ var Extend = require('../../utils/object/Extend');
|
|||
var SetValue = require('../../utils/object/SetValue');
|
||||
var ShaderRender = require('./ShaderRender');
|
||||
var TransformMatrix = require('../components/TransformMatrix');
|
||||
var ArrayEach = require('../../utils/array/Each');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
|
@ -1218,6 +1219,12 @@ var Shader = new Class({
|
|||
this.glTexture = null;
|
||||
this.texture = null;
|
||||
}
|
||||
|
||||
ArrayEach(this.uniforms, function (uniform)
|
||||
{
|
||||
renderer.deleteUniformLocation(uniform.uniformLocation);
|
||||
uniform.uniformLocation = null;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -2279,6 +2279,42 @@ var WebGLRenderer = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a WebGLAttribLocation from the GL instance.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.WebGLRenderer#deleteAttribLocation
|
||||
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper} attrib - The attrib location to be deleted.
|
||||
* @since 3.80.0
|
||||
*/
|
||||
deleteAttribLocation: function (attrib)
|
||||
{
|
||||
if (attrib)
|
||||
{
|
||||
ArrayRemove(this.glAttribLocationWrappers, attrib);
|
||||
attrib.destroy();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a WebGLUniformLocation from the GL instance.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.WebGLRenderer#deleteUniformLocation
|
||||
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper} uniform - The uniform location to be deleted.
|
||||
* @since 3.80.0
|
||||
*/
|
||||
deleteUniformLocation: function (uniform)
|
||||
{
|
||||
if (uniform)
|
||||
{
|
||||
ArrayRemove(this.glUniformLocationWrappers, uniform);
|
||||
uniform.destroy();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a WebGLBuffer from the GL instance.
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
var Class = require('../../utils/Class');
|
||||
var ArrayEach = require('../../utils/array/Each');
|
||||
var GetFastValue = require('../../utils/object/GetFastValue');
|
||||
var WEBGL_CONST = require('./const');
|
||||
|
||||
|
@ -1167,14 +1168,25 @@ var WebGLShader = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.renderer.deleteProgram(this.program);
|
||||
var renderer = this.renderer;
|
||||
ArrayEach(this.uniforms, function (uniform)
|
||||
{
|
||||
renderer.deleteUniformLocation(uniform.location);
|
||||
});
|
||||
this.uniforms = null;
|
||||
|
||||
ArrayEach(this.attributes, function (attrib)
|
||||
{
|
||||
renderer.deleteAttribLocation(attrib.location);
|
||||
});
|
||||
this.attributes = null;
|
||||
|
||||
renderer.deleteProgram(this.program);
|
||||
|
||||
this.pipeline = null;
|
||||
this.renderer = null;
|
||||
this.gl = null;
|
||||
this.program = null;
|
||||
this.attributes = null;
|
||||
this.uniforms = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
* @property {number} offset - The offset, in bytes, of this attribute data in the vertex array. Equivalent to `offsetof(vertex, attrib)` in C.
|
||||
* @property {boolean} normalized - Should the attribute data be normalized?
|
||||
* @property {boolean} enabled - You should set this to `false` by default. The pipeline will enable it on boot.
|
||||
* @property {number} location - You should set this to `-1` by default. The pipeline will set it on boot.
|
||||
* @property {(-1|Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper)} location - You should set this to `-1` by default. The pipeline will set it on boot.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue