| 5 | (function() { |
| 6 | const { GPU } = require('../../src'); |
| 7 | function threeD(mode) { |
| 8 | const gpu = new GPU({ mode }); |
| 9 | |
| 10 | const kernel = gpu.createKernel(function(grid) { |
| 11 | return grid[this.thread.y][this.thread.x]; |
| 12 | }) |
| 13 | .setOutput([5, 5]); |
| 14 | |
| 15 | //This would cause the above to fail |
| 16 | gpu.createKernel(function() { return 0; }) |
| 17 | .setOutput([5, 5, 5]) |
| 18 | .build(); |
| 19 | |
| 20 | const result = kernel([ |
| 21 | [0,1,2,3,4], |
| 22 | [1,2,3,4,5], |
| 23 | [2,3,4,5,6], |
| 24 | [3,4,5,6,7], |
| 25 | [4,5,6,7,8] |
| 26 | ]); |
| 27 | assert.equal(result.length, 5); |
| 28 | assert.deepEqual(result.map(function(v) { return Array.from(v); }), [ |
| 29 | [0,1,2,3,4], |
| 30 | [1,2,3,4,5], |
| 31 | [2,3,4,5,6], |
| 32 | [3,4,5,6,7], |
| 33 | [4,5,6,7,8] |
| 34 | ]); |
| 35 | gpu.destroy(); |
| 36 | } |
| 37 | |
| 38 | test('Issue #159 - for vars auto', () => { |
| 39 | threeD(null); |