Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Async Batching in WebWorker #8432

@Maksims

Description

@Maksims

Batching - is an amazing technique, that enables us to create complex scenes in runtime with loads of objects, and still have reduced number of drawcalls, when used tactically with materials.
We use spatial grid with LoD's. And have to batch/re-batch in runtime, as parts of our scenes can change.

But the sync nature of batching, and the fact it runs on CPU, has a significant drawbacks, where it can lead to significant main thread locks.

We would love if batching would be a bit more simplified in terms of data access - currently it heavily relies on VertexIterator, which abstracts away the underlying data. While it brings convenience abstracting away data variability.
But it makes harder to have raw buffers, that we could do a few things with:

  1. Have a dedicated WebWorker process, that would be able to accept mesh's data, meshInstance's data and batch them in buffers. This would offload main thread, and even allow speeding up batching by running multiple WebWorkers, benefiting from today's multi-core CPUs.
  2. Explore other capabilities by using GPU for such tasks, potentially TransformFeedback on WebGL2, and Compute Shaders on WebGPU. While combining buffers together is a fast operation, transforming every vertex by world matrix - is the time consuming part, and could be performed once on the GPU.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions