Skip to content

Commit 48c0ba2

Browse files
committed
Better flush handling
1 parent c5b538a commit 48c0ba2

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ var WebGLPipeline = new Class({
688688
* @method Phaser.Renderer.WebGL.WebGLPipeline#bind
689689
* @since 3.0.0
690690
*
691-
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
691+
* @param {boolean} [reset=false] - Should the vertex attribute pointers be fully reset?
692692
* @param {number} [shader=0] - If this is a multi-shader pipeline, which shader should be bound?
693693
*
694694
* @return {this} This WebGLPipeline instance.
@@ -702,11 +702,9 @@ var WebGLPipeline = new Class({
702702
this.setShader(shader);
703703
}
704704

705-
this.currentShader.bind(false);
706-
707705
this.renderer.setVertexBuffer(this.vertexBuffer);
708706

709-
this.currentShader.setAttribPointers(reset);
707+
this.currentShader.bind(reset);
710708

711709
return this;
712710
},
@@ -805,18 +803,23 @@ var WebGLPipeline = new Class({
805803
{
806804
var gl = this.gl;
807805
var vertexCount = this.vertexCount;
808-
var topology = this.topology;
809806
var vertexSize = this.currentShader.vertexSize;
810807

811-
if (vertexCount === 0)
808+
if (vertexCount > 0)
812809
{
813-
return;
814-
}
810+
if (vertexCount === this.vertexCapacity)
811+
{
812+
gl.bufferData(gl.ARRAY_BUFFER, this.vertexData, gl.DYNAMIC_DRAW);
813+
}
814+
else
815+
{
816+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize));
817+
}
815818

816-
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize));
817-
gl.drawArrays(topology, 0, vertexCount);
819+
gl.drawArrays(this.topology, 0, vertexCount);
818820

819-
this.vertexCount = 0;
821+
this.vertexCount = 0;
822+
}
820823

821824
return this;
822825
},
@@ -993,8 +996,6 @@ var WebGLPipeline = new Class({
993996

994997
var vertexOffset = (this.vertexCount * this.currentShader.vertexComponentCount) - 1;
995998

996-
// tintEffect = 1;
997-
998999
vertexViewF32[++vertexOffset] = x0;
9991000
vertexViewF32[++vertexOffset] = y0;
10001001
vertexViewF32[++vertexOffset] = u0;

0 commit comments

Comments
 (0)