-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin mechanism for extending render engine interfaces and objects #702
Comments
We discussed the idea of letting gz-rendering load its own plugins in #482 for making gazebo visual plugins work but opted to implement it in gz-gazebo instead. I think it's still valuable to support loading plugins in gz-rendering. The proposed implementation approach sounds good. From the use case described, it's sounds like it's different from the type of plugins in gz-gazebo or gz-gui, where the proposed gz-rendering plugins don't have standard interfaces (e.g. |
Some more detail about the use case:
There's a draft PR here with an implementation: srmainwaring/asv_wave_sim#61. It works as intended however the code needs to be refactored and simplified as most of the functionality adapted from the As an aside there is also something unusual going on with the render engine singletons. The following are called after {
auto engine = rendering::Ogre2RenderEngine::Instance();
auto graphicsAPI = engine->GraphicsAPI();
gzdbg << "Using graphicsAPI: "
<< GraphicsAPIUtils::Str(graphicsAPI) << "\n";
}
// outputs
// Using graphicsAPI: OPENGL Which is the default, but incorrect as the Metal render engine has already been initialised and loaded. {
auto engine = rendering::engine("ogre2");
auto graphicsAPI = engine->GraphicsAPI();
gzdbg << "Using graphicsAPI: "
<< GraphicsAPIUtils::Str(graphicsAPI) << "\n";
}
// outputs
// Using graphicsAPI: METAL Which is correct when using the Metal render engine. The first case is used in |
thanks for explaining the use case and how the extension plugin is implemented. So My understanding is:
that's weird. The minimal scene is created and initialized using metal backend and this happens before the extension plugin is loaded or after?
Note that I'm not exactly sure what the behavior is when the |
Yes, that's the gist of it. In step 1. it's not guaranteed that I'm wondering whether the problem with the singletons is caused by the fact that The fix is to add a #include "RenderEngine.hh"
RenderEngine::~RenderEngine() = default; |
Oh, I believe this may fix some other things I have been running in to. I'm going to open a PR with just this fix. |
Desired behaviour
Add a mechanism for external projects to extend the render engine interface and implementation.
The present render engine plugin mechanism allows external projects to add custom render engines that implement part or all of the current render engine interface, but it does not allow the interface to be extended via plugins.
For example if you wanted to add a
ForceVisual
the current approach would be to add classes to the existinggz-rendering
library and add aCreateForceVisual
method toScene
(and equivalents for each render engine implementation). It would be useful to be able to add such objects in external projects without having to change the core libraries.The use case I have in mind is for an plugin for an OceanVisual. The visual plugin requires a number of custom rendering objects that subclass from
rendering::Visual
andrendering::Geometry
. My current implementation defines these directly in the system plugin, however it turns out that on some platforms the approach is sensitive to the order in which the plugins are loaded which can result in either the render engine being improperly initialised or the loader reporting missing symbols.Alternatives considered
Define extensions directly in system plugins. This can be made to work, but is not robust and may fail on some platforms. It is also not very modular and does not enable custom rendering extensions to be easily shared.
Implementation suggestion
Add a mechanism analogous to RenderEngine, RenderEnginePlugin, RenderEngineManger that allows extension interfaces and their implementation to be defined in plugins and loaded at runtime. The extension manager should have a mechanism to check that required (render engine) dependencies are available and have been loaded before attempting to load extensions.
Additional context
I'll attempt to implement this approach in an external project (asv_wave_sim). If it works I'll factor out the extension mechanism and submit it as a PR. In the meanwhile if the team have any suggestions of recommendations on an approach that would be welcomed!
The text was updated successfully, but these errors were encountered: