From 0862e40b41bd85e51fc9e5cf4f1e623a37b6a79d Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 28 May 2019 18:01:39 -0700 Subject: [PATCH 1/6] Adding ui to debug render settings --- .../scripting/RenderScriptingInterface.cpp | 12 +++--- .../src/scripting/RenderScriptingInterface.h | 31 ++++++++++++--- .../utilities/render/luci/RenderSettings.qml | 38 +++++++++++++++++++ .../utilities/render/renderSettings.js | 7 ++++ 4 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 scripts/developer/utilities/render/luci/RenderSettings.qml create mode 100644 scripts/developer/utilities/render/renderSettings.js diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 360a75b557..14fd9c6878 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -19,24 +19,24 @@ RenderScriptingInterface* RenderScriptingInterface::getInstance() { } RenderScriptingInterface::RenderScriptingInterface() { - setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD); + setRenderMethod((RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD); setShadowsEnabled(_shadowsEnabledSetting.get()); setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); setAntialiasingEnabled(_antialiasingEnabledSetting.get()); } -QString RenderScriptingInterface::getRenderMethod() { - return (render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD; +RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { + return (RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD; } -void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { - render::Args::RenderMethod newMethod = renderMethod == FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED; +void RenderScriptingInterface::setRenderMethod(RenderScriptingInterface::RenderMethod renderMethod) { + RenderMethod newMethod = renderMethod == RenderMethod::FORWARD ? RenderMethod::FORWARD : RenderMethod::DEFERRED; if (_renderMethodSetting.get() == newMethod) { return; } if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod)); + QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(RenderScriptingInterface::RenderMethod, renderMethod)); return; } diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 329433fb60..5476ac7cbf 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -25,7 +25,7 @@ */ class RenderScriptingInterface : public QObject { Q_OBJECT - Q_PROPERTY(QString renderMethod READ getRenderMethod WRITE setRenderMethod) + Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod) Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled) Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled) Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled) @@ -35,6 +35,13 @@ public: static RenderScriptingInterface* getInstance(); + // RenderMethod enum type + enum RenderMethod { + DEFERRED = render::Args::RenderMethod::DEFERRED, + FORWARD = render::Args::RenderMethod::FORWARD, + }; + Q_ENUM(RenderMethod); + public slots: /**jsdoc * Get a config for a job by name @@ -50,16 +57,16 @@ public slots: /**jsdoc * Gets the current render method * @function Render.getRenderMethod - * @returns {string} "deferred" or "forward" + * @returns {number} "DEFERRED" or "FORWARD" */ - QString getRenderMethod(); + RenderMethod getRenderMethod(); /**jsdoc * Sets the current render method * @function Render.setRenderMethod - * @param {string} renderMethod - "deferred" or "forward" + * @param {number} renderMethod - "DEFERRED" or "FORWARD" */ - void setRenderMethod(const QString& renderMethod); + void setRenderMethod(RenderMethod renderMethod); /**jsdoc * Whether or not shadows are enabled @@ -103,6 +110,20 @@ public slots: */ void setAntialiasingEnabled(bool enabled); + /**jsdoc + * Gets the current render resolution scale + * @function Render.getRenderResolutionScale + * @returns {number} + */ +// RenderMethod getRenderMethod(); + + /**jsdoc + * Sets the current render method + * @function Render.setRenderMethod + * @param {number} renderMethod - "DEFERRED" or "FORWARD" + */ + // void setRenderMethod(RenderMethod renderMethod); + private: Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; Setting::Handle _shadowsEnabledSetting { "shadowsEnabled", true }; diff --git a/scripts/developer/utilities/render/luci/RenderSettings.qml b/scripts/developer/utilities/render/luci/RenderSettings.qml new file mode 100644 index 0000000000..13a124db26 --- /dev/null +++ b/scripts/developer/utilities/render/luci/RenderSettings.qml @@ -0,0 +1,38 @@ +// +// Render Settings.qml +// +// Created by Sam Gateau on 5/28/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +import controlsUit 1.0 as HifiControls + +import "../../lib/prop" as Prop + +Column { + anchors.fill: parent + id: theGrapchicsSettings; + + Prop.PropEnum { + label: "Render Method" + object: Render + property: "renderMethod" + enums: [ + "Deferred", + "Forward" + ] + } + + Prop.PropBool { + label: "Shadows" + object: Render + property: "shadowsEnabled" + } +} + diff --git a/scripts/developer/utilities/render/renderSettings.js b/scripts/developer/utilities/render/renderSettings.js new file mode 100644 index 0000000000..451fa798f8 --- /dev/null +++ b/scripts/developer/utilities/render/renderSettings.js @@ -0,0 +1,7 @@ +// Test key commands +var window = Desktop.createWindow(Script.resolvePath('./luci/RenderSettings.qml'), { + title: "Render Settings", + presentationMode: Desktop.PresentationMode.NATIVE, + size: {x: 350, y: 700} +}); + From aedc631c45371ff51a8d49d6889a2787e4d3fe06 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 28 May 2019 21:55:17 -0700 Subject: [PATCH 2/6] Gathering all the needed settings in one place --- .../src/scripting/PerformanceScriptingInterface.cpp | 5 +++++ .../src/scripting/PerformanceScriptingInterface.h | 3 ++- .../src/scripting/RenderScriptingInterface.cpp | 5 +++++ interface/src/scripting/RenderScriptingInterface.h | 8 ++++++++ .../utilities/render/luci/RenderSettings.qml | 13 +++++++++---- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index b1b4e62dca..b1a6fcccae 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -27,6 +27,11 @@ PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface: return (PerformanceScriptingInterface::RefreshRateProfile)qApp->getRefreshRateManager().getRefreshRateProfile(); } +QStringList PerformanceScriptingInterface::getRefreshRateProfileNames() const { + static const QStringList refreshRateProfileNames = { "Eco", "Interactive", "Realtime" }; + return refreshRateProfileNames; +} + int PerformanceScriptingInterface::getActiveRefreshRate() const { return qApp->getRefreshRateManager().getActiveRefreshRate(); } diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index 90b51d173c..2138afdc65 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -33,14 +33,15 @@ public: ~PerformanceScriptingInterface() = default; public slots: + void setRefreshRateProfile(RefreshRateProfile refreshRateProfile); RefreshRateProfile getRefreshRateProfile() const; + QStringList getRefreshRateProfileNames() const; int getActiveRefreshRate() const; RefreshRateManager::UXMode getUXMode() const; RefreshRateManager::RefreshRateRegime getRefreshRateRegime() const; - private: static std::once_flag registry_flag; }; diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 14fd9c6878..1185ca93b0 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -48,6 +48,11 @@ void RenderScriptingInterface::setRenderMethod(RenderScriptingInterface::RenderM } } +QStringList RenderScriptingInterface::getRenderMethodNames() const { + static const QStringList refrenderMethodNames = { "Deferred", "Forward" }; + return refrenderMethodNames; +} + bool RenderScriptingInterface::getShadowsEnabled() { return _shadowsEnabledSetting.get(); } diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 5476ac7cbf..907b62a465 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -68,6 +68,14 @@ public slots: */ void setRenderMethod(RenderMethod renderMethod); + /**jsdoc + * Gets the possible enum names of the RenderMethod type + * @function Render.getRenderMethodNames + * @returns [string] [ "DEFERRED", "FORWARD" ] + */ + QStringList getRenderMethodNames() const; + + /**jsdoc * Whether or not shadows are enabled * @function Render.getShadowsEnabled diff --git a/scripts/developer/utilities/render/luci/RenderSettings.qml b/scripts/developer/utilities/render/luci/RenderSettings.qml index 13a124db26..042ea3776b 100644 --- a/scripts/developer/utilities/render/luci/RenderSettings.qml +++ b/scripts/developer/utilities/render/luci/RenderSettings.qml @@ -19,14 +19,19 @@ Column { anchors.fill: parent id: theGrapchicsSettings; + Prop.PropEnum { + label: "Refresh Rate Profile" + //object: Performance + valueVarSetter: Performance.setRefreshRateProfile + valueVarGetter: Performance.getRefreshRateProfile + enums: Performance.getRefreshRateProfileNames() + } + Prop.PropEnum { label: "Render Method" object: Render property: "renderMethod" - enums: [ - "Deferred", - "Forward" - ] + enums: Render.getRenderMethodNames() } Prop.PropBool { From bf7617ea8e2393ab890421f475218774444ca569 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 29 May 2019 15:47:14 -0700 Subject: [PATCH 3/6] INtroducing the PerformanceManager --- interface/src/Application.cpp | 20 ++++++++++ interface/src/Application.h | 4 ++ interface/src/PerformanceManager.cpp | 31 ++++++++++++++ interface/src/PerformanceManager.h | 40 +++++++++++++++++++ .../PerformanceScriptingInterface.cpp | 13 ++++++ .../scripting/PerformanceScriptingInterface.h | 15 ++++++- .../scripting/RenderScriptingInterface.cpp | 2 +- .../src/scripting/RenderScriptingInterface.h | 15 +++---- 8 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 interface/src/PerformanceManager.cpp create mode 100644 interface/src/PerformanceManager.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9064c7676b..74b812aa65 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5361,6 +5361,26 @@ void Application::loadSettings() { } } + if (_firstRun.get()) { + // If this is our first run, evalute the Platform Tier and assign the matching Performance profile by default. + // A bunch of Performance, Simulation and Render settings will be set to a matching default value from this + + // Here is the mapping between pelatformTIer and performance profile + const std::array platformToPerformanceProfileMap = {{ + PerformanceManager::PerformanceProfile::MID, // platform::Profiler::UNKNOWN + PerformanceManager::PerformanceProfile::LOW, // platform::Profiler::LOW + PerformanceManager::PerformanceProfile::MID, // platform::Profiler::MID + PerformanceManager::PerformanceProfile::HIGH // platform::Profiler::HIGH + }}; + + // What is our profile? + auto platformTier = platform::Profiler::profilePlatform(); + + // Then let's assign the performance profile setting from it + getPerformanceManager().setPerformanceProfile(platformToPerformanceProfileMap[platformTier]); + + } + // finish initializing the camera, based on everything we checked above. Third person camera will be used if no settings // dictated that we should be in first person Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, isFirstPerson); diff --git a/interface/src/Application.h b/interface/src/Application.h index 837fb8eae6..2cea492d56 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -57,6 +57,7 @@ #include "gpu/Context.h" #include "LoginStateManager.h" #include "Menu.h" +#include "PerformanceManager.h" #include "RefreshRateManager.h" #include "octree/OctreePacketProcessor.h" #include "render/Engine.h" @@ -203,6 +204,8 @@ public: CompositorHelper& getApplicationCompositor() const; Overlays& getOverlays() { return _overlays; } + + PerformanceManager& getPerformanceManager() { return _performanceManager; } RefreshRateManager& getRefreshRateManager() { return _refreshRateManager; } size_t getRenderFrameCount() const { return _graphicsEngine.getRenderFrameCount(); } @@ -734,6 +737,7 @@ private: QUuid _loginDialogID; QUuid _avatarInputsBarID; LoginStateManager _loginStateManager; + PerformanceManager _performanceManager; RefreshRateManager _refreshRateManager; quint64 _lastFaceTrackerUpdate; diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp new file mode 100644 index 0000000000..fac55661b7 --- /dev/null +++ b/interface/src/PerformanceManager.cpp @@ -0,0 +1,31 @@ +// +// PerformanceManager.cpp +// interface/src/ +// +// Created by Sam Gateau on 2019-05-29. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "PerformanceManager.h" + +PerformanceManager::PerformanceManager() +{ +} + +void PerformanceManager::setPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile) { + _performanceProfileSettingLock.withWriteLock([&] { + _performanceProfileSetting.set((int)performanceProfile); + }); +} + +PerformanceManager::PerformanceProfile PerformanceManager::getPerformanceProfile() const { + PerformanceProfile profile = PerformanceProfile::MID; + + profile = (PerformanceProfile) _performanceProfileSettingLock.resultWithReadLock([&] { + return _performanceProfileSetting.get(); + }); + + return profile; +} \ No newline at end of file diff --git a/interface/src/PerformanceManager.h b/interface/src/PerformanceManager.h new file mode 100644 index 0000000000..ea24f260b8 --- /dev/null +++ b/interface/src/PerformanceManager.h @@ -0,0 +1,40 @@ +// +// PerformanceManager.h +// interface/src/ +// +// Created by Sam Gateau on 2019-05-29. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PerformanceManager_h +#define hifi_PerformanceManager_h + +#include + +#include +#include + +class PerformanceManager { +public: + enum PerformanceProfile { + LOW = 0, + MID, + HIGH, + PROFILE_COUNT + }; + + PerformanceManager(); + ~PerformanceManager() = default; + + void setPerformanceProfile(PerformanceProfile performanceProfile); + PerformanceProfile getPerformanceProfile() const; + +private: + mutable ReadWriteLockable _performanceProfileSettingLock; + Setting::Handle _performanceProfileSetting { "performanceProfile", PerformanceManager::PerformanceProfile::MID }; +}; + +#endif diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index b1a6fcccae..b948e2167c 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -19,6 +19,19 @@ PerformanceScriptingInterface::PerformanceScriptingInterface() { }); } +void PerformanceScriptingInterface::setPerformanceProfile(PerformanceProfile performanceProfile) { + qApp->getPerformanceManager().setPerformanceProfile((PerformanceManager::PerformanceProfile)performanceProfile); +} + +PerformanceScriptingInterface::PerformanceProfile PerformanceScriptingInterface::getPerformanceProfile() const { + return (PerformanceScriptingInterface::PerformanceProfile)qApp->getPerformanceManager().getPerformanceProfile(); +} + +QStringList PerformanceScriptingInterface::getPerformanceProfileNames() const { + static const QStringList performanceProfileNames = { "Low", "Mid", "High" }; + return performanceProfileNames; +} + void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) { qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile); } diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index 2138afdc65..98f9aa222b 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -14,12 +14,22 @@ #include +#include "../PerformanceManager.h" #include "../RefreshRateManager.h" class PerformanceScriptingInterface : public QObject { Q_OBJECT public: + + // PerformanceManager PerformanceProfile tri state level enums + enum PerformanceProfile { + LOW = PerformanceManager::PerformanceProfile::LOW, + MID = PerformanceManager::PerformanceProfile::MID, + HIGH = PerformanceManager::PerformanceProfile::HIGH, + }; + // Q_ENUM(PerformanceProfile) + // Must match RefreshRateManager enums enum RefreshRateProfile { ECO = RefreshRateManager::RefreshRateProfile::ECO, @@ -28,12 +38,15 @@ public: }; Q_ENUM(RefreshRateProfile) - PerformanceScriptingInterface(); ~PerformanceScriptingInterface() = default; public slots: + void setPerformanceProfile(PerformanceProfile performanceProfile); + PerformanceProfile getPerformanceProfile() const; + QStringList getPerformanceProfileNames() const; + void setRefreshRateProfile(RefreshRateProfile refreshRateProfile); RefreshRateProfile getRefreshRateProfile() const; QStringList getRefreshRateProfileNames() const; diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 1185ca93b0..085606179d 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -124,4 +124,4 @@ void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { mainViewAntialiasingConfig->setDebugFXAA(true); } } -} \ No newline at end of file +} diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 907b62a465..16608a7cb4 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -119,24 +119,25 @@ public slots: void setAntialiasingEnabled(bool enabled); /**jsdoc - * Gets the current render resolution scale - * @function Render.getRenderResolutionScale + * Gets the current viewport resolution scale + * @function Render.getViewportResolutionScale * @returns {number} */ -// RenderMethod getRenderMethod(); + // float getViewportResolutionScale(); /**jsdoc - * Sets the current render method - * @function Render.setRenderMethod - * @param {number} renderMethod - "DEFERRED" or "FORWARD" + * Sets the current viewport resolution scale + * @function Render.setViewportResolutionScale + * @param {number} resolutionScale - between epsilon and 1.0 */ - // void setRenderMethod(RenderMethod renderMethod); + // void setViewportResolutionScale(float resolutionScale); private: Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; Setting::Handle _shadowsEnabledSetting { "shadowsEnabled", true }; Setting::Handle _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false }; Setting::Handle _antialiasingEnabledSetting { "antialiasingEnabled", true }; + Setting::Handle _viewportResolutionScaleSetting{ "viewportResolutionScale", 1.0f }; }; #endif // hifi_RenderScriptingInterface_h From 48ecb4265cf3b7be2c83c5b9fe5ddd0ee25b37e4 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 29 May 2019 16:43:28 -0700 Subject: [PATCH 4/6] re declare q_enum on platformProfile --- interface/src/scripting/PerformanceScriptingInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index 98f9aa222b..a13d1bf887 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -28,7 +28,7 @@ public: MID = PerformanceManager::PerformanceProfile::MID, HIGH = PerformanceManager::PerformanceProfile::HIGH, }; - // Q_ENUM(PerformanceProfile) + Q_ENUM(PerformanceProfile) // Must match RefreshRateManager enums enum RefreshRateProfile { From a212a8a36a25ea269ea90ee6370d30d89981ddbd Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 29 May 2019 17:49:17 -0700 Subject: [PATCH 5/6] COnnect the profile tier to the performance setting and assign on first run or after reset... --- interface/src/PerformanceManager.cpp | 40 +++++++++++++++++-- interface/src/PerformanceManager.h | 3 ++ .../utilities/render/luci/RenderSettings.qml | 8 ++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index fac55661b7..2b7dc30b96 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -10,14 +10,20 @@ // #include "PerformanceManager.h" +#include "scripting/RenderScriptingInterface.h" + PerformanceManager::PerformanceManager() { } void PerformanceManager::setPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile) { - _performanceProfileSettingLock.withWriteLock([&] { - _performanceProfileSetting.set((int)performanceProfile); - }); + if (getPerformanceProfile() != performanceProfile) { + _performanceProfileSettingLock.withWriteLock([&] { + _performanceProfileSetting.set((int)performanceProfile); + }); + + applyPerformanceProfile(performanceProfile); + } } PerformanceManager::PerformanceProfile PerformanceManager::getPerformanceProfile() const { @@ -28,4 +34,30 @@ PerformanceManager::PerformanceProfile PerformanceManager::getPerformanceProfile }); return profile; -} \ No newline at end of file +} + +void PerformanceManager::applyPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile) { + + switch (performanceProfile) { + case PerformanceProfile::HIGH: + RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED); + RenderScriptingInterface::getInstance()->setShadowsEnabled(true); + qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE); + + break; + case PerformanceProfile::MID: + RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED); + RenderScriptingInterface::getInstance()->setShadowsEnabled(false); + qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE); + + break; + case PerformanceProfile::LOW: + RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::FORWARD); + RenderScriptingInterface::getInstance()->setShadowsEnabled(false); + qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO); + + break; + default: + break; + } +} diff --git a/interface/src/PerformanceManager.h b/interface/src/PerformanceManager.h index ea24f260b8..8417650aaf 100644 --- a/interface/src/PerformanceManager.h +++ b/interface/src/PerformanceManager.h @@ -35,6 +35,9 @@ public: private: mutable ReadWriteLockable _performanceProfileSettingLock; Setting::Handle _performanceProfileSetting { "performanceProfile", PerformanceManager::PerformanceProfile::MID }; + + // The concrete performance profile changes + void applyPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile); }; #endif diff --git a/scripts/developer/utilities/render/luci/RenderSettings.qml b/scripts/developer/utilities/render/luci/RenderSettings.qml index 042ea3776b..e9e3906dfe 100644 --- a/scripts/developer/utilities/render/luci/RenderSettings.qml +++ b/scripts/developer/utilities/render/luci/RenderSettings.qml @@ -19,6 +19,14 @@ Column { anchors.fill: parent id: theGrapchicsSettings; + Prop.PropEnum { + label: "Performance Profile" + //object: Performance + valueVarSetter: Performance.setPerformanceProfile + valueVarGetter: Performance.getPerformanceProfile + enums: Performance.getPerformanceProfileNames() + } + Prop.PropEnum { label: "Refresh Rate Profile" //object: Performance From b88deb52b093c05826ed2de9ca027f682265075e Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 30 May 2019 12:03:44 -0700 Subject: [PATCH 6/6] Cleaning up the interface for the Performance PRESET and the associated debug ui --- interface/src/Application.cpp | 14 ++-- interface/src/PerformanceManager.cpp | 30 ++++---- interface/src/PerformanceManager.h | 14 ++-- .../PerformanceScriptingInterface.cpp | 14 ++-- .../scripting/PerformanceScriptingInterface.h | 18 ++--- .../render/luci/PerformanceSettings.qml | 43 +++++++++++ .../utilities/render/luci/Platform.qml | 67 +++++++++++++++++ .../utilities/render/luci/RenderSettings.qml | 21 +----- .../developer/utilities/render/luci/qmldir | 6 +- .../utilities/render/performanceSetup.js | 6 ++ .../utilities/render/performanceSetup.qml | 56 ++++++++++++++ .../developer/utilities/render/platform.js | 2 +- .../developer/utilities/render/platform.qml | 75 ------------------- 13 files changed, 225 insertions(+), 141 deletions(-) create mode 100644 scripts/developer/utilities/render/luci/PerformanceSettings.qml create mode 100644 scripts/developer/utilities/render/luci/Platform.qml create mode 100644 scripts/developer/utilities/render/performanceSetup.js create mode 100644 scripts/developer/utilities/render/performanceSetup.qml delete mode 100644 scripts/developer/utilities/render/platform.qml diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 74b812aa65..ae226598d1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5366,18 +5366,18 @@ void Application::loadSettings() { // A bunch of Performance, Simulation and Render settings will be set to a matching default value from this // Here is the mapping between pelatformTIer and performance profile - const std::array platformToPerformanceProfileMap = {{ - PerformanceManager::PerformanceProfile::MID, // platform::Profiler::UNKNOWN - PerformanceManager::PerformanceProfile::LOW, // platform::Profiler::LOW - PerformanceManager::PerformanceProfile::MID, // platform::Profiler::MID - PerformanceManager::PerformanceProfile::HIGH // platform::Profiler::HIGH + const std::array platformToPerformancePresetMap = {{ + PerformanceManager::PerformancePreset::MID, // platform::Profiler::UNKNOWN + PerformanceManager::PerformancePreset::LOW, // platform::Profiler::LOW + PerformanceManager::PerformancePreset::MID, // platform::Profiler::MID + PerformanceManager::PerformancePreset::HIGH // platform::Profiler::HIGH }}; // What is our profile? auto platformTier = platform::Profiler::profilePlatform(); - // Then let's assign the performance profile setting from it - getPerformanceManager().setPerformanceProfile(platformToPerformanceProfileMap[platformTier]); + // Then let's assign the performance preset setting from it + getPerformanceManager().setPerformancePreset(platformToPerformancePresetMap[platformTier]); } diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index 2b7dc30b96..9e96763ff6 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -16,42 +16,42 @@ PerformanceManager::PerformanceManager() { } -void PerformanceManager::setPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile) { - if (getPerformanceProfile() != performanceProfile) { - _performanceProfileSettingLock.withWriteLock([&] { - _performanceProfileSetting.set((int)performanceProfile); +void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePreset preset) { + if (getPerformancePreset() != preset) { + _performancePresetSettingLock.withWriteLock([&] { + _performancePresetSetting.set((int)preset); }); - applyPerformanceProfile(performanceProfile); + applyPerformancePreset(preset); } } -PerformanceManager::PerformanceProfile PerformanceManager::getPerformanceProfile() const { - PerformanceProfile profile = PerformanceProfile::MID; +PerformanceManager::PerformancePreset PerformanceManager::getPerformancePreset() const { + PerformancePreset preset = PerformancePreset::MID; - profile = (PerformanceProfile) _performanceProfileSettingLock.resultWithReadLock([&] { - return _performanceProfileSetting.get(); + preset = (PerformancePreset) _performancePresetSettingLock.resultWithReadLock([&] { + return _performancePresetSetting.get(); }); - return profile; + return preset; } -void PerformanceManager::applyPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile) { +void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformancePreset preset) { - switch (performanceProfile) { - case PerformanceProfile::HIGH: + switch (preset) { + case PerformancePreset::HIGH: RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED); RenderScriptingInterface::getInstance()->setShadowsEnabled(true); qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE); break; - case PerformanceProfile::MID: + case PerformancePreset::MID: RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED); RenderScriptingInterface::getInstance()->setShadowsEnabled(false); qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE); break; - case PerformanceProfile::LOW: + case PerformancePreset::LOW: RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::FORWARD); RenderScriptingInterface::getInstance()->setShadowsEnabled(false); qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO); diff --git a/interface/src/PerformanceManager.h b/interface/src/PerformanceManager.h index 8417650aaf..14742626c3 100644 --- a/interface/src/PerformanceManager.h +++ b/interface/src/PerformanceManager.h @@ -19,7 +19,7 @@ class PerformanceManager { public: - enum PerformanceProfile { + enum PerformancePreset { LOW = 0, MID, HIGH, @@ -29,15 +29,15 @@ public: PerformanceManager(); ~PerformanceManager() = default; - void setPerformanceProfile(PerformanceProfile performanceProfile); - PerformanceProfile getPerformanceProfile() const; + void setPerformancePreset(PerformancePreset performancePreset); + PerformancePreset getPerformancePreset() const; private: - mutable ReadWriteLockable _performanceProfileSettingLock; - Setting::Handle _performanceProfileSetting { "performanceProfile", PerformanceManager::PerformanceProfile::MID }; + mutable ReadWriteLockable _performancePresetSettingLock; + Setting::Handle _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::MID }; - // The concrete performance profile changes - void applyPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile); + // The concrete performance preset changes + void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset); }; #endif diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index b948e2167c..4f7c2b0fda 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -19,17 +19,17 @@ PerformanceScriptingInterface::PerformanceScriptingInterface() { }); } -void PerformanceScriptingInterface::setPerformanceProfile(PerformanceProfile performanceProfile) { - qApp->getPerformanceManager().setPerformanceProfile((PerformanceManager::PerformanceProfile)performanceProfile); +void PerformanceScriptingInterface::setPerformancePreset(PerformancePreset performancePreset) { + qApp->getPerformanceManager().setPerformancePreset((PerformanceManager::PerformancePreset)performancePreset); } -PerformanceScriptingInterface::PerformanceProfile PerformanceScriptingInterface::getPerformanceProfile() const { - return (PerformanceScriptingInterface::PerformanceProfile)qApp->getPerformanceManager().getPerformanceProfile(); +PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::getPerformancePreset() const { + return (PerformanceScriptingInterface::PerformancePreset)qApp->getPerformanceManager().getPerformancePreset(); } -QStringList PerformanceScriptingInterface::getPerformanceProfileNames() const { - static const QStringList performanceProfileNames = { "Low", "Mid", "High" }; - return performanceProfileNames; +QStringList PerformanceScriptingInterface::getPerformancePresetNames() const { + static const QStringList performancePresetNames = { "Low", "Mid", "High" }; + return performancePresetNames; } void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) { diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index a13d1bf887..3dbcd620fa 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -22,13 +22,13 @@ class PerformanceScriptingInterface : public QObject { Q_OBJECT public: - // PerformanceManager PerformanceProfile tri state level enums - enum PerformanceProfile { - LOW = PerformanceManager::PerformanceProfile::LOW, - MID = PerformanceManager::PerformanceProfile::MID, - HIGH = PerformanceManager::PerformanceProfile::HIGH, + // PerformanceManager PerformancePreset tri state level enums + enum PerformancePreset { + LOW = PerformanceManager::PerformancePreset::LOW, + MID = PerformanceManager::PerformancePreset::MID, + HIGH = PerformanceManager::PerformancePreset::HIGH, }; - Q_ENUM(PerformanceProfile) + Q_ENUM(PerformancePreset) // Must match RefreshRateManager enums enum RefreshRateProfile { @@ -43,9 +43,9 @@ public: public slots: - void setPerformanceProfile(PerformanceProfile performanceProfile); - PerformanceProfile getPerformanceProfile() const; - QStringList getPerformanceProfileNames() const; + void setPerformancePreset(PerformancePreset performancePreset); + PerformancePreset getPerformancePreset() const; + QStringList getPerformancePresetNames() const; void setRefreshRateProfile(RefreshRateProfile refreshRateProfile); RefreshRateProfile getRefreshRateProfile() const; diff --git a/scripts/developer/utilities/render/luci/PerformanceSettings.qml b/scripts/developer/utilities/render/luci/PerformanceSettings.qml new file mode 100644 index 0000000000..7bb923a25e --- /dev/null +++ b/scripts/developer/utilities/render/luci/PerformanceSettings.qml @@ -0,0 +1,43 @@ +// +// Performance Settings.qml +// +// Created by Sam Gateau on 5/28/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +import "../../lib/prop" as Prop + +Column { + anchors.left: parent.left + anchors.right: parent.right + + Prop.PropString { + label: "Platform Tier" + //object: Performance + valueVarSetter: function (v) {} + valueVarGetter: function () { + return PlatformInfo.getPlatformTierNames()[PlatformInfo.getTierProfiled()]; } + } + + Prop.PropEnum { + label: "Performance Preset" + //object: Performance + valueVarSetter: Performance.setPerformancePreset + valueVarGetter: Performance.getPerformancePreset + enums: Performance.getPerformancePresetNames() + } + + Prop.PropEnum { + label: "Refresh Rate Profile" + //object: Performance + valueVarSetter: Performance.setRefreshRateProfile + valueVarGetter: Performance.getRefreshRateProfile + enums: Performance.getRefreshRateProfileNames() + } +} diff --git a/scripts/developer/utilities/render/luci/Platform.qml b/scripts/developer/utilities/render/luci/Platform.qml new file mode 100644 index 0000000000..78a32b1749 --- /dev/null +++ b/scripts/developer/utilities/render/luci/Platform.qml @@ -0,0 +1,67 @@ +// +// platform.qml +// +// Created by Sam Gateau on 5/25/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +import controlsUit 1.0 as HifiControls + +import "../../lib/prop" as Prop + +Column { + width: parent.width + + Prop.PropGroup { + id: computer + label: "Computer" + isUnfold: true + + Component.onCompleted: { + computer.populateFromObjectProps(JSON.parse(PlatformInfo.getComputer())) + } + } + Prop.PropGroup { + id: cpu + label: "CPU" + isUnfold: true + + Component.onCompleted: { + cpu.populateFromObjectProps(JSON.parse(PlatformInfo.getCPU(0))) + } + } + Prop.PropGroup { + id: memory + label: "Memory" + isUnfold: true + + Component.onCompleted: { + memory.populateFromObjectProps(JSON.parse(PlatformInfo.getMemory())) + } + } + Prop.PropGroup { + id: gpu + label: "GPU" + isUnfold: true + + Component.onCompleted: { + gpu.populateFromObjectProps(JSON.parse(PlatformInfo.getGPU(0))) + } + } + Prop.PropGroup { + id: display + label: "Display" + isUnfold: true + + Component.onCompleted: { + display.populateFromObjectProps(JSON.parse(PlatformInfo.getDisplay(0))) + } + } +} + diff --git a/scripts/developer/utilities/render/luci/RenderSettings.qml b/scripts/developer/utilities/render/luci/RenderSettings.qml index e9e3906dfe..906c117b3a 100644 --- a/scripts/developer/utilities/render/luci/RenderSettings.qml +++ b/scripts/developer/utilities/render/luci/RenderSettings.qml @@ -11,29 +11,12 @@ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 -import controlsUit 1.0 as HifiControls - import "../../lib/prop" as Prop Column { - anchors.fill: parent - id: theGrapchicsSettings; + anchors.left: parent.left + anchors.right: parent.right - Prop.PropEnum { - label: "Performance Profile" - //object: Performance - valueVarSetter: Performance.setPerformanceProfile - valueVarGetter: Performance.getPerformanceProfile - enums: Performance.getPerformanceProfileNames() - } - - Prop.PropEnum { - label: "Refresh Rate Profile" - //object: Performance - valueVarSetter: Performance.setRefreshRateProfile - valueVarGetter: Performance.getRefreshRateProfile - enums: Performance.getRefreshRateProfileNames() - } Prop.PropEnum { label: "Render Method" diff --git a/scripts/developer/utilities/render/luci/qmldir b/scripts/developer/utilities/render/luci/qmldir index 7a7d6a8ca6..3ebd9fcd8d 100644 --- a/scripts/developer/utilities/render/luci/qmldir +++ b/scripts/developer/utilities/render/luci/qmldir @@ -4,4 +4,8 @@ ToneMapping 1.0 ToneMapping.qml BoundingBoxes 1.0 BoundingBoxes.qml Framebuffer 1.0 Framebuffer.qml Antialiasing 1.0 Antialiasing.qml -Culling 1.0 Culling.qml \ No newline at end of file +Culling 1.0 Culling.qml + +Platform 1.0 Platform.qml +RenderSettings 1.0 RenderSettings.qml +PerformanceSettings 1.0 PerformanceSettings.qml diff --git a/scripts/developer/utilities/render/performanceSetup.js b/scripts/developer/utilities/render/performanceSetup.js new file mode 100644 index 0000000000..a8c179e0e8 --- /dev/null +++ b/scripts/developer/utilities/render/performanceSetup.js @@ -0,0 +1,6 @@ +var window = Desktop.createWindow(Script.resolvePath('./performanceSetup.qml'), { + title: "Performance Setup", + presentationMode: Desktop.PresentationMode.NATIVE, + size: {x: 350, y: 700} +}); + diff --git a/scripts/developer/utilities/render/performanceSetup.qml b/scripts/developer/utilities/render/performanceSetup.qml new file mode 100644 index 0000000000..db7c5619a3 --- /dev/null +++ b/scripts/developer/utilities/render/performanceSetup.qml @@ -0,0 +1,56 @@ +// +// platformSetupInspector.qml +// +// Created by Sam Gateau on 5/30/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.3 + +import controlsUit 1.0 as HifiControls + +import "../lib/prop" as Prop +import "luci" + +Rectangle { + anchors.fill: parent + id: platform; + + Prop.Global { id: global;} + color: global.colorBack + + ScrollView { + anchors.fill: parent + clip: true + Column { + anchors.left: parent.left + anchors.right: parent.right + + Prop.PropFolderPanel { + label: "Performance Settings" + isUnfold: true + panelFrameData: Component { + PerformanceSettings {} + } + } + Prop.PropFolderPanel { + label: "Render Settings" + isUnfold: true + panelFrameData: Component { + RenderSettings {} + } + } + Prop.PropFolderPanel { + label: "Platform" + panelFrameData: Component { + Platform {} + } + } + } + } +} + diff --git a/scripts/developer/utilities/render/platform.js b/scripts/developer/utilities/render/platform.js index 9678bf3ff1..fbb7cbb8c4 100644 --- a/scripts/developer/utilities/render/platform.js +++ b/scripts/developer/utilities/render/platform.js @@ -10,7 +10,7 @@ PlatformInfo.getNumGPUs() PlatformInfo.getGPU(0) // {"driver":"25.21.14.1967","model":"NVIDIA GeForce GTX 1080","vendor":"NVIDIA GeForce GTX 1080","videoMemory":8079} -var window = Desktop.createWindow(Script.resolvePath('./platform.qml'), { +var window = Desktop.createWindow(Script.resolvePath('./luci/Platform.qml'), { title: "Platform", presentationMode: Desktop.PresentationMode.NATIVE, size: {x: 350, y: 700} diff --git a/scripts/developer/utilities/render/platform.qml b/scripts/developer/utilities/render/platform.qml deleted file mode 100644 index 775ad8e106..0000000000 --- a/scripts/developer/utilities/render/platform.qml +++ /dev/null @@ -1,75 +0,0 @@ -// -// platform.qml -// -// Created by Sam Gateau on 5/25/2019 -// Copyright 2019 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.7 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 - -import controlsUit 1.0 as HifiControls - -import "../lib/prop" as Prop - -Rectangle { - anchors.fill: parent - id: platform; - - Prop.Global { id: global;} - color: global.colorBack - - Column { - width: parent.width - - Prop.PropGroup { - id: computer - label: "Computer" - isUnfold: true - - Component.onCompleted: { - computer.populateFromObjectProps(JSON.parse(PlatformInfo.getComputer())) - } - } - Prop.PropGroup { - id: cpu - label: "CPU" - isUnfold: true - - Component.onCompleted: { - cpu.populateFromObjectProps(JSON.parse(PlatformInfo.getCPU(0))) - } - } - Prop.PropGroup { - id: memory - label: "Memory" - isUnfold: true - - Component.onCompleted: { - memory.populateFromObjectProps(JSON.parse(PlatformInfo.getMemory())) - } - } - Prop.PropGroup { - id: gpu - label: "GPU" - isUnfold: true - - Component.onCompleted: { - gpu.populateFromObjectProps(JSON.parse(PlatformInfo.getGPU(0))) - } - } - Prop.PropGroup { - id: display - label: "Display" - isUnfold: true - - Component.onCompleted: { - display.populateFromObjectProps(JSON.parse(PlatformInfo.getDisplay(0))) - } - } - } -} -