mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
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
76 lines
2.6 KiB
JavaScript
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]);
|
|
}); |