From 916ff31cf6bbe79ba39937a02ad4bf9d884e0449 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 30 May 2019 17:51:21 -0700 Subject: [PATCH 1/5] adjust the preset options --- interface/src/PerformanceManager.cpp | 2 ++ interface/src/PerformanceManager.h | 3 ++- interface/src/scripting/PerformanceScriptingInterface.cpp | 2 +- interface/src/scripting/PerformanceScriptingInterface.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index 9e96763ff6..fc601fdf8a 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -57,7 +57,9 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO); break; + case PerformancePreset::UNKNOWN: default: + // Do nothing anymore break; } } diff --git a/interface/src/PerformanceManager.h b/interface/src/PerformanceManager.h index 14742626c3..adbc5804b1 100644 --- a/interface/src/PerformanceManager.h +++ b/interface/src/PerformanceManager.h @@ -20,7 +20,8 @@ class PerformanceManager { public: enum PerformancePreset { - LOW = 0, + UNKNOWN = 0, // Matching the platform Tier profiles enumeration for coherence + LOW, MID, HIGH, PROFILE_COUNT diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index 4f7c2b0fda..a571e305d9 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -28,7 +28,7 @@ PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface:: } QStringList PerformanceScriptingInterface::getPerformancePresetNames() const { - static const QStringList performancePresetNames = { "Low", "Mid", "High" }; + static const QStringList performancePresetNames = { "Unknown", "Low", "Mid", "High" }; return performancePresetNames; } diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index 3dbcd620fa..c416b23b56 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -27,6 +27,7 @@ public: LOW = PerformanceManager::PerformancePreset::LOW, MID = PerformanceManager::PerformancePreset::MID, HIGH = PerformanceManager::PerformancePreset::HIGH, + UNKNOWN = PerformanceManager::PerformancePreset::UNKNOWN, }; Q_ENUM(PerformancePreset) From 4e2480d032321f905f84908f3b36e8dfa0392871 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 31 May 2019 00:00:44 -0700 Subject: [PATCH 2/5] cleaning up case of enum names and aligning the PerformancePreset with the PlatformTier --- .../src/scripting/PerformanceScriptingInterface.cpp | 4 ++-- .../src/scripting/PerformanceScriptingInterface.h | 2 +- .../src/scripting/PlatformInfoScriptingInterface.h | 8 ++++---- interface/src/scripting/RenderScriptingInterface.cpp | 9 ++++++--- interface/src/scripting/RenderScriptingInterface.h | 11 +++++++---- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index a571e305d9..81f1fcd3ad 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -28,7 +28,7 @@ PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface:: } QStringList PerformanceScriptingInterface::getPerformancePresetNames() const { - static const QStringList performancePresetNames = { "Unknown", "Low", "Mid", "High" }; + static const QStringList performancePresetNames = { "UNKNOWN", "LOW", "MID", "HIGH" }; return performancePresetNames; } @@ -41,7 +41,7 @@ PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface: } QStringList PerformanceScriptingInterface::getRefreshRateProfileNames() const { - static const QStringList refreshRateProfileNames = { "Eco", "Interactive", "Realtime" }; + static const QStringList refreshRateProfileNames = { "ECO", "INTERACTIVE", "REALTIME" }; return refreshRateProfileNames; } diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index c416b23b56..bf76261691 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -24,10 +24,10 @@ public: // PerformanceManager PerformancePreset tri state level enums enum PerformancePreset { + UNKNOWN = PerformanceManager::PerformancePreset::UNKNOWN, LOW = PerformanceManager::PerformancePreset::LOW, MID = PerformanceManager::PerformancePreset::MID, HIGH = PerformanceManager::PerformancePreset::HIGH, - UNKNOWN = PerformanceManager::PerformancePreset::UNKNOWN, }; Q_ENUM(PerformancePreset) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 0ca9dbff1a..476c5c5788 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -186,8 +186,8 @@ public slots: /**jsdoc * Get the Platform TIer profiled on startup of the Computer - * Platform Tier is an ineger/enum value: - * LOW = 0, MID = 1, HIGH = 2 + * Platform Tier is an integer/enum value: + * UNKNOWN = 0, LOW = 1, MID = 2, HIGH = 3 * @function PlatformInfo.getTierProfiled * @returns {number} The Platform Tier profiled on startup. */ @@ -195,8 +195,8 @@ public slots: /**jsdoc * Get the Platform Tier possible Names as an array of strings - * Platform Tier is an ineger/enum value: - * LOW = 0, MID = 1, HIGH = 2 + * Platform Tier names are: + * [ "UNKNOWN", "LOW", "MID", "HIGH" ] * @function PlatformInfo.getPlatformTierNames * @returns {string} The array of names matching the number returned from PlatformInfo.getTierProfiled */ diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 085606179d..3d761a2bb7 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -10,8 +10,6 @@ #include "LightingModel.h" #include "AntialiasingEffect.h" -const QString DEFERRED = "deferred"; -const QString FORWARD = "forward"; RenderScriptingInterface* RenderScriptingInterface::getInstance() { static RenderScriptingInterface sharedInstance; @@ -45,11 +43,12 @@ void RenderScriptingInterface::setRenderMethod(RenderScriptingInterface::RenderM _renderMethodSetting.set(newMethod); config->setBranch(newMethod); emit config->dirtyEnabled(); + emit settingsChanged(); } } QStringList RenderScriptingInterface::getRenderMethodNames() const { - static const QStringList refrenderMethodNames = { "Deferred", "Forward" }; + static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" }; return refrenderMethodNames; } @@ -72,6 +71,7 @@ void RenderScriptingInterface::setShadowsEnabled(bool enabled) { Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); _shadowsEnabledSetting.set(enabled); lightingModelConfig->setShadow(enabled); + emit settingsChanged(); } } @@ -94,6 +94,7 @@ void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); _ambientOcclusionEnabledSetting.set(enabled); lightingModelConfig->setAmbientOcclusion(enabled); + emit settingsChanged(); } } @@ -123,5 +124,7 @@ void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { mainViewJitterCamConfig->none(); mainViewAntialiasingConfig->setDebugFXAA(true); } + + emit settingsChanged(); } } diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 16608a7cb4..e2ae8bbff5 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -25,10 +25,10 @@ */ class RenderScriptingInterface : public QObject { Q_OBJECT - 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) + Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged) + Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged) + Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged) + Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged) public: RenderScriptingInterface(); @@ -132,6 +132,9 @@ public slots: */ // void setViewportResolutionScale(float resolutionScale); +signals: + void settingsChanged(); + private: Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; Setting::Handle _shadowsEnabledSetting { "shadowsEnabled", true }; From 54d1705f06a3b95b93ebe0470e021d92faab05ca Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 31 May 2019 18:42:26 -0700 Subject: [PATCH 3/5] Testing a different approach --- interface/src/Application.cpp | 22 ++--------- interface/src/PerformanceManager.cpp | 26 ++++++++++++- interface/src/PerformanceManager.h | 6 ++- .../scripting/RenderScriptingInterface.cpp | 37 ++++++++++--------- .../src/scripting/RenderScriptingInterface.h | 17 ++++++--- 5 files changed, 64 insertions(+), 44 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ae226598d1..b8a9df72d6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5361,25 +5361,9 @@ 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 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 preset setting from it - getPerformanceManager().setPerformancePreset(platformToPerformancePresetMap[platformTier]); - - } + // Setup the PerformanceManager which will enforce the several settings to match the Preset + // On the first run, the Preset is evaluated from the + getPerformanceManager().setupPerformancePresetSettings(_firstRun.get()); // 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 diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index fc601fdf8a..19bfcd41c7 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -10,10 +10,34 @@ // #include "PerformanceManager.h" +#include + #include "scripting/RenderScriptingInterface.h" PerformanceManager::PerformanceManager() { + setPerformancePreset((PerformancePreset) _performancePresetSetting.get()); +} + +void PerformanceManager::setupPerformancePresetSettings(bool evaluatePlatformTier) { + if (evaluatePlatformTier || (getPerformancePreset() == UNKNOWN)) { + // If evaluatePlatformTier, 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 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 preset setting from it + setPerformancePreset(platformToPerformancePresetMap[platformTier]); + } } void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePreset preset) { @@ -27,7 +51,7 @@ void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePre } PerformanceManager::PerformancePreset PerformanceManager::getPerformancePreset() const { - PerformancePreset preset = PerformancePreset::MID; + PerformancePreset preset = PerformancePreset::UNKNOWN; preset = (PerformancePreset) _performancePresetSettingLock.resultWithReadLock([&] { return _performancePresetSetting.get(); diff --git a/interface/src/PerformanceManager.h b/interface/src/PerformanceManager.h index adbc5804b1..2931d1f17b 100644 --- a/interface/src/PerformanceManager.h +++ b/interface/src/PerformanceManager.h @@ -30,12 +30,16 @@ public: PerformanceManager(); ~PerformanceManager() = default; + // Setup the PerformanceManager which will enforce the several settings to match the Preset + // If evaluatePlatformTier is true, the Preset is evaluated from the Platform::Profiler::profilePlatform() + void setupPerformancePresetSettings(bool evaluatePlatformTier); + void setPerformancePreset(PerformancePreset performancePreset); PerformancePreset getPerformancePreset() const; private: mutable ReadWriteLockable _performancePresetSettingLock; - Setting::Handle _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::MID }; + Setting::Handle _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::UNKNOWN }; // The concrete performance preset changes void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset); diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 3d761a2bb7..af8af131a0 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -10,6 +10,7 @@ #include "LightingModel.h" #include "AntialiasingEffect.h" +std::once_flag RenderScriptingInterface::registry_flag; RenderScriptingInterface* RenderScriptingInterface::getInstance() { static RenderScriptingInterface sharedInstance; @@ -17,32 +18,34 @@ RenderScriptingInterface* RenderScriptingInterface::getInstance() { } RenderScriptingInterface::RenderScriptingInterface() { - setRenderMethod((RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD); + std::call_once(registry_flag, [] { + qmlRegisterType("RenderEnums", 1, 0, "RenderEnums"); + }); + + setRenderMethod((RenderMethod)_renderMethodSettingLock.resultWithReadLock([&] { + return _renderMethodSetting.get(); + })); setShadowsEnabled(_shadowsEnabledSetting.get()); setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); setAntialiasingEnabled(_antialiasingEnabledSetting.get()); } RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { - return (RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD; + return (RenderMethod) _renderMethod; } -void RenderScriptingInterface::setRenderMethod(RenderScriptingInterface::RenderMethod renderMethod) { - RenderMethod newMethod = renderMethod == RenderMethod::FORWARD ? RenderMethod::FORWARD : RenderMethod::DEFERRED; - if (_renderMethodSetting.get() == newMethod) { - return; - } +void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { + if (_renderMethod != (int) renderMethod) { + _renderMethodSettingLock.withWriteLock([&] { + _renderMethod = (int)renderMethod; + _renderMethodSetting.set((int)renderMethod); - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(RenderScriptingInterface::RenderMethod, renderMethod)); - return; - } - - auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); - if (config) { - _renderMethodSetting.set(newMethod); - config->setBranch(newMethod); - emit config->dirtyEnabled(); + auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); + if (config) { + _renderMethodSetting.set((int)renderMethod); + config->setBranch((int)renderMethod); + } + }); emit settingsChanged(); } } diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index e2ae8bbff5..3a7d2169b4 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -25,10 +25,10 @@ */ class RenderScriptingInterface : public QObject { Q_OBJECT - Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged) - Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged) - Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged) - Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged) + // Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged) + // Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged) + // Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged) + // Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged) public: RenderScriptingInterface(); @@ -36,11 +36,11 @@ public: static RenderScriptingInterface* getInstance(); // RenderMethod enum type - enum RenderMethod { + enum class RenderMethod { DEFERRED = render::Args::RenderMethod::DEFERRED, FORWARD = render::Args::RenderMethod::FORWARD, }; - Q_ENUM(RenderMethod); + Q_ENUM(RenderMethod) public slots: /**jsdoc @@ -136,11 +136,16 @@ signals: void settingsChanged(); private: + int _renderMethod { -1 }; + mutable ReadWriteLockable _renderMethodSettingLock; 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 }; + + static std::once_flag registry_flag; }; #endif // hifi_RenderScriptingInterface_h From 2a4d0cfaece3aeaf0e1a27a0bb1c9502bc7bee91 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 3 Jun 2019 18:06:28 -0700 Subject: [PATCH 4/5] Addressing the initialization bug not applying REnderMethod properly, Adjusting RefrehRateProfile to Realtime in High performancePreset --- interface/src/Application.cpp | 4 + interface/src/PerformanceManager.cpp | 2 +- .../PerformanceScriptingInterface.cpp | 2 + .../scripting/PerformanceScriptingInterface.h | 6 + .../scripting/RenderScriptingInterface.cpp | 154 ++++++++++-------- .../src/scripting/RenderScriptingInterface.h | 34 +++- .../utilities/lib/jet/qml/TaskPropView.qml | 7 +- .../developer/utilities/lib/prop/PropEnum.qml | 2 +- .../utilities/lib/prop/style/Global.qml | 1 + .../utilities/lib/prop/style/PiCanvasIcon.qml | 22 ++- .../utilities/lib/prop/style/PiCheckBox.qml | 46 +++++- .../utilities/lib/prop/style/PiComboBox.qml | 15 +- .../lib/prop/style/PiFolderPanel.qml | 7 +- .../render/luci/PerformanceSettings.qml | 11 +- .../utilities/render/luci/Platform.qml | 3 +- .../utilities/render/performanceSetup.qml | 53 +++--- 16 files changed, 232 insertions(+), 137 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d1b3d46dfc..34af465485 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5375,6 +5375,10 @@ void Application::loadSettings() { } } + // Load settings of the RenderScritpingInterface + // Do that explicitely before being used + RenderScriptingInterface::getInstance()->loadSettings(); + // Setup the PerformanceManager which will enforce the several settings to match the Preset // On the first run, the Preset is evaluated from the getPerformanceManager().setupPerformancePresetSettings(_firstRun.get()); diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index 19bfcd41c7..e7591e8b57 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -66,7 +66,7 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP case PerformancePreset::HIGH: RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED); RenderScriptingInterface::getInstance()->setShadowsEnabled(true); - qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE); + qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME); break; case PerformancePreset::MID: diff --git a/interface/src/scripting/PerformanceScriptingInterface.cpp b/interface/src/scripting/PerformanceScriptingInterface.cpp index bdd0dd2451..33ad9a3f95 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.cpp +++ b/interface/src/scripting/PerformanceScriptingInterface.cpp @@ -21,6 +21,7 @@ PerformanceScriptingInterface::PerformanceScriptingInterface() { void PerformanceScriptingInterface::setPerformancePreset(PerformancePreset performancePreset) { qApp->getPerformanceManager().setPerformancePreset((PerformanceManager::PerformancePreset)performancePreset); + emit settingsChanged(); } PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::getPerformancePreset() const { @@ -34,6 +35,7 @@ QStringList PerformanceScriptingInterface::getPerformancePresetNames() const { void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) { qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile); + emit settingsChanged(); } PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface::getRefreshRateProfile() const { diff --git a/interface/src/scripting/PerformanceScriptingInterface.h b/interface/src/scripting/PerformanceScriptingInterface.h index bf76261691..92d4273dfb 100644 --- a/interface/src/scripting/PerformanceScriptingInterface.h +++ b/interface/src/scripting/PerformanceScriptingInterface.h @@ -20,6 +20,9 @@ class PerformanceScriptingInterface : public QObject { Q_OBJECT + Q_PROPERTY(PerformancePreset performancePreset READ getPerformancePreset WRITE setPerformancePreset NOTIFY settingsChanged) + Q_PROPERTY(RefreshRateProfile refreshRateProfile READ getRefreshRateProfile WRITE setRefreshRateProfile NOTIFY settingsChanged) + public: // PerformanceManager PerformancePreset tri state level enums @@ -56,6 +59,9 @@ public slots: RefreshRateManager::UXMode getUXMode() const; RefreshRateManager::RefreshRateRegime getRefreshRateRegime() const; +signals: + void settingsChanged(); + private: static std::once_flag registry_flag; }; diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index af8af131a0..4418ff6e46 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -21,34 +21,43 @@ RenderScriptingInterface::RenderScriptingInterface() { std::call_once(registry_flag, [] { qmlRegisterType("RenderEnums", 1, 0, "RenderEnums"); }); +} - setRenderMethod((RenderMethod)_renderMethodSettingLock.resultWithReadLock([&] { - return _renderMethodSetting.get(); - })); - setShadowsEnabled(_shadowsEnabledSetting.get()); - setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); - setAntialiasingEnabled(_antialiasingEnabledSetting.get()); +void RenderScriptingInterface::loadSettings() { + _renderSettingLock.withReadLock([&] { + _renderMethod.store(_renderMethodSetting.get()); + _shadowsEnabled.store(_shadowsEnabledSetting.get()); + _ambientOcclusionEnabled.store(_ambientOcclusionEnabledSetting.get()); + _antialiasingEnabled.store(_antialiasingEnabledSetting.get()); + }); + forceRenderMethod((RenderMethod)_renderMethod.load()); + forceShadowsEnabled(_shadowsEnabled.load()); + forceAmbientOcclusionEnabled(_ambientOcclusionEnabled.load()); + forceAntialiasingEnabled(_antialiasingEnabled.load()); } RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { - return (RenderMethod) _renderMethod; + return (RenderMethod) _renderMethod.load(); } void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { if (_renderMethod != (int) renderMethod) { - _renderMethodSettingLock.withWriteLock([&] { - _renderMethod = (int)renderMethod; - _renderMethodSetting.set((int)renderMethod); - - auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); - if (config) { - _renderMethodSetting.set((int)renderMethod); - config->setBranch((int)renderMethod); - } - }); + forceRenderMethod(renderMethod); emit settingsChanged(); } } +void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) { + _renderSettingLock.withWriteLock([&] { + _renderMethod = (int)renderMethod; + _renderMethodSetting.set((int)renderMethod); + + auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); + if (config) { + _renderMethodSetting.set((int)renderMethod); + config->setBranch((int)renderMethod); + } + }); +} QStringList RenderScriptingInterface::getRenderMethodNames() const { static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" }; @@ -56,78 +65,83 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { } bool RenderScriptingInterface::getShadowsEnabled() { - return _shadowsEnabledSetting.get(); + return _shadowsEnabled.load(); } void RenderScriptingInterface::setShadowsEnabled(bool enabled) { - if (_shadowsEnabledSetting.get() == enabled) { - return; - } - - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled)); - return; - } - - auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); - if (lightingModelConfig) { - Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); - _shadowsEnabledSetting.set(enabled); - lightingModelConfig->setShadow(enabled); + if (_shadowsEnabled != enabled) { + forceShadowsEnabled(enabled); emit settingsChanged(); } } +void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { + _renderSettingLock.withWriteLock([&] { + _shadowsEnabled.store(enabled); + _shadowsEnabledSetting.set(enabled); + + auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); + if (lightingModelConfig) { + Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); + lightingModelConfig->setShadow(enabled); + } + }); +} + bool RenderScriptingInterface::getAmbientOcclusionEnabled() { - return _ambientOcclusionEnabledSetting.get(); + return _ambientOcclusionEnabled.load(); } void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { - if (_ambientOcclusionEnabledSetting.get() == enabled) { - return; - } - - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled)); - return; - } - - auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); - if (lightingModelConfig) { - Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); - _ambientOcclusionEnabledSetting.set(enabled); - lightingModelConfig->setAmbientOcclusion(enabled); + if (_ambientOcclusionEnabled.load() != enabled) { + forceAmbientOcclusionEnabled(enabled); emit settingsChanged(); } } +void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { + _renderSettingLock.withWriteLock([&] { + _ambientOcclusionEnabled.store(enabled); + _ambientOcclusionEnabledSetting.set(enabled); + + auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); + if (lightingModelConfig) { + Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); + lightingModelConfig->setAmbientOcclusion(enabled); + } + }); +} + bool RenderScriptingInterface::getAntialiasingEnabled() { - return _antialiasingEnabledSetting.get(); + return _antialiasingEnabled.load(); } void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { - if (_antialiasingEnabledSetting.get() == enabled) { - return; - } - - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled)); - return; - } - - auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.JitterCam"); - auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.Antialiasing"); - if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { - Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); - _antialiasingEnabledSetting.set(enabled); - if (enabled) { - mainViewJitterCamConfig->play(); - mainViewAntialiasingConfig->setDebugFXAA(false); - } else { - mainViewJitterCamConfig->none(); - mainViewAntialiasingConfig->setDebugFXAA(true); - } - + if (_antialiasingEnabled.load() != enabled) { + forceAntialiasingEnabled(enabled); emit settingsChanged(); } } + +void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) { + _renderSettingLock.withWriteLock([&] { + _antialiasingEnabled.store(enabled); + _antialiasingEnabledSetting.set(enabled); + + auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.JitterCam"); + auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.Antialiasing"); + if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { + Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); + if (enabled) { + mainViewJitterCamConfig->play(); + mainViewAntialiasingConfig->setDebugFXAA(false); + } + else { + mainViewJitterCamConfig->none(); + mainViewAntialiasingConfig->setDebugFXAA(true); + } + } + }); +} + + diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 3a7d2169b4..abfff67f20 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -25,10 +25,10 @@ */ class RenderScriptingInterface : public QObject { Q_OBJECT - // Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged) - // Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged) - // Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged) - // Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged) + Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged) + Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged) + Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged) + Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged) public: RenderScriptingInterface(); @@ -42,6 +42,12 @@ public: }; Q_ENUM(RenderMethod) + + // Load Settings + // Synchronize the runtime value to the actual setting + // Need to be called on start up to re-initialize the runtime to the saved setting states + void loadSettings(); + public slots: /**jsdoc * Get a config for a job by name @@ -136,14 +142,26 @@ signals: void settingsChanged(); private: - int _renderMethod { -1 }; - mutable ReadWriteLockable _renderMethodSettingLock; - Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; + // One lock to serialize and access safely all the settings + mutable ReadWriteLockable _renderSettingLock; + // Runtime atomic value of each settings + std::atomic_int _renderMethod{ render::Args::RenderMethod::DEFERRED }; + std::atomic_bool _shadowsEnabled{ true }; + std::atomic_bool _ambientOcclusionEnabled{ false }; + std::atomic_bool _antialiasingEnabled { true }; + + // Actual settings saved on disk + 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 }; + + // Force assign both setting AND runtime value to the parameter value + void forceRenderMethod(RenderMethod renderMethod); + void forceShadowsEnabled(bool enabled); + void forceAmbientOcclusionEnabled(bool enabled); + void forceAntialiasingEnabled(bool enabled); static std::once_flag registry_flag; }; diff --git a/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml b/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml index 165edcf2e1..0dd978be63 100644 --- a/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml +++ b/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml @@ -75,7 +75,12 @@ Prop.PropGroup { filled: root.jobEnabled fillColor: (root.jobEnabled ? global.colorGreenHighlight : global.colorOrangeAccent) icon: 5 - iconMouseArea.onClicked: { toggleJobActivation() } + + MouseArea{ + id: mousearea + anchors.fill: parent + onClicked: { root.toggleJobActivation() } + } } } diff --git a/scripts/developer/utilities/lib/prop/PropEnum.qml b/scripts/developer/utilities/lib/prop/PropEnum.qml index 87c2845c90..c7869050ba 100644 --- a/scripts/developer/utilities/lib/prop/PropEnum.qml +++ b/scripts/developer/utilities/lib/prop/PropEnum.qml @@ -19,7 +19,7 @@ PropItem { property alias enums : valueCombo.model Component.onCompleted: { - // valueVar = root.valueVarGetter(); + valueVar = root.valueVarGetter(); } PropComboBox { diff --git a/scripts/developer/utilities/lib/prop/style/Global.qml b/scripts/developer/utilities/lib/prop/style/Global.qml index bbc8acfa0b..2330d9876c 100644 --- a/scripts/developer/utilities/lib/prop/style/Global.qml +++ b/scripts/developer/utilities/lib/prop/style/Global.qml @@ -29,6 +29,7 @@ Item { readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight readonly property color colorBorderLight: hifi.colors.lightGray readonly property color colorBorderHighight: hifi.colors.blueHighlight + readonly property color colorBorderLighter: hifi.colors.faintGray readonly property color colorOrangeAccent: "#FF6309" readonly property color colorRedAccent: "#C62147" diff --git a/scripts/developer/utilities/lib/prop/style/PiCanvasIcon.qml b/scripts/developer/utilities/lib/prop/style/PiCanvasIcon.qml index 2fc3ed10ec..985ecfdac6 100644 --- a/scripts/developer/utilities/lib/prop/style/PiCanvasIcon.qml +++ b/scripts/developer/utilities/lib/prop/style/PiCanvasIcon.qml @@ -29,11 +29,19 @@ Canvas { } property var fillColor: global.colorBorderHighight - onFillColorChanged: function () { //console.log("fillColor changed to: " + filled ); + onFillColorChanged: function () { //console.log("fillColor changed to: " + fillColor ); requestPaint() } - property alias iconMouseArea: mousearea + property var stroked: true + onStrokedChanged: function () { //console.log("Stroked changed to: " + stroked ); + requestPaint() + } + + property var strokeColor: global.colorBorderLight + onStrokeColorChanged: function () { //console.log("strokeColor changed to: " + strokeColor ); + requestPaint() + } contextType: "2d" onPaint: { @@ -86,14 +94,10 @@ Canvas { if (filled) { context.fillStyle = fillColor; context.fill(); - } else { - context.strokeStyle = fillColor; + } + if (stroked) { + context.strokeStyle = strokeColor; context.stroke(); } } - - MouseArea{ - id: mousearea - anchors.fill: parent - } } \ No newline at end of file diff --git a/scripts/developer/utilities/lib/prop/style/PiCheckBox.qml b/scripts/developer/utilities/lib/prop/style/PiCheckBox.qml index 1e1f03669b..83d9ebd591 100644 --- a/scripts/developer/utilities/lib/prop/style/PiCheckBox.qml +++ b/scripts/developer/utilities/lib/prop/style/PiCheckBox.qml @@ -9,15 +9,47 @@ // import QtQuick 2.7 -import controlsUit 1.0 as HifiControls +import QtQuick.Controls 2.2 -HifiControls.CheckBox { +CheckBox { Global { id: global } - - color: global.fontColor + id: control + text: "" + checked: true + spacing: 0 - //anchors.left: root.splitter.right - //anchors.verticalCenter: root.verticalCenter - //width: root.width * global.valueAreaWidthScale + indicator: Rectangle { + color: global.colorBack + border.color: control.down ? global.colorBorderLighter : global.colorBorderLight + border.width: global.valueBorderWidth + radius: global.valueBorderRadius / 2 + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + implicitWidth: global.iconWidth + implicitHeight: global.iconWidth + + Rectangle { + visible: control.checked + + color: global.colorBorderHighight + radius: global.valueBorderRadius / 4 + + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + implicitWidth: global.iconWidth - 2 + implicitHeight: global.iconHeight - 2 + } + } + + contentItem: PiText { + text: control.text + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHLeft + anchors.left: control.indicator.right + leftPadding: global.horizontalMargin + } + height: global.slimHeight } \ No newline at end of file diff --git a/scripts/developer/utilities/lib/prop/style/PiComboBox.qml b/scripts/developer/utilities/lib/prop/style/PiComboBox.qml index d9e029b702..92164fefc5 100644 --- a/scripts/developer/utilities/lib/prop/style/PiComboBox.qml +++ b/scripts/developer/utilities/lib/prop/style/PiComboBox.qml @@ -28,7 +28,7 @@ ComboBox { horizontalAlignment: global.valueTextAlign } background: Rectangle { - color:highlighted?global.colorBackHighlight:global.color; + color:highlighted ? global.colorBackHighlight : global.colorBack; } highlighted: valueCombo.highlightedIndex === index } @@ -38,11 +38,8 @@ ComboBox { x: valueCombo.width - width - valueCombo.rightPadding y: valueCombo.topPadding + (valueCombo.availableHeight - height) / 2 - icon: 1 - /*Connections { - target: valueCombo - onPressedChanged: { canvas.icon = control.down + 1 } - }*/ + strokeColor: (valueCombo.down ? global.colorBorderLighter : global.colorBorderLight ) + icon: 1 + valueCombo.down } contentItem: PiText { @@ -56,8 +53,8 @@ ComboBox { background: Rectangle { implicitWidth: 120 implicitHeight: 40 - color: global.color - border.color: valueCombo.popup.visible ? global.colorBorderHighight : global.colorBorderLight + color: global.colorBack + border.color: valueCombo.popup.visible ? global.colorBorderLighter : global.colorBorderLight border.width: global.valueBorderWidth radius: global.valueBorderRadius } @@ -78,7 +75,7 @@ ComboBox { } background: Rectangle { - color: global.color + color: global.colorBack border.color: global.colorBorderHighight radius: global.valueBorderRadius } diff --git a/scripts/developer/utilities/lib/prop/style/PiFolderPanel.qml b/scripts/developer/utilities/lib/prop/style/PiFolderPanel.qml index d66c0708d3..1f476cab75 100644 --- a/scripts/developer/utilities/lib/prop/style/PiFolderPanel.qml +++ b/scripts/developer/utilities/lib/prop/style/PiFolderPanel.qml @@ -72,7 +72,12 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter fillColor: global.colorOrangeAccent - iconMouseArea.onClicked: { root.isUnfold = !root.isUnfold } + + MouseArea{ + id: mousearea + anchors.fill: parent + onClicked: { root.isUnfold = !root.isUnfold } + } } } diff --git a/scripts/developer/utilities/render/luci/PerformanceSettings.qml b/scripts/developer/utilities/render/luci/PerformanceSettings.qml index 7bb923a25e..ba3ecada9d 100644 --- a/scripts/developer/utilities/render/luci/PerformanceSettings.qml +++ b/scripts/developer/utilities/render/luci/PerformanceSettings.qml @@ -19,7 +19,6 @@ Column { Prop.PropString { label: "Platform Tier" - //object: Performance valueVarSetter: function (v) {} valueVarGetter: function () { return PlatformInfo.getPlatformTierNames()[PlatformInfo.getTierProfiled()]; } @@ -27,17 +26,15 @@ Column { Prop.PropEnum { label: "Performance Preset" - //object: Performance - valueVarSetter: Performance.setPerformancePreset - valueVarGetter: Performance.getPerformancePreset + object: Performance + property: "performancePreset" enums: Performance.getPerformancePresetNames() } Prop.PropEnum { label: "Refresh Rate Profile" - //object: Performance - valueVarSetter: Performance.setRefreshRateProfile - valueVarGetter: Performance.getRefreshRateProfile + object: Performance + property: "refreshRateProfile" enums: Performance.getRefreshRateProfileNames() } } diff --git a/scripts/developer/utilities/render/luci/Platform.qml b/scripts/developer/utilities/render/luci/Platform.qml index 78a32b1749..9c5ffda070 100644 --- a/scripts/developer/utilities/render/luci/Platform.qml +++ b/scripts/developer/utilities/render/luci/Platform.qml @@ -16,7 +16,8 @@ import controlsUit 1.0 as HifiControls import "../../lib/prop" as Prop Column { - width: parent.width + anchors.left: parent.left + anchors.right: parent.right Prop.PropGroup { id: computer diff --git a/scripts/developer/utilities/render/performanceSetup.qml b/scripts/developer/utilities/render/performanceSetup.qml index db7c5619a3..416c074e0f 100644 --- a/scripts/developer/utilities/render/performanceSetup.qml +++ b/scripts/developer/utilities/render/performanceSetup.qml @@ -24,33 +24,42 @@ Rectangle { color: global.colorBack ScrollView { - anchors.fill: parent + anchors.fill: parent clip: true - Column { - anchors.left: parent.left - anchors.right: parent.right + Column { + anchors.left: parent.left + anchors.right: parent.right - Prop.PropFolderPanel { - label: "Performance Settings" - isUnfold: true - panelFrameData: Component { - PerformanceSettings {} + Prop.PropFolderPanel { + label: "Performance Settings" + isUnfold: true + panelFrameData: Component { + PerformanceSettings { + anchors.left: parent.left + anchors.right: parent.right + } + } } - } - Prop.PropFolderPanel { - label: "Render Settings" - isUnfold: true - panelFrameData: Component { - RenderSettings {} + Prop.PropFolderPanel { + label: "Render Settings" + isUnfold: true + panelFrameData: Component { + RenderSettings { + anchors.left: parent.left + anchors.right: parent.right + } + } } + /* Prop.PropFolderPanel { + label: "Platform" + panelFrameData: Component { + Platform { + anchors.left: parent.left + anchors.right: parent.right + } + } + }*/ } - Prop.PropFolderPanel { - label: "Platform" - panelFrameData: Component { - Platform {} - } - } - } } } From f51e491d853c806ef052c123df10ca125e7e3e93 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 4 Jun 2019 10:11:12 -0700 Subject: [PATCH 5/5] Removing the atomics and fixing mistakes pointed out inreview --- .../scripting/RenderScriptingInterface.cpp | 38 +++++++++---------- .../src/scripting/RenderScriptingInterface.h | 10 ++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 4418ff6e46..730fef3966 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -10,13 +10,14 @@ #include "LightingModel.h" #include "AntialiasingEffect.h" -std::once_flag RenderScriptingInterface::registry_flag; RenderScriptingInterface* RenderScriptingInterface::getInstance() { static RenderScriptingInterface sharedInstance; return &sharedInstance; } +std::once_flag RenderScriptingInterface::registry_flag; + RenderScriptingInterface::RenderScriptingInterface() { std::call_once(registry_flag, [] { qmlRegisterType("RenderEnums", 1, 0, "RenderEnums"); @@ -25,19 +26,19 @@ RenderScriptingInterface::RenderScriptingInterface() { void RenderScriptingInterface::loadSettings() { _renderSettingLock.withReadLock([&] { - _renderMethod.store(_renderMethodSetting.get()); - _shadowsEnabled.store(_shadowsEnabledSetting.get()); - _ambientOcclusionEnabled.store(_ambientOcclusionEnabledSetting.get()); - _antialiasingEnabled.store(_antialiasingEnabledSetting.get()); + _renderMethod = (_renderMethodSetting.get()); + _shadowsEnabled = (_shadowsEnabledSetting.get()); + _ambientOcclusionEnabled = (_ambientOcclusionEnabledSetting.get()); + _antialiasingEnabled = (_antialiasingEnabledSetting.get()); }); - forceRenderMethod((RenderMethod)_renderMethod.load()); - forceShadowsEnabled(_shadowsEnabled.load()); - forceAmbientOcclusionEnabled(_ambientOcclusionEnabled.load()); - forceAntialiasingEnabled(_antialiasingEnabled.load()); + forceRenderMethod((RenderMethod)_renderMethod); + forceShadowsEnabled(_shadowsEnabled); + forceAmbientOcclusionEnabled(_ambientOcclusionEnabled); + forceAntialiasingEnabled(_antialiasingEnabled); } RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { - return (RenderMethod) _renderMethod.load(); + return (RenderMethod) _renderMethod; } void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { @@ -53,7 +54,6 @@ void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) { auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); if (config) { - _renderMethodSetting.set((int)renderMethod); config->setBranch((int)renderMethod); } }); @@ -65,7 +65,7 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { } bool RenderScriptingInterface::getShadowsEnabled() { - return _shadowsEnabled.load(); + return _shadowsEnabled; } void RenderScriptingInterface::setShadowsEnabled(bool enabled) { @@ -77,7 +77,7 @@ void RenderScriptingInterface::setShadowsEnabled(bool enabled) { void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { _renderSettingLock.withWriteLock([&] { - _shadowsEnabled.store(enabled); + _shadowsEnabled = (enabled); _shadowsEnabledSetting.set(enabled); auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); @@ -89,11 +89,11 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { } bool RenderScriptingInterface::getAmbientOcclusionEnabled() { - return _ambientOcclusionEnabled.load(); + return _ambientOcclusionEnabled; } void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { - if (_ambientOcclusionEnabled.load() != enabled) { + if (_ambientOcclusionEnabled != enabled) { forceAmbientOcclusionEnabled(enabled); emit settingsChanged(); } @@ -101,7 +101,7 @@ void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { _renderSettingLock.withWriteLock([&] { - _ambientOcclusionEnabled.store(enabled); + _ambientOcclusionEnabled = (enabled); _ambientOcclusionEnabledSetting.set(enabled); auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.LightingModel"); @@ -113,11 +113,11 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { } bool RenderScriptingInterface::getAntialiasingEnabled() { - return _antialiasingEnabled.load(); + return _antialiasingEnabled; } void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { - if (_antialiasingEnabled.load() != enabled) { + if (_antialiasingEnabled != enabled) { forceAntialiasingEnabled(enabled); emit settingsChanged(); } @@ -125,7 +125,7 @@ void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) { _renderSettingLock.withWriteLock([&] { - _antialiasingEnabled.store(enabled); + _antialiasingEnabled = (enabled); _antialiasingEnabledSetting.set(enabled); auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.JitterCam"); diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index abfff67f20..df2e138b08 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -145,11 +145,11 @@ private: // One lock to serialize and access safely all the settings mutable ReadWriteLockable _renderSettingLock; - // Runtime atomic value of each settings - std::atomic_int _renderMethod{ render::Args::RenderMethod::DEFERRED }; - std::atomic_bool _shadowsEnabled{ true }; - std::atomic_bool _ambientOcclusionEnabled{ false }; - std::atomic_bool _antialiasingEnabled { true }; + // Runtime value of each settings + int _renderMethod{ RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; + bool _shadowsEnabled{ true }; + bool _ambientOcclusionEnabled{ false }; + bool _antialiasingEnabled { true }; // Actual settings saved on disk Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };