(mode)
| 152 | }); |
| 153 | |
| 154 | function cpuWithTexturesArray3WithSinglePrecision(mode) { |
| 155 | const gpu = new GPU({ mode }); |
| 156 | const kernel = gpu.createKernel(function() { |
| 157 | return [this.thread.x, this.thread.x, this.thread.x]; |
| 158 | }, { |
| 159 | output: [2], |
| 160 | pipeline: true, |
| 161 | precision: 'single', |
| 162 | }); |
| 163 | const texture = kernel(); |
| 164 | assert.ok(texture.toArray); |
| 165 | assert.deepEqual(texture.toArray().map(value => Array.from(value)), [[0,0,0], [1,1,1]]); |
| 166 | const cpu = new GPU({ mode: 'cpu' }); |
| 167 | const cpuKernel = cpu.createKernel(function(v) { |
| 168 | return v[this.thread.x]; |
| 169 | }, { output: [2] }); |
| 170 | assert.notOk(cpuKernel.kernel.textureCache); |
| 171 | const result = cpuKernel(texture); |
| 172 | assert.ok(cpuKernel.kernel.textureCache); |
| 173 | assert.deepEqual(result.map(value => Array.from(value)), [[0,0,0], [1,1,1]]); |
| 174 | let calledTwice = false; |
| 175 | texture.toArray = () => { |
| 176 | calledTwice = true; |
| 177 | }; |
| 178 | assert.deepEqual(cpuKernel(texture).map(value => Array.from(value)), [[0,0,0], [1,1,1]]); |
| 179 | assert.equal(calledTwice, false); |
| 180 | gpu.destroy(); |
| 181 | } |
| 182 | |
| 183 | (GPU.isGPUSupported && GPU.isSinglePrecisionSupported ? test : skip)('Array(3) with single precision auto', () => { |
| 184 | cpuWithTexturesArray3WithSinglePrecision(); |
no test coverage detected
searching dependent graphs…