shader_checker: add plumbing for debug
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp
index 8b49660..835a334 100644
--- a/layers/shader_checker.cpp
+++ b/layers/shader_checker.cpp
@@ -31,14 +31,17 @@
 #include "loader_platform.h"
 #include "vk_dispatch_table_helper.h"
 #include "vkLayer.h"
+#include "layers_config.h"
+#include "layers_msg.h"
 // The following is #included again to catch certain OS-specific functions
 // being used:
 #include "loader_platform.h"
 
 #include "SPIRV/spirv.h"
 
-static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
 
+static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
+static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
 
 
 static void
@@ -103,6 +106,27 @@
 static std::unordered_map<void *, shader_source *> shader_map;
 
 
+static void
+initLayer()
+{
+    const char *strOpt;
+    // initialize ShaderChecker options
+    getLayerOptionEnum("ShaderCheckerReportLevel", (uint32_t *) &g_reportingLevel);
+    g_actionIsDefault = getLayerOptionEnum("ShaderCheckerDebugAction", (uint32_t *) &g_debugAction);
+
+    if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG)
+    {
+        strOpt = getLayerOption("ShaderCheckerLogFilename");
+        if (strOpt)
+        {
+            g_logFile = fopen(strOpt, "w");
+        }
+        if (g_logFile == NULL)
+            g_logFile = stdout;
+    }
+}
+
+
 static VkLayerDispatchTable * initLayerTable(const VkBaseLayerObject *gpuw)
 {
     VkLayerDispatchTable *pTable;
@@ -128,6 +152,8 @@
 {
     VkLayerDispatchTable* pTable = tableMap[gpu];
     VkResult result = pTable->CreateDevice(gpu, pCreateInfo, pDevice);
+
+    loader_platform_thread_once(&g_initOnce, initLayer);
     // create a mapping for the device object into the dispatch table
     tableMap.emplace(*pDevice, pTable);
     return result;
@@ -727,6 +753,8 @@
 
     initLayerTable((const VkBaseLayerObject *) gpu);
 
+    loader_platform_thread_once(&g_initOnce, initLayer);
+
 #define ADD_HOOK(fn)    \
     if (!strncmp(#fn, pName, sizeof(#fn))) \
         return (void *) fn