|
4 | 4 | *
|
5 | 5 | * GPU Accelerated JavaScript
|
6 | 6 | *
|
7 |
| - * @version 2.4.7 |
8 |
| - * @date Mon Jan 06 2020 13:35:02 GMT-0500 (Eastern Standard Time) |
| 7 | + * @version 2.4.8 |
| 8 | + * @date Wed Jan 08 2020 07:08:29 GMT-0500 (Eastern Standard Time) |
9 | 9 | *
|
10 | 10 | * @license MIT
|
11 | 11 | * The MIT License
|
@@ -4387,13 +4387,17 @@ function getToArrayString(kernelResult, textureName) {
|
4387 | 4387 | if (property === 'context') {
|
4388 | 4388 | return null;
|
4389 | 4389 | }
|
| 4390 | + if (property === '_framebuffer') { |
| 4391 | + return '_framebuffer'; |
| 4392 | + } |
4390 | 4393 | if (kernelResult.hasOwnProperty(property)) {
|
4391 | 4394 | return JSON.stringify(kernelResult[property]);
|
4392 | 4395 | }
|
4393 | 4396 | throw new Error(`unhandled thisLookup ${ property }`);
|
4394 | 4397 | }
|
4395 | 4398 | });
|
4396 | 4399 | return `() => {
|
| 4400 | + let _framebuffer; |
4397 | 4401 | ${flattenedFunctions}
|
4398 | 4402 | return toArray();
|
4399 | 4403 | }`;
|
@@ -5526,18 +5530,20 @@ class GLTextureFloat extends GLTexture {
|
5526 | 5530 | this.type = 'ArrayTexture(1)';
|
5527 | 5531 | }
|
5528 | 5532 | renderRawOutput() {
|
5529 |
| - const { context: gl } = this; |
5530 |
| - const framebuffer = gl.createFramebuffer(); |
5531 |
| - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); |
| 5533 | + const { context: gl, size } = this; |
| 5534 | + if (!this._framebuffer) { |
| 5535 | + this._framebuffer = gl.createFramebuffer(); |
| 5536 | + } |
| 5537 | + gl.bindFramebuffer(gl.FRAMEBUFFER, this._framebuffer); |
5532 | 5538 | gl.framebufferTexture2D(
|
5533 | 5539 | gl.FRAMEBUFFER,
|
5534 | 5540 | gl.COLOR_ATTACHMENT0,
|
5535 | 5541 | gl.TEXTURE_2D,
|
5536 | 5542 | this.texture,
|
5537 | 5543 | 0
|
5538 | 5544 | );
|
5539 |
| - const result = new Float32Array(this.size[0] * this.size[1] * 4); |
5540 |
| - gl.readPixels(0, 0, this.size[0], this.size[1], gl.RGBA, gl.FLOAT, result); |
| 5545 | + const result = new Float32Array(size[0] * size[1] * 4); |
| 5546 | + gl.readPixels(0, 0, size[0], size[1], gl.RGBA, gl.FLOAT, result); |
5541 | 5547 | return result;
|
5542 | 5548 | }
|
5543 | 5549 | renderValues() {
|
@@ -8467,9 +8473,11 @@ class WebGLKernelArray extends WebGLKernelValue {
|
8467 | 8473 | const { maxTextureSize } = this.kernel.constructor.features;
|
8468 | 8474 | if (width > maxTextureSize || height > maxTextureSize) {
|
8469 | 8475 | if (width > height) {
|
8470 |
| - throw new Error(`Argument width of ${width} larger than maximum size of ${maxTextureSize} for your GPU`); |
| 8476 | + throw new Error(`Argument texture width of ${width} larger than maximum size of ${maxTextureSize} for your GPU`); |
| 8477 | + } else if (width < height) { |
| 8478 | + throw new Error(`Argument texture height of ${height} larger than maximum size of ${maxTextureSize} for your GPU`); |
8471 | 8479 | } else {
|
8472 |
| - throw new Error(`Argument height of ${height} larger than maximum size of ${maxTextureSize} for your GPU`); |
| 8480 | + throw new Error(`Argument texture height and width of ${height} larger than maximum size of ${maxTextureSize} for your GPU`); |
8473 | 8481 | }
|
8474 | 8482 | }
|
8475 | 8483 | }
|
@@ -8666,7 +8674,7 @@ class WebGLKernelValueDynamicSingleArray extends WebGLKernelValueSingleArray {
|
8666 | 8674 | this.dimensions = utils.getDimensions(value, true);
|
8667 | 8675 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
8668 | 8676 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
8669 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 8677 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
8670 | 8678 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
8671 | 8679 | this.kernel.setUniform3iv(this.dimensionsId, this.dimensions);
|
8672 | 8680 | this.kernel.setUniform2iv(this.sizeId, this.textureSize);
|
@@ -8767,7 +8775,7 @@ class WebGLKernelValueDynamicSingleInput extends WebGLKernelValueSingleInput {
|
8767 | 8775 | this.dimensions = new Int32Array([w || 1, h || 1, d || 1]);
|
8768 | 8776 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
8769 | 8777 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
8770 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 8778 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
8771 | 8779 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
8772 | 8780 | this.kernel.setUniform3iv(this.dimensionsId, this.dimensions);
|
8773 | 8781 | this.kernel.setUniform2iv(this.sizeId, this.textureSize);
|
@@ -8795,7 +8803,7 @@ class WebGLKernelValueDynamicUnsignedArray extends WebGLKernelValueUnsignedArray
|
8795 | 8803 | this.dimensions = utils.getDimensions(value, true);
|
8796 | 8804 | this.textureSize = utils.getMemoryOptimizedPackedTextureSize(this.dimensions, this.bitRatio);
|
8797 | 8805 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * (4 / this.bitRatio);
|
8798 |
| - this.checkSize(this.textureSize[0] * (4 / this.bitRatio), this.textureSize[1] * (4 / this.bitRatio)); |
| 8806 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
8799 | 8807 | const Type = this.getTransferArrayType(value);
|
8800 | 8808 | this.preUploadValue = new Type(this.uploadArrayLength);
|
8801 | 8809 | this.uploadValue = new Uint8Array(this.preUploadValue.buffer);
|
@@ -8826,7 +8834,7 @@ class WebGLKernelValueDynamicUnsignedInput extends WebGLKernelValueUnsignedInput
|
8826 | 8834 | this.dimensions = new Int32Array([w || 1, h || 1, d || 1]);
|
8827 | 8835 | this.textureSize = utils.getMemoryOptimizedPackedTextureSize(this.dimensions, this.bitRatio);
|
8828 | 8836 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * (4 / this.bitRatio);
|
8829 |
| - this.checkSize(this.textureSize[0] * (4 / this.bitRatio), this.textureSize[1] * (4 / this.bitRatio)); |
| 8837 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
8830 | 8838 | const Type = this.getTransferArrayType(value.value);
|
8831 | 8839 | this.preUploadValue = new Type(this.uploadArrayLength);
|
8832 | 8840 | this.uploadValue = new Uint8Array(this.preUploadValue.buffer);
|
@@ -9125,7 +9133,7 @@ class WebGLKernelValueSingleArray extends WebGLKernelArray {
|
9125 | 9133 | this.dimensions = utils.getDimensions(value, true);
|
9126 | 9134 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
9127 | 9135 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
9128 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 9136 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9129 | 9137 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
9130 | 9138 | }
|
9131 | 9139 |
|
@@ -9178,7 +9186,7 @@ class WebGLKernelValueSingleArray1DI extends WebGLKernelArray {
|
9178 | 9186 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(valueDimensions, this.bitRatio);
|
9179 | 9187 | this.dimensions = new Int32Array([valueDimensions[1], 1, 1]);
|
9180 | 9188 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
9181 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 9189 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9182 | 9190 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
9183 | 9191 | }
|
9184 | 9192 |
|
@@ -9261,7 +9269,7 @@ class WebGLKernelValueSingleArray2DI extends WebGLKernelArray {
|
9261 | 9269 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(valueDimensions, this.bitRatio);
|
9262 | 9270 | this.dimensions = new Int32Array([valueDimensions[1], valueDimensions[2], 1]);
|
9263 | 9271 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
9264 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 9272 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9265 | 9273 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
9266 | 9274 | }
|
9267 | 9275 |
|
@@ -9344,7 +9352,7 @@ class WebGLKernelValueSingleArray3DI extends WebGLKernelArray {
|
9344 | 9352 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(valueDimensions, this.bitRatio);
|
9345 | 9353 | this.dimensions = new Int32Array([valueDimensions[1], valueDimensions[2], valueDimensions[3]]);
|
9346 | 9354 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
9347 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 9355 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9348 | 9356 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
9349 | 9357 | }
|
9350 | 9358 |
|
@@ -9423,7 +9431,7 @@ class WebGLKernelValueSingleInput extends WebGLKernelArray {
|
9423 | 9431 | this.dimensions = new Int32Array([w || 1, h || 1, d || 1]);
|
9424 | 9432 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
9425 | 9433 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
9426 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 9434 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9427 | 9435 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
9428 | 9436 | }
|
9429 | 9437 |
|
@@ -9471,7 +9479,7 @@ class WebGLKernelValueUnsignedArray extends WebGLKernelArray {
|
9471 | 9479 | this.dimensions = utils.getDimensions(value, true);
|
9472 | 9480 | this.textureSize = utils.getMemoryOptimizedPackedTextureSize(this.dimensions, this.bitRatio);
|
9473 | 9481 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * (4 / this.bitRatio);
|
9474 |
| - this.checkSize(this.textureSize[0] * (4 / this.bitRatio), this.textureSize[1] * (4 / this.bitRatio)); |
| 9482 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9475 | 9483 | this.TranserArrayType = this.getTransferArrayType(value);
|
9476 | 9484 | this.preUploadValue = new this.TranserArrayType(this.uploadArrayLength);
|
9477 | 9485 | this.uploadValue = new Uint8Array(this.preUploadValue.buffer);
|
@@ -9523,7 +9531,7 @@ class WebGLKernelValueUnsignedInput extends WebGLKernelArray {
|
9523 | 9531 | this.dimensions = new Int32Array([w || 1, h || 1, d || 1]);
|
9524 | 9532 | this.textureSize = utils.getMemoryOptimizedPackedTextureSize(this.dimensions, this.bitRatio);
|
9525 | 9533 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * (4 / this.bitRatio);
|
9526 |
| - this.checkSize(this.textureSize[0] * (4 / this.bitRatio), this.textureSize[1] * (4 / this.bitRatio)); |
| 9534 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
9527 | 9535 | this.TranserArrayType = this.getTransferArrayType(value.value);
|
9528 | 9536 | this.preUploadValue = new this.TranserArrayType(this.uploadArrayLength);
|
9529 | 9537 | this.uploadValue = new Uint8Array(this.preUploadValue.buffer);
|
@@ -11693,7 +11701,7 @@ class WebGL2KernelValueDynamicSingleArray extends WebGL2KernelValueSingleArray {
|
11693 | 11701 | this.dimensions = utils.getDimensions(value, true);
|
11694 | 11702 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
11695 | 11703 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
11696 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 11704 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
11697 | 11705 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
11698 | 11706 | this.kernel.setUniform3iv(this.dimensionsId, this.dimensions);
|
11699 | 11707 | this.kernel.setUniform2iv(this.sizeId, this.textureSize);
|
@@ -11798,7 +11806,7 @@ class WebGL2KernelValueDynamicSingleInput extends WebGL2KernelValueSingleInput {
|
11798 | 11806 | this.dimensions = new Int32Array([w || 1, h || 1, d || 1]);
|
11799 | 11807 | this.textureSize = utils.getMemoryOptimizedFloatTextureSize(this.dimensions, this.bitRatio);
|
11800 | 11808 | this.uploadArrayLength = this.textureSize[0] * this.textureSize[1] * this.bitRatio;
|
11801 |
| - this.checkSize(this.textureSize[0] * this.bitRatio, this.textureSize[1] * this.bitRatio); |
| 11809 | + this.checkSize(this.textureSize[0], this.textureSize[1]); |
11802 | 11810 | this.uploadValue = new Float32Array(this.uploadArrayLength);
|
11803 | 11811 | this.kernel.setUniform3iv(this.dimensionsId, this.dimensions);
|
11804 | 11812 | this.kernel.setUniform2iv(this.sizeId, this.textureSize);
|
|
0 commit comments