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

Function testImmutableKernelTextureDoesNotLeak

test/internal/recycling.js:229–259  ·  view source on GitHub ↗
(precision, done, mode)

Source from the content-addressed store, hash-verified

227});
228
229function testImmutableKernelTextureDoesNotLeak(precision, done, mode) {
230 const gpu = new GPU({ mode });
231 const toTexture = gpu.createKernel(function(value) {
232 return value[this.thread.x];
233 }, {
234 output: [1],
235 pipeline: true,
236 immutable: true,
237 precision,
238 });
239 const one = toTexture([1]);
240 assert.equal(one.texture._refs, 2); // one's texture will be used in two places at first, in one and toTexture.texture
241 assert.equal(toTexture.texture.texture, one.texture); // very important, a clone was mode, but not a deep clone
242 assert.notEqual(one, toTexture.texture);
243 const two = toTexture([2]);
244 assert.equal(one.texture._refs, 1); // was tracked on toTexture.texture, and deleted
245 assert.equal(toTexture.texture.texture, two.texture);
246 assert.notEqual(toTexture.texture.texture, one.texture);
247 assert.equal(two.texture._refs, 2);
248 one.delete();
249 two.delete();
250 assert.equal(one.texture._refs, 0);
251 assert.equal(two.texture._refs, 1); // still used by toTexture.texture
252 two.delete(); // already deleted
253 assert.equal(two.texture._refs, 1); // still used by toTexture
254 gpu.destroy()
255 .then(() => {
256 assert.equal(two.texture._refs, 0);
257 done();
258 });
259}
260
261test('immutable unsigned precision kernel.texture does not leak auto', t => {
262 testImmutableKernelTextureDoesNotLeak('unsigned', t.async());

Callers 1

recycling.jsFile · 0.85

Calls 3

createKernelMethod · 0.95
destroyMethod · 0.95
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…