()
| 15 | }; |
| 16 | |
| 17 | function loaded() { |
| 18 | const gpu = new GPU({ mode }); |
| 19 | const kernel = gpu.createKernel(function(image) { |
| 20 | const pixel = image[this.thread.y][this.thread.x]; |
| 21 | return (pixel[0] + pixel[1] + pixel[2]) / 3; |
| 22 | }) |
| 23 | .setDynamicArguments(true) |
| 24 | .setDynamicOutput(true) |
| 25 | .setOutput([276, 183]); |
| 26 | |
| 27 | const pixels1 = kernel(image1); |
| 28 | kernel.setOutput([138, 91]); |
| 29 | const pixels2 = kernel(image2); |
| 30 | |
| 31 | assert.ok(pixels1[0][0] > .43); |
| 32 | assert.ok(pixels1[0][0] < .45); |
| 33 | assert.equal(pixels1.length, image1.height); |
| 34 | assert.equal(pixels1[0].length, image1.width); |
| 35 | assert.ok(pixels2[0][0] > .82); |
| 36 | assert.ok(pixels2[0][0] < .83); |
| 37 | assert.equal(pixels2.length, image2.height); |
| 38 | assert.equal(pixels2[0].length, image2.width); |
| 39 | |
| 40 | gpu.destroy(); |
| 41 | done(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | (typeof Image !== 'undefined' ? test : skip)('HTML Image auto', t => { |
no test coverage detected
searching dependent graphs…