forked from fingerecho/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat-output.js
More file actions
42 lines (37 loc) · 1.18 KB
/
float-output.js
File metadata and controls
42 lines (37 loc) · 1.18 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
(function() {
var lst = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8]);
var gpu;
function floatOutputKernel(output, mode) {
gpu = new GPU({ mode: mode });
return gpu.createKernel(function(lst) {
return lst[this.thread.x];
})
.setFloatOutput(true)
.setOutput(output);
}
QUnit.test( "floatOutput (auto)", function() {
var result = floatOutputKernel([lst.length], null)(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (cpu)", function() {
var result = floatOutputKernel([lst.length], 'cpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (gpu)", function() {
var result = floatOutputKernel([lst.length], 'gpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl)", function() {
var result = floatOutputKernel([lst.length], 'webgl')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl2)", function() {
var result = floatOutputKernel([lst.length], 'webgl2')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
})();