mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
Merge pull request #15670 from samcake/nut
BUGZ-467 and BUGZ-488 : Fixing buggy performance preset setup behavior
This commit is contained in:
commit
2fbb28835c
18 changed files with 289 additions and 164 deletions
|
@ -5375,25 +5375,13 @@ void Application::loadSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_firstRun.get()) {
|
// Load settings of the RenderScritpingInterface
|
||||||
// If this is our first run, evalute the Platform Tier and assign the matching Performance profile by default.
|
// Do that explicitely before being used
|
||||||
// A bunch of Performance, Simulation and Render settings will be set to a matching default value from this
|
RenderScriptingInterface::getInstance()->loadSettings();
|
||||||
|
|
||||||
// Here is the mapping between pelatformTIer and performance profile
|
// Setup the PerformanceManager which will enforce the several settings to match the Preset
|
||||||
const std::array<PerformanceManager::PerformancePreset, platform::Profiler::NumTiers> platformToPerformancePresetMap = {{
|
// On the first run, the Preset is evaluated from the
|
||||||
PerformanceManager::PerformancePreset::MID, // platform::Profiler::UNKNOWN
|
getPerformanceManager().setupPerformancePresetSettings(_firstRun.get());
|
||||||
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
|
// 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
|
// dictated that we should be in first person
|
||||||
|
|
|
@ -10,10 +10,34 @@
|
||||||
//
|
//
|
||||||
#include "PerformanceManager.h"
|
#include "PerformanceManager.h"
|
||||||
|
|
||||||
|
#include <platform/Profiler.h>
|
||||||
|
|
||||||
#include "scripting/RenderScriptingInterface.h"
|
#include "scripting/RenderScriptingInterface.h"
|
||||||
|
|
||||||
PerformanceManager::PerformanceManager()
|
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<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
|
||||||
|
setPerformancePreset(platformToPerformancePresetMap[platformTier]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePreset preset) {
|
void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePreset preset) {
|
||||||
|
@ -27,7 +51,7 @@ void PerformanceManager::setPerformancePreset(PerformanceManager::PerformancePre
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceManager::PerformancePreset PerformanceManager::getPerformancePreset() const {
|
PerformanceManager::PerformancePreset PerformanceManager::getPerformancePreset() const {
|
||||||
PerformancePreset preset = PerformancePreset::MID;
|
PerformancePreset preset = PerformancePreset::UNKNOWN;
|
||||||
|
|
||||||
preset = (PerformancePreset) _performancePresetSettingLock.resultWithReadLock<int>([&] {
|
preset = (PerformancePreset) _performancePresetSettingLock.resultWithReadLock<int>([&] {
|
||||||
return _performancePresetSetting.get();
|
return _performancePresetSetting.get();
|
||||||
|
@ -42,7 +66,7 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP
|
||||||
case PerformancePreset::HIGH:
|
case PerformancePreset::HIGH:
|
||||||
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED);
|
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::DEFERRED);
|
||||||
RenderScriptingInterface::getInstance()->setShadowsEnabled(true);
|
RenderScriptingInterface::getInstance()->setShadowsEnabled(true);
|
||||||
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::INTERACTIVE);
|
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PerformancePreset::MID:
|
case PerformancePreset::MID:
|
||||||
|
@ -57,7 +81,9 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP
|
||||||
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO);
|
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case PerformancePreset::UNKNOWN:
|
||||||
default:
|
default:
|
||||||
|
// Do nothing anymore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
class PerformanceManager {
|
class PerformanceManager {
|
||||||
public:
|
public:
|
||||||
enum PerformancePreset {
|
enum PerformancePreset {
|
||||||
LOW = 0,
|
UNKNOWN = 0, // Matching the platform Tier profiles enumeration for coherence
|
||||||
|
LOW,
|
||||||
MID,
|
MID,
|
||||||
HIGH,
|
HIGH,
|
||||||
PROFILE_COUNT
|
PROFILE_COUNT
|
||||||
|
@ -29,12 +30,16 @@ public:
|
||||||
PerformanceManager();
|
PerformanceManager();
|
||||||
~PerformanceManager() = default;
|
~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);
|
void setPerformancePreset(PerformancePreset performancePreset);
|
||||||
PerformancePreset getPerformancePreset() const;
|
PerformancePreset getPerformancePreset() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable ReadWriteLockable _performancePresetSettingLock;
|
mutable ReadWriteLockable _performancePresetSettingLock;
|
||||||
Setting::Handle<int> _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::MID };
|
Setting::Handle<int> _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::UNKNOWN };
|
||||||
|
|
||||||
// The concrete performance preset changes
|
// The concrete performance preset changes
|
||||||
void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset);
|
void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset);
|
||||||
|
|
|
@ -21,6 +21,7 @@ PerformanceScriptingInterface::PerformanceScriptingInterface() {
|
||||||
|
|
||||||
void PerformanceScriptingInterface::setPerformancePreset(PerformancePreset performancePreset) {
|
void PerformanceScriptingInterface::setPerformancePreset(PerformancePreset performancePreset) {
|
||||||
qApp->getPerformanceManager().setPerformancePreset((PerformanceManager::PerformancePreset)performancePreset);
|
qApp->getPerformanceManager().setPerformancePreset((PerformanceManager::PerformancePreset)performancePreset);
|
||||||
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::getPerformancePreset() const {
|
PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::getPerformancePreset() const {
|
||||||
|
@ -28,12 +29,13 @@ PerformanceScriptingInterface::PerformancePreset PerformanceScriptingInterface::
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PerformanceScriptingInterface::getPerformancePresetNames() const {
|
QStringList PerformanceScriptingInterface::getPerformancePresetNames() const {
|
||||||
static const QStringList performancePresetNames = { "Low", "Mid", "High" };
|
static const QStringList performancePresetNames = { "UNKNOWN", "LOW", "MID", "HIGH" };
|
||||||
return performancePresetNames;
|
return performancePresetNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) {
|
void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) {
|
||||||
qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile);
|
qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile);
|
||||||
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface::getRefreshRateProfile() const {
|
PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface::getRefreshRateProfile() const {
|
||||||
|
@ -41,7 +43,7 @@ PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface:
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PerformanceScriptingInterface::getRefreshRateProfileNames() const {
|
QStringList PerformanceScriptingInterface::getRefreshRateProfileNames() const {
|
||||||
static const QStringList refreshRateProfileNames = { "Eco", "Interactive", "Realtime" };
|
static const QStringList refreshRateProfileNames = { "ECO", "INTERACTIVE", "REALTIME" };
|
||||||
return refreshRateProfileNames;
|
return refreshRateProfileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,14 @@
|
||||||
|
|
||||||
class PerformanceScriptingInterface : public QObject {
|
class PerformanceScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(PerformancePreset performancePreset READ getPerformancePreset WRITE setPerformancePreset NOTIFY settingsChanged)
|
||||||
|
Q_PROPERTY(RefreshRateProfile refreshRateProfile READ getRefreshRateProfile WRITE setRefreshRateProfile NOTIFY settingsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// PerformanceManager PerformancePreset tri state level enums
|
// PerformanceManager PerformancePreset tri state level enums
|
||||||
enum PerformancePreset {
|
enum PerformancePreset {
|
||||||
|
UNKNOWN = PerformanceManager::PerformancePreset::UNKNOWN,
|
||||||
LOW = PerformanceManager::PerformancePreset::LOW,
|
LOW = PerformanceManager::PerformancePreset::LOW,
|
||||||
MID = PerformanceManager::PerformancePreset::MID,
|
MID = PerformanceManager::PerformancePreset::MID,
|
||||||
HIGH = PerformanceManager::PerformancePreset::HIGH,
|
HIGH = PerformanceManager::PerformancePreset::HIGH,
|
||||||
|
@ -55,6 +59,9 @@ public slots:
|
||||||
RefreshRateManager::UXMode getUXMode() const;
|
RefreshRateManager::UXMode getUXMode() const;
|
||||||
RefreshRateManager::RefreshRateRegime getRefreshRateRegime() const;
|
RefreshRateManager::RefreshRateRegime getRefreshRateRegime() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void settingsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::once_flag registry_flag;
|
static std::once_flag registry_flag;
|
||||||
};
|
};
|
||||||
|
|
|
@ -186,8 +186,8 @@ public slots:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get the Platform TIer profiled on startup of the Computer
|
* Get the Platform TIer profiled on startup of the Computer
|
||||||
* Platform Tier is an ineger/enum value:
|
* Platform Tier is an integer/enum value:
|
||||||
* LOW = 0, MID = 1, HIGH = 2
|
* UNKNOWN = 0, LOW = 1, MID = 2, HIGH = 3
|
||||||
* @function PlatformInfo.getTierProfiled
|
* @function PlatformInfo.getTierProfiled
|
||||||
* @returns {number} The Platform Tier profiled on startup.
|
* @returns {number} The Platform Tier profiled on startup.
|
||||||
*/
|
*/
|
||||||
|
@ -195,8 +195,8 @@ public slots:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get the Platform Tier possible Names as an array of strings
|
* Get the Platform Tier possible Names as an array of strings
|
||||||
* Platform Tier is an ineger/enum value:
|
* Platform Tier names are:
|
||||||
* LOW = 0, MID = 1, HIGH = 2
|
* [ "UNKNOWN", "LOW", "MID", "HIGH" ]
|
||||||
* @function PlatformInfo.getPlatformTierNames
|
* @function PlatformInfo.getPlatformTierNames
|
||||||
* @returns {string} The array of names matching the number returned from PlatformInfo.getTierProfiled
|
* @returns {string} The array of names matching the number returned from PlatformInfo.getTierProfiled
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,118 +10,138 @@
|
||||||
#include "LightingModel.h"
|
#include "LightingModel.h"
|
||||||
#include "AntialiasingEffect.h"
|
#include "AntialiasingEffect.h"
|
||||||
|
|
||||||
const QString DEFERRED = "deferred";
|
|
||||||
const QString FORWARD = "forward";
|
|
||||||
|
|
||||||
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
||||||
static RenderScriptingInterface sharedInstance;
|
static RenderScriptingInterface sharedInstance;
|
||||||
return &sharedInstance;
|
return &sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::once_flag RenderScriptingInterface::registry_flag;
|
||||||
|
|
||||||
RenderScriptingInterface::RenderScriptingInterface() {
|
RenderScriptingInterface::RenderScriptingInterface() {
|
||||||
setRenderMethod((RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD);
|
std::call_once(registry_flag, [] {
|
||||||
setShadowsEnabled(_shadowsEnabledSetting.get());
|
qmlRegisterType<RenderScriptingInterface>("RenderEnums", 1, 0, "RenderEnums");
|
||||||
setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get());
|
});
|
||||||
setAntialiasingEnabled(_antialiasingEnabledSetting.get());
|
}
|
||||||
|
|
||||||
|
void RenderScriptingInterface::loadSettings() {
|
||||||
|
_renderSettingLock.withReadLock([&] {
|
||||||
|
_renderMethod = (_renderMethodSetting.get());
|
||||||
|
_shadowsEnabled = (_shadowsEnabledSetting.get());
|
||||||
|
_ambientOcclusionEnabled = (_ambientOcclusionEnabledSetting.get());
|
||||||
|
_antialiasingEnabled = (_antialiasingEnabledSetting.get());
|
||||||
|
});
|
||||||
|
forceRenderMethod((RenderMethod)_renderMethod);
|
||||||
|
forceShadowsEnabled(_shadowsEnabled);
|
||||||
|
forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);
|
||||||
|
forceAntialiasingEnabled(_antialiasingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() {
|
RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() {
|
||||||
return (RenderMethod)_renderMethodSetting.get() == RenderMethod::DEFERRED ? RenderMethod::DEFERRED : RenderMethod::FORWARD;
|
return (RenderMethod) _renderMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScriptingInterface::setRenderMethod(RenderScriptingInterface::RenderMethod renderMethod) {
|
void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) {
|
||||||
RenderMethod newMethod = renderMethod == RenderMethod::FORWARD ? RenderMethod::FORWARD : RenderMethod::DEFERRED;
|
if (_renderMethod != (int) renderMethod) {
|
||||||
if (_renderMethodSetting.get() == newMethod) {
|
forceRenderMethod(renderMethod);
|
||||||
return;
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) {
|
||||||
|
_renderSettingLock.withWriteLock([&] {
|
||||||
|
_renderMethod = (int)renderMethod;
|
||||||
|
_renderMethodSetting.set((int)renderMethod);
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
|
||||||
QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(RenderScriptingInterface::RenderMethod, renderMethod));
|
if (config) {
|
||||||
return;
|
config->setBranch((int)renderMethod);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
|
|
||||||
if (config) {
|
|
||||||
_renderMethodSetting.set(newMethod);
|
|
||||||
config->setBranch(newMethod);
|
|
||||||
emit config->dirtyEnabled();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList RenderScriptingInterface::getRenderMethodNames() const {
|
QStringList RenderScriptingInterface::getRenderMethodNames() const {
|
||||||
static const QStringList refrenderMethodNames = { "Deferred", "Forward" };
|
static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" };
|
||||||
return refrenderMethodNames;
|
return refrenderMethodNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getShadowsEnabled() {
|
bool RenderScriptingInterface::getShadowsEnabled() {
|
||||||
return _shadowsEnabledSetting.get();
|
return _shadowsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScriptingInterface::setShadowsEnabled(bool enabled) {
|
void RenderScriptingInterface::setShadowsEnabled(bool enabled) {
|
||||||
if (_shadowsEnabledSetting.get() == enabled) {
|
if (_shadowsEnabled != enabled) {
|
||||||
return;
|
forceShadowsEnabled(enabled);
|
||||||
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
void RenderScriptingInterface::forceShadowsEnabled(bool enabled) {
|
||||||
QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled));
|
_renderSettingLock.withWriteLock([&] {
|
||||||
return;
|
_shadowsEnabled = (enabled);
|
||||||
}
|
|
||||||
|
|
||||||
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
|
||||||
if (lightingModelConfig) {
|
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
|
|
||||||
_shadowsEnabledSetting.set(enabled);
|
_shadowsEnabledSetting.set(enabled);
|
||||||
lightingModelConfig->setShadow(enabled);
|
|
||||||
}
|
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||||
|
if (lightingModelConfig) {
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
|
||||||
|
lightingModelConfig->setShadow(enabled);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getAmbientOcclusionEnabled() {
|
bool RenderScriptingInterface::getAmbientOcclusionEnabled() {
|
||||||
return _ambientOcclusionEnabledSetting.get();
|
return _ambientOcclusionEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) {
|
void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) {
|
||||||
if (_ambientOcclusionEnabledSetting.get() == enabled) {
|
if (_ambientOcclusionEnabled != enabled) {
|
||||||
return;
|
forceAmbientOcclusionEnabled(enabled);
|
||||||
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) {
|
||||||
QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled));
|
_renderSettingLock.withWriteLock([&] {
|
||||||
return;
|
_ambientOcclusionEnabled = (enabled);
|
||||||
}
|
|
||||||
|
|
||||||
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
|
||||||
if (lightingModelConfig) {
|
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
|
|
||||||
_ambientOcclusionEnabledSetting.set(enabled);
|
_ambientOcclusionEnabledSetting.set(enabled);
|
||||||
lightingModelConfig->setAmbientOcclusion(enabled);
|
|
||||||
}
|
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||||
|
if (lightingModelConfig) {
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
|
||||||
|
lightingModelConfig->setAmbientOcclusion(enabled);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getAntialiasingEnabled() {
|
bool RenderScriptingInterface::getAntialiasingEnabled() {
|
||||||
return _antialiasingEnabledSetting.get();
|
return _antialiasingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) {
|
void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) {
|
||||||
if (_antialiasingEnabledSetting.get() == enabled) {
|
if (_antialiasingEnabled != enabled) {
|
||||||
return;
|
forceAntialiasingEnabled(enabled);
|
||||||
}
|
emit settingsChanged();
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
|
|
||||||
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) {
|
||||||
|
_renderSettingLock.withWriteLock([&] {
|
||||||
|
_antialiasingEnabled = (enabled);
|
||||||
|
_antialiasingEnabledSetting.set(enabled);
|
||||||
|
|
||||||
|
auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
|
||||||
|
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
|
||||||
|
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
|
||||||
|
if (enabled) {
|
||||||
|
mainViewJitterCamConfig->play();
|
||||||
|
mainViewAntialiasingConfig->setDebugFXAA(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainViewJitterCamConfig->none();
|
||||||
|
mainViewAntialiasingConfig->setDebugFXAA(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
*/
|
*/
|
||||||
class RenderScriptingInterface : public QObject {
|
class RenderScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod)
|
Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged)
|
||||||
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled)
|
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged)
|
||||||
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled)
|
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged)
|
||||||
Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled)
|
Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderScriptingInterface();
|
RenderScriptingInterface();
|
||||||
|
@ -36,11 +36,17 @@ public:
|
||||||
static RenderScriptingInterface* getInstance();
|
static RenderScriptingInterface* getInstance();
|
||||||
|
|
||||||
// RenderMethod enum type
|
// RenderMethod enum type
|
||||||
enum RenderMethod {
|
enum class RenderMethod {
|
||||||
DEFERRED = render::Args::RenderMethod::DEFERRED,
|
DEFERRED = render::Args::RenderMethod::DEFERRED,
|
||||||
FORWARD = render::Args::RenderMethod::FORWARD,
|
FORWARD = render::Args::RenderMethod::FORWARD,
|
||||||
};
|
};
|
||||||
Q_ENUM(RenderMethod);
|
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:
|
public slots:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -132,12 +138,32 @@ public slots:
|
||||||
*/
|
*/
|
||||||
// void setViewportResolutionScale(float resolutionScale);
|
// void setViewportResolutionScale(float resolutionScale);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void settingsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// One lock to serialize and access safely all the settings
|
||||||
|
mutable ReadWriteLockable _renderSettingLock;
|
||||||
|
|
||||||
|
// 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<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
|
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
|
||||||
Setting::Handle<bool> _shadowsEnabledSetting { "shadowsEnabled", true };
|
Setting::Handle<bool> _shadowsEnabledSetting { "shadowsEnabled", true };
|
||||||
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false };
|
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false };
|
||||||
Setting::Handle<bool> _antialiasingEnabledSetting { "antialiasingEnabled", true };
|
Setting::Handle<bool> _antialiasingEnabledSetting { "antialiasingEnabled", true };
|
||||||
Setting::Handle<float> _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;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RenderScriptingInterface_h
|
#endif // hifi_RenderScriptingInterface_h
|
||||||
|
|
|
@ -75,7 +75,12 @@ Prop.PropGroup {
|
||||||
filled: root.jobEnabled
|
filled: root.jobEnabled
|
||||||
fillColor: (root.jobEnabled ? global.colorGreenHighlight : global.colorOrangeAccent)
|
fillColor: (root.jobEnabled ? global.colorGreenHighlight : global.colorOrangeAccent)
|
||||||
icon: 5
|
icon: 5
|
||||||
iconMouseArea.onClicked: { toggleJobActivation() }
|
|
||||||
|
MouseArea{
|
||||||
|
id: mousearea
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: { root.toggleJobActivation() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ PropItem {
|
||||||
property alias enums : valueCombo.model
|
property alias enums : valueCombo.model
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// valueVar = root.valueVarGetter();
|
valueVar = root.valueVarGetter();
|
||||||
}
|
}
|
||||||
|
|
||||||
PropComboBox {
|
PropComboBox {
|
||||||
|
|
|
@ -29,6 +29,7 @@ Item {
|
||||||
readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight
|
readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight
|
||||||
readonly property color colorBorderLight: hifi.colors.lightGray
|
readonly property color colorBorderLight: hifi.colors.lightGray
|
||||||
readonly property color colorBorderHighight: hifi.colors.blueHighlight
|
readonly property color colorBorderHighight: hifi.colors.blueHighlight
|
||||||
|
readonly property color colorBorderLighter: hifi.colors.faintGray
|
||||||
|
|
||||||
readonly property color colorOrangeAccent: "#FF6309"
|
readonly property color colorOrangeAccent: "#FF6309"
|
||||||
readonly property color colorRedAccent: "#C62147"
|
readonly property color colorRedAccent: "#C62147"
|
||||||
|
|
|
@ -29,11 +29,19 @@ Canvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
property var fillColor: global.colorBorderHighight
|
property var fillColor: global.colorBorderHighight
|
||||||
onFillColorChanged: function () { //console.log("fillColor changed to: " + filled );
|
onFillColorChanged: function () { //console.log("fillColor changed to: " + fillColor );
|
||||||
requestPaint()
|
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"
|
contextType: "2d"
|
||||||
onPaint: {
|
onPaint: {
|
||||||
|
@ -86,14 +94,10 @@ Canvas {
|
||||||
if (filled) {
|
if (filled) {
|
||||||
context.fillStyle = fillColor;
|
context.fillStyle = fillColor;
|
||||||
context.fill();
|
context.fill();
|
||||||
} else {
|
}
|
||||||
context.strokeStyle = fillColor;
|
if (stroked) {
|
||||||
|
context.strokeStyle = strokeColor;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea{
|
|
||||||
id: mousearea
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -9,15 +9,47 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import controlsUit 1.0 as HifiControls
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
CheckBox {
|
||||||
Global { id: global }
|
Global { id: global }
|
||||||
|
id: control
|
||||||
color: global.fontColor
|
text: ""
|
||||||
|
checked: true
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
//anchors.left: root.splitter.right
|
indicator: Rectangle {
|
||||||
//anchors.verticalCenter: root.verticalCenter
|
color: global.colorBack
|
||||||
//width: root.width * global.valueAreaWidthScale
|
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
|
height: global.slimHeight
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ ComboBox {
|
||||||
horizontalAlignment: global.valueTextAlign
|
horizontalAlignment: global.valueTextAlign
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color:highlighted?global.colorBackHighlight:global.color;
|
color:highlighted ? global.colorBackHighlight : global.colorBack;
|
||||||
}
|
}
|
||||||
highlighted: valueCombo.highlightedIndex === index
|
highlighted: valueCombo.highlightedIndex === index
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,8 @@ ComboBox {
|
||||||
x: valueCombo.width - width - valueCombo.rightPadding
|
x: valueCombo.width - width - valueCombo.rightPadding
|
||||||
y: valueCombo.topPadding + (valueCombo.availableHeight - height) / 2
|
y: valueCombo.topPadding + (valueCombo.availableHeight - height) / 2
|
||||||
|
|
||||||
icon: 1
|
strokeColor: (valueCombo.down ? global.colorBorderLighter : global.colorBorderLight )
|
||||||
/*Connections {
|
icon: 1 + valueCombo.down
|
||||||
target: valueCombo
|
|
||||||
onPressedChanged: { canvas.icon = control.down + 1 }
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: PiText {
|
contentItem: PiText {
|
||||||
|
@ -56,8 +53,8 @@ ComboBox {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 120
|
implicitWidth: 120
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
color: global.color
|
color: global.colorBack
|
||||||
border.color: valueCombo.popup.visible ? global.colorBorderHighight : global.colorBorderLight
|
border.color: valueCombo.popup.visible ? global.colorBorderLighter : global.colorBorderLight
|
||||||
border.width: global.valueBorderWidth
|
border.width: global.valueBorderWidth
|
||||||
radius: global.valueBorderRadius
|
radius: global.valueBorderRadius
|
||||||
}
|
}
|
||||||
|
@ -78,7 +75,7 @@ ComboBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: global.color
|
color: global.colorBack
|
||||||
border.color: global.colorBorderHighight
|
border.color: global.colorBorderHighight
|
||||||
radius: global.valueBorderRadius
|
radius: global.valueBorderRadius
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,12 @@ Item {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
fillColor: global.colorOrangeAccent
|
fillColor: global.colorOrangeAccent
|
||||||
iconMouseArea.onClicked: { root.isUnfold = !root.isUnfold }
|
|
||||||
|
MouseArea{
|
||||||
|
id: mousearea
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: { root.isUnfold = !root.isUnfold }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ Column {
|
||||||
|
|
||||||
Prop.PropString {
|
Prop.PropString {
|
||||||
label: "Platform Tier"
|
label: "Platform Tier"
|
||||||
//object: Performance
|
|
||||||
valueVarSetter: function (v) {}
|
valueVarSetter: function (v) {}
|
||||||
valueVarGetter: function () {
|
valueVarGetter: function () {
|
||||||
return PlatformInfo.getPlatformTierNames()[PlatformInfo.getTierProfiled()]; }
|
return PlatformInfo.getPlatformTierNames()[PlatformInfo.getTierProfiled()]; }
|
||||||
|
@ -27,17 +26,15 @@ Column {
|
||||||
|
|
||||||
Prop.PropEnum {
|
Prop.PropEnum {
|
||||||
label: "Performance Preset"
|
label: "Performance Preset"
|
||||||
//object: Performance
|
object: Performance
|
||||||
valueVarSetter: Performance.setPerformancePreset
|
property: "performancePreset"
|
||||||
valueVarGetter: Performance.getPerformancePreset
|
|
||||||
enums: Performance.getPerformancePresetNames()
|
enums: Performance.getPerformancePresetNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop.PropEnum {
|
Prop.PropEnum {
|
||||||
label: "Refresh Rate Profile"
|
label: "Refresh Rate Profile"
|
||||||
//object: Performance
|
object: Performance
|
||||||
valueVarSetter: Performance.setRefreshRateProfile
|
property: "refreshRateProfile"
|
||||||
valueVarGetter: Performance.getRefreshRateProfile
|
|
||||||
enums: Performance.getRefreshRateProfileNames()
|
enums: Performance.getRefreshRateProfileNames()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ import controlsUit 1.0 as HifiControls
|
||||||
import "../../lib/prop" as Prop
|
import "../../lib/prop" as Prop
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
Prop.PropGroup {
|
Prop.PropGroup {
|
||||||
id: computer
|
id: computer
|
||||||
|
|
|
@ -24,33 +24,42 @@ Rectangle {
|
||||||
color: global.colorBack
|
color: global.colorBack
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
Column {
|
Column {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
Prop.PropFolderPanel {
|
Prop.PropFolderPanel {
|
||||||
label: "Performance Settings"
|
label: "Performance Settings"
|
||||||
isUnfold: true
|
isUnfold: true
|
||||||
panelFrameData: Component {
|
panelFrameData: Component {
|
||||||
PerformanceSettings {}
|
PerformanceSettings {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Prop.PropFolderPanel {
|
||||||
Prop.PropFolderPanel {
|
label: "Render Settings"
|
||||||
label: "Render Settings"
|
isUnfold: true
|
||||||
isUnfold: true
|
panelFrameData: Component {
|
||||||
panelFrameData: Component {
|
RenderSettings {
|
||||||
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 {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue