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

Function cpuWithTexturesArray3WithSinglePrecision

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

Source from the content-addressed store, hash-verified

152});
153
154function 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();

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…