From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../tests/cts/checkout/src/stress/queue/README.txt | 1 + .../cts/checkout/src/stress/queue/submit.spec.ts | 102 +++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 dom/webgpu/tests/cts/checkout/src/stress/queue/README.txt create mode 100644 dom/webgpu/tests/cts/checkout/src/stress/queue/submit.spec.ts (limited to 'dom/webgpu/tests/cts/checkout/src/stress/queue') diff --git a/dom/webgpu/tests/cts/checkout/src/stress/queue/README.txt b/dom/webgpu/tests/cts/checkout/src/stress/queue/README.txt new file mode 100644 index 0000000000..adb4ec40ce --- /dev/null +++ b/dom/webgpu/tests/cts/checkout/src/stress/queue/README.txt @@ -0,0 +1 @@ +Stress tests covering GPUQueue usage. diff --git a/dom/webgpu/tests/cts/checkout/src/stress/queue/submit.spec.ts b/dom/webgpu/tests/cts/checkout/src/stress/queue/submit.spec.ts new file mode 100644 index 0000000000..e1551727e2 --- /dev/null +++ b/dom/webgpu/tests/cts/checkout/src/stress/queue/submit.spec.ts @@ -0,0 +1,102 @@ +export const description = ` +Stress tests for command submission to GPUQueue objects. +`; + +import { makeTestGroup } from '../../common/framework/test_group.js'; +import { iterRange } from '../../common/util/util.js'; +import { GPUTest } from '../../webgpu/gpu_test.js'; + +export const g = makeTestGroup(GPUTest); + +g.test('huge_command_buffer') + .desc( + `Tests submission of huge command buffers to a GPUQueue. Huge buffers are +encoded by chaining together long sequences of compute passes, with expected +results verified at the end of the test.` + ) + .fn(async t => { + const kNumElements = 64; + const data = new Uint32Array([...iterRange(kNumElements, x => x)]); + const buffer = t.makeBufferWithContents(data, GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC); + const pipeline = t.device.createComputePipeline({ + layout: 'auto', + compute: { + module: t.device.createShaderModule({ + code: ` + struct Buffer { data: array, }; + @group(0) @binding(0) var buffer: Buffer; + @compute @workgroup_size(1) fn main( + @builtin(global_invocation_id) id: vec3) { + buffer.data[id.x] = buffer.data[id.x] + 1u; + } + `, + }), + entryPoint: 'main', + }, + }); + const bindGroup = t.device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [{ binding: 0, resource: { buffer } }], + }); + const encoder = t.device.createCommandEncoder(); + const kNumIterations = 500_000; + for (let i = 0; i < kNumIterations; ++i) { + const pass = encoder.beginComputePass(); + pass.setPipeline(pipeline); + pass.setBindGroup(0, bindGroup); + pass.dispatchWorkgroups(kNumElements); + pass.end(); + } + t.device.queue.submit([encoder.finish()]); + t.expectGPUBufferValuesEqual( + buffer, + new Uint32Array([...iterRange(kNumElements, x => x + kNumIterations)]) + ); + }); + +g.test('many_command_buffers') + .desc( + `Tests submission of a huge number of command buffers to a GPUQueue by a single +submit() call.` + ) + .fn(async t => { + const kNumElements = 64; + const data = new Uint32Array([...iterRange(kNumElements, x => x)]); + const buffer = t.makeBufferWithContents(data, GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC); + const pipeline = t.device.createComputePipeline({ + layout: 'auto', + compute: { + module: t.device.createShaderModule({ + code: ` + struct Buffer { data: array, }; + @group(0) @binding(0) var buffer: Buffer; + @compute @workgroup_size(1) fn main( + @builtin(global_invocation_id) id: vec3) { + buffer.data[id.x] = buffer.data[id.x] + 1u; + } + `, + }), + entryPoint: 'main', + }, + }); + const bindGroup = t.device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [{ binding: 0, resource: { buffer } }], + }); + const kNumIterations = 500_000; + const buffers = []; + for (let i = 0; i < kNumIterations; ++i) { + const encoder = t.device.createCommandEncoder(); + const pass = encoder.beginComputePass(); + pass.setPipeline(pipeline); + pass.setBindGroup(0, bindGroup); + pass.dispatchWorkgroups(kNumElements); + pass.end(); + buffers.push(encoder.finish()); + } + t.device.queue.submit(buffers); + t.expectGPUBufferValuesEqual( + buffer, + new Uint32Array([...iterRange(kNumElements, x => x + kNumIterations)]) + ); + }); -- cgit v1.2.3