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

Function testImmutableMappedKernelTextureRecycling

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

Source from the content-addressed store, hash-verified

69});
70
71function testImmutableMappedKernelTextureRecycling(precision, mode) {
72 const gpu = new GPU({ mode });
73 function oneOff(value) {
74 return value;
75 }
76 const kernel = gpu.createKernelMap({
77 oneOffValue: oneOff
78 },function(value1, value2) {
79 oneOff(value2[0] - 1);
80 return value1[0] + 1;
81 }, {
82 output: [1],
83 pipeline: true,
84 immutable: true,
85 precision,
86 });
87 let map = kernel([0], [11]);
88 const newTextureSpy = sinon.spy(kernel.texture.constructor.prototype, 'newTexture');
89 for (let i = 0; i < 10; i++) {
90 let lastResults = map;
91 map = kernel(map.result, map.oneOffValue);
92 lastResults.result.delete();
93 lastResults.oneOffValue.delete();
94 }
95 assert.deepEqual(map.result.toArray(), new Float32Array([11]));
96 assert.deepEqual(map.oneOffValue.toArray(), new Float32Array([0]));
97 assert.equal(newTextureSpy.callCount, 2);
98 assert.equal(gpu.kernels.length, 2);
99 newTextureSpy.restore();
100 gpu.destroy();
101}
102
103test('immutable single precision mapped kernel auto', () => {
104 testImmutableMappedKernelTextureRecycling('single')

Callers 1

recycling.jsFile · 0.85

Calls 6

createKernelMapMethod · 0.95
destroyMethod · 0.95
oneOffFunction · 0.85
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…