(mode)
| 103 | }); |
| 104 | |
| 105 | function cpuWithTexturesArray2WithSinglePrecision(mode) { |
| 106 | const gpu = new GPU({ mode }); |
| 107 | const kernel = gpu.createKernel(function() { |
| 108 | return [this.thread.x, this.thread.x]; |
| 109 | }, { |
| 110 | output: [2], |
| 111 | pipeline: true, |
| 112 | precision: 'single', |
| 113 | }); |
| 114 | const texture = kernel(); |
| 115 | assert.ok(texture.toArray); |
| 116 | assert.deepEqual(texture.toArray().map(value => Array.from(value)), [[0,0], [1,1]]); |
| 117 | const cpu = new GPU({ mode: 'cpu' }); |
| 118 | const cpuKernel = cpu.createKernel(function(v) { |
| 119 | return v[this.thread.x]; |
| 120 | }, { output: [2] }); |
| 121 | assert.notOk(cpuKernel.kernel.textureCache); |
| 122 | const result = cpuKernel(texture); |
| 123 | assert.ok(cpuKernel.kernel.textureCache); |
| 124 | assert.deepEqual(result.map(value => Array.from(value)), [[0,0], [1,1]]); |
| 125 | let calledTwice = false; |
| 126 | texture.toArray = () => { |
| 127 | calledTwice = true; |
| 128 | }; |
| 129 | assert.deepEqual(cpuKernel(texture).map(value => Array.from(value)), [[0,0], [1,1]]); |
| 130 | assert.equal(calledTwice, false); |
| 131 | gpu.destroy(); |
| 132 | } |
| 133 | |
| 134 | (GPU.isGPUSupported && GPU.isSinglePrecisionSupported ? test : skip)('Array(2) with single precision auto', () => { |
| 135 | cpuWithTexturesArray2WithSinglePrecision(); |
no test coverage detected
searching dependent graphs…