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

Function cpuWithTexturesArray4WithSinglePrecision

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

Source from the content-addressed store, hash-verified

201});
202
203function 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();

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…