Better support of AMD GPU/APU on Windows

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Zolko
Posts: 935
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Postby Zolko » Mon Jun 29, 2020 10:54 am

koin3D wrote:
Sun Jun 28, 2020 2:29 pm
Making evolve Coin3D/Koin3D, by :
is there support for small object culling ?

What I mean is that when having large assemblies, small objects, or small features, are not seen: if the scenegraph tries to render everything, the performance could come to a halt. Imagine a ship, a car, a house, ... designed by a team in all the details: with assemblies and good organisation, it's quite easy to come to very large models very fast. If every screw of a car is rendered, there will come a point where the GPU/CPU will crawl to a halt.

I think this is called culling, or LOD (level of detail) but I don't know the precise mechanism. I could imagine that if the bounding box of a feature/part is smaller than 2 pixels (TBC), the part is not actually rendered and replaced by a square box of the same color.


For example, even with this very simple model with Lego bricks that has ~300 parts, the individual bricks have small fillets all around, which is realistic when looking closely. But in a large view, these fillets are not seen, and yet the 3D viewing and rotation is extremely slow, less than 1 fps:


Image
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
koin3D
Posts: 11
Joined: Sat Jun 27, 2020 6:20 pm

Re: Better support of AMD GPU/APU on Windows

Postby koin3D » Mon Jun 29, 2020 9:09 pm

Zolko wrote:
Mon Jun 29, 2020 10:54 am
Can you share the freecad project file used to generate the image you posted on your GitHub ? So I can see where is the optimization problem.
Yes, LOD and culling are optimization techniques, Coin3D 4 have them, but maybe FreeCAD isn't using them.
realthunder
Posts: 1591
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Postby realthunder » Tue Jun 30, 2020 12:42 am

Zolko wrote:
Mon Jun 29, 2020 10:54 am
is there support for small object culling ?
Can I have the file, too. Coin support of LOD is here. As you can see, it requires and application to provide simplified geometries, and FreeCAD doesn't have it at the moment. FreeCAD currently relies on render cache for acceleration. 300 objects shouldn't really slow down that much. I'd like to have a look at your file.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Zolko
Posts: 935
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Postby Zolko » Tue Jun 30, 2020 5:51 am

koin3D wrote:
Mon Jun 29, 2020 9:09 pm
Can you share the freecad project file used to generate the image you posted on your GitHub ?
realthunder wrote:
Tue Jun 30, 2020 12:42 am
Can I have the file, too.
It's here:

https://github.com/Zolko-123/FreeCAD_Ex ... p?raw=true

Please mind that it was made with an old version of Assembly4 so you will get a bunch of errors about ExpressionEngine, but that doesn't impact the rendering.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
carlopav
Posts: 1378
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Better support of AMD GPU/APU on Windows

Postby carlopav » Tue Jun 30, 2020 6:53 am

Posting to subscribe to the topic.
I'm really happy to see people involved in this field. Godspeed you guys!
follow my experiments on BIM modelling for architecture design
realthunder
Posts: 1591
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Postby realthunder » Wed Jul 01, 2020 4:34 am

Zolko wrote:
Tue Jun 30, 2020 5:51 am
Please mind that it was made with an old version of Assembly4 so you will get a bunch of errors about ExpressionEngine, but that doesn't impact the rendering.
First, make sure VBO is enabled (Preference -> Display -> Use OpenGL VBO). With my release image, I got 50 fps with fresh loading of your project. Once I selected a few objects, some of the render cache gets trashed, and the it drops to about 20 fps. This can be improved, but not easy. With upstream I get 10 fps on fresh load. I tried to identify what causes the difference, but couldn't find any single major factor. It is probably affected by multiple patches.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Zolko
Posts: 935
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Postby Zolko » Wed Jul 01, 2020 9:08 am

realthunder wrote:
Wed Jul 01, 2020 4:34 am
With upstream I get 10 fps on fresh load. I tried to identify what causes the difference, but couldn't find any single major factor. It is probably affected by multiple patches.
I get 1 Fps. But the worst part is when zooming and pre-selection highlighting is enabled: then it drops to 0.1 fps. When I disable preselection highlighting it's acceptable, with that its horrible: when I wildly move the mouse over the bricks, it tries to highlight them, but since the movement is too fast it can't, so it lags, and at some point it freezes, nothing is happening, I have to wait 10 seconds inactive for it to recover. I've also seen this with another large model : with lots of features/objects, moving around becomes impossible, especially when zooming at the mouse: it tries to highlight the preselection, but since that point moves during zooming and there are lots of small objects around, it can't manage.

Would it be possible to give a slight delay in this pre-selection highlighting, something like :the mouse has to be static for 0.1s (100ms TBC) before it tries to highlight objects ? Here some balance should be made between interactivity for small scenes, and usability for large ones.


realthunder wrote:
Tue Jun 30, 2020 12:42 am
Coin support of LOD is here. As you can see, it requires and application to provide simplified geometries, and FreeCAD doesn't have it at the moment.
wait, not so fast: what SolidWorks does, sometimes, is to replace a part during movement with its bounding box, this FreeCAD could do also. May-be is this worth exploring: for small (TBD) parts, replace them during 3D manipulation by their bounding box. Then, when static for >0.2s (TBD, may-be user settable in preferences) render the objects in full.

With current FreeCAD, it's simply impossible to use it with large assemblies and a medium-powered laptop (a new Dell XPS 13). We'll quite soon hit some usability wall if nothing is done here.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
realthunder
Posts: 1591
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Postby realthunder » Thu Jul 02, 2020 12:35 am

Zolko wrote:
Wed Jul 01, 2020 9:08 am
Would it be possible to give a slight delay in this pre-selection highlighting, something like :the mouse has to be static for 0.1s (100ms TBC) before it tries to highlight objects ? Here some balance should be made between interactivity for small scenes, and usability for large ones.
I have done some optimization of pre-selection in my branch, and it works well. But it is not as simple as just adding some delay. Because if the 3D picking operation is long comparing to rendering, adding delay doesn't help that much. Besides, the user may expect to see realtime coordinate change in preselection message when moving the mouse along some geometry.

realthunder wrote:
Tue Jun 30, 2020 12:42 am
wait, not so fast: what SolidWorks does, sometimes, is to replace a part during movement with its bounding box, this FreeCAD could do also. May-be is this worth exploring: for small (TBD) parts, replace them during 3D manipulation by their bounding box. Then, when static for >0.2s (TBD, may-be user settable in preferences) render the objects in full.
I never said FreeCAD can't have this feature, I just say it doesn't have it at the moment. Coin3D LOD does not have the capability to auto simplify geometry, so the application must do it. Simply replacing the geometry with its bounding box won't work well in many cases, especially with convex geometry. To do it automatically, we'll need some convex decomposition, and replace each decomposed sub-geometry with a bounding box. And additionally, we could offer user manual 'defeaturing'. All in all, it is not a simple task, but yes, it is worth doing for sure.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Zolko
Posts: 935
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Postby Zolko » Thu Jul 02, 2020 7:30 am

realthunder wrote:
Thu Jul 02, 2020 12:35 am
Zolko wrote:
Wed Jul 01, 2020 9:08 am
Would it be possible to give a slight delay in this pre-selection highlighting, something like :the mouse has to be static for 0.1s (100ms TBC) before it tries to highlight objects ?
it is not as simple as just adding some delay. Because if the 3D picking operation is long comparing to rendering, adding delay doesn't help that much.
Are you sure ? It seems to me that if the pre-selection is slow, then not doing it while moving and rotating (and zooming) should improve the overall user experience. With a mouse it is actually impossible to do both at the same time (with a 3D-space thingy you can), so if the scenegraph did disable selection during movement wouldn't be noticed I think.

realthunder wrote:
Tue Jun 30, 2020 12:42 am
wait, not so fast: what SolidWorks does, sometimes, is to replace a part during movement with its bounding box, this FreeCAD could do also. May-be is this worth exploring: for small (TBD) parts, replace them during 3D manipulation by their bounding box. Then, when static for >0.2s (TBD, may-be user settable in preferences) render the objects in full.
Simply replacing the geometry with its bounding box won't work well in many cases, especially with convex geometry. To do it automatically, we'll need some convex decomposition, and replace each decomposed sub-geometry with a bounding box.
If it's too complex than it might break more than it is worth, so if anything I'd try some very basic thing.

Large scenes come mostly with nested assemblies (assemblies of sub-assemblies and sub-sub-assemblies). So what if, for example, all parts (and linked parts) beyond nesting level N (N=2 or 3) would be displayed by their bounding box ? You would want the first levels of the assembly to be displayed or else you wouldn't know how the scene is rotated, but everything below level 2 or 3 will be details that you will want to see while static. N could be user-settable and those with powerful hardware might want to disable this entirely. How difficult would it be to implement something like this ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
OficineRobotica
Posts: 192
Joined: Thu Feb 21, 2019 8:17 am

Re: Better support of AMD GPU/APU on Windows

Postby OficineRobotica » Fri Jul 03, 2020 6:28 am

koin3D wrote:
Sat Jun 27, 2020 6:53 pm
Would you be so kind to test this file for me to see if you get the same freeze of the interface? I am getting the feeling that I am hitting a hardware dependent bug and I really don't want to waste @realthunder's time any more, at least until we pinpoint the culprit of this strange behavior.

Background:
- I experience a complete application freeze when using the linkstage3 branch if using the assembly3 workbench, force a solver error and clicking the tree in any way
- if using the latest 0.19 appimage I can't reproduce the bug so it must be something introduced with the shadow or the overlay interface(just my guess)
- being on linux I went ahead and deleted the .config/FreeCad and ./FreeCad folders from my home so the appimage started barenaked. In that case after the solver error it was enough to hover the tree for one tooltip to show to get the freeze of the interface.
-I have access to 2 machines. My laptop with amd/vega8 apu and a tower pc with a i3 6600 gtx1050. Strangely the freezes occur only on the amd side. Even realthunder couldn't reproduce on his machine.
-you have got a interface freeze also when asking for the "scene inspector"

freeze_asm3_1.jpeg
freeze_asm3_1.jpeg (369.65 KiB) Viewed 151 times
To reproduce:
-switch to assembly3 workbench
-select the highlighted face only and add a "PlaneAlignment" constraint
-there will be a error message saying that it needs 2 planar surfaces
-click something in the tree -> irrecoverable freeze

Of course you can test on windows but if someone with a amd apu can test on linux too it can help narrow a bit the search for the cause.
Thank you so much
testASM3.FCStd
(69.2 KiB) Downloaded 9 times