gpu.js/test/issues/159-3d.js
2018-09-05 21:04:23 +01:00

52 lines
1.1 KiB
JavaScript

(function() {
function threeD(mode) {
var gpu = new GPU({ mode: mode });
const kernel = gpu.createKernel(function(grid) {
return grid[this.thread.y][this.thread.x];
})
.setOutput([5, 5]);
//This would cause the above to fail
gpu.createKernel(function() { return 0; })
.setOutput([5, 5, 5])
.build();
var result = kernel([
[0,1,2,3,4],
[1,2,3,4,5],
[2,3,4,5,6],
[3,4,5,6,7],
[4,5,6,7,8]
]);
QUnit.assert.equal(result.length, 5);
QUnit.assert.deepValueEqual(result, [
[0,1,2,3,4],
[1,2,3,4,5],
[2,3,4,5,6],
[3,4,5,6,7],
[4,5,6,7,8]
]);
gpu.destroy();
}
QUnit.test('Issue #159 - for vars (cpu)', function() {
threeD('cpu');
});
QUnit.test('Issue #159 - for vars (auto)', function() {
threeD(null);
});
QUnit.test('Issue #159 - for vars (gpu)', function() {
threeD('gpu');
});
QUnit.test('Issue #159 - for vars (webgl)', function() {
threeD('webgl');
});
QUnit.test('Issue #159 - for vars (webgl2)', function() {
threeD('webgl2');
});
})();