move texImage2d to setupOutputTexture

This commit is contained in:
Robert Plummer 2017-07-28 11:58:32 -04:00
parent 6166a8571e
commit 1f3cc9d3a8
3 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}
/**