COnnect the profile tier to the performance setting and assign on first run or after reset...

This commit is contained in:
Sam Gateau 2019-05-29 17:49:17 -07:00
parent 473bd33515
commit a212a8a36a
3 changed files with 47 additions and 4 deletions

View file

@ -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;
}
}
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;
}
}

View file

@ -35,6 +35,9 @@ public:
private:
mutable ReadWriteLockable _performanceProfileSettingLock;
Setting::Handle<int> _performanceProfileSetting { "performanceProfile", PerformanceManager::PerformanceProfile::MID };
// The concrete performance profile changes
void applyPerformanceProfile(PerformanceManager::PerformanceProfile performanceProfile);
};
#endif

View file

@ -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