forked from fingerecho/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants-float.js
More file actions
47 lines (42 loc) · 1.16 KB
/
constants-float.js
File metadata and controls
47 lines (42 loc) · 1.16 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
(function() {
function floatConstantTest(mode) {
var gpu = new GPU({ mode: mode });
var float = 200.01;
var tryConst = gpu.createKernel(
function() {
return this.constants.float;
},
{
constants: { float }
}
).setOutput([2]);
var result = tryConst();
var match = new Float32Array([200.01, 200.01]);
var test = (
result[0].toFixed(1) === match[0].toFixed(1)
&& result[1].toFixed(1) === match[1].toFixed(1)
);
QUnit.assert.ok(test, 'float constant passed test');
tryConst.destroy();
}
QUnit.test( 'floatConstantTest (auto)', function(assert) {
var mode = null;
floatConstantTest(mode);
});
QUnit.test( 'floatConstantTest (gpu)', function(assert) {
var mode = 'gpu';
floatConstantTest(mode);
});
QUnit.test( 'floatConstantTest (webgl)', function(assert) {
var mode = 'webgl';
floatConstantTest(mode);
});
QUnit.test( 'floatConstantTest (webgl2)', function(assert) {
var mode = 'webgl2';
floatConstantTest(mode);
});
QUnit.test( 'floatConstantTest (cpu)', function(assert) {
var mode = 'cpu';
floatConstantTest(mode);
});
})();