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
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 »

OficineRobotica wrote: Fri Jul 03, 2020 6:28 am
testASM3.FCStd
I've tried to reproduce your steps but for me it doesn't freeze, I can click on the tree and select. I have Ryzen desktop with AMD GPU but not APU.
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Better support of AMD GPU/APU on Windows

Post by OficineRobotica »

czinehuba wrote: Fri Jul 03, 2020 1:54 pm I've tried to reproduce your steps but for me it doesn't freeze, I can click on the tree and select. I have Ryzen desktop with AMD GPU but not APU.
Thank you for your feedback. This is getting hard to pin point.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
Rene
Posts: 35
Joined: Sun Mar 08, 2015 6:32 pm

Re: Better support of AMD GPU/APU on Windows

Post by Rene »

AMD CPU, 5700XT, W7

- switched to assembly3 workbench
- selected the highlighted face only and added a "PlaneAlignment" constraint
- sometimes can click around treeview for few seconds and then I get irrecoverable freeze
- F5 and get the error message about needing two faces
- click something in the tree -> irrecoverable freeze

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21300 +2367 (Git)
Build type: Release
Branch: LinkStage3
Hash: daf93f78cc3809ec0b63f8da8ee9002750f5f169
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Estonian/Estonia (et_EE)
stuff
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: Thu Jul 02, 2020 7:30 am 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.
Sure. Because there is really no way of telling whether the mouse is paused for actually picking or something else. So even with the timer, the picking may kick in at some undesirable moment, for example, right before the user wants to rotate the view. BTW, the picking is not active while you drag the mouse. The real solution is to improve the overall picking efficiency, which I already did.

realthunder wrote: Tue Jun 30, 2020 12:42 am 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 ?
The criteria of which level of detail to use shouldn't be based on model hierarchy, but instead, based on its view projection size, and Coin3D does just that. So in theory a developer can change the assembly coin scene to add a LOD node and using a box for low level of details. But to make this feature usable for end user requires a lot more work.
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
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Post by realthunder »

OficineRobotica wrote: Fri Jul 03, 2020 6:28 am -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.
So it is graphics related? That's very unexpected. Maybe we can find out where it stucks. Please start the AppImage in a terminal using command line. And then open your system's task manager to find the FreeCAD process (which is named exactly as 'FreeCAD') and remember its PID, which is just a integer number. Then make FreeCAD freeze. Open another terminal. Type the following command, replacing PID with the PID number of FreeCAD. And this should cause FreeCAD to crash and print out its stack trace in the first terminal. Please post the stack trace here.

Code: Select all

kill -ABRT PID
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
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Better support of AMD GPU/APU on Windows

Post by OficineRobotica »

realthunder wrote: Sat Jul 04, 2020 4:06 am Type the following command, replacing PID with the PID number of FreeCAD. And this should cause FreeCAD to crash and print out its stack trace in the first terminal. Please post the stack trace here.
Ha hah @realthunder. I knew you are a hero. Given the number of amd apu powered laptops that is hitting the market at a good price point lately this is worth looking in to. Thank you.

Stack trace:

Code: Select all

Traceback (most recent call last):
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/assembly.py", line 2399, in execute
    self.getElements(True)
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/assembly.py", line 2444, in getElements
    Constraint.check(obj,elementInfo,True)
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/constraint.py", line 498, in check
    mcs.getType(tp).check(elements,checkCount)
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/constraint.py", line 1073, in check
    'elements'.format(cls.getName()))
<class 'RuntimeError'>: Constraint "PlaneAlignment" requires at least two elements
Recompute failed! Please check report view.
46.070473 <asm3.main> assembly.py(3608): solver exception when auto recompute
Traceback (most recent call last):
  File "<string>", line 519, in _catch
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/solver.py", line 416, in solve
    return _solve(*args,**kargs)
  File "/tmp/.mount_FreeCAXEPk9E/usr/Mod/asm3/freecad/asm3/solver.py", line 382, in _solve
    'Failed to recompute {}'.format(objName(assembly)))
RuntimeError: Failed to recompute testASM3#Assembly

Received signal 6
#0 0x7fd3cb66294e <unknown>
#1 0x7fd3cb662dfa <unknown>
#2 0x7fd3cb663345 <unknown>
#3 0x7fd44b16af20 <unknown>
#4 0x7fd44d08f578 App::FeaturePythonPyT<>::__setattro()
#5 0x7fd44d52a3d0 PyObject_SetAttr
#6 0x7fd44d3a50ef _PyEval_EvalFrameDefault
#7 0x7fd44d3a9380 function_code_fastcall
#8 0x7fd44d48148f _PyFunction_FastCallDict
#9 0x7fd44d48330e _PyObject_Call_Prepend
#10 0x7fd44d481898 PyObject_Call
#11 0x7fd44d3a59ae _PyEval_EvalFrameDefault
#12 0x7fd44d55b00f _PyEval_EvalCodeWithName
#13 0x7fd44d4810e0 _PyFunction_FastCallKeywords
#14 0x7fd44d3aa116 call_function.lto_priv.1542
#15 0x7fd44d3a3cb9 _PyEval_EvalFrameDefault
#16 0x7fd44d55b00f _PyEval_EvalCodeWithName
#17 0x7fd44d4810e0 _PyFunction_FastCallKeywords
#18 0x7fd44d3aa116 call_function.lto_priv.1542
#19 0x7fd44d3a3cb9 _PyEval_EvalFrameDefault
#20 0x7fd44d55b00f _PyEval_EvalCodeWithName
#21 0x7fd44d4810e0 _PyFunction_FastCallKeywords
#22 0x7fd44d3aa116 call_function.lto_priv.1542
#23 0x7fd44d3a3cb9 _PyEval_EvalFrameDefault
#24 0x7fd44d3a9380 function_code_fastcall
#25 0x7fd44d48148f _PyFunction_FastCallDict
#26 0x7fd44d48330e _PyObject_Call_Prepend
#27 0x7fd44d481898 PyObject_Call
#28 0x7fd44dfb9e10 Gui::SelectionObserverPython::setPreselection()
#29 0x7fd44dfb84e6 Gui::SelectionObserver::_onSelectionChanged()
#30 0x7fd44dcc46dc boost::signals2::detail::signal_impl<>::operator()()
#31 0x7fd44dfbb256 Gui::SelectionSingleton::notify()
#32 0x7fd44dfbbee4 Gui::SelectionSingleton::setPreselect()
#33 0x7fd44dcc6871 Gui::TreeWidget::onPreSelectTimer()
#34 0x7fd44b6e2cbc QMetaObject::activate()
#35 0x7fd44b6e9cf7 QTimer::timeout()
#36 0x7fd44b6e9ebb QTimer::timerEvent()
#37 0x7fd44b6e16d2 QObject::event()
#38 0x7fd44bee888e QApplicationPrivate::notify_helper()
#39 0x7fd44beee551 QApplication::notify()
#40 0x7fd44daf1b79 Gui::GUIApplication::notify()
#41 0x7fd44b6cc6f8 QCoreApplication::notifyInternal2()
#42 0x7fd44b6fb06d QTimerInfoList::activateTimers()
#43 0x7fd44b6fb757 <unknown>
#44 0x7fd44b6fb775 <unknown>
#45 0x7fd447aeb63b g_main_context_dispatch
#46 0x7fd447aeb881 g_main_context_iterate.isra.23
#47 0x7fd447aeb90e g_main_context_iteration
#48 0x7fd44b6fb91d QEventDispatcherGlib::processEvents()
#49 0x7fd44b6c921b QEventLoop::exec()
#50 0x7fd44b6ccfab QCoreApplication::exec()
#51 0x7fd44da5beb3 Gui::Application::runApplication()
#52 0x5576209177cd main
#53 0x7fd44b14db97 __libc_start_main
#54 0x55762091851f <unknown>
  r8: 0000000000000000  r9: 0000000000000000 r10: 0000000000000000 r11: 00007fd44b2e8c40
 r12: 00007fd3c6a341e0 r13: 0000557623af3580 r14: 00005576227ab660 r15: 0000557626c73b58
  di: 00007fff74b171b0  si: 000055762274d010  bp: 0000557626c73b50  bx: 0000557626c73b58
  dx: 000055762274d010  ax: 0000000000000000  cx: 0000000000000000  sp: 00007fff74b17440
  ip: 00007fd44d08f578 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


Some more observations:
-the freeze happens strangely only when inside assembly3 workbench
-I just noticed that, in the case of assemblies, if an error occurs because of a constraint, that constraint is "higlited" in the tree(it is selected). If I click in a blank space of the 3d view so the offending selected item in the tree gets unselected I can avoid the freeze.
-I started experiencing these freezes when I wanted to rebuild the cnc with asm3.While inside the workbench I had the impresion of random fresses because I opened files of components modeled with a older version of FC(still 0.19). After recompute if any error was generated, automatically some offending item in the tree would get selected. Going starit to the tree would freese FC. So my guess is that it is related to a error of any kind in the report view combined with a selected item in the tree. Not strictly related to some solver/asm3 error.
Rene wrote: Fri Jul 03, 2020 5:07 pm AMD CPU, 5700XT, W7

- click something in the tree -> irrecoverable freeze
Thank you for triyng this out. For now, if you need to avoid this freeze when some error occurs just click In a blank space in the 3dView so the Item in the tree gets unselected. That would get FC out of the "pre freeze" state. Then you can click the tree witbought problems.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Better support of AMD GPU/APU on Windows

Post by realthunder »

OficineRobotica wrote: Sat Jul 04, 2020 5:38 am Ha hah @realthunder. I knew you are a hero. Given the number of amd apu powered laptops that is hitting the market at a good price point lately this is worth looking in to. Thank you.
Yep, the stack trace points me to the right direction. Please make a new clone of asm3 in your user directory and try. It has nothing to do with platform differences. The problem only shows up when SelectionOnTop is disabled, which activates the auto element visibility logic, i.e. auto show an originally invisible Element when mouse is over. And this logic is flawed causing an infinite recursion. It should be fixed now.
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
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Better support of AMD GPU/APU on Windows

Post by OficineRobotica »

realthunder wrote: Sat Jul 04, 2020 1:32 pm It should be fixed now.
Works flawlessly. Thank you. With this you really sped up my workflow. I can't use FC master because of the lack of shadows :lol:
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
koin3D
Posts: 20
Joined: Sat Jun 27, 2020 6:20 pm

Re: Better support of AMD GPU/APU on Windows

Post by koin3D »

vocx wrote: Sat Jun 27, 2020 9:11 pm
koin3D wrote: Sat Jun 27, 2020 6:53 pm ...
I tested it quickly with FreeCAD 0.18.4, on Windows 10, and it worked well
Test with 0.19.
Released a new version, 1.3.5, that works well with FreeCAD 0.19 (See my first post on this thread)

https://github.com/YvesBoyadjian/glintercept/releases
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 »

realthunder wrote: Sat Jul 04, 2020 3:55 am BTW, the picking is not active while you drag the mouse.
what do you mean by that ? When I move the mouse over a model, the relevant things (faces, edges ...) are highlighted: this is pre-selection highlighting, and when I set it to OFF in the preferences then it disappears, and the overall 3D move is much smoother. So, in addition to this ON/OFF option, would it be possible to add the option to have a DELAY: the pre-selection is very practical, having it completely OFF is a hindrance, so a delay (even if not optimal, I understand, but may-be easier to implement) could be a good compromise between practicality/performance/complexity

realthunder wrote: Tue Jun 30, 2020 12:42 am
Large scenes come mostly with nested assemblies (assemblies of sub-assemblies and sub-sub-assemblies)
The criteria of which level of detail to use shouldn't be based on model hierarchy, but instead, based on its view projection size, and Coin3D does just that. So in theory a developer can change the assembly coin scene to add a LOD node and using a box for low level of details. But to make this feature usable for end user requires a lot more work.
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".
try the Assembly4 workbench for FreCAD — tutorials here and here
Post Reply