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