Recent

Author Topic: ThorVG - test (lightweight vector graphics engine)  (Read 3609 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 1118
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #30 on: February 11, 2026, 11:28:52 am »
Many Apologies Hermet.

Just love the way ThorVG renders and animates.

elkhalafy

  • New member
  • *
  • Posts: 7
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #31 on: February 12, 2026, 07:11:39 am »
I looking for this library ported to Lazarus, but it's C++ or you already fully ported to FPC

Thank you

Antek

  • New Member
  • *
  • Posts: 11
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #32 on: February 12, 2026, 12:52:35 pm »
I tested the project provided by @Boleeman.
It just worked on win11 64bit.
But the cpu usage is (very) high. One core is running with nearly 100%, with given "driving.json" and 25fps.
I think this is because of sofware(cpu) rendering:
Code: Pascal  [Select][+][-]
  1. tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_SMART_RENDER);
  2.  tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S);

I don't know how to use opengl rendering backend.
Code: Pascal  [Select][+][-]
  1. tvgCanvas := tvg_glcanvas_create( TVG_ENGINE_OPTION_DEFAULT);

Code: Pascal  [Select][+][-]
  1. tvg_glcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), ......

But I think hw rendering is crucial for apps when using animations (heavily).

Great work!




 

Zvoni

  • Hero Member
  • *****
  • Posts: 3294
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #33 on: February 12, 2026, 01:29:05 pm »
*snip*
But the cpu usage is (very) high. One core is running with nearly 100%, with given "driving.json" and 25fps.
I think this is because of sofware(cpu) rendering:
Code: Pascal  [Select][+][-]
  1. tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_SMART_RENDER);
  2.  tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S);
tvg_swcanvas_create --> have a guess, what the "sw" is standing for

Quote
I don't know how to use opengl rendering backend.
Code: Pascal  [Select][+][-]
  1. tvgCanvas := tvg_glcanvas_create( TVG_ENGINE_OPTION_DEFAULT);

Code: Pascal  [Select][+][-]
  1. tvg_glcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), ......

But I think hw rendering is crucial for apps when using animations (heavily).

Great work!


https://www.thorvg.org/post/thorvg-v1-0-a-new-generation-released
Scroll down to D. Performance

I see a "Renderer" with the following Entries
CPU (SW)
GPU (GL)

And don't you know it: there is a "tvg_glcanvas_create" (as you found out)
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #34 on: February 12, 2026, 04:53:12 pm »
@Antek
For OpenGL, you probably need to create a context. I haven't worked with OpenGL before. You either need to study examples of working with OpenGL from Lazarus and ThorVG yourself, or wait until someone adapts the examples

SW animation can be accelerated; at least 50% is lost in the depths of LCL when rendering Bitmap (I'm talking about Windows; in other widget sets, everything may be different; in general, you need to adapt the rendering everywhere for minimal overhead)
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #35 on: February 12, 2026, 04:58:52 pm »
@Antek
Also, change this to this
Code: Diff  [Select][+][-]
  1. - ...tvg_engine_init(whatever);
  2. + ...tvg_engine_init(1);
It took a lot of load off my CPU
Looks like a ThorVG bug?
I may seem rude - please don't take it personally

Boleeman

  • Hero Member
  • *****
  • Posts: 1118
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #36 on: February 13, 2026, 08:37:20 am »
My previous compiled DLL just had only sw enabled and not GL.
I went back and recompiled the dll with GL enabled. Attached is a slightly larger new GL enabled thorvg-1.dll DLL.


I also tried to enable the wg mode rasterizer (which uses GPU) but that option was rejected (my Acer A4 laptop has a GPU, saw this by Ctrl + Shift + Esc and went to the Performance tab). Not sure why it was rejected when compiling the dll?

Perhaps someone can try the GL mode to see if it now works with the newly compiled DLL?
« Last Edit: February 13, 2026, 08:55:12 am by Boleeman »

Zvoni

  • Hero Member
  • *****
  • Posts: 3294
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #37 on: February 13, 2026, 09:43:58 am »
My previous compiled DLL just had only sw enabled and not GL.
I went back and recompiled the dll with GL enabled. Attached is a slightly larger new GL enabled thorvg-1.dll DLL.


I also tried to enable the wg mode rasterizer (which uses GPU) but that option was rejected (my Acer A4 laptop has a GPU, saw this by Ctrl + Shift + Esc and went to the Performance tab). Not sure why it was rejected when compiling the dll?

Perhaps someone can try the GL mode to see if it now works with the newly compiled DLL?

Acc. to their website, wg is not fully supported (experimental?)
https://www.thorvg.org/native-apis
Go to Classes - Class List - tvg - wgcanvas
Quote
Detailed Description

A class for the rendering graphic elements with a WebGPU raster engine.

Warning
    Please do not use it. This class is not fully supported yet.
at least as of v 0.15
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Boleeman

  • Hero Member
  • *****
  • Posts: 1118
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #38 on: February 13, 2026, 10:04:51 am »
Thanks Zvoni for explaining why that wg mode did not work.

I also enabled Enable CPU Vectorization(SIMD) in the GL enabled thorvg-1.dll so hopefully thorvg should render more efficiently.

ALLIGATOR's suggestion of using tvg_engine_init(1); reduced the load of my AMD CPU to 18 to 21% rather than the high 90% that I was seeing before.


« Last Edit: February 13, 2026, 10:10:23 am by Boleeman »

Zvoni

  • Hero Member
  • *****
  • Posts: 3294
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #39 on: February 13, 2026, 10:11:52 am »
Thanks Zvoni for explaining why that wg mode did not work.

I also enabled Enable CPU Vectorization(SIMD) in the GL enabled thorvg-1.dll so hopefully thorvg should render more efficiently.

ALLIGATOR's suggestion of using tvg_engine_init(1); reduced the load of my AMD CPU to 18 to 21% rather than the high 90% that I was seeing before.
As far as i understood the docs: https://www.thorvg.org/native-tutorial
tvg_engine_init(x);
the "x" is for "Count of WorkerThreads", soooooo...... ?

IIRC, there are some Pascal-Routines to determine Number of CPU's the Program runs on,
so maybe your Computer just doesn't like you spawning 4 additional threads on its AMD
« Last Edit: February 13, 2026, 10:18:08 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #40 on: February 13, 2026, 11:42:18 am »
As far as i understood the docs: https://www.thorvg.org/native-tutorial
tvg_engine_init(x);
the "x" is for "Count of WorkerThreads", soooooo...... ?

Yes, but it didn't seem to affect the FPS at all.
I have 1 - 2.5% load on 12 cores for Lottie car animation
With a different value, it was 90% of 12 cores, which is unthinkable for car animation

Therefore, I still lean towards the idea that this is some kind of bug in ThorVG (or I misunderstood something)
I may seem rude - please don't take it personally

Boleeman

  • Hero Member
  • *****
  • Posts: 1118
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #41 on: February 13, 2026, 01:47:56 pm »
Was anyone able to make a GL animation sample?

« Last Edit: February 13, 2026, 08:49:24 pm by Boleeman »

LeP

  • Full Member
  • ***
  • Posts: 197
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #42 on: February 13, 2026, 03:07:25 pm »
Yes, but it didn't seem to affect the FPS at all.
I have 1 - 2.5% load on 12 cores for Lottie car animation
With a different value, it was 90% of 12 cores, which is unthinkable for car animation

Therefore, I still lean towards the idea that this is some kind of bug in ThorVG (or I misunderstood something)
I tried some values form 0 to max core count of my PC (INTEL family 14) and with 0 I have a 99% of load, with values more than 1 (so 2,3,4, ....) the load increases progressively up to approximately 25%, while with a value of 1 the load remains between 1% and 2%
I will try with OpenGL ...

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #43 on: February 14, 2026, 04:55:46 am »
Was anyone able to make a GL animation sample?

I just want to mention again
that with one core in tvg_engine_init, there is a heavy load (under Windows) also from the internal logic of LCL. If we switch to WinAPI, I expect the load to be reduced by half
I may seem rude - please don't take it personally

Antek

  • New Member
  • *
  • Posts: 11
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #44 on: February 14, 2026, 12:35:09 pm »
@alligator , @boleeman

I tested : tvg_engine_init(x)
case (1) : 0-1% cpu usage
case >1: ~ x* 5% cpu usage
amd cpu.

I don't know how to use opengl. So I can't test.
Best.
 

 

TinyPortal © 2005-2018