forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path300-nested-array-index.js
More file actions
51 lines (39 loc) · 1.29 KB
/
300-nested-array-index.js
File metadata and controls
51 lines (39 loc) · 1.29 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
50
51
const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('issue #300');
function nestedArrayIndex(mode) {
const gpu1 = new GPU({ mode });
const gpu2 = new GPU({ mode });
// these 2 should be equivalent
const broken = gpu1.createKernel(function(input, lookup) {
return lookup[input[this.thread.x]];
})
.setOutput([1]);
const working = gpu2.createKernel(function(input, lookup) {
const idx = input[this.thread.x];
return lookup[idx];
})
.setOutput([1]);
assert.equal(broken([2], [7, 13, 19, 23])[0], 19);
assert.equal(working([2], [7, 13, 19, 23])[0], 19);
gpu1.destroy();
gpu2.destroy();
}
test('Issue #300 nested array index - auto', () => {
nestedArrayIndex();
});
test('Issue #300 nested array index - gpu', () => {
nestedArrayIndex('gpu');
});
(GPU.isWebGLSupported ? test : skip)('Issue #300 nested array index - webgl', () => {
nestedArrayIndex('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('Issue #300 nested array index - webgl2', () => {
nestedArrayIndex('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('Issue #300 nested array index - headlessgl', () => {
nestedArrayIndex('headlessgl');
});
test('Issue #300 nested array index - cpu', () => {
nestedArrayIndex('cpu');
});