From ab1a2ad490d4770b0752bca17ff2657ea24cae64 Mon Sep 17 00:00:00 2001 From: Abhishek Soni Date: Sat, 1 Jul 2017 03:33:07 +0530 Subject: [PATCH 1/4] CPU fallback for createKernels --- src/gpu.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gpu.js b/src/gpu.js index e938fd78..3bf60088 100644 --- a/src/gpu.js +++ b/src/gpu.js @@ -130,6 +130,13 @@ module.exports = class GPU { /// {Function} callable kernel function /// createKernels() { + if (!utils.isWebGlDrawBuffersSupported) { + this._runner = new CPURunner({ + canvas: this._canvas, + webGl: this._webGl + }); + } + let fn; let settings; if (typeof arguments[arguments.length - 2] === 'function') { From deb5a70b469ceb576381e0da7f68f3179cf4f53e Mon Sep 17 00:00:00 2001 From: Abhishek Soni Date: Sat, 1 Jul 2017 03:33:41 +0530 Subject: [PATCH 2/4] Fix tests for create-kernels.js --- test/src/features/create-kernels.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/features/create-kernels.js b/test/src/features/create-kernels.js index 1b4aded2..d86aae1a 100644 --- a/test/src/features/create-kernels.js +++ b/test/src/features/create-kernels.js @@ -31,7 +31,7 @@ function createArrayKernels(mode, dimensions, canvas) { function createKernel(mode, dimensions, canvas) { var gpu = new GPU({mode: mode, canvas: canvas}); return gpu.createKernel(function (a) { - return a[this.thread.x][this.thread.y]; + return a[this.thread.x]; }).setDimensions(dimensions); } From 4f342db7bf9fddb7b3a94b531b57159c52aeb2ee Mon Sep 17 00:00:00 2001 From: Abhishek Soni Date: Sat, 1 Jul 2017 09:37:59 +0530 Subject: [PATCH 3/4] move fallback check after settings/fn check --- src/gpu.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gpu.js b/src/gpu.js index 3bf60088..deee9ba1 100644 --- a/src/gpu.js +++ b/src/gpu.js @@ -130,13 +130,6 @@ module.exports = class GPU { /// {Function} callable kernel function /// createKernels() { - if (!utils.isWebGlDrawBuffersSupported) { - this._runner = new CPURunner({ - canvas: this._canvas, - webGl: this._webGl - }); - } - let fn; let settings; if (typeof arguments[arguments.length - 2] === 'function') { @@ -145,6 +138,14 @@ module.exports = class GPU { } else { fn = arguments[arguments.length - 1]; } + + if (!utils.isWebGlDrawBuffersSupported) { + this._runner = new CPURunner({ + canvas: this._canvas, + webGl: this._webGl + }); + } + const kernel = this.createKernel(fn, settings); if (Array.isArray(arguments[0])) { const functions = arguments[0]; From 5cd438707ddb7e6876fcbd406063e499efeeea2b Mon Sep 17 00:00:00 2001 From: Abhishek Soni Date: Sat, 1 Jul 2017 09:41:42 +0530 Subject: [PATCH 4/4] pass settings to the runner instance --- src/gpu.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gpu.js b/src/gpu.js index deee9ba1..b17cbefa 100644 --- a/src/gpu.js +++ b/src/gpu.js @@ -140,10 +140,7 @@ module.exports = class GPU { } if (!utils.isWebGlDrawBuffersSupported) { - this._runner = new CPURunner({ - canvas: this._canvas, - webGl: this._webGl - }); + this._runner = new CPURunner(settings); } const kernel = this.createKernel(fn, settings);