gpu.js/test/features/float-output.js
Robert Plummer 87e2be5fba feat: Migrating to use gl, bump version number
Not ready yet, but close.  Need build scripts from headless-gl upstream.
2019-01-04 10:29:45 -05:00

88 lines
2.4 KiB
JavaScript

var GPU = require('../../src/index');
(function() {
var lst = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8]);
var gpu;
function floatOutputKernel(output, mode) {
gpu = new GPU({ mode: mode });
return gpu.createKernel(function(lst) {
return lst[this.thread.x];
})
.setFloatOutput(true)
.setOutput(output);
}
QUnit.test( "floatOutput (auto)", function() {
var result = floatOutputKernel([lst.length], null)(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (cpu)", function() {
var result = floatOutputKernel([lst.length], 'cpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (gpu)", function() {
var result = floatOutputKernel([lst.length], 'gpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl)", function() {
var result = floatOutputKernel([lst.length], 'webgl')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl2)", function() {
var result = floatOutputKernel([lst.length], 'webgl2')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
})();
(function() {
var lst = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8]);
var gpu;
function floatOutputKernel(output, mode) {
gpu = new GPU({ mode: mode });
return gpu.createKernel(function(lst) {
return lst[this.thread.x];
})
.setFloatOutput(true)
.setOutput(output);
}
QUnit.test( "floatOutput (auto)", function() {
var result = floatOutputKernel([lst.length], null)(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (cpu)", function() {
var result = floatOutputKernel([lst.length], 'cpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (gpu)", function() {
var result = floatOutputKernel([lst.length], 'gpu')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl)", function() {
var result = floatOutputKernel([lst.length], 'webgl')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
QUnit.test( "floatOutput (webgl2)", function() {
var result = floatOutputKernel([lst.length], 'webgl2')(lst);
QUnit.assert.deepEqual(result, lst);
gpu.destroy();
});
})();