mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
fix: Added test suite for arrays and inputs for webgl and webgl2 fix: Rename "floatOutput" feature to "precision". Values can be "unsigned" or "single" fix: Add input and Input to typings fix: Use Int32Array for input.size
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
const { assert, skip, test, module: describe } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
|
|
describe('features: single precision');
|
|
function singlePrecisionKernel(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];
|
|
}, {
|
|
precision: 'single',
|
|
output: [lst.length]
|
|
});
|
|
assert.deepEqual(kernel(lst), lst);
|
|
gpu.destroy();
|
|
}
|
|
|
|
(GPU.isSinglePrecisionSupported ? test : skip)("auto", () => {
|
|
singlePrecisionKernel(null);
|
|
});
|
|
|
|
test("cpu", () => {
|
|
singlePrecisionKernel('cpu');
|
|
});
|
|
|
|
(GPU.isSinglePrecisionSupported ? test : skip)("gpu", () => {
|
|
singlePrecisionKernel('gpu');
|
|
});
|
|
|
|
(GPU.isSinglePrecisionSupported && GPU.isWebGLSupported ? test : skip)("webgl", () => {
|
|
singlePrecisionKernel('webgl');
|
|
});
|
|
|
|
(GPU.isWebGL2Supported ? test : skip)("webgl2", () => {
|
|
singlePrecisionKernel('webgl2');
|
|
});
|
|
|
|
(GPU.isHeadlessGLSupported ? test : skip)("headlessgl", () => {
|
|
singlePrecisionKernel('headlessgl');
|
|
});
|