-
Notifications
You must be signed in to change notification settings - Fork 51
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 Metal support for the Ogre2 Render Engine #461
Comments
Using Metal in the ign-rendering examplesThe examples have been modified to allow the Metal render system to be set using an extra command line option: ./simple_demo ogre2 metal The StatusRunning with Metal, correct behaviour
Running with Metal, incorrect behaviour
Not working with Metal Not yet ported
Not suitable for Metal
(*) Example is for |
@iche033 I think the Metal support is nearly there. The main remaining issue is with the GPURays. It turns out that Metal does not support the pixel format Edit: It looks like the textures used in the two render passes in GpuRay will need to use |
I made some changes switching away from |
Thanks @iche033 .The pixel format changes solves the Metal shader compilation issue. Edit: GPU ray is now working properly on Metal. I'll commit the changes and update the task list. |
@iche033 and @darksylinc I'd appreciate your thoughts on the best approach to use Metal with QML and in particular Scene3d or its equivalent with a view to getting ign-gui and ign-gazebo fully supported on macOS. I've got a basic demo working using the scene from
I've left all the quad animation from the Qt example, and have not forced the render to update when Qt doesn't think anything has changed (so the camera is only updated when animating). One of my main concerns is getting the garbage collection / ARC policy right in the interop between objective-c and c++. The example doesn't have ARC enabled, so I suspect there is a resource leak, however if I use weak references in Ogre::MetalTextureGpu I see runtime exceptions when running in Xcode (although not from the command line cmake build). |
Is CFBridgingRetain & CFBridgingRelease available to you from C++? If so you can use that. Else you'll have to wrap those calls within some Obj C code. See Edit: Please note that OgreMetalRenderSystem.mm is compiled with ARC enabled. The rest of the files don't have to; but where your "bridge/wrap" code is defined should have ARC enabled |
Thanks @darksylinc that's good to know. |
Aside from the example To get |
Desired behaviour
Add support for the Ogre2 Metal render system when using the
ogre2
render engine and allow the choice of render system to be controlled using a plugin parameter.Alternatives considered
The alternative is to only support the GL3+ render system on all platforms. There is ongoing work to support macOS using GL3+. The proposal is that this continue in parallel for perhaps the next couple of release cycles.
Implementation suggestion
Ogre2 already supports Metal for HlmsPbs and HmlsUnlit, so the major work needed for the core material system has been done.
Outline of the tasks to implement:
Ogre2RenderEngine
to select the either GL3+ or Metal render systemsign-rendering/tree/ign-rendering5/ogre2/src/media/materials/programs
and update the materials to automatically select the correct shader for the render systemAdditional context
Apple have deprecated OpenGL for macOS. While OpenGL is still available on macOS Big Sur 11.4 it is becoming increasingly difficult to support on that platform. Upstream libraries such as Ogre2 are focussing on Metal and OpenGL > 4.2 and support for legacy OpenGL will become progressively more time consuming as these libraries advance.
macOS no longer has good tools for debugging OpenGL programs: tools such as OpenGL Profiler while available with Xcode 12.5 are no longer working correctly, alternatives such as Renderdoc are not supported on macOS. On the other hand there is very good support for debugging Metal shaders from within Xcode. This may be of benefit when developing and testing new shaders which could then be ported to OpenGL from Metal.
Links to related discussions
Detailed tasks
Set up Metal dev environment
osrf/simulation/ogre2.2.rb
.Load Metal render system
Port shaders to Metal
Update examples
The text was updated successfully, but these errors were encountered: