(mode)
| 4 | describe('features: CPU with Textures'); |
| 5 | |
| 6 | function cpuWithTexturesNumberWithSinglePrecision(mode) { |
| 7 | const gpu = new GPU({ mode }); |
| 8 | const kernel = gpu.createKernel(function() { |
| 9 | return this.thread.x; |
| 10 | }, { |
| 11 | output: [2], |
| 12 | pipeline: true, |
| 13 | precision: 'single', |
| 14 | }); |
| 15 | const texture = kernel(); |
| 16 | assert.ok(texture.toArray); |
| 17 | assert.deepEqual(Array.from(texture.toArray()), [0, 1]); |
| 18 | const cpu = new GPU({ mode: 'cpu' }); |
| 19 | const cpuKernel = cpu.createKernel(function(v) { |
| 20 | return v[this.thread.x]; |
| 21 | }, { output: [2] }); |
| 22 | assert.notOk(cpuKernel.kernel.textureCache); |
| 23 | const result = cpuKernel(texture); |
| 24 | assert.ok(cpuKernel.kernel.textureCache); |
| 25 | assert.deepEqual(Array.from(result), [0, 1]); |
| 26 | let calledTwice = false; |
| 27 | texture.toArray = () => { |
| 28 | calledTwice = true; |
| 29 | }; |
| 30 | assert.deepEqual(Array.from(cpuKernel(texture)), [0, 1]); |
| 31 | assert.equal(calledTwice, false); |
| 32 | gpu.destroy(); |
| 33 | } |
| 34 | |
| 35 | (GPU.isGPUSupported && GPU.isSinglePrecisionSupported ? test : skip)('number with single precision auto', () => { |
| 36 | cpuWithTexturesNumberWithSinglePrecision(); |
no test coverage detected
searching dependent graphs…