Changeset View
Standalone View
source/renderer/RenderingOptions.cpp
Show All 17 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "RenderingOptions.h" | #include "RenderingOptions.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/ShadowMap.h" | |||||
SRenderingOptions g_RenderingOptions; | SRenderingOptions g_RenderingOptions; | ||||
RenderPath RenderPathEnum::FromString(const CStr8& name) | RenderPath RenderPathEnum::FromString(const CStr8& name) | ||||
{ | { | ||||
if (name == "default") | if (name == "default") | ||||
return DEFAULT; | return DEFAULT; | ||||
if (name == "fixed") | if (name == "fixed") | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | SRenderingOptions::SRenderingOptions() | ||||
m_PostProc = false; | m_PostProc = false; | ||||
m_ShowSky = false; | m_ShowSky = false; | ||||
m_DisplayFrustum = false; | m_DisplayFrustum = false; | ||||
m_RenderActors = true; | m_RenderActors = true; | ||||
} | } | ||||
void SRenderingOptions::ReadConfig() | void SRenderingOptions::ReadConfig() | ||||
{ | { | ||||
CFG_GET_VAL("shadows", m_Shadows); | #define DEFAULT_HOOK(config, variable) g_ConfigDB.RegisterHook(config, [this]() { CFG_GET_VAL(config, variable); } ); | ||||
CFG_GET_VAL("shadowpcf", m_ShadowPCF); | |||||
vladislavbelov: It's a bit dangerous, as it's not guaranteed that the variables is the class member. | |||||
Done Inline ActionsWell, the earlier Macro would have worked around that, but @elexis preferred it differently. Your call. (I _might_ be able to work out a template trick for that, your call) wraitii: Well, the earlier Macro would have worked around that, but @elexis preferred it differently. | |||||
Not Done Inline ActionsWhy is it dangerous and not a feature? elexis: Why is it dangerous and not a feature?
| |||||
Not Done Inline ActionsI guess it will complain if the reference doesnt exist anymore (local variable), otherwise shouldn't be wrong to be able to pass globals for example. Also the private keyword limits the use of the function. Didnt check too thoroughly, was the previous macro actually more strict? Sure we cant be as strict without resorting to a macro? elexis: I guess it will complain if the reference doesnt exist anymore (local variable), otherwise… | |||||
Not Done Inline Actions
Because it might capture a local variable or a member with a different lifetime.
Who? vladislavbelov: > Why is it dangerous and not a feature?
Because it might capture a local variable or a member… | |||||
Not Done Inline ActionsThe program, as in runtime error. elexis: The program, as in runtime error.
The first version of the diff has the same possibility, no? | |||||
Not Done Inline Actions
It's UB, so we don't know what will happen exactly.
I didn't see, which one? vladislavbelov: > The program, as in runtime error.
It's UB, so we don't know what will happen exactly.
> The… | |||||
Not Done Inline ActionsYou can click on the History tab -> https://code.wildfiregames.com/D2293?id=9775 elexis: You can click on the History tab -> https://code.wildfiregames.com/D2293?id=9775 | |||||
Done Inline ActionsYou're correct, sorry, the macro didn't improve anything in that respect. I can add a comment if necessary. wraitii: You're correct, sorry, the macro didn't improve anything in that respect.
Still I would side… | |||||
CFG_GET_VAL("preferglsl", m_PreferGLSL); | g_ConfigDB.RegisterHook("shadowquality", []() { | ||||
Not Done Inline Actionsconst ? Stan: const ? | |||||
CFG_GET_VAL("postproc", m_PostProc); | g_Renderer.GetShadowMap().RecreateTexture(); | ||||
CFG_GET_VAL("smoothlos", m_SmoothLOS); | }); | ||||
Not Done Inline ActionsIs it guaranteed that this lifetime isn't shorter than CConfigDB? vladislavbelov: Is it guaranteed that `this` lifetime isn't shorter than `CConfigDB`? | |||||
Done Inline ActionsIn this instance it's a global, so it should be fine wraitii: In this instance it's a global, so it should be fine | |||||
g_ConfigDB.RegisterHook("shadows", [this]() { | |||||
bool enabled; | |||||
CFG_GET_VAL("shadows", enabled); | |||||
SetShadows(enabled); | |||||
}); | |||||
g_ConfigDB.RegisterHook("shadowpcf", [this]() { | |||||
bool enabled; | |||||
CFG_GET_VAL("shadowpcf", enabled); | |||||
SetShadowPCF(enabled); | |||||
}); | |||||
DEFAULT_HOOK("postproc", m_PostProc); | |||||
DEFAULT_HOOK("smoothlos", m_SmoothLOS); | |||||
g_ConfigDB.RegisterHook("renderpath", [this]() { | |||||
CStr renderPath; | CStr renderPath; | ||||
CFG_GET_VAL("renderpath", renderPath); | CFG_GET_VAL("renderpath", renderPath); | ||||
SetRenderPath(RenderPathEnum::FromString(renderPath)); | SetRenderPath(RenderPathEnum::FromString(renderPath)); | ||||
}); | |||||
CFG_GET_VAL("watereffects", m_WaterEffects); | DEFAULT_HOOK("watereffects", m_WaterEffects); | ||||
CFG_GET_VAL("waterfancyeffects", m_WaterFancyEffects); | DEFAULT_HOOK("waterfancyeffects", m_WaterFancyEffects); | ||||
CFG_GET_VAL("waterrealdepth", m_WaterRealDepth); | DEFAULT_HOOK("waterrealdepth", m_WaterRealDepth); | ||||
CFG_GET_VAL("waterrefraction", m_WaterRefraction); | DEFAULT_HOOK("waterrefraction", m_WaterRefraction); | ||||
CFG_GET_VAL("waterreflection", m_WaterReflection); | DEFAULT_HOOK("waterreflection", m_WaterReflection); | ||||
CFG_GET_VAL("watershadows", m_WaterShadows); | DEFAULT_HOOK("watershadows", m_WaterShadows); | ||||
CFG_GET_VAL("particles", m_Particles); | DEFAULT_HOOK("particles", m_Particles); | ||||
CFG_GET_VAL("fog", m_Fog); | g_ConfigDB.RegisterHook("fog", [this]() { | ||||
CFG_GET_VAL("silhouettes", m_Silhouettes); | bool enabled; | ||||
CFG_GET_VAL("showsky", m_ShowSky); | CFG_GET_VAL("fog", enabled); | ||||
SetFog(enabled); | |||||
}); | |||||
DEFAULT_HOOK("silhouettes", m_Silhouettes); | |||||
DEFAULT_HOOK("showsky", m_ShowSky); | |||||
CFG_GET_VAL("novbo", m_NoVBO); | DEFAULT_HOOK("novbo", m_NoVBO); | ||||
CFG_GET_VAL("forcealphatest", m_ForceAlphaTest); | DEFAULT_HOOK("forcealphatest", m_ForceAlphaTest); | ||||
CFG_GET_VAL("gpuskinning", m_GPUSkinning); | DEFAULT_HOOK("gpuskinning", m_GPUSkinning); | ||||
CFG_GET_VAL("renderactors", m_RenderActors); | DEFAULT_HOOK("renderactors", m_RenderActors); | ||||
#undef DEFAULT_HOOK | |||||
} | } | ||||
Done Inline ActionsRegression :) Stan: Regression :) | |||||
Done Inline Actionssee above :) wraitii: see above :) | |||||
void SRenderingOptions::SetShadows(bool value) | void SRenderingOptions::SetShadows(bool value) | ||||
{ | { | ||||
m_Shadows = value; | m_Shadows = value; | ||||
g_Renderer.MakeShadersDirty(); | g_Renderer.MakeShadersDirty(); | ||||
} | } | ||||
void SRenderingOptions::SetShadowPCF(bool value) | void SRenderingOptions::SetShadowPCF(bool value) | ||||
Show All 24 Lines |
It's a bit dangerous, as it's not guaranteed that the variables is the class member.