Update to Magnum with windowed EGL support; better static plugin linking for Python#1861
Update to Magnum with windowed EGL support; better static plugin linking for Python#1861Skylion007 merged 9 commits intomainfrom
Conversation
The --headless option of setup.py now just disables or enables the GUI viewer and should probably eventually get renamed for clarity.
These were only a hopeful "async" crutch and got superseded by much better async shader compilation API.
Now it's there directly after `import magnum`, without having to fiddle with dlopen flags and getting it from `import habitat` instead.
|
Wow, this would remove the need for a lot of the CONDA binaries we need to build since we can actually remove --headless option. What about the GPU selection using CUDA_VISIBLE_DEVICES in CUDA mode, does that still work? Seems like it's not compiling at the moment. |
|
It does, I just messed up a define :P |
I didn't change any of this code.
|
Completely agree with @Skylion007! We should use this opportunity to simplify our multiple conda binaries. |
aclegg3
left a comment
There was a problem hiding this comment.
LGTM. We can follow-up with:
- refactor of CI conda build to remove headless variants
- refactor documentation to clarify role of "headless" build
|
Before I merge, can you explicitly confirm that the GUI viewer, now running on EGL instead of GLX, works for you on Linux? This is quite a significant change and I don't want to be a build-breaker :) |
Confirm the C++ viewer works for me. |
This smells like corrupted memory. Some return_value_policy probably not handled correctly in the magnum-bindings perhaps (@mosra)? |
|
@mosra Looked through the new python bindings, had some minor performance nits: mosra/magnum-bindings#16 |
|
There isn't really anything in this PR that would introduce any new bindings executed in this case, so this looks rather strange. @aclegg3 if you change the new Unfortunately I won't be able to look into this myself until I have a non-broken Linux machine again (hopefully Monday?). |
|
Now that I can, I rebuilt all my everything with If you have time, can you try with the disabled option and/or give me the crash backtrace? Cross-confirming if the python viewer crashes/works on a different machine would be useful as well (@Skylion007? thank you), to rule out system-specific issues. |
I re-tried this with the current version, no custom setup, and everything is working as expected now. 🎉 |
|
Great, let's merge this. |
|
Oh? No crashes? EGL just working? That whole nightmare, just gone? Amazing!! I'm too afraid to press the merge button myself, please do that for me 😅 |
Motivation and Context
A bugreport I received last week resulted in a nice cleanup of platform-dependent GL context creation, conincidentally also fixing something we've been talking about last Thursday:
MAGNUM_TARGET_EGLoption, replacingMAGNUM_TARGET_HEADLESS. It's because EGL is no longer just for headless (or GLES) use cases, but can now also be used to create GL context in the windowed GLFW (or SDL) apps.--headlessoption ofsetup.pythus now only enables or disables the GUI viewer, nothing else. It should probably get renamed to something better, but I didn't want to break everything for everyone, so I didn't. (I also forgot most of what I knew about Habitat's buildsystem, and I don't know anything about Conda or Python packaging, so I don't feel competent enough to do such changes.)Apart from that, this introduces a new & cleaner way of linking static plugins to Magnum's binaries:
The
StbTrueTypeFontplugin is now linked directly to the Magnum Python module via a newMAGNUM_PYTHON_BINDINGS_STATIC_PLUGINSoption, resolving the text rendering TODO from Use Magnum's builtin text rendering instead of ImGui; expose it in Python #1853. Thus it's enough to justimport magnumto have the plugin available frommagnum.text.FontManager, no need to fiddle with any dlopen flags anymore.In a similar spirit, the Basis Compression Tool could be replaced by adding just the following to
src/cmake/dependencies.cmake, getting rid of the CMake 3.13 requirement:Let me know if you want that change as well -- I didn't do that to avoid breaking existing workflows, the
magnum-imageconverterexecutable would no longer be insrc/tools/imageconverterafter that.And, the same could be used to build an in-tree version of the
magnum-scenecoverterutility equipped with all needed plugins so you can have the asset processing capabilities directly inside Habitat instead of using my prebuilt binaries. On the other hand, this would serve maybe a 1% use case, while adding an ever-growing list of large dependencies (some of which might not even be possible to build as CMake subprojects).Regarding the glTF conversion / export I'm working, this brings some more bits (~2kLOC of additions for
magnum-sceneconverter, in particular), but the final piece that brings everything together is still being cooked. But again, unless you'd like to have it integrated directly in Habitat as shown above, it'll get to you in a form of prebuilt binaries.Finally, recently Magnum also received a contribution allowing parallel GL shader compilation. If used correctly, it allows the driver to spread shader compilation over more CPU cores instead of going sequentially. It's mainly useful on the web on Windows, where ANGLE performs time-consuming GLSL -> HLSL / DXIL transpiling. But it's not really a problem with native GL on Linux / macOS, so I only adapted the code to API deprecations related to this feature, without actually doing anything to enable async compilation.
How Has This Been Tested
I might have missed something in the build scripts and CI setups here, please point that out if something feels fishy. Oh and any additional testing is welcome, especially from people using the
--headlessbuilds. Thanks!