Skip to content
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 to Gazebo for macOS #1225

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/cmd/cmdsim.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ Please use [GZ_SIM_RESOURCE_PATH] instead."
if options['server'] == 0 && options['gui'] == 0

if plugin.end_with? ".dylib"
puts "`gz sim` currently only works with the -s argument on macOS.
puts "On macOS `gz sim` currently only works with either the -s argument
or the -g argument, you cannot run both server and gui in one terminal.
See https://github.com/gazebosim/gz-sim/issues/44 for more info."
exit(-1)
end
Expand Down Expand Up @@ -530,12 +531,6 @@ See https://github.com/gazebosim/gz-sim/issues/44 for more info."
options['wait_gui'], options['headless-rendering'])
# Otherwise run the gui
else options['gui']
if plugin.end_with? ".dylib"
puts "`gz sim` currently only works with the -s argument on macOS.
See https://github.com/gazebosim/gz-sim/issues/44 for more info."
exit(-1)
end

ENV['RMT_PORT'] = '1501'
Importer.runGui(options['gui_config'], options['file'],
options['wait_gui'], options['render_engine_gui'])
Expand Down
2 changes: 2 additions & 0 deletions src/gui/plugins/component_inspector/Boolean.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Rectangle {
// Horizontal margins
property int margin: 5

property int tooltipDelay: 500

RowLayout {
anchors.fill: parent

Expand Down
2 changes: 2 additions & 0 deletions src/gui/plugins/modules/TypeIcon.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Image {
*/
property string entityType: ''

property int tooltipDelay: 500

/**
* Image address according to type
*/
Expand Down
3 changes: 3 additions & 0 deletions src/gui/plugins/visualize_lidar/VisualizeLidar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ GridLayout {
anchors.leftMargin: 10
anchors.rightMargin: 10

property int tooltipDelay: 500
property int tooltipTimeout: 1000

CheckBox {
Layout.alignment: Qt.AlignHCenter
id: displayVisual
Expand Down
9 changes: 9 additions & 0 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2583,11 +2583,20 @@ void RenderUtil::Init()
rendering::setPluginPaths(pluginPath.PluginPaths());

std::map<std::string, std::string> params;
#ifdef __APPLE__
// TODO(srmainwaring): implement facility for overriding the default
// graphics API in macOS, in which case there are restrictions on
// the version of OpenGL used.
params["metal"] = "1";
#else
if (this->dataPtr->useCurrentGLContext)
params["useCurrentGLContext"] = "1";
#endif

if (this->dataPtr->isHeadlessRendering)
params["headless"] = "1";
params["winID"] = this->dataPtr->winID;

this->dataPtr->engine = rendering::engine(this->dataPtr->engineName, params);
if (!this->dataPtr->engine)
{
Expand Down
23 changes: 23 additions & 0 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ void SensorsPrivate::WaitForInit()
this->renderUtil.SetBackgroundColor(*this->backgroundColor);
if (this->ambientLight)
this->renderUtil.SetAmbientLight(*this->ambientLight);
#ifndef __APPLE__
this->renderUtil.Init();
srmainwaring marked this conversation as resolved.
Show resolved Hide resolved
#else
// On macOS the render engine must be initialised on the main thread.
// See Sensors::Update.
#endif
this->scene = this->renderUtil.Scene();
this->scene->SetCameraPassCountPerGpuFlush(6u);
this->initialized = true;
Expand Down Expand Up @@ -599,6 +604,24 @@ void Sensors::Update(const UpdateInfo &_info,
{
GZ_PROFILE("Sensors::Update");
std::unique_lock<std::mutex> lock(this->dataPtr->renderMutex);

#ifdef __APPLE__
// On macOS the render engine must be initialised on the main thread.
if (!this->dataPtr->initialized &&
(_ecm.HasComponentType(components::BoundingBoxCamera::typeId) ||
_ecm.HasComponentType(components::Camera::typeId) ||
_ecm.HasComponentType(components::DepthCamera::typeId) ||
_ecm.HasComponentType(components::GpuLidar::typeId) ||
_ecm.HasComponentType(components::RgbdCamera::typeId) ||
_ecm.HasComponentType(components::ThermalCamera::typeId) ||
_ecm.HasComponentType(components::SegmentationCamera::typeId) ||
_ecm.HasComponentType(components::WideAngleCamera::typeId)))
{
igndbg << "Initialization needed" << std::endl;
this->dataPtr->renderUtil.Init();
}
#endif

if (this->dataPtr->running && this->dataPtr->initialized)
{
this->dataPtr->renderUtil.UpdateECM(_info, _ecm);
Expand Down