(precision, mode)
| 69 | }); |
| 70 | |
| 71 | function testImmutableMappedKernelTextureRecycling(precision, mode) { |
| 72 | const gpu = new GPU({ mode }); |
| 73 | function oneOff(value) { |
| 74 | return value; |
| 75 | } |
| 76 | const kernel = gpu.createKernelMap({ |
| 77 | oneOffValue: oneOff |
| 78 | },function(value1, value2) { |
| 79 | oneOff(value2[0] - 1); |
| 80 | return value1[0] + 1; |
| 81 | }, { |
| 82 | output: [1], |
| 83 | pipeline: true, |
| 84 | immutable: true, |
| 85 | precision, |
| 86 | }); |
| 87 | let map = kernel([0], [11]); |
| 88 | const newTextureSpy = sinon.spy(kernel.texture.constructor.prototype, 'newTexture'); |
| 89 | for (let i = 0; i < 10; i++) { |
| 90 | let lastResults = map; |
| 91 | map = kernel(map.result, map.oneOffValue); |
| 92 | lastResults.result.delete(); |
| 93 | lastResults.oneOffValue.delete(); |
| 94 | } |
| 95 | assert.deepEqual(map.result.toArray(), new Float32Array([11])); |
| 96 | assert.deepEqual(map.oneOffValue.toArray(), new Float32Array([0])); |
| 97 | assert.equal(newTextureSpy.callCount, 2); |
| 98 | assert.equal(gpu.kernels.length, 2); |
| 99 | newTextureSpy.restore(); |
| 100 | gpu.destroy(); |
| 101 | } |
| 102 | |
| 103 | test('immutable single precision mapped kernel auto', () => { |
| 104 | testImmutableMappedKernelTextureRecycling('single') |
no test coverage detected
searching dependent graphs…