Stop leaking VAOs
This commit is contained in:
parent
70201bb29c
commit
03b4ec2cc6
|
@ -385,12 +385,15 @@ class ThreeDRenderer extends Renderer {
|
||||||
|
|
||||||
private cubeVertexPositionBuffer: WebGLBuffer;
|
private cubeVertexPositionBuffer: WebGLBuffer;
|
||||||
private cubeIndexBuffer: WebGLBuffer;
|
private cubeIndexBuffer: WebGLBuffer;
|
||||||
|
|
||||||
private glyphPositionsBuffer: WebGLBuffer;
|
private glyphPositionsBuffer: WebGLBuffer;
|
||||||
private glyphPositions: number[];
|
private glyphPositions: number[];
|
||||||
private glyphPositionRanges: Range[];
|
private glyphPositionRanges: Range[];
|
||||||
private glyphTexCoords: glmatrix.vec4[];
|
private glyphTexCoords: glmatrix.vec4[];
|
||||||
private glyphSizes: glmatrix.vec2[];
|
private glyphSizes: glmatrix.vec2[];
|
||||||
|
|
||||||
|
private distantGlyphVAO: WebGLVertexArrayObjectOES | null;
|
||||||
|
|
||||||
constructor(renderContext: ThreeDView) {
|
constructor(renderContext: ThreeDView) {
|
||||||
super(renderContext);
|
super(renderContext);
|
||||||
|
|
||||||
|
@ -616,8 +619,9 @@ class ThreeDRenderer extends Renderer {
|
||||||
const gl = this.renderContext.gl;
|
const gl = this.renderContext.gl;
|
||||||
|
|
||||||
// Prepare the distant glyph VAO.
|
// Prepare the distant glyph VAO.
|
||||||
const vao = this.renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
if (this.distantGlyphVAO == null)
|
||||||
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(vao);
|
this.distantGlyphVAO = this.renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
||||||
|
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.distantGlyphVAO);
|
||||||
const distantGlyphProgram = this.renderContext.shaderPrograms.demo3DDistantGlyph;
|
const distantGlyphProgram = this.renderContext.shaderPrograms.demo3DDistantGlyph;
|
||||||
gl.useProgram(distantGlyphProgram.program);
|
gl.useProgram(distantGlyphProgram.program);
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderContext.quadPositionsBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderContext.quadPositionsBuffer);
|
||||||
|
@ -733,7 +737,6 @@ class ThreeDRenderer extends Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderContext.vertexArrayObjectExt.deleteVertexArrayOES(vao);
|
|
||||||
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(null);
|
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,9 @@ export abstract class Renderer {
|
||||||
protected abstract get usedSizeFactor(): glmatrix.vec2;
|
protected abstract get usedSizeFactor(): glmatrix.vec2;
|
||||||
protected abstract get worldTransform(): glmatrix.mat4;
|
protected abstract get worldTransform(): glmatrix.mat4;
|
||||||
|
|
||||||
|
private implicitCoverInteriorVAO: WebGLVertexArrayObjectOES | null;
|
||||||
|
private implicitCoverCurveVAO: WebGLVertexArrayObjectOES | null;
|
||||||
|
|
||||||
private instancedPathIDVBO: WebGLBuffer | null;
|
private instancedPathIDVBO: WebGLBuffer | null;
|
||||||
private timerQueryPollInterval: number | null;
|
private timerQueryPollInterval: number | null;
|
||||||
|
|
||||||
|
@ -282,13 +285,13 @@ export abstract class Renderer {
|
||||||
renderContext.gl.disable(renderContext.gl.BLEND);
|
renderContext.gl.disable(renderContext.gl.BLEND);
|
||||||
|
|
||||||
// Set up the implicit cover interior VAO.
|
// Set up the implicit cover interior VAO.
|
||||||
//
|
|
||||||
// TODO(pcwalton): Cache these.
|
|
||||||
const directInteriorProgram =
|
const directInteriorProgram =
|
||||||
renderContext.shaderPrograms[this.directInteriorProgramName];
|
renderContext.shaderPrograms[this.directInteriorProgramName];
|
||||||
const implicitCoverInteriorVAO = renderContext.vertexArrayObjectExt
|
if (this.implicitCoverInteriorVAO == null) {
|
||||||
|
this.implicitCoverInteriorVAO = renderContext.vertexArrayObjectExt
|
||||||
.createVertexArrayOES();
|
.createVertexArrayOES();
|
||||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(implicitCoverInteriorVAO);
|
}
|
||||||
|
renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.implicitCoverInteriorVAO);
|
||||||
this.initImplicitCoverInteriorVAO(objectIndex, instanceRange);
|
this.initImplicitCoverInteriorVAO(objectIndex, instanceRange);
|
||||||
|
|
||||||
// Draw direct interior parts.
|
// Draw direct interior parts.
|
||||||
|
@ -331,8 +334,11 @@ export abstract class Renderer {
|
||||||
//
|
//
|
||||||
// TODO(pcwalton): Cache these.
|
// TODO(pcwalton): Cache these.
|
||||||
const directCurveProgram = renderContext.shaderPrograms[this.directCurveProgramName];
|
const directCurveProgram = renderContext.shaderPrograms[this.directCurveProgramName];
|
||||||
const implicitCoverCurveVAO = renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
if (this.implicitCoverCurveVAO == null) {
|
||||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(implicitCoverCurveVAO);
|
this.implicitCoverCurveVAO = renderContext.vertexArrayObjectExt
|
||||||
|
.createVertexArrayOES();
|
||||||
|
}
|
||||||
|
renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.implicitCoverCurveVAO);
|
||||||
this.initImplicitCoverCurveVAO(objectIndex, instanceRange);
|
this.initImplicitCoverCurveVAO(objectIndex, instanceRange);
|
||||||
|
|
||||||
// Draw direct curve parts.
|
// Draw direct curve parts.
|
||||||
|
|
Loading…
Reference in New Issue