forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path410-if-statement.js
More file actions
52 lines (42 loc) · 1.01 KB
/
410-if-statement.js
File metadata and controls
52 lines (42 loc) · 1.01 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
52
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('issue #410 - if statement when unsigned on NVidia');
function ifStatement(mode) {
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(function(a) {
const paramDenom = a[this.thread.x][1] - a[this.thread.x][0];
if(paramDenom === 0) {
return 100;
}
return 200;
})
.setPrecision('unsigned')
.setOutput([2]);
const result =
kernel(
[
[0, 0],
[0, 2]
]
);
assert.deepEqual(Array.from(result), [100,200]);
gpu.destroy();
}
test('auto', () => {
ifStatement();
});
test('gpu', () => {
ifStatement('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
ifStatement('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
ifStatement('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
ifStatement('headlessgl');
});
test('cpu', () => {
ifStatement('cpu');
});