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

Function cpuWithTexturesArray2WithSinglePrecision

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

Source from the content-addressed store, hash-verified

103});
104
105function cpuWithTexturesArray2WithSinglePrecision(mode) {
106 const gpu = new GPU({ mode });
107 const kernel = gpu.createKernel(function() {
108 return [this.thread.x, this.thread.x];
109 }, {
110 output: [2],
111 pipeline: true,
112 precision: 'single',
113 });
114 const texture = kernel();
115 assert.ok(texture.toArray);
116 assert.deepEqual(texture.toArray().map(value => Array.from(value)), [[0,0], [1,1]]);
117 const cpu = new GPU({ mode: 'cpu' });
118 const cpuKernel = cpu.createKernel(function(v) {
119 return v[this.thread.x];
120 }, { output: [2] });
121 assert.notOk(cpuKernel.kernel.textureCache);
122 const result = cpuKernel(texture);
123 assert.ok(cpuKernel.kernel.textureCache);
124 assert.deepEqual(result.map(value => Array.from(value)), [[0,0], [1,1]]);
125 let calledTwice = false;
126 texture.toArray = () => {
127 calledTwice = true;
128 };
129 assert.deepEqual(cpuKernel(texture).map(value => Array.from(value)), [[0,0], [1,1]]);
130 assert.equal(calledTwice, false);
131 gpu.destroy();
132}
133
134(GPU.isGPUSupported && GPU.isSinglePrecisionSupported ? test : skip)('Array(2) with single precision auto', () => {
135 cpuWithTexturesArray2WithSinglePrecision();

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…