(mode)
| 201 | }); |
| 202 | |
| 203 | function cpuWithTexturesArray4WithSinglePrecision(mode) { |
| 204 | const gpu = new GPU({ mode }); |
| 205 | const kernel = gpu.createKernel(function() { |
| 206 | return [this.thread.x, this.thread.x, this.thread.x, this.thread.x]; |
| 207 | }, { |
| 208 | output: [2], |
| 209 | pipeline: true, |
| 210 | precision: 'single', |
| 211 | }); |
| 212 | const texture = kernel(); |
| 213 | assert.ok(texture.toArray); |
| 214 | assert.deepEqual(texture.toArray().map(value => Array.from(value)), [[0,0,0,0], [1,1,1,1]]); |
| 215 | const cpu = new GPU({ mode: 'cpu' }); |
| 216 | const cpuKernel = cpu.createKernel(function(v) { |
| 217 | return v[this.thread.x]; |
| 218 | }, { output: [2] }); |
| 219 | assert.notOk(cpuKernel.kernel.textureCache); |
| 220 | const result = cpuKernel(texture); |
| 221 | assert.ok(cpuKernel.kernel.textureCache); |
| 222 | assert.deepEqual(result.map(value => Array.from(value)), [[0,0,0,0], [1,1,1,1]]); |
| 223 | let calledTwice = false; |
| 224 | texture.toArray = () => { |
| 225 | calledTwice = true; |
| 226 | }; |
| 227 | assert.deepEqual(cpuKernel(texture).map(value => Array.from(value)), [[0,0,0,0], [1,1,1,1]]); |
| 228 | assert.equal(calledTwice, false); |
| 229 | gpu.destroy(); |
| 230 | } |
| 231 | |
| 232 | (GPU.isGPUSupported && GPU.isSinglePrecisionSupported ? test : skip)('Array(4) with single precision auto', () => { |
| 233 | cpuWithTexturesArray4WithSinglePrecision(); |
no test coverage detected
searching dependent graphs…