Skip to content

WebGPU: Stop calling setPipeline when it's the same pipeline #31065

@greggman

Description

@greggman

Description

Using the webgpu-dev-extension and checking "show redundant state settings" (version 0.0.35) shows that three.js sometimes calls setPipeline with the same pipeline it previously set. That's not an error, but depending on the number for redundant calls it can add up to at least a few percent of JS perf at least.

For example:

Image

at 795 redundant calls at 120fps that's 93400 calls per second to setPipeline that weren't needed.

Solution

In the WebGPURenderer, when encoding a pass encoder, track the last pipeline set and don't set it again if the next thing uses the same pipeline.

Alternatives

Ignore and lose perf

Additional context

https://github.com/greggman/webgpu-dev-extension?tab=readme-ov-file#show-redundant-state-setting

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions