mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
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
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
const { assert, skip, test, module: describe, only } = require('qunit');
|
|
const { GPU } = require('../../../../../../../src');
|
|
|
|
describe('feature: to-string single precision array style kernel map returns 2D Array');
|
|
|
|
function testReturn(mode, context, canvas) {
|
|
const gpu = new GPU({ mode });
|
|
function addOne(value) {
|
|
return value + 1;
|
|
}
|
|
const originalKernel = gpu.createKernelMap([addOne], function(a) {
|
|
const result = a[this.thread.x] + 1;
|
|
addOne(result);
|
|
return result;
|
|
}, {
|
|
canvas,
|
|
context,
|
|
output: [2, 2],
|
|
precision: 'single',
|
|
});
|
|
|
|
const a = [1, 2, 3, 4, 5, 6];
|
|
const expected = [
|
|
new Float32Array([2, 3]),
|
|
new Float32Array([2, 3]),
|
|
];
|
|
const expectedZero = [
|
|
new Float32Array([3, 4]),
|
|
new Float32Array([3, 4]),
|
|
];
|
|
const originalResult = originalKernel(a);
|
|
assert.deepEqual(originalResult.result, expected);
|
|
assert.deepEqual(originalResult[0], expectedZero);
|
|
const kernelString = originalKernel.toString(a);
|
|
const newResult = new Function('return ' + kernelString)()({ context })(a);
|
|
assert.deepEqual(newResult.result, expected);
|
|
assert.deepEqual(newResult[0], expectedZero);
|
|
gpu.destroy();
|
|
}
|
|
|
|
(GPU.isSinglePrecisionSupported && GPU.isWebGLSupported ? test : skip)('webgl', () => {
|
|
const canvas = document.createElement('canvas');
|
|
const context = canvas.getContext('webgl');
|
|
testReturn('webgl', context, canvas);
|
|
});
|
|
|
|
(GPU.isSinglePrecisionSupported && GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
|
|
const canvas = document.createElement('canvas');
|
|
const context = canvas.getContext('webgl2');
|
|
testReturn('webgl2', context, canvas);
|
|
});
|
|
|
|
(GPU.isSinglePrecisionSupported && GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
|
|
testReturn('headlessgl', require('gl')(1, 1), null);
|
|
});
|
|
|
|
test('cpu', () => {
|
|
testReturn('cpu');
|
|
});
|