Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing a Dedicated Thread for the Painter Backend #595

Open
M-Adoo opened this issue May 31, 2024 · 0 comments
Open

Implementing a Dedicated Thread for the Painter Backend #595

M-Adoo opened this issue May 31, 2024 · 0 comments
Labels

Comments

@M-Adoo
Copy link
Collaborator

M-Adoo commented May 31, 2024

In our current painter architecture, the painter generates path commands and the backend renders them. These two processes are completely independent, with only a PainterResult passed from the Painter to its backend.

This separation allows us to easily parallelize the painter and its backend by using a Mutex to synchronize them with every frame.

For the GPU backend, we can leverage the GPU's parallelism in two ways:

  1. Tessellating the path into triangles, which can be a heavy task.
  2. Interacting with the GPU and awaiting its response, can be time-consuming, especially in the browser where we have to go from wasm to JS to WebGL (sometimes taking milliseconds).

By introducing a dedicated render thread, we can reduce the load on the main thread:

We use ULP to represent the tasks of the main thread, such as user interaction, layout, painting, etc.
We use SS to represent the tasks of tessellation and submission to the GPU.

main thread: ----|ULP|--|ULP|--....->
render thread: --------|SS|---|SS| --...-->

The subsequent ULP doesn't need to wait for the previous SS to finish.

@M-Adoo M-Adoo added enhancement New feature or request framework L-Easy labels May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant