Robert Plummer 86af54efef fix: Node support for v8+
fix: Move `make` cli command to gulp so it runs in parallel
fix: Add official support for `Array1D(2|3|4)`, `Array2D(2|3|4)`, and `Array3D(2|3|4)` and unit tests
fix: Add offical support for `Array(2)`, `Array(3)`, and `Array(4)` and unit tests
fix: Mandelbulb constant used a constant, so moved to appropriate location
fix: Failing unit test for Safari
fix: When not falling back in HeadlessGL, call `STACKGL_resize_drawingbuffer`
fix: Remove `xyz` variable from glsl
fix: Add `uniform4fv` and `uniform4iv` to WebGL implementation
fix: Check for kernel settings `constantTypes` and `argumentTypes`
fix: Inherit type from kernel in KernelValue constructors
fix: Add some typescript details for `GPUVariableType`, `IKernelSettings`, and `ITypesList`
fix: Add support for 4d array in `utils.getMemoryOptimizedFloatTextureSize` for the special use case of `Array3D(2|3|4)`
fix: Add `utils.flatten4dArrayTo` for the special use case of `Array3D(2|3|4)`
fix: Add support for 4d array in `utils.flattenTo`
fix: Bump and build
2019-07-24 12:56:05 -04:00

46 lines
1.4 KiB
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../../../../../src');
describe('feature: to-string unsigned precision arguments Float');
function testArgument(mode, context, canvas) {
const gpu = new GPU({ mode });
const originalKernel = gpu.createKernel(function(a) {
return Math.floor(a) === 100 ? 42 : -42;
}, {
canvas,
context,
output: [1],
precision: 'unsigned',
argumentTypes: { a: 'Float' },
});
assert.equal(originalKernel.argumentTypes[0], 'Float');
assert.deepEqual(originalKernel(100)[0], 42);
assert.deepEqual(originalKernel(10)[0], -42);
const kernelString = originalKernel.toString(100);
const newKernel = new Function('return ' + kernelString)()({ context });
assert.deepEqual(newKernel(100)[0], 42);
assert.deepEqual(newKernel(10)[0], -42);
gpu.destroy();
}
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
const canvas = document.createElement('canvas');
const context = canvas.getContext('webgl');
testArgument('webgl', context, canvas);
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
const canvas = document.createElement('canvas');
const context = canvas.getContext('webgl2');
testArgument('webgl2', context, canvas);
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testArgument('headlessgl', require('gl')(1, 1), null);
});
test('cpu', () => {
testArgument('cpu');
});