gpu.js/test/issues/410-if-statement.js
Robert Plummer 7bcfbed234 feat: Pre type check with FunctionTracer
feat: Add cat demo
feat: Type check even on CPU
fix: ArrayTexture support as arguments for internal arrays
fix: Typo from "Interger" to "Integer"
feat: Bump and build version number
2019-06-17 18:00:36 -04:00

53 lines
1.0 KiB
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('issue #410 - if statement when unsigned on NVidia');
function ifStatement(mode) {
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(function(a) {
const paramDenom = a[this.thread.x][1] - a[this.thread.x][0];
if(paramDenom === 0) {
return 100;
}
return 200;
})
.setPrecision('unsigned')
.setOutput([2]);
const result =
kernel(
[
[0, 0],
[0, 2]
]
);
assert.deepEqual(Array.from(result), [100,200]);
gpu.destroy();
}
test('auto', () => {
ifStatement();
});
test('gpu', () => {
ifStatement('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
ifStatement('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
ifStatement('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
ifStatement('headlessgl');
});
test('cpu', () => {
ifStatement('cpu');
});