swr/rast: simplify knob default value setup
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 31 Jul 2017 22:22:54 +0000 (17:22 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 2 Aug 2017 16:39:33 +0000 (11:39 -0500)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.h
src/gallium/drivers/swr/rasterizer/core/knobs_init.h

index b02870be46402d8ec72f8e3309531f7935a2d34a..d81f7d019eb0a7803707bf765b8a8236a6f4af5d 100644 (file)
@@ -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;
 
index ba2df2292f0a7536ec9dc4a8ddffb6222fd27d81..12c2a3031eafa2d42f0ed00a5b0105b3b5897484 100644 (file)
@@ -91,16 +91,18 @@ static inline void ConvertEnvToKnob(const char* pOverride, std::string& knobValu
 template <typename T>
 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());
+    }
 }