← Back to team overview

kicad-developers team mailing list archive

Re: Kicad's way of drawing filled zones


Hi Tomasz,

This is an interesting challenge!

Did you consider other approaches apart from the ones you listed?

I have no full knowledge how GAL is rendering so maybe some of my suggestions may not make sense.

I believe GAL is already doing some cache of the layers using textures.
It may not be possible to get a full buffer resolution of the board ( eg memory limitation? )
but could be possible to implement some kind of techniques used on game engines?
For instance: trying to render just the visible part of the board ( culling ) or on the case on render the full board, implement some kind of "level of detail" to render a less accurate version ? ( eg as you pointed the vias could be a special case and simplified while on distance )

Out of curiosity, is 3D viewer able to render that board? :P
Would be possible to share that Victor-s project or where we can get it?

Mario Luzeiro

From: Kicad-developers <kicad-developers-bounces+mrluzeiro=ua.pt@xxxxxxxxxxxxxxxxxxx> on behalf of Tomasz Wlostowski <tomasz.wlostowski@xxxxxxx>
Sent: 10 May 2019 17:33
To: Kicad Developers
Subject: [Kicad-developers] Kicad's way of drawing filled zones


I've been recently playing with Victor's huge 32-layer PCB design and
trying to improve the performance of pcbnew for larger designs. This
board causes even pretty decent PCs to crash/render glitches due to
pcbnew's enormous VBO (Vertex Buffer) memory consumption.

It turns out it's caused by the way KiCad renders filled zones:
- the inside of a zone is drawn/plotted as a filled polygon with 0-width
boundary. This one not a problem - we already triangulate the polygons
and I recently developed a patch for the OpenGL GAL that allows reusing
vertices of triangulated polys in the VBO/Index buffer to further reduce
memory footprint.
- the thick outline is drawn with rounded segments with the width =
minimum width of the polygon. Since we don't have arcs in polygons, each
of round features (e.g. vias) surrounded by a zone gets a ton of tiny
segments in the polygon outline. Each rounded segment in OpenGL is
composed of 2 triangles, hence 6 vertices (that can't be reused...). For
Victor's board it means 1 GB (sic!) of the VBO goes for outlines of the
polygons alone. Disabling the outline drawing makes the renderer work
smooth again.

I've been experimenting with some ways to fix this:
- generating the thick outline strokes using a Geometry Shader (which
means bumping up GL 3.0+), which means farewell to many Linux/older
integrated Graphics users.
- caching a triangulated polygon which is a boolean sum of the filled
inside and the thick stroked outline. This takes a lot of time (~2
minutes for Victor's design) to load and still takes quite a bit of VBO
memory. Another downside is that the polygons are not fully WYSIWYG
(outline segments have true rounded corners, while the corners of the
displayed shape would be approximated with line segments).
- change the way KiCad handles filled zones to calculate the (stroke +
inside) boolean sum during zone filling process. It means changes to the
plotting/GAL/3D code, but no changes to the file format. We'll also be
forced to inform the users that they have to refill the zones if they
read a file generated by an older KiCad version.

Which solution would you prefer?

Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Follow ups