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