summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/stress/device/bind_group_allocation.spec.ts
blob: 5d428f3edbce10ae055a5a1f83acbf0a5a5c8e14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
export const description = `
Stress tests for allocation of GPUBindGroup objects through GPUDevice.
`;

import { makeTestGroup } from '../../common/framework/test_group.js';
import { GPUTest } from '../../webgpu/gpu_test.js';

export const g = makeTestGroup(GPUTest);

g.test('coexisting')
  .desc(`Tests allocation of many coexisting GPUBindGroup objects.`)
  .fn(t => {
    const kNumGroups = 1_000_000;
    const buffer = t.device.createBuffer({
      size: 64,
      usage: GPUBufferUsage.STORAGE,
    });
    const layout = t.device.createBindGroupLayout({
      entries: [
        {
          binding: 0,
          visibility: GPUShaderStage.COMPUTE,
          buffer: { type: 'storage' },
        },
      ],
    });
    const bindGroups = [];
    for (let i = 0; i < kNumGroups; ++i) {
      bindGroups.push(
        t.device.createBindGroup({
          layout,
          entries: [{ binding: 0, resource: { buffer } }],
        })
      );
    }
  });

g.test('continuous')
  .desc(
    `Tests allocation and implicit GC of many GPUBindGroup objects over time.
Objects are sequentially created and dropped for GC over a very large number of
iterations.`
  )
  .fn(t => {
    const kNumGroups = 5_000_000;
    const buffer = t.device.createBuffer({
      size: 64,
      usage: GPUBufferUsage.STORAGE,
    });
    const layout = t.device.createBindGroupLayout({
      entries: [
        {
          binding: 0,
          visibility: GPUShaderStage.COMPUTE,
          buffer: { type: 'storage' },
        },
      ],
    });
    for (let i = 0; i < kNumGroups; ++i) {
      t.device.createBindGroup({
        layout,
        entries: [{ binding: 0, resource: { buffer } }],
      });
    }
  });