thorvg icon indicating copy to clipboard operation
thorvg copied to clipboard

engines: support direct injection mode

Open hermet opened this issue 1 month ago • 3 comments

Currently, WebGL and WebGPU support rendering via RTT (render-to-texture). We can also support direct injection with appropriate context management. This integration could improve rendering performance on target platforms. Make this an optional mode so users can choose the integration method based on their needs and environments. Basically, ThorVG has considered to support this with the Canvas target() API.

It's good to begin.

Image

hermet avatar Nov 11 '25 13:11 hermet

On native machines, we can have direct FBO injection now. However, it's just a POC waiting for fine-tuning, such as MSAA, color space, and so on.

Comparison

Image In the original version, we need to render an extra FBO to a texture and then draw it as a rectangle. Image

wenjieshen avatar Nov 19 '25 09:11 wenjieshen

@wenjieshen what do you think at performance?

hermet avatar Nov 19 '25 15:11 hermet

@wenjieshen what do you think at performance?

In the edge case, for example, a 4K resolution canvas with simple animation can experience a 3x speedup through direct rendering. It represents an ideal value, but I haven't aligned the quality of results between the two approaches.

Image Image

wenjieshen avatar Nov 20 '25 03:11 wenjieshen