gpu.js/test/features/input.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

35 lines
887 B
JavaScript

(function() {
function input(mode) {
const gpu = new GPU({ mode: mode });
const input = GPU.input;
const kernel = gpu.createKernel(function(a, b) {
return a[this.thread.y][this.thread.x] + b[this.thread.y][this.thread.x];
})
.setOutput([9]);
const a = new Float32Array(9);
a.set([1,2,3,4,5,6,7,8,9]);
const b = new Float32Array(9);
b.set([1,2,3,4,5,6,7,8,9]);
const result = kernel(input(a, [3, 3]), input(b, [3, 3]));
QUnit.assert.deepEqual(QUnit.extend([], result), [2,4,6,8,10,12,14,16,18]);
}
QUnit.test( "input (WebGL Only) (auto)", function() {
input();
});
QUnit.test( "input (WebGL Only) (gpu)", function() {
input('gpu');
});
QUnit.test( "input (WebGL Only) (webgl)", function() {
input('webgl');
});
QUnit.test( "input (WebGL Only) (webgl2)", function() {
input('webgl2');
});
})();