gpu.js/test/issues/553-permanent-flip.js
Robert Plummer 03972cc1fa fix: #553 call gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); on every texture type and add unit tests
fix: Framebuffer loss after texture is deleted
fix: Split up array and primitive (index.js) types of KernelValues and introduce .setup()
  * This was needed to handle .toArray() from the fix from #553
fix: Performance fix, define texture types in `kernelValue.setup()`, rather than on every `kernelValue.updateValue()`
2020-01-06 13:36:00 -05:00

67 lines
1.7 KiB
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('issue #553 - permanent flip');
function testFixPermanentFlip(precision, mode) {
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(function(a1, a2, a3, a4) {
return a2[this.thread.x];
}, {
precision,
output: [4]
});
const arr = [1, 2, 3, 4];
for (let i = 0; i < 4; i++) {
assert.deepEqual(kernel(
999,
arr,
new Image(2, 2),
999,
), new Float32Array(arr));
}
gpu.destroy();
}
// unsigned
(typeof Image === 'undefined' ? skip : test)('auto unsigned', () => {
testFixPermanentFlip('unsigned');
});
(typeof Image === 'undefined' ? skip : test)('gpu unsigned', () => {
testFixPermanentFlip('unsigned', 'gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl unsigned', () => {
testFixPermanentFlip('unsigned', 'webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2 unsigned', () => {
testFixPermanentFlip('unsigned', 'webgl2');
});
(typeof Image === 'undefined' ? skip : test)('cpu unsigned', () => {
testFixPermanentFlip('unsigned', 'cpu');
});
// single
(typeof Image === 'undefined' ? skip : test)('auto single', () => {
testFixPermanentFlip('single');
});
(typeof Image === 'undefined' ? skip : test)('gpu single', () => {
testFixPermanentFlip('single', 'gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl single', () => {
testFixPermanentFlip('single', 'webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2 single', () => {
testFixPermanentFlip('single', 'webgl2');
});
(typeof Image === 'undefined' ? skip : test)('cpu single', () => {
testFixPermanentFlip('single', 'cpu');
});