From: Tim Rowley Date: Mon, 31 Jul 2017 22:22:54 +0000 (-0500) Subject: swr/rast: simplify knob default value setup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8fe4c13b23d11b3ef980969dea80de9da1fd105;p=mesa.git swr/rast: simplify knob default value setup Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.h b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.h index b02870be464..d81f7d019eb 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.h +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.h @@ -67,12 +67,6 @@ public: return Value(); } -protected: - Knob(T const &defaultValue) : - m_Value(expandEnvironmentVariables(defaultValue)) - { - } - private: T m_Value; }; @@ -83,10 +77,10 @@ private: { \\ - Knob_##_name() : Knob<_type>(_default) { } \\ - static const char* Name() { return "KNOB_" #_name; } \\ + static _type DefaultValue() { return (_default); } \\ + } _name; #define GET_KNOB(_name) g_GlobalKnobs._name.Value() @@ -117,8 +111,9 @@ struct GlobalKnobs % endif % endfor - GlobalKnobs(); + std::string ToString(const char* optPerLinePrefix=""); + GlobalKnobs(); }; extern GlobalKnobs g_GlobalKnobs; diff --git a/src/gallium/drivers/swr/rasterizer/core/knobs_init.h b/src/gallium/drivers/swr/rasterizer/core/knobs_init.h index ba2df2292f0..12c2a3031ea 100644 --- a/src/gallium/drivers/swr/rasterizer/core/knobs_init.h +++ b/src/gallium/drivers/swr/rasterizer/core/knobs_init.h @@ -91,16 +91,18 @@ static inline void ConvertEnvToKnob(const char* pOverride, std::string& knobValu template static inline void InitKnob(T& knob) { - - // TODO, read registry first - - // Second, read environment variables + // Read environment variables const char* pOverride = getenv(knob.Name()); if (pOverride) { - auto knobValue = knob.Value(); + auto knobValue = knob.DefaultValue(); ConvertEnvToKnob(pOverride, knobValue); knob.Value(knobValue); } + else + { + // Set default value + knob.Value(knob.DefaultValue()); + } }