From 1f3cc9d3a876bc274143ed6a342c81f5e15000fe Mon Sep 17 00:00:00 2001 From: Robert Plummer Date: Fri, 28 Jul 2017 11:58:32 -0400 Subject: [PATCH] move texImage2d to setupOutputTexture --- bin/gpu-core.js | 2 +- bin/gpu.js | 14 +++++++------- src/backend/web-gl/kernel.js | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/gpu-core.js b/bin/gpu-core.js index f08a3ab2..b77dc89c 100644 --- a/bin/gpu-core.js +++ b/bin/gpu-core.js @@ -5,7 +5,7 @@ * GPU Accelerated JavaScript * * @version 0.0.0 - * @date Thu Jul 27 2017 10:40:08 GMT-0400 (EDT) + * @date Fri Jul 28 2017 11:56:49 GMT-0400 (EDT) * * @license MIT * The MIT License diff --git a/bin/gpu.js b/bin/gpu.js index 8b43c5ca..d90c8b44 100644 --- a/bin/gpu.js +++ b/bin/gpu.js @@ -5,7 +5,7 @@ * GPU Accelerated JavaScript * * @version 0.0.0 - * @date Thu Jul 27 2017 10:40:09 GMT-0400 (EDT) + * @date Fri Jul 28 2017 11:56:49 GMT-0400 (EDT) * * @license MIT * The MIT License @@ -2186,12 +2186,6 @@ module.exports = function (_KernelBase) { this.setupOutputTexture(); - if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); - } else { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - } - if (this.subKernelOutputTextures !== null) { var extDrawBuffersMap = this.extDrawBuffersMap = [gl.COLOR_ATTACHMENT0]; for (var _i = 0; _i < this.subKernelOutputTextures.length; _i++) { @@ -2340,6 +2334,7 @@ module.exports = function (_KernelBase) { key: 'setupOutputTexture', value: function setupOutputTexture() { var gl = this._webGl; + var texSize = this.texSize; this.detachOutputTexture(); this.outputTexture = this.getOutputTexture(); gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); @@ -2348,6 +2343,11 @@ module.exports = function (_KernelBase) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + if (this.floatOutput) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + } else { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } } diff --git a/src/backend/web-gl/kernel.js b/src/backend/web-gl/kernel.js index fe3f07c3..6d93d390 100644 --- a/src/backend/web-gl/kernel.js +++ b/src/backend/web-gl/kernel.js @@ -232,12 +232,6 @@ module.exports = class WebGLKernel extends KernelBase { this.setupOutputTexture(); - if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); - } else { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - } - if (this.subKernelOutputTextures !== null) { const extDrawBuffersMap = this.extDrawBuffersMap = [gl.COLOR_ATTACHMENT0]; for (let i = 0; i < this.subKernelOutputTextures.length; i++) { @@ -429,6 +423,7 @@ module.exports = class WebGLKernel extends KernelBase { */ setupOutputTexture() { const gl = this._webGl; + const texSize = this.texSize; this.detachOutputTexture(); this.outputTexture = this.getOutputTexture(); gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); @@ -437,6 +432,11 @@ module.exports = class WebGLKernel extends KernelBase { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + if (this.floatOutput) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + } else { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } } /**