Merge pull request #15647 from samcake/nut

BUGZ-192: On first run, apply "performanceProfile" according to platform tier
This commit is contained in:
Sam Gateau 2019-05-30 14:01:40 -07:00 committed by GitHub
commit c78c904491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 430 additions and 91 deletions

View file

@ -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<PerformanceManager::PerformancePreset, platform::Profiler::NumTiers> 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]);
}
// 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);

View file

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

View file

@ -0,0 +1,63 @@
//
// 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"
#include "scripting/RenderScriptingInterface.h"
PerformanceManager::PerformanceManager()
{
}
void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePreset preset) {
if (getPerformancePreset() != preset) {
_performancePresetSettingLock.withWriteLock([&] {
_performancePresetSetting.set((int)preset);
});
applyPerformancePreset(preset);
}
}
PerformanceManager::PerformancePreset PerformanceManager::getPerformancePreset() const {
PerformancePreset preset = PerformancePreset::MID;
preset = (PerformancePreset) _performancePresetSettingLock.resultWithReadLock<int>([&] {
return _performancePresetSetting.get();
});
return preset;
}
void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformancePreset preset) {
switch (preset) {
case PerformancePreset::HIGH:
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED);
RenderScriptingInterface::getInstance()->setShadowsEnabled(true);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE);
break;
case PerformancePreset::MID:
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE);
break;
case PerformancePreset::LOW:
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::FORWARD);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO);
break;
default:
break;
}
}

View file

@ -0,0 +1,43 @@
//
// 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 <string>
#include <SettingHandle.h>
#include <shared/ReadWriteLockable.h>
class PerformanceManager {
public:
enum PerformancePreset {
LOW = 0,
MID,
HIGH,
PROFILE_COUNT
};
PerformanceManager();
~PerformanceManager() = default;
void setPerformancePreset(PerformancePreset performancePreset);
PerformancePreset getPerformancePreset() const;
private:
mutable ReadWriteLockable _performancePresetSettingLock;
Setting::Handle<int> _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::MID };
// The concrete performance preset changes
void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset);
};
#endif

View file

@ -19,6 +19,19 @@ PerformanceScriptingInterface::PerformanceScriptingInterface() {
});
}
void PerformanceScriptingInterface::setPerformancePreset(PerformancePreset performancePreset) {
qApp->getPerformanceManager().setPerformancePreset((PerformanceManager::PerformancePreset)performancePreset);
}
PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::getPerformancePreset() const {
return (PerformanceScriptingInterface::PerformancePreset)qApp->getPerformanceManager().getPerformancePreset();
}
QStringList PerformanceScriptingInterface::getPerformancePresetNames() const {
static const QStringList performancePresetNames = { "Low", "Mid", "High" };
return performancePresetNames;
}
void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) {
qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile);
}
@ -27,6 +40,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();
}

View file

@ -14,12 +14,22 @@
#include <QObject>
#include "../PerformanceManager.h"
#include "../RefreshRateManager.h"
class PerformanceScriptingInterface : public QObject {
Q_OBJECT
public:
// PerformanceManager PerformancePreset tri state level enums
enum PerformancePreset {
LOW = PerformanceManager::PerformancePreset::LOW,
MID = PerformanceManager::PerformancePreset::MID,
HIGH = PerformanceManager::PerformancePreset::HIGH,
};
Q_ENUM(PerformancePreset)
// Must match RefreshRateManager enums
enum RefreshRateProfile {
ECO = RefreshRateManager::RefreshRateProfile::ECO,
@ -28,19 +38,23 @@ public:
};
Q_ENUM(RefreshRateProfile)
PerformanceScriptingInterface();
~PerformanceScriptingInterface() = default;
public slots:
void setPerformancePreset(PerformancePreset performancePreset);
PerformancePreset getPerformancePreset() const;
QStringList getPerformancePresetNames() const;
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;
};

View file

@ -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;
}
@ -48,6 +48,11 @@ void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) {
}
}
QStringList RenderScriptingInterface::getRenderMethodNames() const {
static const QStringList refrenderMethodNames = { "Deferred", "Forward" };
return refrenderMethodNames;
}
bool RenderScriptingInterface::getShadowsEnabled() {
return _shadowsEnabledSetting.get();
}
@ -119,4 +124,4 @@ void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) {
mainViewAntialiasingConfig->setDebugFXAA(true);
}
}
}
}

View file

@ -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,24 @@ public slots:
/**jsdoc
* Gets the current render method
* @function Render.getRenderMethod
* @returns {string} <code>"deferred"</code> or <code>"forward"</code>
* @returns {number} <code>"DEFERRED"</code> or <code>"FORWARD"</code>
*/
QString getRenderMethod();
RenderMethod getRenderMethod();
/**jsdoc
* Sets the current render method
* @function Render.setRenderMethod
* @param {string} renderMethod - <code>"deferred"</code> or <code>"forward"</code>
* @param {number} renderMethod - <code>"DEFERRED"</code> or <code>"FORWARD"</code>
*/
void setRenderMethod(const QString& renderMethod);
void setRenderMethod(RenderMethod renderMethod);
/**jsdoc
* Gets the possible enum names of the RenderMethod type
* @function Render.getRenderMethodNames
* @returns [string] [ <code>"DEFERRED"</code>, <code>"FORWARD"</code> ]
*/
QStringList getRenderMethodNames() const;
/**jsdoc
* Whether or not shadows are enabled
@ -103,11 +118,26 @@ public slots:
*/
void setAntialiasingEnabled(bool enabled);
/**jsdoc
* Gets the current viewport resolution scale
* @function Render.getViewportResolutionScale
* @returns {number}
*/
// float getViewportResolutionScale();
/**jsdoc
* Sets the current viewport resolution scale
* @function Render.setViewportResolutionScale
* @param {number} resolutionScale - between epsilon and 1.0
*/
// void setViewportResolutionScale(float resolutionScale);
private:
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
Setting::Handle<bool> _shadowsEnabledSetting { "shadowsEnabled", true };
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false };
Setting::Handle<bool> _antialiasingEnabledSetting { "antialiasingEnabled", true };
Setting::Handle<float> _viewportResolutionScaleSetting{ "viewportResolutionScale", 1.0f };
};
#endif // hifi_RenderScriptingInterface_h

View file

@ -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()
}
}

View file

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

View file

@ -0,0 +1,34 @@
//
// 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 "../../lib/prop" as Prop
Column {
anchors.left: parent.left
anchors.right: parent.right
Prop.PropEnum {
label: "Render Method"
object: Render
property: "renderMethod"
enums: Render.getRenderMethodNames()
}
Prop.PropBool {
label: "Shadows"
object: Render
property: "shadowsEnabled"
}
}

View file

@ -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
Culling 1.0 Culling.qml
Platform 1.0 Platform.qml
RenderSettings 1.0 RenderSettings.qml
PerformanceSettings 1.0 PerformanceSettings.qml

View file

@ -0,0 +1,6 @@
var window = Desktop.createWindow(Script.resolvePath('./performanceSetup.qml'), {
title: "Performance Setup",
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 350, y: 700}
});

View file

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

View file

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

View file

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

View file

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