(mode)
| 526 | }); |
| 527 | |
| 528 | function dynamicOutput3DGrows(mode) { |
| 529 | const gpu = new GPU({ mode }); |
| 530 | const kernel = gpu.createKernel(function() { |
| 531 | return this.output.x + this.output.y + this.thread.z + this.thread.x + this.thread.y + this.thread.z; |
| 532 | }, { dynamicOutput: true }); |
| 533 | |
| 534 | kernel.setOutput([2,2,2]); |
| 535 | let result = kernel(); |
| 536 | assert.equal(result.length, 2); |
| 537 | assert.deepEqual(result.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]); |
| 538 | assert.deepEqual(Array.from(kernel.output), [2,2,2]); |
| 539 | |
| 540 | kernel.setOutput([3,3,3]); |
| 541 | result = kernel(); |
| 542 | assert.equal(result.length, 3); |
| 543 | assert.deepEqual(result.map(matrix => matrix.map(row => Array.from(row))), [ |
| 544 | [ |
| 545 | [6,7,8], |
| 546 | [7,8,9], |
| 547 | [8,9,10] |
| 548 | ], |
| 549 | [ |
| 550 | [8,9,10], |
| 551 | [9,10,11], |
| 552 | [10,11,12] |
| 553 | ], |
| 554 | [ |
| 555 | [10,11,12], |
| 556 | [11,12,13], |
| 557 | [12,13,14] |
| 558 | ] |
| 559 | ]); |
| 560 | assert.deepEqual(Array.from(kernel.output), [3,3,3]); |
| 561 | |
| 562 | gpu.destroy(); |
| 563 | } |
| 564 | |
| 565 | test('dynamic output 3d grows auto', () => { |
| 566 | dynamicOutput3DGrows(); |
no test coverage detected
searching dependent graphs…