Skip to content

Commit

Permalink
Performance optimize buffer parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Feb 24, 2016
1 parent 6d45a0c commit 17a653d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions js/data/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Buffer.prototype._createPushMethod = function() {

body += 'var i = this.length++;\n';
body += 'var o = i * ' + this.itemSize + ';\n';
body += 'if (o + ' + this.itemSize + ' > this.capacity) { this._resize(this.capacity * 1.5); }\n';
body += 'if (o + ' + this.itemSize + ' > this.capacity) { this._resize(this.capacity * ' + Buffer.CAPACITY_RESIZE_MULTIPLE + '); }\n';

for (var i = 0; i < this.attributes.length; i++) {
var attribute = this.attributes[i];
Expand Down Expand Up @@ -269,7 +269,14 @@ Buffer.ELEMENT_ATTRIBUTE_TYPE = Buffer.AttributeType.UNSIGNED_SHORT;
* @private
* @readonly
*/
Buffer.CAPACITY_DEFAULT = 8192;
Buffer.CAPACITY_DEFAULT = 1024;

/**
* @property {number}
* @private
* @readonly
*/
Buffer.CAPACITY_RESIZE_MULTIPLE = 5;

/**
* WebGL performs best if buffer sizes are aligned to 2 byte boundaries.
Expand Down
2 changes: 1 addition & 1 deletion test/js/data/buffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('Buffer', function(t) {
var buffer = create();

t.equal(buffer.type, Buffer.BufferType.VERTEX);
t.equal(buffer.capacity, 8192);
t.equal(buffer.capacity, 1024);
t.equal(buffer.length, 0);
t.equal(buffer.itemSize, 8);
t.ok(buffer.arrayBuffer);
Expand Down

0 comments on commit 17a653d

Please sign in to comment.