mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
Change `HTMLImageArray` render strategy to `gl.NEAREST`, like all the others Let `WebGL2FunctionNode` extend `WebGLFunctionNode` and lighten Remove all the different html pages associated with tests, and just use one file to handle them and use qunit for filtering them Bump version number
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
(function () {
|
|
function getResult(mode) {
|
|
var A = [
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1]
|
|
];
|
|
|
|
var B = [
|
|
[1, 1, 1],
|
|
[1, 1, 1]
|
|
];
|
|
|
|
var gpu = new GPU({ mode: mode });
|
|
|
|
function multiply(b, a, y, x) {
|
|
var sum = 0;
|
|
for (var i = 0; i < 2; i++) {
|
|
sum += b[y][i] * a[i][x];
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
var kernels = gpu.createKernelMap({
|
|
multiplyResult: multiply
|
|
}, function (a, b) {
|
|
return multiply(b, a, this.thread.y, this.thread.x);
|
|
})
|
|
.setOutput([B.length, A.length]);
|
|
|
|
return kernels(A, B).result;
|
|
}
|
|
QUnit.test( "Issue #91 - type detection (GPU only) (auto)", function() {
|
|
var result = getResult();
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
|
|
});
|
|
QUnit.test( "Issue #91 - type detection (GPU only) (gpu)", function() {
|
|
var result = getResult('gpu');
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
|
|
});
|
|
QUnit.test( "Issue #91 - type detection (GPU only) (webgl)", function() {
|
|
var result = getResult('webgl');
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
|
|
});
|
|
QUnit.test( "Issue #91 - type detection (GPU only) (webgl2)", function() {
|
|
var result = getResult('webgl2');
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[0]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[1]), [2,2]);
|
|
QUnit.assert.deepEqual(QUnit.extend([], result[2]), [0,0]);
|
|
});
|
|
})(); |