forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.js
More file actions
44 lines (31 loc) · 873 Bytes
/
json.js
File metadata and controls
44 lines (31 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('json serialize');
function testJSONSerialize(mode) {
const gpu = new GPU({mode});
const kernel = gpu.createKernel(function (value) {
return value;
}, {output: [1]});
kernel(1);
const json = kernel.toJSON();
const jsonKernel = gpu.createKernel(json);
assert.equal(jsonKernel(3)[0], 3);
}
test('auto', () => {
testJSONSerialize();
});
test('gpu', () => {
testJSONSerialize('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
testJSONSerialize('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
testJSONSerialize('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testJSONSerialize('headlessgl');
});
test('cpu', () => {
testJSONSerialize('cpu');
});