Robert Plummer 82832902cc fix: Move jellyfish images to actual files
fix: added `warnVarUsage` and `Dealing With Transpilation`
fix: Test dynamic arguments and provide some fixes for
fix: Dynamic arguments for `CPUFunctionNode`
fix: Dynamic arguments for `WebGLKernelValueDynamicHTMLImage`, `WebGLKernelValueDynamicNumberTexture`, `WebGLKernelValueDynamicSingleInput`, `WebGL2KernelValueDynamicHTMLImage`, `WebGL2KernelValueDynamicNumberTexture`, and `WebGL2KernelValueDynamicSingleInput`
fix: `onRequestFallback` settings in `createKernel` and `createKernel` inclusion of `loopMaxIterations`, `dynamicOutput`, and `dynamicArgument` in settings for when switching kernels
fix: `WebGL2Kernel` and `HeadlessGLKernel` typescript definition extensions
2019-07-05 11:03:25 -04:00

39 lines
1.1 KiB
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../../../../../src');
describe('feature: to-string unsigned precision arguments HTMLImage');
function testArgument(mode, done) {
const image = new Image();
image.src = 'jellyfish.jpeg';
image.onload = () => {
const gpu = new GPU({mode});
const originalKernel = gpu.createKernel(function (a) {
const pixel = a[0][0];
return pixel.g * 255;
}, {
output: [1],
precision: 'unsigned',
argumentTypes: ['HTMLImage'],
});
const canvas = originalKernel.canvas;
const context = originalKernel.context;
assert.deepEqual(originalKernel(image)[0], 84);
const kernelString = originalKernel.toString(image);
const newKernel = new Function('return ' + kernelString)()({context, canvas});
assert.deepEqual(newKernel(image)[0], 84);
gpu.destroy();
done();
}
}
(GPU.isWebGLSupported ? test : skip)('webgl', t => {
testArgument('webgl', t.async());
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', t => {
testArgument('webgl2', t.async());
});