Skip to content

wgpu should cache pipelines #7716

Open
@jimblandy

Description

@jimblandy

wgpu is too slow when render or compute pipelines are created repeatedly.

At present, each call to wgpu_core::global::Global::device_create_compute_pipeline results in a separate call to wgpu_hal::Device::create_compute_pipeline. Render pipelines are similar. However, the WebGPU specification says (§2.2.4 User Agent State):

... It is expected that user agents will have compilation caches for the result of expensive compilation like GPUShaderModule, GPURenderPipeline and GPUComputePipeline.

This means that applications are within their rights to assume that calling createRenderPipeline in every animation frame, with the same parameters, should be cheap.

This Firefox profile shows that the Marching Cubes demo ends up pegging the Canvas Renderer thread running DXC. The profile has other problems, like taking 270ms for every requestAnimationFrame call, but the time in DXC is responsible for the pace of calls to requestAnimationFrame being only around 1fps.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions