Page 1 of 2
How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 09:25
by decai
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.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 11:09
by sfernandez
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?
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 11:24
by decai
We using Noesis 3.1 with DrawLine. The lines may changing position by interactive with mouse every frame.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 11:31
by sfernandez
And I guess you are already using a precreated Pen for drawing all those lines, not creating new Pens (and Brushes) every frame, right?
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 11:55
by decai
Yes, we are not create pens or brushes every frame.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 12:23
by jsantos
Does it improve if you use DrawRectangle instead?
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 12:51
by decai
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.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 14:30
by decai
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.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 31 Aug 2021, 15:54
by jsantos
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.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Posted: 02 Sep 2021, 09:37
by decai
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.