mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
Cleanup and add random support (seeded by... Math.random()!) I went through api and cleaned it up considerably
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const { assert, skip, test, module: describe } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
|
|
describe('float output textures');
|
|
|
|
function floatTexturesKernel(output, 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];
|
|
}, { output: [lst.length], floatTextures: true });
|
|
|
|
const result = kernel(lst);
|
|
assert.deepEqual(result, lst);
|
|
gpu.destroy();
|
|
}
|
|
|
|
(GPU.isKernelMapSupported ? test : skip)("floatTextures auto", () => {
|
|
floatTexturesKernel();
|
|
});
|
|
|
|
test("cpu", () => {
|
|
assert.throws(() => {
|
|
floatTexturesKernel('cpu');
|
|
});
|
|
});
|
|
|
|
(GPU.isKernelMapSupported ? test : skip)("gpu", () => {
|
|
floatTexturesKernel('gpu');
|
|
});
|
|
|
|
(GPU.isWebGLSupported && GPU.isKernelMapSupported ? test : skip)("webgl", () => {
|
|
floatTexturesKernel('webgl');
|
|
});
|
|
|
|
(GPU.isWebGL2Supported ? test : skip)("webgl2", () => {
|
|
floatTexturesKernel('webgl2');
|
|
});
|
|
|
|
(GPU.isHeadlessGLSupported && GPU.isKernelMapSupported ? test : skip)("headlessgl", () => {
|
|
floatTexturesKernel('headlessgl');
|
|
});
|