mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-25 16:08:02 +00:00
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
39 lines
1.1 KiB
JavaScript
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());
|
|
});
|
|
|
|
|