• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / luma.gl / 25682229234

11 May 2026 04:12PM UTC coverage: 74.906% (+0.2%) from 74.662%
25682229234

push

github

web-flow
feat(gpgpu): add module for generic data processing (#2594)

5759 of 8643 branches covered (66.63%)

Branch coverage included in aggregate %.

379 of 457 new or added lines in 26 files covered. (82.93%)

12659 of 15945 relevant lines covered (79.39%)

847.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
/modules/gpgpu/src/utils/buffer-pool.ts
1
// luma.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import {Device, Buffer} from '@luma.gl/core';
6

7
class BufferPool {
8
  overAlloc: number = 2;
3✔
9
  poolSize: number = 100;
3✔
10

11
  private bufferPools: Map<Device, Buffer[]>;
12

13
  constructor() {
14
    this.bufferPools = new Map();
3✔
15
  }
16

17
  createOrReuse(device: Device, byteLength: number): Buffer {
18
    const pool = this.bufferPools.get(device);
78✔
19
    const i = pool ? pool.findIndex(b => b.byteLength >= byteLength) : -1;
78✔
20
    if (i < 0) {
78✔
21
      return device.createBuffer({
26✔
22
        usage: Buffer.VERTEX | Buffer.STORAGE | Buffer.COPY_DST | Buffer.COPY_SRC,
23
        byteLength: byteLength * this.overAlloc
24
      });
25
    }
26
    const [result] = pool!.splice(i, 1);
52✔
27
    return result;
52✔
28
  }
29

30
  recycle(buffer: Buffer) {
31
    const device = buffer.device;
75✔
32
    if (!this.bufferPools.has(device)) {
75✔
33
      this.bufferPools.set(device, []);
6✔
34
    }
35
    const pool = this.bufferPools.get(device)!;
75✔
36
    // Sort buffers by increasing size
37
    const i = pool.findIndex(b => b.byteLength > buffer.byteLength);
88✔
38
    if (i < 0) {
75✔
39
      pool.push(buffer);
66✔
40
    } else {
41
      pool.splice(i, 0, buffer);
9✔
42
    }
43
    while (this.poolSize && pool.length > this.poolSize) {
75✔
44
      // Drop the smallest one
NEW
45
      pool.shift()!.destroy();
×
46
    }
47
  }
48
}
49

50
export const bufferPool = new BufferPool();
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc