bind_group_allocation.spec.ts (1703B)
1 export const description = ` 2 Stress tests for allocation of GPUBindGroup objects through GPUDevice. 3 `; 4 5 import { makeTestGroup } from '../../common/framework/test_group.js'; 6 import { GPUTest } from '../../webgpu/gpu_test.js'; 7 8 export const g = makeTestGroup(GPUTest); 9 10 g.test('coexisting') 11 .desc(`Tests allocation of many coexisting GPUBindGroup objects.`) 12 .fn(t => { 13 const kNumGroups = 1_000_000; 14 const buffer = t.createBufferTracked({ 15 size: 64, 16 usage: GPUBufferUsage.STORAGE, 17 }); 18 const layout = t.device.createBindGroupLayout({ 19 entries: [ 20 { 21 binding: 0, 22 visibility: GPUShaderStage.COMPUTE, 23 buffer: { type: 'storage' }, 24 }, 25 ], 26 }); 27 const bindGroups = []; 28 for (let i = 0; i < kNumGroups; ++i) { 29 bindGroups.push( 30 t.device.createBindGroup({ 31 layout, 32 entries: [{ binding: 0, resource: { buffer } }], 33 }) 34 ); 35 } 36 }); 37 38 g.test('continuous') 39 .desc( 40 `Tests allocation and implicit GC of many GPUBindGroup objects over time. 41 Objects are sequentially created and dropped for GC over a very large number of 42 iterations.` 43 ) 44 .fn(t => { 45 const kNumGroups = 5_000_000; 46 const buffer = t.createBufferTracked({ 47 size: 64, 48 usage: GPUBufferUsage.STORAGE, 49 }); 50 const layout = t.device.createBindGroupLayout({ 51 entries: [ 52 { 53 binding: 0, 54 visibility: GPUShaderStage.COMPUTE, 55 buffer: { type: 'storage' }, 56 }, 57 ], 58 }); 59 for (let i = 0; i < kNumGroups; ++i) { 60 t.device.createBindGroup({ 61 layout, 62 entries: [{ binding: 0, resource: { buffer } }], 63 }); 64 } 65 });