layers: Add DEBUG_OUTPUT support to shader_checker
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Mon, 5 Oct 2015 21:59:58 +0000 (15:59 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 8 Oct 2015 22:56:24 +0000 (16:56 -0600)
layers/shader_checker.cpp

index 9cf7c4f..94c5fd6 100644 (file)
 struct layer_data {
     debug_report_data *report_data;
     // TODO: put instance data here
-    VkDbgMsgCallback logging_callback;
+    std::vector<VkDbgMsgCallback> logging_callback;
 
     layer_data() :
-        report_data(nullptr),
-        logging_callback(nullptr)
+        report_data(nullptr)
     {};
 };
 
@@ -261,6 +260,7 @@ init_shader_checker(layer_data *my_data)
     uint32_t debug_action = 0;
     FILE *log_output = NULL;
     const char *option_str;
+    VkDbgMsgCallback callback;
     // initialize ShaderChecker options
     report_flags = getLayerOptionFlags("ShaderCheckerReportFlags", 0);
     getLayerOptionEnum("ShaderCheckerDebugAction", (uint32_t *) &debug_action);
@@ -269,7 +269,13 @@ init_shader_checker(layer_data *my_data)
     {
         option_str = getLayerOption("ShaderCheckerLogFilename");
         log_output = getLayerLogOutput(option_str, "ShaderChecker");
-        layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &my_data->logging_callback);
+        layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback);
+        my_data->logging_callback.push_back(callback);
+    }
+
+    if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) {
+        layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback);
+        my_data->logging_callback.push_back(callback);
     }
 
     if (!globalLockInitialized)
@@ -1212,8 +1218,10 @@ VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance)
 
     // Clean up logging callback, if any
     layer_data *my_data = get_my_data_ptr(key, layer_data_map);
-    if (my_data->logging_callback) {
-        layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback);
+    while (my_data->logging_callback.size() > 0) {
+        VkDbgMsgCallback callback = my_data->logging_callback.back();
+        layer_destroy_msg_callback(my_data->report_data, callback);
+        my_data->logging_callback.pop_back();
     }
 
     layer_debug_report_destroy_instance(my_data->report_data);