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!
koin3D
Posts: 20
Joined: Sat Jun 27, 2020 6:20 pm

Re: Better support of AMD GPU/APU on Windows

Post by koin3D »

Zolko wrote: Sun Jul 05, 2020 12:18 pm OK, I understand. But this will quite soon become the next bottleneck for FreeCAD. The question whether FreeCAD is up to the level of other (commercial) CAD systems pops-up frequently here, and if this problem is not solved the answer will be "no".
At least for your example, it is not a problem of "Level Of Detail", nor "Culling" . The VRAM consumption of your model is about 1 GB, which is acceptable. The percentage of occupation of GPU is quite low also.

1) The picking is slow, (Action when you move the mouse over the 3D view, and the brick under the pointer becomes highlighted), which should not be the case with 300 parts.

2) When I select the "Model" node, under "asm_Garden" node, and after the whole scene has become green, drawing time in the 3D view is catastrophic (nearly freezing), even if you are in "OpenInventor" mode, and just want to rotate the view.

3) If I demand the "Scene Inspector" view, it is also very long before I have a response (Completely abnormal, there is not so much informations in this view).

In all cases, it is the CPU occupation that is at 100% of one thread.

It is clearly a case of algorithm optimization, maybe in the "SoFCSelectionRoot" and/or "SoFCSelection" nodes, for problems 1 and 2.

Debugging those performance problems is pretty easy : On Windows, just run this example project with a debug version of FreeCAD (or a release version with PDB files) with Visual Studio, and click on the "Break All" button while waiting for a lengthy action, and you will see what the program was doing.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Post by Zolko »

koin3D wrote: Sun Jul 05, 2020 4:42 pm In all cases, it is the CPU occupation that is at 100% of one thread.
...
It is clearly a case of algorithm optimization, maybe in the "SoFCSelectionRoot" and/or "SoFCSelection" nodes, for problems 1 and 2.
...
Debugging those performance problems is pretty easy
Thank-you for this investigation. Unfortunately, I don't have the programming skills to solve any of this, so I'll hope that some other people will pick up on it.
try the Assembly4 workbench for FreCAD — tutorials here and here
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Post by realthunder »

Zolko wrote: Mon Jul 06, 2020 10:51 am Thank-you for this investigation. Unfortunately, I don't have the programming skills to solve any of this, so I'll hope that some other people will pick up on it.
It seems that you have missed the fact that I have already stated in the beginning that most of the problems are fixed in my branch? Have you tried my release image?

phpBB [video]


koin3D wrote: Sun Jul 05, 2020 4:42 pm 3) If I demand the "Scene Inspector" view, it is also very long before I have a response (Completely abnormal, there is not so much informations in this view).
I have done some optimization of the scene inspector with my latest release, to populate the tree node on demand. Previously, the tree is populated in full before display.

Debugging those performance problems is pretty easy : On Windows, just run this example project with a debug version of FreeCAD (or a release version with PDB files) with Visual Studio, and click on the "Break All" button while waiting for a lengthy action, and you will see what the program was doing.
I have done that, and no it is not that simple. There are multiple factors causing the slow down. Even if I have fixed most of the problems in my branch, I can't easily identify which part is the major factor.
Try Assembly3 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
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Post by Zolko »

koin3D wrote: Sun Jul 05, 2020 4:42 pm 2) When I select the "Model" node, under "asm_Garden" node, and after the whole scene has become green, drawing time in the 3D view is catastrophic (nearly freezing), even if you are in "OpenInventor" mode, and just want to rotate the view.
yes, this is what I also see, also with my other models. It also happens with large STEP imports, therefore not something Assembly4 or App::Link related.

It is barely usable, and certainly not something up to the task of a serious 3D CAD system. I understand that until now very few people have tested FreeCAD with large models / scenes, therefore may-be it was not seen/measured before. Did someone else try to load large models into FreeCAD ?

realthunder wrote: Tue Jul 07, 2020 1:10 am It seems that you have missed the fact that I have already stated in the beginning that most of the problems are fixed in my branch? Have you tried my release image?
not yet, I have very little extra time currently, but will try
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
czinehuba
Posts: 160
Joined: Mon Oct 15, 2018 4:59 am
Location: UK
Contact:

Re: Better support of AMD GPU/APU on Windows

Post by czinehuba »

Zolko wrote: Tue Jul 07, 2020 1:20 pm Did someone else try to load large models into FreeCAD ?
Yes Not the most exhaustive assembly, but has quite a lot of parts bolted connections ect. And I've tried with many more and it does work similarly. No performance issue.
indexer main assy_FC.png
indexer main assy_FC.png (188.68 KiB) Viewed 1614 times
It work really smoothly. I haven't put on the FPS counter, but I had issues before similar to yours when loading larger assemblies. Performance was very poor and sluggish.

But in the last few releases it is good.
Also show's how a cylinder is replaced with polygon for better performance.
indexer main assy_FC_details.png
indexer main assy_FC_details.png (108.76 KiB) Viewed 1614 times

OS: Arch Linux (GNOME/gnome)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21300 +2418 (Git) AppImage
Build type: Release
Branch: LinkStage3
Hash: 1bf376e6abb6824991a2f8f6da1f7eefd1df9ce4
Python version: 3.7.6
Qt version: 5.12.1
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Better support of AMD GPU/APU on Windows

Post by Zolko »

czinehuba wrote: Tue Jul 07, 2020 1:44 pm
Zolko wrote: Tue Jul 07, 2020 1:20 pm Did someone else try to load large models into FreeCAD ?
Yes Not the most exhaustive assembly, but has quite a lot of parts bolted connections ect. And I've tried with many more and it does work similarly. No performance issue.
nice. would you have the possibility to do a STEP export and upload it somewhere so I can test it ? Or the native file/zip ? May-be I'm doing something really stupid.
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
czinehuba
Posts: 160
Joined: Mon Oct 15, 2018 4:59 am
Location: UK
Contact:

Re: Better support of AMD GPU/APU on Windows

Post by czinehuba »

Unfortunately I can't, as these are client files. Sorry.
I will try to look at some open source design..

I rember. NASA
https://opensourcerover.jpl.nasa.gov/#!/home

Has an open source rover. You could use that.

Will try to find some more open source designs.
koin3D
Posts: 20
Joined: Sat Jun 27, 2020 6:20 pm

Re: Better support of AMD GPU/APU on Windows

Post by koin3D »

Zolko wrote: Tue Jul 07, 2020 1:20 pm
koin3D wrote: Sun Jul 05, 2020 4:42 pm 2) When I select the "Model" node, under "asm_Garden" node, and after the whole scene has become green, drawing time in the 3D view is catastrophic (nearly freezing), even if you are in "OpenInventor" mode, and just want to rotate the view.
yes, this is what I also see, also with my other models. It also happens with large STEP imports, therefore not something Assembly4 or App::Link related.

It is barely usable, and certainly not something up to the task of a serious 3D CAD system. I understand that until now very few people have tested FreeCAD with large models / scenes, therefore may-be it was not seen/measured before. Did someone else try to load large models into FreeCAD ?

realthunder wrote: Tue Jul 07, 2020 1:10 am It seems that you have missed the fact that I have already stated in the beginning that most of the problems are fixed in my branch? Have you tried my release image?
not yet, I have very little extra time currently, but will try
For problem 2), I think I found an improvement :
In method "void SoBrepFaceSet::renderSelection(SoGLRenderAction *action, SelContextPtr ctx, bool push)",
there is a call to renderShape() method. (Line 1382 in SoBRepFaceSet.cpp)
I simply changed the second parameter, "hasVBO", from "false" to "true" :

Code: Select all

		// YB
        renderShape(action, /*false*/true, static_cast<const SoGLCoordinateElement*>(coords), &(cindices[start]), length,
            &(pindices[id]), numparts, normals_s, nindices_s, &mb, mindices, &tb, tindices, nbind, mbind, doTextures?1:0);
It improves rendering speed a lot when a general selection is active

@realthunder : Saw your video, this is a big improvement of the version I tested, nice :)
Last edited by koin3D on Tue Jul 07, 2020 11:50 pm, edited 1 time in total.
otoien
Posts: 87
Joined: Sun Aug 13, 2017 2:38 am

Re: Better support of AMD GPU/APU on Windows

Post by otoien »

Under edit -preferences-display tab, ticking on "Use OpenGL VBO" increased performance a lot for me. I discovered this when I got a new work computer (Thinkpad X1 extreme). In the beginning, a very complicated model I am working on (about 460MB) that only gave me about 1 fps on my old T440p when viewing the whole model suddenly was up at 15-20 fps on the new one (the main CPU itself is only good for 1.5 -2x the performance increase). I thought this was a lot of speed improvement even with the stronger Graphics adapter (Nvidia GeForce GTX 1650 vs GeForce GT 730M). Then I noticed this option somehow was selected on the new computer, while not on the old one. After ticking that on, the old computer is up at 5-6 fps. (I have not followed the whole thread so apologize if this is irrelevant to the AMD GPU of the thread title, just responding to the last message.)
(The version I tested on was slightly older than this one but similar on both computers:)
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21777 (Git)
Build type: Release
Branch: master
Hash: 478823b90967a9b76796c64f74b8e3a5440150fa
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
koin3D
Posts: 20
Joined: Sat Jun 27, 2020 6:20 pm

Re: Better support of AMD GPU/APU on Windows

Post by koin3D »

otoien wrote: Tue Jul 07, 2020 10:41 pm Under edit -preferences-display tab, ticking on "Use OpenGL VBO" increased performance a lot for me. I discovered this when I got a new work computer (Thinkpad X1 extreme). In the beginning, a very complicated model I am working on (about 460MB) that only gave me about 1 fps on my old T440p when viewing the whole model suddenly was up at 15-20 fps on the new one (the main CPU itself is only good for 1.5 -2x the performance increase). I thought this was a lot of speed improvement even with the stronger Graphics adapter Nvidia GeForce GTX 1650 vs GeForce GT 730M. Then I noticed this option somehow was selected on the new computer, while not on the old one. After ticking that on, the old computer is up at 5-6 fps. (I have not followed the whole thread so apologize if this is irrelevant to the AMD GPU of the thread title, just responding to the last message.)
(The version I tested on was slightly older than this one but similar on both computers:)
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21777 (Git)
Build type: Release
Branch: master
Hash: 478823b90967a9b76796c64f74b8e3a5440150fa
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
Maybe this option should be removed from next release of FreeCAD, as VBO was introduced in 2003, with OpenGL 1.5 :
https://www.khronos.org/opengl/wiki/History_of_OpenGL
Today, 100 % of OpenGL implementations support this feature, even software ones.
In my opinion, keeping this option in the GUI is not relevant anymore.
Post Reply