layers: Add constructors for layer_data
authorCody Northrop <cody@lunarg.com>
Mon, 28 Sep 2015 21:09:32 +0000 (15:09 -0600)
committerCody Northrop <cody@lunarg.com>
Mon, 28 Sep 2015 21:10:46 +0000 (15:10 -0600)
layers/device_limits.cpp
layers/draw_state.cpp
layers/image.cpp
layers/mem_tracker.cpp
layers/object_track.h
layers/param_checker.cpp
layers/shader_checker.cpp
layers/swapchain.cpp
layers/swapchain.h
layers/threading.h

index 30e57d4463eddc9953fa22a09268a3cf3239ac7b..37ad695f170dd89c027c10e658abe38257d561ee 100644 (file)
 #include "vk_layer_extension_utils.h"
 #include "vk_layer_utils.h"
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     // TODO: put instance data here
     VkDbgMsgCallback logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
 
 static std::unordered_map<void *, layer_data *> layer_data_map;
 static device_table_map device_limits_device_table_map;
index 915b940773035e64a1e6d53af62dbef41a3aa76f..5a6d121182c80848e28e02c9232cacc70632958d 100644 (file)
 #include "vk_layer_logging.h"
 #include "vk_layer_extension_utils.h"
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     // TODO: put instance data here
     VkDbgMsgCallback logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
 
 static std::unordered_map<void *, layer_data *> layer_data_map;
 static device_table_map draw_state_device_table_map;
index c3ff045cd3b7a45989ca1290a81b0866ad7275aa..d58f1a7548679c47c049bac9fae26ae872f93153 100644 (file)
 
 using namespace std;
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     VkDbgMsgCallback logging_callback;
     VkPhysicalDevice physicalDevice;
     unordered_map<uint64_t, unique_ptr<IMAGE_STATE>> imageMap;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr),
+        physicalDevice(0)
+    {};
+};
 
 static unordered_map<void*, layer_data*> layer_data_map;
 static device_table_map image_device_table_map;
index 36574f60cd8d73f5aae65ba1a6b5786302b210ec..f42b686f46f6d2dc3cce6594dd96ae43dc2394ed 100644 (file)
@@ -50,12 +50,18 @@ static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
 // Object value will be used to identify them internally.
 static const VkDeviceMemory MEMTRACKER_SWAP_CHAIN_IMAGE_KEY = static_cast<VkDeviceMemory>(-1);
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     // TODO: put instance data here
     VkDbgMsgCallback logging_callback;
     bool wsi_enabled;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr),
+        wsi_enabled(false)
+    {};
+};
 
 static unordered_map<void *, layer_data *> layer_data_map;
 
index dd266106088851092e69ac941e42046523a16810..e7d58201b2d0d444e47c7e15a317ed6eaecfe608 100644 (file)
@@ -65,13 +65,20 @@ uint64_t objTrackGetObjectsOfTypeCount(VkDevice, VkDbgObjectType type);
 typedef uint64_t (*OBJ_TRACK_GET_OBJECT_COUNT)(VkDevice);
 typedef uint64_t (*OBJ_TRACK_GET_OBJECTS_OF_TYPE_COUNT)(VkDevice, VkDbgObjectType);
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     //TODO: put instance data here
     VkDbgMsgCallback   logging_callback;
     bool wsi_enabled;
     bool objtrack_extensions_enabled;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr),
+        wsi_enabled(false),
+        objtrack_extensions_enabled(false)
+    {};
+};
 
 struct instExts {
     bool wsi_enabled;
index 0b6909ddb915682ea4d7235d5af47102d5943fb9..7c8d6c71d9e1102c1f7ef002e28928d7d7b5e03e 100644 (file)
 #include "vk_layer_logging.h"
 #include "vk_layer_extension_utils.h"
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     VkDbgMsgCallback logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
 
 static std::unordered_map<void*, layer_data*> layer_data_map;
 static device_table_map pc_device_table_map;
index 41d10b110ec0d19bfd4209c2a9b1cc95b66fd2cc..6146b94b1af5c1c3a5e9f9984c77a5573fbe0e55 100644 (file)
 #include "spirv/spirv.hpp"
 
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     // TODO: put instance data here
     VkDbgMsgCallback logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
 
 static std::unordered_map<void *, layer_data *> layer_data_map;
 static device_table_map shader_checker_device_table_map;
index bfcd2ab87d83766d44c44325c854d05f7f2806f6..a36854b0f25bd330725ae1757d605561b3fb594b 100644 (file)
@@ -145,7 +145,7 @@ static void initSwapchain(void)
         // Turn on logging, since it was requested:
         option_str = getLayerOption("SwapchainLogFilename");
         log_output = getLayerLogOutput(option_str, "Swapchain");
-        layer_create_msg_callback(&mydata.report_data, report_flags,
+        layer_create_msg_callback(mydata.report_data, report_flags,
                                   log_callback, (void *) log_output,
                                   &mydata.logging_callback);
     }
@@ -351,7 +351,6 @@ VK_LAYER_EXPORT void VKAPI vkDestroyDevice(VkDevice device)
         if (deviceMap[device].pPresentModes) {
             free(deviceMap[device].pPresentModes);
         }
-        deviceMap.erase(device);
         if (!pDevice->swapchains.empty()) {
             LOG_ERROR(VK_OBJECT_TYPE_DEVICE, device, "VkDevice",
                       SWAPCHAIN_DEL_DEVICE_BEFORE_SWAPCHAINS,
@@ -366,6 +365,7 @@ VK_LAYER_EXPORT void VKAPI vkDestroyDevice(VkDevice device)
             }
             pDevice->swapchains.clear();
         }
+        deviceMap.erase(device);
     }
 }
 
@@ -657,7 +657,7 @@ static VkBool32 validateCreateSwapchainKHR(VkDevice device, const VkSwapchainCre
                 }
             }
             // Log the message that we've built up:
-            skipCall |= debug_report_log_msg(&mydata.report_data,
+            skipCall |= debug_report_log_msg(mydata.report_data,
                                              VK_DBG_REPORT_ERROR_BIT,
                                              VK_OBJECT_TYPE_DEVICE,
                                              (uint64_t) device, 0, 
@@ -1104,12 +1104,12 @@ static inline PFN_vkVoidFunction layer_intercept_instance_proc(const char *name)
 
 VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(VkInstance instance, VkFlags msgFlags, const PFN_vkDbgMsgCallback pfnMsgCallback, void* pUserData, VkDbgMsgCallback* pMsgCallback)
 {
-    return layer_create_msg_callback(&mydata.report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
+    return layer_create_msg_callback(mydata.report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
 }
 
 VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback(VkInstance instance, VkDbgMsgCallback msgCallback)
 {
-    layer_destroy_msg_callback(&mydata.report_data, msgCallback);
+    layer_destroy_msg_callback(mydata.report_data, msgCallback);
     return VK_SUCCESS;
 }
 
index 8414d474b91215940d931c2d8de1ac94e55d2679..9a336283f7c6e5a8f09463f3e4a9f679cfe1a517 100644 (file)
@@ -65,21 +65,27 @@ typedef enum _SWAPCHAIN_ERROR
 
 
 // The following is for logging error messages:
-typedef struct _layer_data {
-    debug_report_data report_data;
+struct layer_data {
+    debug_report_data *report_data;
     VkDbgMsgCallback logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
+
 #define LAYER_NAME (char *) "Swapchain"
 #define LOG_ERROR_NON_VALID_OBJ(objType, type, obj)                     \
-    log_msg(&mydata.report_data, VK_DBG_REPORT_ERROR_BIT, (objType),    \
+    log_msg(mydata.report_data, VK_DBG_REPORT_ERROR_BIT, (objType),    \
             (uint64_t) (obj), 0, SWAPCHAIN_INVALID_HANDLE, LAYER_NAME,  \
             "%s() called with a non-valid %s.", __FUNCTION__, (obj))
 
 #define LOG_ERROR(objType, type, obj, enm, fmt, ...)                    \
-    log_msg(&mydata.report_data, VK_DBG_REPORT_ERROR_BIT, (objType),    \
+    log_msg(mydata.report_data, VK_DBG_REPORT_ERROR_BIT, (objType),    \
             (uint64_t) (obj), 0, (enm), LAYER_NAME, (fmt), __VA_ARGS__)
 #define LOG_PERF_WARNING(objType, type, obj, enm, fmt, ...)             \
-    log_msg(&mydata.report_data, VK_DBG_REPORT_PERF_WARN_BIT, (objType), \
+    log_msg(mydata.report_data, VK_DBG_REPORT_PERF_WARN_BIT, (objType), \
             (uint64_t) (obj), 0, (enm), LAYER_NAME, (fmt), __VA_ARGS__)
 
 
index 367679c7ecefffead6c4507aa7345bab494bf12b..5335578b82e0b3553eaaa3504ce944cf264fd7f4 100644 (file)
@@ -34,10 +34,15 @@ typedef enum _THREADING_CHECKER_ERROR
     THREADING_CHECKER_SINGLE_THREAD_REUSE,              // Object used simultaneously by recursion in single thread
 } THREADING_CHECKER_ERROR;
 
-typedef struct _layer_data {
+struct layer_data {
     debug_report_data *report_data;
     VkDbgMsgCallback   logging_callback;
-} layer_data;
+
+    layer_data() :
+        report_data(nullptr),
+        logging_callback(nullptr)
+    {};
+};
 
 static std::unordered_map<void*, layer_data *> layer_data_map;
 static device_table_map                        Threading_device_table_map;