gpu.js/test/features/float-output.js
Robert Plummer 82e4966551 feat: v2.0.0rc1
Cleanup and add random support (seeded by... Math.random()!)
I went through api and cleaned it up considerably
2019-01-31 18:24:25 -05:00

38 lines
901 B
JavaScript

const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('features: float output');
function floatOutputKernel(mode) {
const lst = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8]);
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(function(lst) {
return lst[this.thread.x];
}, { floatOutput: true, output: [lst.length] });
assert.deepEqual(kernel(lst), lst);
gpu.destroy();
}
test("auto", () => {
floatOutputKernel(null);
});
test("cpu", () => {
floatOutputKernel('cpu');
});
test("gpu", () => {
floatOutputKernel('gpu');
});
(GPU.isWebGLSupported ? test : skip)("webgl", () => {
floatOutputKernel('webgl');
});
(GPU.isWebGL2Supported ? test : skip)("webgl2", () => {
floatOutputKernel('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)("headlessgl", () => {
floatOutputKernel('headlessgl');
});