mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
const { assert, skip, test, module: describe, only } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
|
|
describe('features: constants integer');
|
|
|
|
function integerConstantTest(mode) {
|
|
const gpu = new GPU({ mode });
|
|
const int = 200;
|
|
const tryConst = gpu.createKernel(
|
|
function() {
|
|
return this.constants.int;
|
|
},
|
|
{
|
|
constants: { int }
|
|
}
|
|
).setOutput([2]);
|
|
const result = tryConst();
|
|
const match = new Float32Array([200, 200]);
|
|
const test = (result[0] === match[0] && result[1] === match[1]);
|
|
assert.ok(test, 'int constant passed test');
|
|
gpu.destroy();
|
|
}
|
|
|
|
test('auto', () => {
|
|
integerConstantTest(null);
|
|
});
|
|
|
|
test('gpu', () => {
|
|
integerConstantTest('gpu');
|
|
});
|
|
|
|
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
|
|
integerConstantTest('webgl');
|
|
});
|
|
|
|
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
|
|
integerConstantTest('webgl2');
|
|
});
|
|
|
|
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
|
|
integerConstantTest('headlessgl');
|
|
});
|
|
|
|
test('cpu', () => {
|
|
integerConstantTest('cpu');
|
|
});
|