Skip to content

Commit 0841724

Browse files
fix: Add missing test
1 parent ab75103 commit 0841724

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const { assert, skip, test, module: describe, only } = require('qunit');
2+
const { GPU } = require('../../../../../../src');
3+
4+
describe('feature: to-string single precision arguments HTMLVideo');
5+
6+
function testArgument(mode, done) {
7+
const video = document.createElement('video');
8+
video.currentTime = 2;
9+
video.src = 'jellyfish.webm';
10+
video.oncanplay = (e) => {
11+
video.oncanplay = null;
12+
setTimeout(() => {
13+
const gpu = new GPU({mode});
14+
const originalKernel = gpu.createKernel(function (a) {
15+
const pixel = a[0][0];
16+
return pixel.g * 255;
17+
}, {
18+
output: [1],
19+
precision: 'single',
20+
argumentTypes: ['HTMLVideo'],
21+
});
22+
const canvas = originalKernel.canvas;
23+
const context = originalKernel.context;
24+
assert.deepEqual(originalKernel(video)[0], 125);
25+
const kernelString = originalKernel.toString(video);
26+
const newKernel = new Function('return ' + kernelString)()({context, canvas});
27+
assert.deepEqual(newKernel(video)[0], 125);
28+
gpu.destroy();
29+
done();
30+
}, 1000);
31+
}
32+
}
33+
34+
(GPU.isWebGLSupported ? test : skip)('webgl', t => {
35+
testArgument('webgl', t.async());
36+
});
37+
38+
(GPU.isWebGL2Supported ? test : skip)('webgl2', t => {
39+
testArgument('webgl2', t.async());
40+
});
41+
42+

0 commit comments

Comments
 (0)