History

Addressing the initialization bug not applying REnderMethod properly, Adjusting RefrehRateProfile to Realtime in High performancePreset

Sam Gateau committed 7 years ago

Commit 2a4d0cf1 parent db04f6116 files · +228 −133Browse files

Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 16 files). Show all

Unified · Split

interface/src/scripting/RenderScriptingInterface.cpp+80−66
@@ -21,34 +21,43 @@ RenderScriptingInterface::RenderScriptingInterface() { · 20 unmodified lines
2121 std::call_once(registry_flag, [] {
2222 qmlRegisterType<RenderScriptingInterface>("RenderEnums", 1, 0, "RenderEnums");
2323 });
24+}
2425
25− setRenderMethod((RenderMethod)_renderMethodSettingLock.resultWithReadLock<int>([&] {
26− return _renderMethodSetting.get();
27− }));
28− setShadowsEnabled(_shadowsEnabledSetting.get());
29− setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get());
30− setAntialiasingEnabled(_antialiasingEnabledSetting.get());
26+void RenderScriptingInterface::loadSettings() {
27+ _renderSettingLock.withReadLock([&] {
28+ _renderMethod.store(_renderMethodSetting.get());
29+ _shadowsEnabled.store(_shadowsEnabledSetting.get());
30+ _ambientOcclusionEnabled.store(_ambientOcclusionEnabledSetting.get());
31+ _antialiasingEnabled.store(_antialiasingEnabledSetting.get());
32+ });
33+ forceRenderMethod((RenderMethod)_renderMethod.load());
34+ forceShadowsEnabled(_shadowsEnabled.load());
35+ forceAmbientOcclusionEnabled(_ambientOcclusionEnabled.load());
36+ forceAntialiasingEnabled(_antialiasingEnabled.load());
3137 }
3238
3339 RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() {
34− return (RenderMethod) _renderMethod;
40+ return (RenderMethod) _renderMethod.load();
3541 }
3642
3743 void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) {
3844 if (_renderMethod != (int) renderMethod) {
39− _renderMethodSettingLock.withWriteLock([&] {
40− _renderMethod = (int)renderMethod;
41− _renderMethodSetting.set((int)renderMethod);
42−
43− auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
44− if (config) {
45− _renderMethodSetting.set((int)renderMethod);
46− config->setBranch((int)renderMethod);
47− }
48− });
45+ forceRenderMethod(renderMethod);
4946 emit settingsChanged();
5047 }
5148 }
49+void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) {
50+ _renderSettingLock.withWriteLock([&] {
51+ _renderMethod = (int)renderMethod;
52+ _renderMethodSetting.set((int)renderMethod);
53+
54+ auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
55+ if (config) {
56+ _renderMethodSetting.set((int)renderMethod);
57+ config->setBranch((int)renderMethod);
58+ }
59+ });
60+}
5261
5362 QStringList RenderScriptingInterface::getRenderMethodNames() const {
5463 static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" };
@@ -56,78 +65,83 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { · 1 unmodified line
5665 }
5766
5867 bool RenderScriptingInterface::getShadowsEnabled() {
59− return _shadowsEnabledSetting.get();
68+ return _shadowsEnabled.load();
6069 }
6170
6271 void RenderScriptingInterface::setShadowsEnabled(bool enabled) {
63− if (_shadowsEnabledSetting.get() == enabled) {
64− return;
65− }
66−
67− if (QThread::currentThread() != thread()) {
68− QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled));
69− return;
72+ if (_shadowsEnabled != enabled) {
73+ forceShadowsEnabled(enabled);
74+ emit settingsChanged();
7075 }
76+}
7177
72− auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
73− if (lightingModelConfig) {
74− Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
78+void RenderScriptingInterface::forceShadowsEnabled(bool enabled) {
79+ _renderSettingLock.withWriteLock([&] {
80+ _shadowsEnabled.store(enabled);
7581 _shadowsEnabledSetting.set(enabled);
76− lightingModelConfig->setShadow(enabled);
77− emit settingsChanged();
78− }
82+
83+ auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
84+ if (lightingModelConfig) {
85+ Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
86+ lightingModelConfig->setShadow(enabled);
87+ }
88+ });
7989 }
8090
8191 bool RenderScriptingInterface::getAmbientOcclusionEnabled() {
82− return _ambientOcclusionEnabledSetting.get();
92+ return _ambientOcclusionEnabled.load();
8393 }
8494
8595 void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) {
86− if (_ambientOcclusionEnabledSetting.get() == enabled) {
87− return;
88− }
89−
90− if (QThread::currentThread() != thread()) {
91− QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled));
92− return;
96+ if (_ambientOcclusionEnabled.load() != enabled) {
97+ forceAmbientOcclusionEnabled(enabled);
98+ emit settingsChanged();
9399 }
100+}
94101
95− auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
96− if (lightingModelConfig) {
97− Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
102+void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) {
103+ _renderSettingLock.withWriteLock([&] {
104+ _ambientOcclusionEnabled.store(enabled);
98105 _ambientOcclusionEnabledSetting.set(enabled);
99− lightingModelConfig->setAmbientOcclusion(enabled);
100− emit settingsChanged();
101− }
106+
107+ auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
108+ if (lightingModelConfig) {
109+ Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
110+ lightingModelConfig->setAmbientOcclusion(enabled);
111+ }
112+ });
102113 }
103114
104115 bool RenderScriptingInterface::getAntialiasingEnabled() {
105− return _antialiasingEnabledSetting.get();
116+ return _antialiasingEnabled.load();
106117 }
107118
108119 void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) {
109− if (_antialiasingEnabledSetting.get() == enabled) {
110− return;
111− }
112−
113− if (QThread::currentThread() != thread()) {
114− QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled));
115− return;
120+ if (_antialiasingEnabled.load() != enabled) {
121+ forceAntialiasingEnabled(enabled);
122+ emit settingsChanged();
116123 }
124+}
117125
118− auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
119− auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
120− if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
121− Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
126+void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) {
127+ _renderSettingLock.withWriteLock([&] {
128+ _antialiasingEnabled.store(enabled);
122129 _antialiasingEnabledSetting.set(enabled);
123− if (enabled) {
124− mainViewJitterCamConfig->play();
125− mainViewAntialiasingConfig->setDebugFXAA(false);
126− } else {
127− mainViewJitterCamConfig->none();
128− mainViewAntialiasingConfig->setDebugFXAA(true);
129− }
130130
131− emit settingsChanged();
132− }
131+ auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
132+ auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
133+ if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
134+ Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
135+ if (enabled) {
136+ mainViewJitterCamConfig->play();
137+ mainViewAntialiasingConfig->setDebugFXAA(false);
138+ }
139+ else {
140+ mainViewJitterCamConfig->none();
141+ mainViewAntialiasingConfig->setDebugFXAA(true);
142+ }
143+ }
144+ });
133145 }
146+
147+