Changed batch limits. Currently running 20,000 pixels in 1 draw call.

This commit is contained in:
Richard Davey 2016-10-30 23:59:47 +00:00
parent c4a79bfadc
commit c27b2f9fca
2 changed files with 18 additions and 14 deletions

View file

@ -6,23 +6,27 @@ Phaser.Renderer.WebGL.GameObjects.PixelField = {
render: function (renderer, src)
{
var pixel;
var verts = src.transform.glVertextData;
for (var i = 0; i < src.list.length; i++)
{
var pixel = src.list[i];
pixel = src.list[i];
renderer.batch.addPixel(
verts.x0 + pixel.x,
verts.y0 + pixel.y,
verts.x1 + pixel.x,
verts.y1 + pixel.y,
verts.x2 + pixel.x,
verts.y2 + pixel.y,
verts.x3 + pixel.x,
verts.y3 + pixel.y,
pixel.color
);
if (pixel.a > 0)
{
renderer.batch.addPixel(
verts.x0 + pixel.x,
verts.y0 + pixel.y,
verts.x1 + pixel.x,
verts.y1 + pixel.y,
verts.x2 + pixel.x,
verts.y2 + pixel.y,
verts.x3 + pixel.x,
verts.y3 + pixel.y,
pixel.color
);
}
}
}

View file

@ -18,11 +18,11 @@ Phaser.Renderer.WebGL.Batch.Pixel = function (manager, batchSize)
// Position (vec2) = 4 * 2 = 8 bytes
// Color (float) = 4 bytes
//
// Total: 12 bytes (per vert) * 4 (4 verts per quad) (= 48 bytes) * maxSize (usually 2000) = 96 kilobytes sent to the GPU every frame
// Total: 12 bytes (per vert) * 4 (4 verts per quad) (= 48 bytes) = 96 kilobytes per 2000 pixels sent to the GPU every frame
var vertSize = (4 * 2) + (4);
Phaser.Renderer.WebGL.Batch.call(this, manager, batchSize * 2, vertSize);
Phaser.Renderer.WebGL.Batch.call(this, manager, batchSize * 10, vertSize);
// View on the vertices as a Float32Array
this.positions = new Float32Array(this.vertices);