gpu.js/test/issues/114-create-kernel-map-run-second-time.js
Robert Plummer b2df0ab604 fix #316
Change `HTMLImageArray` render strategy to `gl.NEAREST`, like all the others
Let `WebGL2FunctionNode` extend `WebGLFunctionNode` and lighten
Remove all the different html pages associated with tests, and just use one file to handle them and use qunit for filtering them
Bump version number
2018-06-12 14:07:41 -04:00

76 lines
2.6 KiB
JavaScript

QUnit.test( "Issue #114 - run createKernelMap the second time (auto)", function() {
const gpu = new GPU();
const A = [1, 2, 3, 4, 5];
const B = [1, 2, 3, 4, 5];
function add(a,b){
return a + b;
}
const kernels = gpu.createKernelMap([add],function(a, b){
return a[this.thread.x] + b[this.thread.x];
}).setOutput([5]);
const E = kernels(A, B).result;
const F = kernels(A, B).result;
const G = kernels(A, B).result;
QUnit.assert.deepEqual(QUnit.extend([], E), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], F), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], G), [2, 4, 6, 8, 10]);
});
QUnit.test( "Issue #114 - run createKernelMap the second time (gpu)", function() {
const gpu = new GPU({ mode: 'gpu' });
const A = [1, 2, 3, 4, 5];
const B = [1, 2, 3, 4, 5];
function add(a,b){
return a + b;
}
const kernels = gpu.createKernelMap([add],function(a, b){
return a[this.thread.x] + b[this.thread.x];
}).setOutput([5]);
const E = kernels(A, B).result;
const F = kernels(A, B).result;
const G = kernels(A, B).result;
QUnit.assert.deepEqual(QUnit.extend([], E), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], F), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], G), [2, 4, 6, 8, 10]);
});
QUnit.test( "Issue #114 - run createKernelMap the second time (webgl)", function() {
const gpu = new GPU({ mode: 'webgl' });
const A = [1, 2, 3, 4, 5];
const B = [1, 2, 3, 4, 5];
function add(a,b){
return a + b;
}
const kernels = gpu.createKernelMap([add],function(a, b){
return a[this.thread.x] + b[this.thread.x];
}).setOutput([5]);
const E = kernels(A, B).result;
const F = kernels(A, B).result;
const G = kernels(A, B).result;
QUnit.assert.deepEqual(QUnit.extend([], E), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], F), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], G), [2, 4, 6, 8, 10]);
});
QUnit.test( "Issue #114 - run createKernelMap the second time (webgl2)", function() {
const gpu = new GPU({ mode: 'webgl2' });
const A = [1, 2, 3, 4, 5];
const B = [1, 2, 3, 4, 5];
function add(a,b){
return a + b;
}
const kernels = gpu.createKernelMap([add],function(a, b){
return a[this.thread.x] + b[this.thread.x];
}).setOutput([5]);
const E = kernels(A, B).result;
const F = kernels(A, B).result;
const G = kernels(A, B).result;
QUnit.assert.deepEqual(QUnit.extend([], E), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], F), [2, 4, 6, 8, 10]);
QUnit.assert.deepEqual(QUnit.extend([], G), [2, 4, 6, 8, 10]);
});