MCPcopy Create free account
hub / github.com/gpujs/gpu.js / testImmutableKernelTextureRecycling

Function testImmutableKernelTextureRecycling

test/internal/recycling.js:7–29  ·  view source on GitHub ↗
(precision, mode)

Source from the content-addressed store, hash-verified

5describe('internal: recycling');
6
7function testImmutableKernelTextureRecycling(precision, mode) {
8 const gpu = new GPU({ mode });
9 const kernel = gpu.createKernel(function(v) {
10 return v[0] + 1;
11 }, {
12 output: [1],
13 pipeline: true,
14 immutable: true,
15 precision,
16 });
17 let result = kernel([0]);
18 const newTextureSpy = sinon.spy(kernel.texture.constructor.prototype, 'newTexture');
19 for (let i = 0; i < 10; i++) {
20 let lastResult = result;
21 result = kernel(result);
22 lastResult.delete();
23 }
24 assert.deepEqual(result.toArray(), new Float32Array([11]));
25 assert.equal(newTextureSpy.callCount, 1);
26 assert.equal(gpu.kernels.length, 2);
27 newTextureSpy.restore();
28 gpu.destroy();
29}
30
31test('immutable single precision kernel auto', () => {
32 testImmutableKernelTextureRecycling('single')

Callers 1

recycling.jsFile · 0.85

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…