Skip to content
Snippets Groups Projects
Commit 620f6838 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

rhi: use Metal when supported on macOS

Fallback to openGL if metal is not supported.

GitLab: jami-project#1413

Change-Id: Id8ac4c817d0b65243becc9963a8bba6621feaf82
parent c57f32ef
No related branches found
No related tags found
No related merge requests found
......@@ -364,7 +364,10 @@ elseif (NOT APPLE)
else() # APPLE
list(APPEND COMMON_SOURCES
${SRC_DIR}/os/macos/updatemanager.mm
${SRC_DIR}/os/macos/connectivitymonitor.mm)
${SRC_DIR}/os/macos/connectivitymonitor.mm
${SRC_DIR}/os/macos/macutils.mm)
list(APPEND COMMON_HEADERS
${SRC_DIR}/os/macos/macutils.h)
if(NOT DEFINED LRC)
if(EXISTS ${PROJECT_SOURCE_DIR}/../install/lrc)
set(LRC ${PROJECT_SOURCE_DIR}/../install/lrc)
......
......@@ -29,6 +29,9 @@
#if defined(HAS_VULKAN)
#include <QVulkanInstance>
#endif
#if defined(Q_OS_MACOS)
#include <os/macos/macutils.h>
#endif
#include <clocale>
......@@ -98,9 +101,12 @@ main(int argc, char* argv[])
auto newArgv = parseInputArgument(argc, argv, qtWebEngineChromiumFlags);
MainApplication app(argc, newArgv);
#if defined(Q_OS_MACOS)
QQuickWindow::setGraphicsApi(QSGRendererInterface::MetalRhi);
if (macutils::isMetalSupported()) {
QQuickWindow::setGraphicsApi(QSGRendererInterface::MetalRhi);
} else {
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
}
#else
if (std::invoke([] {
#if defined(HAS_VULKAN)
......
/*
* Copyright (C) 2022 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
class macutils
{
public:
static bool isMetalSupported();
};
/*
* Copyright (C) 2022 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "macutils.h"
#include <MetalKit/MetalKit.h>
bool macutils::isMetalSupported() {
return ([[MTLCopyAllDevices() autorelease] count] > 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment