forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants-float.js
More file actions
49 lines (42 loc) · 1.09 KB
/
constants-float.js
File metadata and controls
49 lines (42 loc) · 1.09 KB
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
45
46
47
48
49
const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('features: constants float');
function floatConstantTest(mode) {
const gpu = new GPU({ mode });
const float = 200.01;
const tryConst = gpu.createKernel(
function() {
return this.constants.float;
},
{
constants: { float },
output: [2]
},
);
const result = tryConst();
const match = new Float32Array([200.01, 200.01]);
const test = (
result[0].toFixed(1) === match[0].toFixed(1)
&& result[1].toFixed(1) === match[1].toFixed(1)
);
assert.ok(test, 'float constant passed test');
gpu.destroy();
}
test('auto', () => {
floatConstantTest(null);
});
test('gpu', () => {
floatConstantTest('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
floatConstantTest('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
floatConstantTest('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
floatConstantTest('headlessgl');
});
test('cpu', () => {
floatConstantTest('cpu');
});