decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 09:25

Hi, our app has a feature to render objects as lines, when add more lines the performance is slow down, is there any way to optimize it? Thanks.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 11:09

Are you using Noesis 3.1, or is this still with 3.0? In 3.1 we added support for faster DrawLine (and others) in DrawingContext.
Are those lines changing per frame?
 
decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 11:24

We using Noesis 3.1 with DrawLine. The lines may changing position by interactive with mouse every frame.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 11:31

And I guess you are already using a precreated Pen for drawing all those lines, not creating new Pens (and Brushes) every frame, right?
 
decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 11:55

Yes, we are not create pens or brushes every frame.
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 12:23

Does it improve if you use DrawRectangle instead?
 
decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 12:51

We combine some lines to a geometry and use drawGeometry for render, drawGeometry is slower than drawLine.
Actually the lines are wireframe of objects project to 2d canvas, we cannot use drawRectangle , but we'll try it.
 
decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 14:30

We have a scene with more than 50000 lines, if you have interest the attachment file contains the data we dump from our app. Each line of the file present the start point and end point of one line.
lines test data.
As we can't upload zip file as attachment, we give a link to download it, if you can't download it please tell us, thanks.
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to optimize performance using DrawingContext to draw 10000 lines?

31 Aug 2021, 15:54

In comparison with 3.0, the performance of OnRender in 3.1 is much better (for example, there are no allocations) but there is still a lot of room for improvement and many things we couldn't finish on time. We will be improving this in successive versions. Also make sure, PPAA is disabled on the node to improve performance.

There is still an alternative (also available in 3.0), you can use MeshGeometry and fill the buffers manually. Could you try it?

We also have plans to expose this in form of
DrawMesh(const Point* vertices, const uint16_t* indices)
as part of the interface of DrawingContext.
 
decai
Topic Author
Posts: 54
Joined: 06 Jul 2016, 18:19

Re: How to optimize performance using DrawingContext to draw 10000 lines?

02 Sep 2021, 09:37

We tested StreamGeometry, if we did not update geometry every frame the performance is OK, but if update geometry data every frame it slower than drawLines.

We did not make draw MeshGeometry with DrawingContenxt::DrawGeometry work well.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 38 guests