MCPcopy Index your code
hub / github.com/gpujs/gpu.js / cpuWithTexturesNumberWithSinglePrecision

Function cpuWithTexturesNumberWithSinglePrecision

test/features/cpu-with-textures.js:6–33  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

4describe('features: CPU with Textures');
5
6function 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();

Callers 1

Calls 4

createKernelMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
toArrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…