Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1 | /* |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 2 | * Vulkan |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 3 | * |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 4 | * Copyright (C) 2015 LunarG, Inc. |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 25 | #include <inttypes.h> |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <assert.h> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 30 | #include <list> |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 31 | #include <map> |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 32 | #include <vector> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 33 | using namespace std; |
| 34 | |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 35 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 36 | #include "vk_dispatch_table_helper.h" |
| 37 | #include "vk_struct_string_helper_cpp.h" |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 38 | #include "mem_tracker.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 39 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 40 | #include "vk_layer_extension_utils.h" |
Ian Elliott | 655cad7 | 2015-02-12 17:08:34 -0700 | [diff] [blame] | 41 | // The following is #included again to catch certain OS-specific functions |
| 42 | // being used: |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 43 | #include "vk_loader_platform.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 44 | #include "vk_layer_table.h" |
| 45 | #include "vk_layer_data.h" |
| 46 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 47 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 48 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 49 | typedef struct _layer_data { |
| 50 | debug_report_data *report_data; |
| 51 | // TODO: put instance data here |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 52 | VkDbgMsgCallback logging_callback; |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 53 | bool wsi_lunarg_enabled; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 54 | } layer_data; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 55 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 56 | static std::unordered_map<void *, layer_data *> layer_data_map; |
| 57 | static device_table_map mem_tracker_device_table_map; |
| 58 | static instance_table_map mem_tracker_instance_table_map; |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 59 | static VkPhysicalDeviceMemoryProperties memProps; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 60 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 61 | // TODO : This can be much smarter, using separate locks for separate global data |
| 62 | static int globalLockInitialized = 0; |
| 63 | static loader_platform_thread_mutex globalLock; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 64 | |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 65 | #define MAX_BINDING 0xFFFFFFFF |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 66 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 67 | unordered_map<VkCmdBuffer, MT_CB_INFO> cbMap; |
| 68 | unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO> memObjMap; |
| 69 | unordered_map<VkObject, MT_OBJ_INFO> objectMap; |
| 70 | unordered_map<VkFence, MT_FENCE_INFO> fenceMap; // Map fence to fence info |
| 71 | unordered_map<VkQueue, MT_QUEUE_INFO> queueMap; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 72 | unordered_map<VkSwapChainWSI, MT_SWAP_CHAIN_INFO*> swapChainMap; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 73 | |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 74 | // TODO : Add per-device fence completion |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 75 | static uint64_t g_currentFenceId = 1; |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 76 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 77 | template layer_data *get_my_data_ptr<layer_data>( |
| 78 | void *data_key, |
| 79 | std::unordered_map<void *, layer_data *> &data_map); |
| 80 | |
| 81 | debug_report_data *mdd(VkObject object) |
| 82 | { |
Courtney Goeltzenleuchter | 6211086 | 2015-06-13 21:39:35 -0600 | [diff] [blame] | 83 | dispatch_key key = get_dispatch_key(object); |
| 84 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 85 | #if DISPATCH_MAP_DEBUG |
| 86 | fprintf(stderr, "MDD: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 87 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 88 | return my_data->report_data; |
| 89 | } |
| 90 | |
| 91 | debug_report_data *mid(VkInstance object) |
| 92 | { |
Courtney Goeltzenleuchter | 6211086 | 2015-06-13 21:39:35 -0600 | [diff] [blame] | 93 | dispatch_key key = get_dispatch_key(object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 94 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(object), layer_data_map); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 95 | #if DISPATCH_MAP_DEBUG |
| 96 | fprintf(stderr, "MID: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 97 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 98 | return my_data->report_data; |
| 99 | } |
| 100 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 101 | // Add new queue for this device to map container |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 102 | static void add_queue_info(const VkQueue queue) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 103 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 104 | MT_QUEUE_INFO* pInfo = &queueMap[queue]; |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 105 | pInfo->lastRetiredId = 0; |
| 106 | pInfo->lastSubmittedId = 0; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 107 | } |
| 108 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 109 | static void delete_queue_info_list( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 110 | void) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 111 | { |
| 112 | // Process queue list, cleaning up each entry before deleting |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 113 | queueMap.clear(); |
| 114 | } |
| 115 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 116 | static void add_swap_chain_info( |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 117 | const VkSwapChainWSI swapChain, const VkSwapChainCreateInfoWSI* pCI) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 118 | { |
| 119 | MT_SWAP_CHAIN_INFO* pInfo = new MT_SWAP_CHAIN_INFO; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 120 | memcpy(&pInfo->createInfo, pCI, sizeof(VkSwapChainCreateInfoWSI)); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 121 | swapChainMap[swapChain] = pInfo; |
| 122 | } |
| 123 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 124 | // Add new CBInfo for this cb to map container |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 125 | static void add_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 126 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 127 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 128 | cbMap[cb].cmdBuffer = cb; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 131 | // Return ptr to Info in CB map, or NULL if not found |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 132 | static MT_CB_INFO* get_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 133 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 134 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 135 | unordered_map<VkCmdBuffer, MT_CB_INFO>::iterator item = cbMap.find(cb); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 136 | if (item != cbMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 137 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 138 | } else { |
| 139 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 140 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 141 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 142 | |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 143 | // Return object info for 'object' or return NULL if no info exists |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 144 | static MT_OBJ_INFO* get_object_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 145 | const VkObject object) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 146 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 147 | unordered_map<VkObject, MT_OBJ_INFO>::iterator item = objectMap.find(object); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 148 | if (item != objectMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 149 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 150 | } else { |
| 151 | return NULL; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 152 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 153 | } |
| 154 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 155 | static MT_OBJ_INFO* add_object_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 156 | VkObject object, |
| 157 | VkStructureType sType, |
| 158 | const void *pCreateInfo, |
| 159 | const int struct_size, |
| 160 | const char *name_prefix) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 161 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 162 | MT_OBJ_INFO* pInfo = &objectMap[object]; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 163 | memset(pInfo, 0, sizeof(MT_OBJ_INFO)); |
| 164 | memcpy(&pInfo->create_info, pCreateInfo, struct_size); |
| 165 | sprintf(pInfo->object_name, "%s_%p", name_prefix, object); |
| 166 | |
| 167 | pInfo->object = object; |
| 168 | pInfo->ref_count = 1; |
| 169 | pInfo->sType = sType; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 170 | |
| 171 | return pInfo; |
| 172 | } |
| 173 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 174 | // Add a fence, creating one if necessary to our list of fences/fenceIds |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 175 | static uint64_t add_fence_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 176 | VkFence fence, |
| 177 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 178 | { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 179 | // Create fence object |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 180 | uint64_t fenceId = g_currentFenceId++; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 181 | // If no fence, create an internal fence to track the submissions |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 182 | if (fence != NULL) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 183 | fenceMap[fence].fenceId = fenceId; |
| 184 | fenceMap[fence].queue = queue; |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 185 | // Validate that fence is in UNSIGNALED state |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 186 | MT_OBJ_INFO* pObjectInfo = get_object_info(fence); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 187 | if (pObjectInfo != NULL) { |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 188 | if (pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 189 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_FENCE, fence, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 190 | "Fence %p submitted in SIGNALED state. Fences must be reset before being submitted", fence); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 191 | } |
| 192 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 193 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 194 | // Update most recently submitted fence and fenceId for Queue |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 195 | queueMap[queue].lastSubmittedId = fenceId; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 196 | return fenceId; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 197 | } |
| 198 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 199 | // Remove a fenceInfo from our list of fences/fenceIds |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 200 | static void delete_fence_info( |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 201 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 202 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 203 | fenceMap.erase(fence); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 204 | } |
| 205 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 206 | // Record information when a fence is known to be signalled |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 207 | static void update_fence_tracking( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 208 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 209 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 210 | unordered_map<VkFence, MT_FENCE_INFO>::iterator fence_item = fenceMap.find(fence); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 211 | if (fence_item != fenceMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 212 | MT_FENCE_INFO *pCurFenceInfo = &(*fence_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 213 | VkQueue queue = pCurFenceInfo->queue; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 214 | unordered_map<VkQueue, MT_QUEUE_INFO>::iterator queue_item = queueMap.find(queue); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 215 | if (queue_item != queueMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 216 | MT_QUEUE_INFO *pQueueInfo = &(*queue_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 217 | if (pQueueInfo->lastRetiredId < pCurFenceInfo->fenceId) { |
| 218 | pQueueInfo->lastRetiredId = pCurFenceInfo->fenceId; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 219 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 220 | } |
| 221 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 222 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 223 | // Update fence state in fenceCreateInfo structure |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 224 | MT_OBJ_INFO* pObjectInfo = get_object_info(fence); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 225 | if (pObjectInfo != NULL) { |
| 226 | pObjectInfo->create_info.fence_create_info.flags = |
| 227 | static_cast<VkFenceCreateFlags>( |
| 228 | pObjectInfo->create_info.fence_create_info.flags | VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 229 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 230 | } |
| 231 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 232 | // Helper routine that updates the fence list for a specific queue to all-retired |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 233 | static void retire_queue_fences( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 234 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 235 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 236 | MT_QUEUE_INFO *pQueueInfo = &queueMap[queue]; |
| 237 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 238 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 241 | // Helper routine that updates all queues to all-retired |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 242 | static void retire_device_fences( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 243 | VkDevice device) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 244 | { |
| 245 | // Process each queue for device |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 246 | // TODO: Add multiple device support |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 247 | for (unordered_map<VkQueue, MT_QUEUE_INFO>::iterator ii=queueMap.begin(); ii!=queueMap.end(); ++ii) { |
| 248 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
| 249 | MT_QUEUE_INFO *pQueueInfo = &(*ii).second; |
| 250 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 251 | } |
| 252 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 253 | // Helper function to validate correct usage bits set for buffers or images |
| 254 | // Verify that (actual & desired) flags != 0 or, |
| 255 | // if strict is true, verify that (actual & desired) flags == desired |
| 256 | // In case of error, report it via dbg callbacks |
David Pinedo | 3831094 | 2015-07-09 16:23:44 -0600 | [diff] [blame] | 257 | static void validate_usage_flags(void* disp_obj, VkFlags actual, VkFlags desired, |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 258 | VkBool32 strict, VkObject obj, VkObjectType obj_type, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 259 | char const* ty_str, char const* func_name, char const* usage_str) |
| 260 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 261 | VkBool32 correct_usage = VK_FALSE; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 262 | if (strict) |
| 263 | correct_usage = ((actual & desired) == desired); |
| 264 | else |
| 265 | correct_usage = ((actual & desired) != 0); |
| 266 | if (!correct_usage) { |
| 267 | log_msg(mdd((VkObject)disp_obj), VK_DBG_REPORT_ERROR_BIT, obj_type, obj, 0, MEMTRACK_INVALID_USAGE_FLAG, "MEM", |
| 268 | "Invalid usage flag for %s %p used by %s. In this case, %s should have %s set during creation.", |
| 269 | ty_str, obj, func_name, ty_str, usage_str); |
| 270 | } |
| 271 | } |
| 272 | // Helper function to validate usage flags for images |
| 273 | // Pulls image info and then sends actual vs. desired usage off to helper above where |
| 274 | // an error will be flagged if usage is not correct |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 275 | static void validate_image_usage_flags(void* disp_obj, VkImage image, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 276 | char const* func_name, char const* usage_string) |
| 277 | { |
| 278 | MT_OBJ_INFO* pInfo = get_object_info(image); |
| 279 | if (pInfo) { |
| 280 | validate_usage_flags(disp_obj, pInfo->create_info.image_create_info.usage, desired, strict, |
| 281 | image, VK_OBJECT_TYPE_IMAGE, "image", func_name, usage_string); |
| 282 | } |
| 283 | } |
| 284 | // Helper function to validate usage flags for buffers |
| 285 | // Pulls buffer info and then sends actual vs. desired usage off to helper above where |
| 286 | // an error will be flagged if usage is not correct |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 287 | static void validate_buffer_usage_flags(void* disp_obj, VkBuffer buffer, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 288 | char const* func_name, char const* usage_string) |
| 289 | { |
| 290 | MT_OBJ_INFO* pInfo = get_object_info(buffer); |
| 291 | if (pInfo) { |
| 292 | validate_usage_flags(disp_obj, pInfo->create_info.buffer_create_info.usage, desired, strict, |
| 293 | buffer, VK_OBJECT_TYPE_BUFFER, "buffer", func_name, usage_string); |
| 294 | } |
| 295 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 296 | // Return ptr to info in map container containing mem, or NULL if not found |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 297 | // Calls to this function should be wrapped in mutex |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 298 | static MT_MEM_OBJ_INFO* get_mem_obj_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 299 | const VkDeviceMemory mem) |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 300 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 301 | unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO>::iterator item = memObjMap.find(mem); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 302 | if (item != memObjMap.end()) { |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 303 | assert((*item).second.object != VK_NULL_HANDLE); |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 304 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 305 | } else { |
| 306 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 307 | } |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 310 | static void add_mem_obj_info( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 311 | const VkObject object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 312 | const VkDeviceMemory mem, |
| 313 | const VkMemoryAllocInfo *pAllocInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 314 | { |
Courtney Goeltzenleuchter | 17fd5ce | 2015-06-13 21:29:26 -0600 | [diff] [blame] | 315 | assert(object != NULL); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 316 | |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 317 | if (pAllocInfo) { // MEM alloc created by vkCreateSwapChainWSI() doesn't have alloc info struct |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 318 | memcpy(&memObjMap[mem].allocInfo, pAllocInfo, sizeof(VkMemoryAllocInfo)); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 319 | // TODO: Update for real hardware, actually process allocation info structures |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 320 | memObjMap[mem].allocInfo.pNext = NULL; |
| 321 | } else { |
| 322 | memset(&memObjMap[mem].allocInfo, 0, sizeof(VkMemoryAllocInfo)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 323 | } |
Courtney Goeltzenleuchter | 17fd5ce | 2015-06-13 21:29:26 -0600 | [diff] [blame] | 324 | memObjMap[mem].object = object; |
| 325 | memObjMap[mem].refCount = 0; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 326 | memObjMap[mem].mem = mem; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 327 | } |
| 328 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 329 | // Find CB Info and add mem reference to list container |
| 330 | // Find Mem Obj Info and add CB reference to list container |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 331 | static VkBool32 update_cmd_buf_and_mem_references( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 332 | const VkCmdBuffer cb, |
| 333 | const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 334 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 335 | VkBool32 result = VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 336 | // First update CB binding in MemObj mini CB list |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 337 | MT_MEM_OBJ_INFO* pMemInfo = get_mem_obj_info(mem); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 338 | if (!pMemInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 339 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 340 | "Trying to bind mem obj %p to CB %p but no info for that mem obj.\n " |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 341 | "Was it correctly allocated? Did it already get freed?", mem, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 342 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 343 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 344 | // Search for cmd buffer object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 345 | VkBool32 found = VK_FALSE; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 346 | if (pMemInfo->pCmdBufferBindings.size() > 0) { |
| 347 | for (list<VkCmdBuffer>::iterator it = pMemInfo->pCmdBufferBindings.begin(); it != pMemInfo->pCmdBufferBindings.end(); ++it) { |
| 348 | if ((*it) == cb) { |
| 349 | found = VK_TRUE; |
| 350 | break; |
| 351 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 355 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 356 | pMemInfo->pCmdBufferBindings.push_front(cb); |
| 357 | pMemInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 358 | } |
| 359 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 360 | // Now update CBInfo's Mem reference list |
| 361 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
| 362 | // TODO: keep track of all destroyed CBs so we know if this is a stale or simply invalid object |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 363 | if (!pCBInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 364 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 365 | "Trying to bind mem obj %p to CB %p but no info for that CB. Was CB incorrectly destroyed?", mem, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 366 | result = VK_FALSE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 367 | } else { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 368 | // Search for memory object in cmd buffer's reference list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 369 | VkBool32 found = VK_FALSE; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 370 | if (pCBInfo->pMemObjList.size() > 0) { |
| 371 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
| 372 | if ((*it) == mem) { |
| 373 | found = VK_TRUE; |
| 374 | break; |
| 375 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 379 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 380 | pCBInfo->pMemObjList.push_front(mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 381 | } |
| 382 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 383 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 384 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 385 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 386 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 387 | // Clear the CB Binding for mem |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 388 | // Calls to this function should be wrapped in mutex |
| 389 | static void remove_cmd_buf_and_mem_reference( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 390 | const VkCmdBuffer cb, |
| 391 | const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 392 | { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 393 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 394 | // TODO : Having this check is not ideal, really if memInfo was deleted, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 395 | // its CB bindings should be cleared and then clear_cmd_buf_and_mem_references wouldn't call |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 396 | // us here with stale mem objs |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 397 | if (pInfo) { |
| 398 | pInfo->pCmdBufferBindings.remove(cb); |
| 399 | pInfo->refCount--; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 400 | } |
| 401 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 402 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 403 | // Free bindings related to CB |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 404 | static VkBool32 clear_cmd_buf_and_mem_references( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 405 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 406 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 407 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 408 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 409 | if (!pCBInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 410 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cb, 0, MEMTRACK_INVALID_CB, "MEM", |
| 411 | "Unable to find global CB info %p for deletion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 412 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 413 | } else { |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 414 | if (pCBInfo->pMemObjList.size() > 0) { |
| 415 | list<VkDeviceMemory> mem_obj_list = pCBInfo->pMemObjList; |
| 416 | for (list<VkDeviceMemory>::iterator it=mem_obj_list.begin(); it!=mem_obj_list.end(); ++it) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 417 | remove_cmd_buf_and_mem_reference(cb, (*it)); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 418 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 419 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 420 | pCBInfo->pMemObjList.clear(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 421 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 422 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 423 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 424 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 425 | // Delete CBInfo from list along with all of it's mini MemObjInfo |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 426 | // and also clear mem references to CB |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 427 | static VkBool32 delete_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 428 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 429 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 430 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 431 | result = clear_cmd_buf_and_mem_references(cb); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 432 | // Delete the CBInfo info |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 433 | if (result == VK_TRUE) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 434 | cbMap.erase(cb); |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 435 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 436 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 437 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 438 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 439 | // Delete the entire CB list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 440 | static VkBool32 delete_cmd_buf_info_list( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 441 | void) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 442 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 443 | for (unordered_map<VkCmdBuffer, MT_CB_INFO>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 444 | clear_cmd_buf_and_mem_references((*ii).first); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 445 | } |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 446 | cbMap.clear(); |
| 447 | return VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 448 | } |
| 449 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 450 | // For given MemObjInfo, report Obj & CB bindings |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 451 | static void reportMemReferencesAndCleanUp( |
| 452 | MT_MEM_OBJ_INFO* pMemObjInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 453 | { |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 454 | size_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size(); |
| 455 | size_t objRefCount = pMemObjInfo->pObjBindings.size(); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 456 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 457 | if ((pMemObjInfo->pCmdBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 458 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, pMemObjInfo->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 459 | "Attempting to free memory object %p which still contains %lu references", |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 460 | pMemObjInfo->mem, (cmdBufRefCount + objRefCount)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 461 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 462 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 463 | if (cmdBufRefCount > 0 && pMemObjInfo->pCmdBufferBindings.size() > 0) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 464 | for (list<VkCmdBuffer>::const_iterator it = pMemObjInfo->pCmdBufferBindings.begin(); it != pMemObjInfo->pCmdBufferBindings.end(); ++it) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 465 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (*it), 0, MEMTRACK_NONE, "MEM", |
| 466 | "Command Buffer %p still has a reference to mem obj %p", (*it), pMemObjInfo->mem); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 467 | } |
| 468 | // Clear the list of hanging references |
| 469 | pMemObjInfo->pCmdBufferBindings.clear(); |
| 470 | } |
| 471 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 472 | if (objRefCount > 0 && pMemObjInfo->pObjBindings.size() > 0) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 473 | for (list<VkObject>::const_iterator it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 474 | /* TODO: Would be nice to return the actual object type */ |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 475 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, (*it), 0, MEMTRACK_NONE, "MEM", |
| 476 | "VK Object %p still has a reference to mem obj %p", (*it), pMemObjInfo->mem); |
Mark Lobodzinski | 6568f91 | 2015-06-11 16:11:20 -0500 | [diff] [blame] | 477 | |
| 478 | // Found an object referencing this memory, remove its pointer to this memobj |
| 479 | MT_OBJ_INFO *pObjInfo = get_object_info(*it); |
| 480 | pObjInfo->pMemObjInfo = NULL; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 481 | } |
| 482 | // Clear the list of hanging references |
| 483 | pMemObjInfo->pObjBindings.clear(); |
| 484 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 485 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 486 | } |
| 487 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 488 | static void deleteMemObjInfo( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 489 | VkObject object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 490 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 491 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 492 | unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO>::iterator item = memObjMap.find(mem); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 493 | if (item != memObjMap.end()) { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 494 | memObjMap.erase(item); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 495 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 496 | else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 497 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 498 | "Request to delete memory object %p not present in memory Object Map", mem); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 499 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 500 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 501 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 502 | // Check if fence for given CB is completed |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 503 | static VkBool32 checkCBCompleted( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 504 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 505 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 506 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 507 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 508 | if (!pCBInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 509 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cb, 0, MEMTRACK_INVALID_CB, "MEM", |
| 510 | "Unable to find global CB info %p to check for completion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 511 | result = VK_FALSE; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 512 | } else if (pCBInfo->lastSubmittedQueue != NULL) { |
| 513 | VkQueue queue = pCBInfo->lastSubmittedQueue; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 514 | MT_QUEUE_INFO *pQueueInfo = &queueMap[queue]; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 515 | if (pCBInfo->fenceId > pQueueInfo->lastRetiredId) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 516 | log_msg(mdd(cb), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cb, 0, MEMTRACK_NONE, "MEM", |
| 517 | "fence %p for CB %p has not been checked for completion", |
| 518 | (void*)pCBInfo->lastSubmittedFence, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 519 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 520 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 521 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 522 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 525 | static VkBool32 freeMemObjInfo( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 526 | VkObject object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 527 | VkDeviceMemory mem, |
| 528 | bool internal) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 529 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 530 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 531 | // Parse global list to find info w/ mem |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 532 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 533 | if (!pInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 534 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 535 | "Couldn't find mem info object for %p\n Was %p never allocated or previously freed?", |
| 536 | (void*)mem, (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 537 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 538 | } else { |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 539 | if (pInfo->allocInfo.allocationSize == 0 && !internal) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 540 | log_msg(mdd(pInfo->object), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 541 | "Attempting to free memory associated with a Persistent Image, %p, " |
| 542 | "this should not be explicitly freed\n", (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 543 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 544 | } else { |
| 545 | // Clear any CB bindings for completed CBs |
| 546 | // TODO : Is there a better place to do this? |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 547 | |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 548 | assert(pInfo->object != VK_NULL_HANDLE); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 549 | list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); |
| 550 | list<VkCmdBuffer>::iterator temp; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 551 | while (pInfo->pCmdBufferBindings.size() > 0 && it != pInfo->pCmdBufferBindings.end()) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 552 | if (VK_TRUE == checkCBCompleted(*it)) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 553 | temp = it; |
| 554 | ++temp; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 555 | clear_cmd_buf_and_mem_references(*it); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 556 | it = temp; |
| 557 | } else { |
| 558 | ++it; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 559 | } |
| 560 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 561 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 562 | // Now verify that no references to this mem obj remain |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 563 | if (0 != pInfo->refCount) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 564 | reportMemReferencesAndCleanUp(pInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 565 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 566 | } |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 567 | // Delete mem obj info |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 568 | deleteMemObjInfo(object, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 569 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 570 | } |
| 571 | return result; |
| 572 | } |
| 573 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 574 | // Remove object binding performs 3 tasks: |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 575 | // 1. Remove ObjectInfo from MemObjInfo list container of obj bindings & free it |
| 576 | // 2. Decrement refCount for MemObjInfo |
| 577 | // 3. Clear MemObjInfo ptr from ObjectInfo |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 578 | static VkBool32 clear_object_binding( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 579 | VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 580 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 581 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 582 | MT_OBJ_INFO* pObjInfo = get_object_info(object); |
| 583 | if (pObjInfo) { |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 584 | if (!pObjInfo->pMemObjInfo || pObjInfo->pMemObjInfo->pObjBindings.size() <= 0) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 585 | log_msg(mdd(object), VK_DBG_REPORT_WARN_BIT, (VkObjectType) 0, object, 0, MEMTRACK_MEM_OBJ_CLEAR_EMPTY_BINDINGS, "MEM", |
| 586 | "Attempting to clear mem binding on obj %p but it has no binding.", (void*)object); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 587 | } else { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 588 | // This obj is bound to a memory object. Remove the reference to this object in that memory object's list, decrement the memObj's refcount |
| 589 | // and set the objects memory binding pointer to NULL. |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 590 | for (list<VkObject>::iterator it = pObjInfo->pMemObjInfo->pObjBindings.begin(); it != pObjInfo->pMemObjInfo->pObjBindings.end(); ++it) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 591 | if ((*it) == object) { |
| 592 | pObjInfo->pMemObjInfo->refCount--; |
| 593 | pObjInfo->pMemObjInfo->pObjBindings.erase(it); |
| 594 | pObjInfo->pMemObjInfo = NULL; |
| 595 | result = VK_TRUE; |
| 596 | break; |
| 597 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 598 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 599 | if (result == VK_FALSE) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 600 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 601 | "While trying to clear mem binding for object %p, unable to find that object referenced by mem obj %p", |
| 602 | object, pObjInfo->pMemObjInfo->mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 603 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 604 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 605 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 606 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 609 | // For NULL mem case, output warning |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 610 | // Make sure given object is in global object map |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 611 | // IF a previous binding existed, output validation error |
| 612 | // Otherwise, add reference from objectInfo to memoryInfo |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 613 | // Add reference off of objInfo |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 614 | // device is required for error logging, need a dispatchable |
| 615 | // object for that. |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 616 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 617 | static VkBool32 set_object_binding( |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 618 | VkObject dispatch_object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 619 | VkObject object, |
| 620 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 621 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 622 | VkBool32 result = VK_FALSE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 623 | // Handle NULL case separately, just clear previous binding & decrement reference |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 624 | if (mem == VK_NULL_HANDLE) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 625 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_WARN_BIT, (VkObjectType) 0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 626 | "Attempting to Bind Obj(%p) to NULL", (void*)object); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 627 | return VK_TRUE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 628 | } else { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 629 | MT_OBJ_INFO* pObjInfo = get_object_info(object); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 630 | if (!pObjInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 631 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 632 | "Attempting to update Binding of Obj(%p) that's not in global list()", (void*)object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 633 | return VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 634 | } |
| 635 | // non-null case so should have real mem obj |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 636 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem); |
| 637 | if (!pInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 638 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 639 | "While trying to bind mem for obj %p, couldn't find info for mem obj %p", (void*)object, (void*)mem); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 640 | return VK_FALSE; |
| 641 | } else { |
| 642 | if (pObjInfo->pMemObjInfo != NULL) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 643 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_REBIND_OBJECT, "MEM", |
| 644 | "Attempting to bind memory (%p) to object (%p) which has already been bound to mem object %p", |
| 645 | (void*)mem, (void*)object, (void*)pObjInfo->pMemObjInfo->mem); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 646 | return VK_FALSE; |
| 647 | } |
| 648 | else { |
| 649 | pInfo->pObjBindings.push_front(object); |
| 650 | pInfo->refCount++; |
| 651 | |
| 652 | // For image objects, make sure default memory state is correctly set |
| 653 | // TODO : What's the best/correct way to handle this? |
| 654 | if (VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pObjInfo->sType) { |
| 655 | if (pObjInfo->create_info.image_create_info.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 656 | VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { |
| 657 | // TODO:: More memory state transition stuff. |
| 658 | } |
| 659 | } |
| 660 | pObjInfo->pMemObjInfo = pInfo; |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | return VK_TRUE; |
| 665 | } |
| 666 | |
| 667 | // For NULL mem case, clear any previous binding Else... |
| 668 | // Make sure given object is in global object map |
| 669 | // IF a previous binding existed, update binding |
| 670 | // Add reference from objectInfo to memoryInfo |
| 671 | // Add reference off of objInfo |
| 672 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 673 | static VkBool32 set_sparse_buffer_binding( |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 674 | VkObject object, |
| 675 | VkDeviceMemory mem) |
| 676 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 677 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 678 | // Handle NULL case separately, just clear previous binding & decrement reference |
| 679 | if (mem == VK_NULL_HANDLE) { |
| 680 | clear_object_binding(object); |
| 681 | return VK_TRUE; |
| 682 | } else { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 683 | MT_OBJ_INFO* pObjInfo = get_object_info(object); |
| 684 | if (!pObjInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 685 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 686 | "Attempting to update Binding of Obj(%p) that's not in global list()", (void*)object); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 687 | return VK_FALSE; |
| 688 | } |
| 689 | // non-null case so should have real mem obj |
| 690 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem); |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 691 | if (!pInfo) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 692 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 693 | "While trying to bind mem for obj %p, couldn't find info for mem obj %p", (void*)object, (void*)mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 694 | return VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 695 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 696 | // Search for object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 697 | VkBool32 found = VK_FALSE; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 698 | if (pInfo->pObjBindings.size() > 0) { |
| 699 | for (list<VkObject>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
| 700 | if ((*it) == object) { |
| 701 | found = VK_TRUE; |
| 702 | break; |
| 703 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 704 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 705 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 706 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 707 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 708 | pInfo->pObjBindings.push_front(object); |
| 709 | pInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 710 | } |
| 711 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 712 | if (pObjInfo->pMemObjInfo) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 713 | clear_object_binding(object); // Need to clear the previous object binding before setting new binding |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 714 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, object, 0, MEMTRACK_NONE, "MEM", |
| 715 | "Updating memory binding for object %p from mem obj %p to %p", object, pObjInfo->pMemObjInfo->mem, mem); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 716 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 717 | pObjInfo->pMemObjInfo = pInfo; |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 718 | } |
| 719 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 720 | return VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 721 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 722 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 723 | // Print details of global Obj tracking list |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 724 | static void print_object_list( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 725 | VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 726 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 727 | MT_OBJ_INFO* pInfo = NULL; |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 728 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 729 | "Details of Object list of size %lu elements", objectMap.size()); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 730 | if (objectMap.size() <= 0) |
| 731 | return; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 732 | for (unordered_map<VkObject, MT_OBJ_INFO>::iterator ii=objectMap.begin(); ii!=objectMap.end(); ++ii) { |
| 733 | pInfo = &(*ii).second; |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 734 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, pInfo->object, 0, MEMTRACK_NONE, "MEM", |
| 735 | " ObjInfo %p has object %p, pMemObjInfo %p", pInfo, pInfo->object, pInfo->pMemObjInfo); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 736 | } |
| 737 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 738 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 739 | // For given Object, get 'mem' obj that it's bound to or NULL if no binding |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 740 | static VkDeviceMemory get_mem_binding_from_object( |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 741 | const VkObject dispObj, const VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 742 | { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 743 | VkDeviceMemory mem = NULL; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 744 | MT_OBJ_INFO* pObjInfo = get_object_info(object); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 745 | if (pObjInfo) { |
| 746 | if (pObjInfo->pMemObjInfo) { |
| 747 | mem = pObjInfo->pMemObjInfo->mem; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 748 | } else { |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 749 | log_msg(mdd(dispObj), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, object, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 750 | "Trying to get mem binding for object %p but object has no mem binding", (void*)object); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 751 | print_object_list(object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 752 | } |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 753 | } else { |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 754 | log_msg(mdd(dispObj), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, object, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 755 | "Trying to get mem binding for object %p but no such object in global list", (void*)object); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 756 | print_object_list(object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 757 | } |
| 758 | return mem; |
| 759 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 760 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 761 | // Print details of MemObjInfo list |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 762 | static void print_mem_list( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 763 | VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 764 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 765 | MT_MEM_OBJ_INFO* pInfo = NULL; |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 766 | // Just printing each msg individually for now, may want to package these into single large print |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 767 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 768 | "MEM INFO : Details of Memory Object list of size %lu elements", memObjMap.size()); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 769 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 770 | if (memObjMap.size() <= 0) |
| 771 | return; |
| 772 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 773 | for (unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO>::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
| 774 | pInfo = &(*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 775 | |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 776 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 777 | " ===MemObjInfo at %p===", (void*)pInfo); |
| 778 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 779 | " Mem object: %p", (void*)pInfo->mem); |
| 780 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 781 | " Ref Count: %u", pInfo->refCount); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 782 | if (0 != pInfo->allocInfo.allocationSize) { |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 783 | string pAllocInfoMsg = vk_print_vkmemoryallocinfo(&pInfo->allocInfo, "{MEM}INFO : "); |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 784 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 785 | " Mem Alloc info:\n%s", pAllocInfoMsg.c_str()); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 786 | } else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 787 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 788 | " Mem Alloc info is NULL (alloc done by vkCreateSwapChainWSI())"); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 789 | } |
| 790 | |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 791 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 792 | " VK OBJECT Binding list of size %lu elements:", pInfo->pObjBindings.size()); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 793 | if (pInfo->pObjBindings.size() > 0) { |
| 794 | for (list<VkObject>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 795 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 796 | " VK OBJECT %p", (*it)); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 797 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 798 | } |
| 799 | |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 800 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 801 | " VK Command Buffer (CB) binding list of size %lu elements", pInfo->pCmdBufferBindings.size()); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 802 | if (pInfo->pCmdBufferBindings.size() > 0) |
| 803 | { |
| 804 | for (list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); it != pInfo->pCmdBufferBindings.end(); ++it) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 805 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 806 | " VK CB %p", (*it)); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 807 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 812 | static void printCBList( |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 813 | VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 814 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 815 | MT_CB_INFO* pCBInfo = NULL; |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 816 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 817 | "Details of CB list of size %lu elements", cbMap.size()); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 818 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 819 | if (cbMap.size() <= 0) |
| 820 | return; |
| 821 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 822 | for (unordered_map<VkCmdBuffer, MT_CB_INFO>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
| 823 | pCBInfo = &(*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 824 | |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 825 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 826 | " CB Info (%p) has CB %p, fenceId %" PRIx64", and fence %p", |
| 827 | (void*)pCBInfo, (void*)pCBInfo->cmdBuffer, pCBInfo->fenceId, |
| 828 | (void*)pCBInfo->lastSubmittedFence); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 829 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 830 | if (pCBInfo->pMemObjList.size() <= 0) |
| 831 | continue; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 832 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 833 | log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 834 | " Mem obj %p", (*it)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 835 | } |
| 836 | } |
| 837 | } |
| 838 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 839 | static void init_mem_tracker( |
| 840 | layer_data *my_data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 841 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 842 | uint32_t report_flags = 0; |
| 843 | uint32_t debug_action = 0; |
| 844 | FILE *log_output = NULL; |
| 845 | const char *option_str; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 846 | // initialize MemTracker options |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 847 | report_flags = getLayerOptionFlags("MemTrackerReportFlags", 0); |
| 848 | getLayerOptionEnum("MemTrackerDebugAction", (uint32_t *) &debug_action); |
Tobin Ehlis | ee70223 | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 849 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 850 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 851 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 852 | option_str = getLayerOption("MemTrackerLogFilename"); |
| 853 | if (option_str) { |
| 854 | log_output = fopen(option_str, "w"); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 855 | } |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 856 | if (log_output == NULL) { |
| 857 | log_output = stdout; |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 858 | } |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 859 | |
| 860 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &my_data->logging_callback); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 861 | } |
| 862 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 863 | if (!globalLockInitialized) |
| 864 | { |
| 865 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 866 | // suggestion is to call this during vkCreateInstance(), and then we |
| 867 | // can clean it up during vkDestroyInstance(). However, that requires |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 868 | // that the layer have per-instance locks. We need to come back and |
| 869 | // address this soon. |
| 870 | loader_platform_thread_create_mutex(&globalLock); |
| 871 | globalLockInitialized = 1; |
| 872 | } |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 873 | |
| 874 | // Zero out memory property data |
| 875 | memset(&memProps, 0, sizeof(VkPhysicalDeviceMemoryProperties)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 878 | // hook DestroyInstance to remove tableInstanceMap entry |
| 879 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) |
| 880 | { |
Jeremy Hayes | 35f8afc | 2015-06-18 10:25:55 -0600 | [diff] [blame] | 881 | // Grab the key before the instance is destroyed. |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 882 | dispatch_key key = get_dispatch_key(instance); |
| 883 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 884 | VkResult res = pTable->DestroyInstance(instance); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 885 | |
| 886 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | 095e677 | 2015-06-16 16:58:52 -0600 | [diff] [blame] | 887 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 888 | if (my_data->logging_callback) { |
| 889 | layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback); |
| 890 | } |
| 891 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 892 | layer_debug_report_destroy_instance(mid(instance)); |
| 893 | layer_data_map.erase(pTable); |
| 894 | |
| 895 | mem_tracker_instance_table_map.erase(key); |
| 896 | assert(mem_tracker_instance_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 897 | return res; |
| 898 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 899 | |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 900 | VkResult VKAPI vkCreateInstance( |
| 901 | const VkInstanceCreateInfo* pCreateInfo, |
| 902 | VkInstance* pInstance) |
| 903 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 904 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, *pInstance); |
Courtney Goeltzenleuchter | d02a964 | 2015-06-08 14:58:39 -0600 | [diff] [blame] | 905 | VkResult result = pTable->CreateInstance(pCreateInfo, pInstance); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 906 | |
| 907 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 908 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 909 | my_data->report_data = debug_report_create_instance( |
| 910 | pTable, |
| 911 | *pInstance, |
| 912 | pCreateInfo->extensionCount, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 913 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 914 | |
| 915 | init_mem_tracker(my_data); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 916 | } |
| 917 | return result; |
| 918 | } |
| 919 | |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 920 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 921 | { |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 922 | uint32_t i; |
| 923 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 924 | my_device_data->wsi_lunarg_enabled = false; |
| 925 | for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 926 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_WSI_LUNARG_EXTENSION_NAME) == 0) |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 927 | my_device_data->wsi_lunarg_enabled = true; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 928 | |
| 929 | } |
| 930 | } |
| 931 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 932 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( |
| 933 | VkPhysicalDevice gpu, |
| 934 | const VkDeviceCreateInfo *pCreateInfo, |
| 935 | VkDevice *pDevice) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 936 | { |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 937 | VkLayerDispatchTable *pDeviceTable = get_dispatch_table(mem_tracker_device_table_map, *pDevice); |
| 938 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 939 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 940 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 941 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 942 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 943 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 944 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 945 | return result; |
| 946 | } |
| 947 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 948 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice( |
| 949 | VkDevice device) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 950 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 951 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 952 | log_msg(mdd(device), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE, device, 0, MEMTRACK_NONE, "MEM", |
| 953 | "Printing List details prior to vkDestroyDevice()"); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 954 | print_mem_list(device); |
| 955 | printCBList(device); |
| 956 | print_object_list(device); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 957 | if (VK_FALSE == delete_cmd_buf_info_list()) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 958 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE, device, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 959 | "Issue deleting global CB list in vkDestroyDevice()"); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 960 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 961 | // Report any memory leaks |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 962 | MT_MEM_OBJ_INFO* pInfo = NULL; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 963 | if (memObjMap.size() > 0) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 964 | for (unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO>::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
| 965 | pInfo = &(*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 966 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 967 | if (pInfo->allocInfo.allocationSize != 0) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 968 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, pInfo->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", |
| 969 | "Mem Object %p has not been freed. You should clean up this memory by calling " |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 970 | "vkFreeMemory(%p) prior to vkDestroyDevice().", pInfo->mem, pInfo->mem); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 971 | } |
Mark Lobodzinski | 2f3b19b | 2015-02-18 18:06:24 -0600 | [diff] [blame] | 972 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 973 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 974 | |
| 975 | // Queues persist until device is destroyed |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 976 | delete_queue_info_list(); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 977 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 978 | layer_debug_report_destroy_device(device); |
| 979 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 980 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 981 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 982 | dispatch_key key = get_dispatch_key(device); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 983 | #if DISPATCH_MAP_DEBUG |
| 984 | fprintf(stderr, "Device: %p, key: %p\n", device, key); |
| 985 | #endif |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 986 | VkLayerDispatchTable *pDisp = get_dispatch_table(mem_tracker_device_table_map, device); |
| 987 | VkResult result = pDisp->DestroyDevice(device); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 988 | mem_tracker_device_table_map.erase(key); |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 989 | assert(mem_tracker_device_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 990 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 991 | return result; |
| 992 | } |
| 993 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 994 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceMemoryProperties( |
| 995 | VkPhysicalDevice physicalDevice, |
| 996 | VkPhysicalDeviceMemoryProperties *pMemoryProperties) |
| 997 | { |
| 998 | VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(mem_tracker_instance_table_map, physicalDevice); |
| 999 | VkResult result = pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); |
| 1000 | if (result == VK_SUCCESS) { |
| 1001 | // copy mem props to local var... |
| 1002 | memcpy(&memProps, pMemoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)); |
| 1003 | } |
| 1004 | return result; |
| 1005 | } |
| 1006 | |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1007 | static const VkLayerProperties mtGlobalLayers[] = { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1008 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1009 | "MemTracker", |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1010 | VK_API_VERSION, |
| 1011 | VK_MAKE_VERSION(0, 1, 0), |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1012 | "Validation layer: MemTracker", |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1013 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1014 | }; |
| 1015 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1016 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1017 | const char *pLayerName, |
| 1018 | uint32_t *pCount, |
| 1019 | VkExtensionProperties* pProperties) |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1020 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1021 | /* Mem tracker does not have any global extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1022 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1023 | } |
| 1024 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1025 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties( |
| 1026 | uint32_t *pCount, |
| 1027 | VkLayerProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1028 | { |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1029 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), |
| 1030 | mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1031 | pCount, pProperties); |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1032 | } |
| 1033 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1034 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1035 | VkPhysicalDevice physicalDevice, |
| 1036 | const char* pLayerName, |
| 1037 | uint32_t* pCount, |
| 1038 | VkExtensionProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1039 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1040 | /* Mem tracker does not have any physical device extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1041 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1042 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1043 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1044 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties( |
| 1045 | VkPhysicalDevice physicalDevice, |
| 1046 | uint32_t* pCount, |
| 1047 | VkLayerProperties* pProperties) |
| 1048 | { |
| 1049 | /* Mem tracker's physical device layers are the same as global */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1050 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1051 | pCount, pProperties); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1052 | } |
| 1053 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1054 | VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue( |
| 1055 | VkDevice device, |
| 1056 | uint32_t queueNodeIndex, |
| 1057 | uint32_t queueIndex, |
| 1058 | VkQueue *pQueue) |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1059 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1060 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1061 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1062 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1063 | add_queue_info(*pQueue); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1064 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1065 | } |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1066 | return result; |
| 1067 | } |
| 1068 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1069 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( |
| 1070 | VkQueue queue, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1071 | uint32_t cmdBufferCount, |
| 1072 | const VkCmdBuffer *pCmdBuffers, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1073 | VkFence fence) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1074 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1075 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1076 | // TODO : Need to track fence and clear mem references when fence clears |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1077 | MT_CB_INFO* pCBInfo = NULL; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1078 | uint64_t fenceId = add_fence_info(fence, queue); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1079 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1080 | print_mem_list(queue); |
| 1081 | printCBList(queue); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1082 | for (uint32_t i = 0; i < cmdBufferCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1083 | pCBInfo = get_cmd_buf_info(pCmdBuffers[i]); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1084 | pCBInfo->fenceId = fenceId; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1085 | pCBInfo->lastSubmittedFence = fence; |
| 1086 | pCBInfo->lastSubmittedQueue = queue; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1087 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1088 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1089 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1090 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueSubmit( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1091 | queue, cmdBufferCount, pCmdBuffers, fence); |
Courtney Goeltzenleuchter | d3fb955 | 2015-04-02 13:39:07 -0600 | [diff] [blame] | 1092 | return result; |
| 1093 | } |
| 1094 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1095 | VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory( |
| 1096 | VkDevice device, |
| 1097 | const VkMemoryAllocInfo *pAllocInfo, |
| 1098 | VkDeviceMemory *pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1099 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1100 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->AllocMemory(device, pAllocInfo, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1101 | // TODO : Track allocations and overall size here |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1102 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1103 | add_mem_obj_info(device, *pMem, pAllocInfo); |
| 1104 | print_mem_list(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1105 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1106 | return result; |
| 1107 | } |
| 1108 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1109 | VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory( |
| 1110 | VkDevice device, |
| 1111 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1112 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1113 | /* From spec : A memory object is freed by calling vkFreeMemory() when it is no longer needed. Before |
Tobin Ehlis | c0418f9 | 2014-11-25 14:47:20 -0700 | [diff] [blame] | 1114 | * freeing a memory object, an application must ensure the memory object is unbound from |
| 1115 | * all API objects referencing it and that it is not referenced by any queued command buffers |
| 1116 | */ |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1117 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 1118 | VkBool32 noerror = freeMemObjInfo(device, mem, false); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1119 | print_mem_list(device); |
| 1120 | print_object_list(device); |
| 1121 | printCBList(device); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1122 | // Output an warning message for proper error/warning handling |
| 1123 | if (noerror == VK_FALSE) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1124 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_FREED_MEM_REF, "MEM", |
| 1125 | "Freeing memory object while it still has references: mem obj %p", (void*)mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1126 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1127 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1128 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->FreeMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1129 | return result; |
| 1130 | } |
| 1131 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1132 | VK_LAYER_EXPORT VkResult VKAPI vkMapMemory( |
| 1133 | VkDevice device, |
| 1134 | VkDeviceMemory mem, |
| 1135 | VkDeviceSize offset, |
| 1136 | VkDeviceSize size, |
| 1137 | VkFlags flags, |
| 1138 | void **ppData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1139 | { |
| 1140 | // TODO : Track when memory is mapped |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1141 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1142 | MT_MEM_OBJ_INFO *pMemObj = get_mem_obj_info(mem); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1143 | if ((memProps.memoryTypes[pMemObj->allocInfo.memoryTypeIndex].propertyFlags & |
| 1144 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1145 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem, 0, MEMTRACK_INVALID_STATE, "MEM", |
| 1146 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set: mem obj %p", (void*)mem); |
Mark Lobodzinski | 95152dc | 2015-02-25 12:16:04 -0600 | [diff] [blame] | 1147 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1148 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1149 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1150 | return result; |
| 1151 | } |
| 1152 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1153 | VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory( |
| 1154 | VkDevice device, |
| 1155 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1156 | { |
| 1157 | // TODO : Track as memory gets unmapped, do we want to check what changed following map? |
| 1158 | // Make sure that memory was ever mapped to begin with |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1159 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->UnmapMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1160 | return result; |
| 1161 | } |
| 1162 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1163 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject( |
| 1164 | VkDevice device, |
| 1165 | VkObjectType objType, |
| 1166 | VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1167 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 1168 | unordered_map<VkObject, MT_OBJ_INFO>::iterator item; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1169 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1170 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1171 | // First check if this is a CmdBuffer or fence |
| 1172 | switch (objType) { |
| 1173 | case VK_OBJECT_TYPE_COMMAND_BUFFER: |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1174 | delete_cmd_buf_info((VkCmdBuffer)object); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1175 | break; |
| 1176 | case VK_OBJECT_TYPE_FENCE: |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1177 | delete_fence_info((VkFence)object); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1178 | break; |
| 1179 | default: |
| 1180 | break; |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1181 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1182 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1183 | if ((item = objectMap.find(object)) != objectMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 1184 | MT_OBJ_INFO* pDelInfo = &(*item).second; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1185 | if (pDelInfo->pMemObjInfo) { |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1186 | // Wsi allocated Memory is tied to image object so clear the binding and free that memory automatically |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1187 | if (0 == pDelInfo->pMemObjInfo->allocInfo.allocationSize) { // Wsi allocated memory has NULL allocInfo w/ 0 size |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1188 | VkDeviceMemory memToFree = pDelInfo->pMemObjInfo->mem; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1189 | clear_object_binding(object); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1190 | freeMemObjInfo(device, memToFree, true); |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 1191 | } |
| 1192 | else { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1193 | // Remove this object from memory object's reference list and decrement its ref counter |
| 1194 | clear_object_binding(object); |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1195 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1196 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1197 | objectMap.erase(item); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1198 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1199 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1200 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1201 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyObject(device, objType, object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1202 | return result; |
| 1203 | } |
| 1204 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1205 | VK_LAYER_EXPORT VkResult VKAPI vkGetObjectMemoryRequirements( |
| 1206 | VkDevice device, |
| 1207 | VkObjectType objType, |
| 1208 | VkObject object, |
| 1209 | VkMemoryRequirements* pRequirements) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1210 | { |
| 1211 | // TODO : What to track here? |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 1212 | // Could potentially save returned mem requirements and validate values passed into BindObjectMemory for this object |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1213 | // From spec : The only objects that are guaranteed to have no external memory requirements are devices, queues, |
| 1214 | // command buffers, shaders and memory objects. |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1215 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetObjectMemoryRequirements(device, objType, object, pRequirements); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1216 | return result; |
| 1217 | } |
| 1218 | |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 1219 | VK_LAYER_EXPORT VkResult VKAPI vkBindObjectMemory( |
| 1220 | VkDevice device, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1221 | VkObjectType objType, |
| 1222 | VkObject object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1223 | VkDeviceMemory mem, |
| 1224 | VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1225 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1226 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->BindObjectMemory(device, objType, object, mem, offset); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1227 | loader_platform_thread_lock_mutex(&globalLock); |
| 1228 | // Track objects tied to memory |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 1229 | set_object_binding(device, object, mem); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1230 | print_object_list(device); |
| 1231 | print_mem_list(device); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1232 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1233 | return result; |
| 1234 | } |
| 1235 | |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 1236 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1237 | VkQueue queue, |
| 1238 | VkBuffer buffer, |
| 1239 | uint32_t numBindings, |
| 1240 | const VkSparseMemoryBindInfo* pBindInfo) |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1241 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1242 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueBindSparseBufferMemory( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1243 | queue, buffer, numBindings, pBindInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1244 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1245 | // Track objects tied to memory |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1246 | if (VK_FALSE == set_sparse_buffer_binding(buffer, pBindInfo->mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1247 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_BUFFER, buffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1248 | "Unable to set object %p binding to mem obj %p", (void*)buffer, (void*)pBindInfo->mem); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1249 | } |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1250 | print_object_list(queue); |
| 1251 | print_mem_list(queue); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1252 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1253 | return result; |
| 1254 | } |
| 1255 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1256 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFence( |
| 1257 | VkDevice device, |
| 1258 | const VkFenceCreateInfo *pCreateInfo, |
| 1259 | VkFence *pFence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1260 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1261 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateFence(device, pCreateInfo, pFence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1262 | if (VK_SUCCESS == result) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1263 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1264 | add_object_info(*pFence, pCreateInfo->sType, pCreateInfo, sizeof(VkFenceCreateInfo), "fence"); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1265 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1266 | } |
| 1267 | return result; |
| 1268 | } |
| 1269 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1270 | VK_LAYER_EXPORT VkResult VKAPI vkResetFences( |
| 1271 | VkDevice device, |
| 1272 | uint32_t fenceCount, |
Courtney Goeltzenleuchter | 2bf8f90 | 2015-06-18 17:28:20 -0600 | [diff] [blame] | 1273 | const VkFence *pFences) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1274 | { |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1275 | /* |
| 1276 | * TODO: Shouldn't we check for error conditions before passing down the chain? |
| 1277 | * What if reason result is not VK_SUCCESS is something we could report as a validation error? |
| 1278 | */ |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1279 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->ResetFences(device, fenceCount, pFences); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1280 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1281 | loader_platform_thread_lock_mutex(&globalLock); |
| 1282 | // Reset fence state in fenceCreateInfo structure |
| 1283 | for (uint32_t i = 0; i < fenceCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1284 | MT_OBJ_INFO* pObjectInfo = get_object_info(pFences[i]); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1285 | if (pObjectInfo != NULL) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1286 | // Validate fences in SIGNALED state |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1287 | if (!(pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1288 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_FENCE, pFences[i], 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 1289 | "Fence %p submitted to VkResetFences in UNSIGNALED STATE", pFences[i]); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1290 | } |
| 1291 | else { |
| 1292 | pObjectInfo->create_info.fence_create_info.flags = |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1293 | static_cast<VkFenceCreateFlags>(pObjectInfo->create_info.fence_create_info.flags & ~VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1294 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1295 | } |
| 1296 | } |
| 1297 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1298 | } |
| 1299 | return result; |
| 1300 | } |
| 1301 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1302 | VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus( |
| 1303 | VkDevice device, |
| 1304 | VkFence fence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1305 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1306 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetFenceStatus(device, fence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1307 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1308 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1309 | update_fence_tracking(fence); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1310 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1311 | } |
| 1312 | return result; |
| 1313 | } |
| 1314 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1315 | VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences( |
| 1316 | VkDevice device, |
| 1317 | uint32_t fenceCount, |
| 1318 | const VkFence *pFences, |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame^] | 1319 | VkBool32 waitAll, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1320 | uint64_t timeout) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1321 | { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1322 | // Verify fence status of submitted fences |
| 1323 | for(uint32_t i = 0; i < fenceCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1324 | MT_OBJ_INFO* pObjectInfo = get_object_info(pFences[i]); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1325 | if (pObjectInfo != NULL) { |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1326 | if (pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1327 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_FENCE, pFences[i], 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 1328 | "VkWaitForFences specified fence %p already in SIGNALED state.", pFences[i]); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1333 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1334 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1335 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1336 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1337 | if (waitAll || fenceCount == 1) { // Clear all the fences |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1338 | for(uint32_t i = 0; i < fenceCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1339 | update_fence_tracking(pFences[i]); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1340 | } |
| 1341 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1342 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1343 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1344 | return result; |
| 1345 | } |
| 1346 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1347 | VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle( |
| 1348 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1349 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1350 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueWaitIdle(queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1351 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1352 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1353 | retire_queue_fences(queue); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1354 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1355 | } |
| 1356 | return result; |
| 1357 | } |
| 1358 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1359 | VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle( |
| 1360 | VkDevice device) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1361 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1362 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DeviceWaitIdle(device); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1363 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1364 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1365 | retire_device_fences(device); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1366 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1367 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1368 | return result; |
| 1369 | } |
| 1370 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1371 | VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent( |
| 1372 | VkDevice device, |
| 1373 | const VkEventCreateInfo *pCreateInfo, |
| 1374 | VkEvent *pEvent) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1375 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1376 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateEvent(device, pCreateInfo, pEvent); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1377 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1378 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1379 | add_object_info(*pEvent, pCreateInfo->sType, pCreateInfo, sizeof(VkEventCreateInfo), "event"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1380 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1381 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1382 | return result; |
| 1383 | } |
| 1384 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1385 | VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool( |
| 1386 | VkDevice device, |
| 1387 | const VkQueryPoolCreateInfo *pCreateInfo, |
| 1388 | VkQueryPool *pQueryPool) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1389 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1390 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateQueryPool(device, pCreateInfo, pQueryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1391 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1392 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1393 | add_object_info(*pQueryPool, pCreateInfo->sType, pCreateInfo, sizeof(VkQueryPoolCreateInfo), "query_pool"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1394 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1395 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1396 | return result; |
| 1397 | } |
| 1398 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1399 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer( |
| 1400 | VkDevice device, |
| 1401 | const VkBufferCreateInfo *pCreateInfo, |
| 1402 | VkBuffer *pBuffer) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1403 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1404 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateBuffer(device, pCreateInfo, pBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1405 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1406 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1407 | add_object_info(*pBuffer, pCreateInfo->sType, pCreateInfo, sizeof(VkBufferCreateInfo), "buffer"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1408 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1409 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1410 | return result; |
| 1411 | } |
| 1412 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1413 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView( |
| 1414 | VkDevice device, |
| 1415 | const VkBufferViewCreateInfo *pCreateInfo, |
| 1416 | VkBufferView *pView) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1417 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1418 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateBufferView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1419 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1420 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1421 | add_object_info(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkBufferViewCreateInfo), "buffer_view"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1422 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1423 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1424 | return result; |
| 1425 | } |
| 1426 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1427 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage( |
| 1428 | VkDevice device, |
| 1429 | const VkImageCreateInfo *pCreateInfo, |
| 1430 | VkImage *pImage) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1431 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1432 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateImage(device, pCreateInfo, pImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1433 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1434 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1435 | add_object_info(*pImage, pCreateInfo->sType, pCreateInfo, sizeof(VkImageCreateInfo), "image"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1436 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1437 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1438 | return result; |
| 1439 | } |
| 1440 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1441 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView( |
| 1442 | VkDevice device, |
| 1443 | const VkImageViewCreateInfo *pCreateInfo, |
| 1444 | VkImageView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1445 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1446 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateImageView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1447 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1448 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1449 | add_object_info(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkImageViewCreateInfo), "image_view"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1450 | // Validate that img has correct usage flags set |
| 1451 | validate_image_usage_flags(device, pCreateInfo->image, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, |
| 1452 | false, "vkCreateImageView()", "VK_IMAGE_USAGE_[SAMPLED|STORAGE]_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1453 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1454 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1455 | return result; |
| 1456 | } |
| 1457 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1458 | VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView( |
| 1459 | VkDevice device, |
| 1460 | const VkColorAttachmentViewCreateInfo *pCreateInfo, |
| 1461 | VkColorAttachmentView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1462 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1463 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateColorAttachmentView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1464 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1465 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1466 | add_object_info(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkColorAttachmentViewCreateInfo), "color_attachment_view"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1467 | // Validate that img has correct usage flags set |
| 1468 | // We don't use the image helper function here as it's a special case that checks struct type |
| 1469 | MT_OBJ_INFO* pInfo = get_object_info(pCreateInfo->image); |
| 1470 | if (pInfo) { |
| 1471 | if (VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI == pInfo->sType) { |
| 1472 | validate_usage_flags(device, pInfo->create_info.swap_chain_create_info.imageUsageFlags, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, true, |
| 1473 | pCreateInfo->image, VK_OBJECT_TYPE_IMAGE, "image", "vkCreateColorAttachmentView()", "VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT"); |
| 1474 | } else if (VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pInfo->sType) { |
| 1475 | validate_usage_flags(device, pInfo->create_info.image_create_info.usage, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, true, |
| 1476 | pCreateInfo->image, VK_OBJECT_TYPE_IMAGE, "image", "vkCreateColorAttachmentView()", "VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT"); |
| 1477 | } |
| 1478 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1479 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1480 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1481 | return result; |
| 1482 | } |
| 1483 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1484 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView( |
| 1485 | VkDevice device, |
| 1486 | const VkDepthStencilViewCreateInfo *pCreateInfo, |
| 1487 | VkDepthStencilView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1488 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1489 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDepthStencilView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1490 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1491 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1492 | add_object_info(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkDepthStencilViewCreateInfo), "ds_view"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1493 | // Validate that img has correct usage flags set |
| 1494 | validate_image_usage_flags(device, pCreateInfo->image, VK_IMAGE_USAGE_DEPTH_STENCIL_BIT, |
| 1495 | true, "vkCreateDepthStencilView()", "VK_IMAGE_USAGE_DEPTH_STENCIL_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1496 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1497 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1498 | return result; |
| 1499 | } |
| 1500 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1501 | VK_LAYER_EXPORT VkResult VKAPI vkCreateShader( |
| 1502 | VkDevice device, |
| 1503 | const VkShaderCreateInfo *pCreateInfo, |
| 1504 | VkShader *pShader) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1505 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1506 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateShader(device, pCreateInfo, pShader); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1507 | return result; |
| 1508 | } |
| 1509 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1510 | //TODO do we need to intercept pipelineCache functions to track objects? |
| 1511 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelines( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1512 | VkDevice device, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1513 | VkPipelineCache pipelineCache, |
| 1514 | uint32_t count, |
| 1515 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1516 | VkPipeline *pPipelines) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1517 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1518 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pPipelines); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1519 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1520 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1521 | add_object_info(*pPipelines, pCreateInfos->sType, pCreateInfos, sizeof(VkGraphicsPipelineCreateInfo), "graphics_pipeline"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1522 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1523 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1524 | return result; |
| 1525 | } |
| 1526 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1527 | VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipelines( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1528 | VkDevice device, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1529 | VkPipelineCache pipelineCache, |
| 1530 | uint32_t count, |
| 1531 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 1532 | VkPipeline *pPipelines) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1533 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1534 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateComputePipelines(device, pipelineCache, count, pCreateInfos, pPipelines); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1535 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1536 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1537 | add_object_info(*pPipelines, pCreateInfos->sType, pCreateInfos, sizeof(VkComputePipelineCreateInfo), "compute_pipeline"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1538 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1539 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1540 | return result; |
| 1541 | } |
| 1542 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1543 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler( |
| 1544 | VkDevice device, |
| 1545 | const VkSamplerCreateInfo *pCreateInfo, |
| 1546 | VkSampler *pSampler) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1547 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1548 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateSampler(device, pCreateInfo, pSampler); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1549 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1550 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1551 | add_object_info(*pSampler, pCreateInfo->sType, pCreateInfo, sizeof(VkSamplerCreateInfo), "sampler"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1552 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1553 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1554 | return result; |
| 1555 | } |
| 1556 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1557 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState( |
| 1558 | VkDevice device, |
| 1559 | const VkDynamicVpStateCreateInfo *pCreateInfo, |
| 1560 | VkDynamicVpState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1561 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1562 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicViewportState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1563 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1564 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1565 | add_object_info(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicVpStateCreateInfo), "viewport_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1566 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1567 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1568 | return result; |
| 1569 | } |
| 1570 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1571 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState( |
| 1572 | VkDevice device, |
| 1573 | const VkDynamicRsStateCreateInfo *pCreateInfo, |
| 1574 | VkDynamicRsState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1575 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1576 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicRasterState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1577 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1578 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1579 | add_object_info(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicRsStateCreateInfo), "raster_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1580 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1581 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1582 | return result; |
| 1583 | } |
| 1584 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1585 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState( |
| 1586 | VkDevice device, |
| 1587 | const VkDynamicCbStateCreateInfo *pCreateInfo, |
| 1588 | VkDynamicCbState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1589 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1590 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1591 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1592 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1593 | add_object_info(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicCbStateCreateInfo), "cb_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1594 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1595 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1596 | return result; |
| 1597 | } |
| 1598 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1599 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState( |
| 1600 | VkDevice device, |
| 1601 | const VkDynamicDsStateCreateInfo *pCreateInfo, |
| 1602 | VkDynamicDsState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1603 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1604 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1605 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1606 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1607 | add_object_info(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicDsStateCreateInfo), "ds_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1608 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1609 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1610 | return result; |
| 1611 | } |
| 1612 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1613 | VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer( |
| 1614 | VkDevice device, |
| 1615 | const VkCmdBufferCreateInfo *pCreateInfo, |
| 1616 | VkCmdBuffer *pCmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1617 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1618 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1619 | // At time of cmd buffer creation, create global cmd buffer info for the returned cmd buffer |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1620 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1621 | if (*pCmdBuffer) |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1622 | add_cmd_buf_info(*pCmdBuffer); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1623 | printCBList(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1624 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1625 | return result; |
| 1626 | } |
| 1627 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1628 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer( |
| 1629 | VkCmdBuffer cmdBuffer, |
| 1630 | const VkCmdBufferBeginInfo *pBeginInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1631 | { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1632 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1633 | // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1634 | if (!checkCBCompleted(cmdBuffer)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1635 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", |
| 1636 | "Calling vkBeginCommandBuffer() on active CB %p before it has completed. " |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1637 | "You must check CB flag before this call.", cmdBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1638 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1639 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1640 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1641 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1642 | clear_cmd_buf_and_mem_references(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1643 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1644 | return result; |
| 1645 | } |
| 1646 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1647 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer( |
| 1648 | VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1649 | { |
| 1650 | // TODO : Anything to do here? |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1651 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->EndCommandBuffer(cmdBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1652 | return result; |
| 1653 | } |
| 1654 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1655 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer( |
| 1656 | VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1657 | { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1658 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1659 | // Verify that CB is complete (not in-flight) |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1660 | if (!checkCBCompleted(cmdBuffer)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1661 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", |
| 1662 | "Resetting CB %p before it has completed. You must check CB flag before " |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1663 | "calling vkResetCommandBuffer().", cmdBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1664 | } |
| 1665 | // Clear memory references as this point. |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1666 | clear_cmd_buf_and_mem_references(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1667 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1668 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->ResetCommandBuffer(cmdBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1669 | return result; |
| 1670 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1671 | // TODO : For any vkCmdBind* calls that include an object which has mem bound to it, |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1672 | // need to account for that mem now having binding to given cmdBuffer |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1673 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline( |
| 1674 | VkCmdBuffer cmdBuffer, |
| 1675 | VkPipelineBindPoint pipelineBindPoint, |
| 1676 | VkPipeline pipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1677 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1678 | #if 0 |
| 1679 | // TODO : If memory bound to pipeline, then need to tie that mem to cmdBuffer |
| 1680 | if (getPipeline(pipeline)) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1681 | MT_CB_INFO *pCBInfo = get_cmd_buf_info(cmdBuffer); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1682 | if (pCBInfo) { |
| 1683 | pCBInfo->pipelines[pipelineBindPoint] = pipeline; |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1684 | } else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1685 | "Attempt to bind Pipeline %p to non-existant command buffer %p!", (void*)pipeline, cmdBuffer); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1686 | layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_INVALID_CB, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1687 | } |
| 1688 | } |
| 1689 | else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1690 | "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1691 | layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE, pipeline, 0, MEMTRACK_INVALID_OBJECT, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1692 | } |
| 1693 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1694 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1695 | } |
| 1696 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1697 | VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject( |
| 1698 | VkCmdBuffer cmdBuffer, |
| 1699 | VkStateBindPoint stateBindPoint, |
| 1700 | VkDynamicStateObject state) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1701 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1702 | MT_OBJ_INFO *pObjInfo; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1703 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1704 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(cmdBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1705 | if (!pCmdBuf) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1706 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_INVALID_CB, "MEM", |
| 1707 | "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1708 | } |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1709 | pObjInfo = get_object_info(state); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1710 | if (!pObjInfo) { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1711 | /* TODO: put in real object type */ |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1712 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, state, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 1713 | "Unable to find dynamic state object %p, was it ever created?", (void*)state); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1714 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1715 | pCmdBuf->pDynamicState[stateBindPoint] = pObjInfo; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1716 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1717 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1718 | } |
| 1719 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1720 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1721 | VkCmdBuffer cmdBuffer, |
| 1722 | VkPipelineBindPoint pipelineBindPoint, |
Mark Lobodzinski | f2093b6 | 2015-06-15 13:21:21 -0600 | [diff] [blame] | 1723 | VkPipelineLayout layout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1724 | uint32_t firstSet, |
| 1725 | uint32_t setCount, |
| 1726 | const VkDescriptorSet *pDescriptorSets, |
| 1727 | uint32_t dynamicOffsetCount, |
| 1728 | const uint32_t *pDynamicOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1729 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1730 | // TODO : Somewhere need to verify that all textures referenced by shaders in DS are in some type of *SHADER_READ* state |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1731 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDescriptorSets( |
Mark Lobodzinski | f2093b6 | 2015-06-15 13:21:21 -0600 | [diff] [blame] | 1732 | cmdBuffer, pipelineBindPoint, layout, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1733 | } |
| 1734 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1735 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1736 | VkCmdBuffer cmdBuffer, |
| 1737 | uint32_t startBinding, |
| 1738 | uint32_t bindingCount, |
| 1739 | const VkBuffer *pBuffers, |
| 1740 | const VkDeviceSize *pOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1741 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1742 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Chia-I Wu | 1915682 | 2015-01-05 13:42:56 +0800 | [diff] [blame] | 1743 | } |
| 1744 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1745 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer( |
| 1746 | VkCmdBuffer cmdBuffer, |
| 1747 | VkBuffer buffer, |
| 1748 | VkDeviceSize offset, |
| 1749 | VkIndexType indexType) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1750 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1751 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1752 | } |
| 1753 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1754 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect( |
| 1755 | VkCmdBuffer cmdBuffer, |
| 1756 | VkBuffer buffer, |
| 1757 | VkDeviceSize offset, |
| 1758 | uint32_t count, |
| 1759 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1760 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1761 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1762 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1763 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1764 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1765 | "In vkCmdDrawIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1766 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1767 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1768 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1771 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect( |
| 1772 | VkCmdBuffer cmdBuffer, |
| 1773 | VkBuffer buffer, |
| 1774 | VkDeviceSize offset, |
| 1775 | uint32_t count, |
| 1776 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1777 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1778 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1779 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1780 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1781 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1782 | "In vkCmdDrawIndexedIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1783 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1784 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1785 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1786 | } |
| 1787 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1788 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect( |
| 1789 | VkCmdBuffer cmdBuffer, |
| 1790 | VkBuffer buffer, |
| 1791 | VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1792 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1793 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1794 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1795 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1796 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1797 | "In vkCmdDispatchIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1798 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1799 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1800 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDispatchIndirect(cmdBuffer, buffer, offset); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1801 | } |
| 1802 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1803 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer( |
| 1804 | VkCmdBuffer cmdBuffer, |
| 1805 | VkBuffer srcBuffer, |
| 1806 | VkBuffer destBuffer, |
| 1807 | uint32_t regionCount, |
| 1808 | const VkBufferCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1809 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1810 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1811 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1812 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1813 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1814 | "In vkCmdCopyBuffer() call unable to update binding of srcBuffer %p to cmdBuffer %p", srcBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1815 | } |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1816 | mem = get_mem_binding_from_object(cmdBuffer, destBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1817 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1818 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1819 | "In vkCmdCopyBuffer() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1820 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1821 | // Validate that SRC & DST buffers have correct usage flags set |
| 1822 | validate_buffer_usage_flags(cmdBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT"); |
| 1823 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1824 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1825 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1826 | } |
| 1827 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1828 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage( |
| 1829 | VkCmdBuffer cmdBuffer, |
| 1830 | VkImage srcImage, |
| 1831 | VkImageLayout srcImageLayout, |
| 1832 | VkImage destImage, |
| 1833 | VkImageLayout destImageLayout, |
| 1834 | uint32_t regionCount, |
| 1835 | const VkImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1836 | { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1837 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1838 | // TODO : Each image will have mem mapping so track them |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1839 | // Validate that src & dst images have correct usage flags set |
| 1840 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 1841 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
| 1842 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1843 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1844 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1845 | } |
| 1846 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1847 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage( |
| 1848 | VkCmdBuffer cmdBuffer, |
| 1849 | VkImage srcImage, |
| 1850 | VkImageLayout srcImageLayout, |
| 1851 | VkImage destImage, |
| 1852 | VkImageLayout destImageLayout, |
| 1853 | uint32_t regionCount, |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 1854 | const VkImageBlit *pRegions, |
| 1855 | VkTexFilter filter) |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 1856 | { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1857 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 1858 | // TODO : Each image will have mem mapping so track them |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1859 | // Validate that src & dst images have correct usage flags set |
| 1860 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 1861 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
| 1862 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1863 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBlitImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1864 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter); |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 1865 | } |
| 1866 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1867 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage( |
| 1868 | VkCmdBuffer cmdBuffer, |
| 1869 | VkBuffer srcBuffer, |
| 1870 | VkImage destImage, |
| 1871 | VkImageLayout destImageLayout, |
| 1872 | uint32_t regionCount, |
| 1873 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1874 | { |
| 1875 | // TODO : Track this |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1876 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1877 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destImage); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1878 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1879 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1880 | "In vkCmdCopyMemoryToImage() call unable to update binding of destImage buffer %p to cmdBuffer %p", destImage, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1881 | } |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1882 | mem = get_mem_binding_from_object(cmdBuffer, srcBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1883 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1884 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1885 | "In vkCmdCopyMemoryToImage() call unable to update binding of srcBuffer %p to cmdBuffer %p", srcBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1886 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1887 | // Validate that src buff & dst image have correct usage flags set |
| 1888 | validate_buffer_usage_flags(cmdBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyBufferToImage()", "VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT"); |
| 1889 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyBufferToImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1890 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1891 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyBufferToImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1892 | cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1893 | } |
| 1894 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1895 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer( |
| 1896 | VkCmdBuffer cmdBuffer, |
| 1897 | VkImage srcImage, |
| 1898 | VkImageLayout srcImageLayout, |
| 1899 | VkBuffer destBuffer, |
| 1900 | uint32_t regionCount, |
| 1901 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1902 | { |
| 1903 | // TODO : Track this |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1904 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1905 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1906 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1907 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1908 | "In vkCmdCopyImageToMemory() call unable to update binding of srcImage buffer %p to cmdBuffer %p", srcImage, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1909 | } |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1910 | mem = get_mem_binding_from_object(cmdBuffer, destBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1911 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1912 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1913 | "In vkCmdCopyImageToMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1914 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1915 | // Validate that dst buff & src image have correct usage flags set |
| 1916 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyImageToBuffer()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 1917 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyImageToBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1918 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1919 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyImageToBuffer( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1920 | cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1921 | } |
| 1922 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1923 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer( |
| 1924 | VkCmdBuffer cmdBuffer, |
| 1925 | VkBuffer destBuffer, |
| 1926 | VkDeviceSize destOffset, |
| 1927 | VkDeviceSize dataSize, |
| 1928 | const uint32_t *pData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1929 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1930 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1931 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1932 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1933 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1934 | "In vkCmdUpdateMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1935 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1936 | // Validate that dst buff has correct usage flags set |
| 1937 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdUpdateBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1938 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1939 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1940 | } |
| 1941 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1942 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer( |
| 1943 | VkCmdBuffer cmdBuffer, |
| 1944 | VkBuffer destBuffer, |
| 1945 | VkDeviceSize destOffset, |
| 1946 | VkDeviceSize fillSize, |
| 1947 | uint32_t data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1948 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1949 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1950 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destBuffer); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1951 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1952 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1953 | "In vkCmdFillMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1954 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1955 | // Validate that dst buff has correct usage flags set |
| 1956 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdFillBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1957 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1958 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1959 | } |
| 1960 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1961 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
| 1962 | VkCmdBuffer cmdBuffer, |
| 1963 | VkImage image, |
| 1964 | VkImageLayout imageLayout, |
Chris Forbes | f0796e1 | 2015-06-24 14:34:53 +1200 | [diff] [blame] | 1965 | const VkClearColorValue *pColor, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1966 | uint32_t rangeCount, |
| 1967 | const VkImageSubresourceRange *pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1968 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1969 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1970 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1971 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1972 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1973 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1974 | "In vkCmdClearColorImage() call unable to update binding of image buffer %p to cmdBuffer %p", image, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1975 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1976 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1977 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1978 | } |
| 1979 | |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 1980 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1981 | VkCmdBuffer cmdBuffer, |
| 1982 | VkImage image, |
| 1983 | VkImageLayout imageLayout, |
| 1984 | float depth, |
| 1985 | uint32_t stencil, |
| 1986 | uint32_t rangeCount, |
| 1987 | const VkImageSubresourceRange *pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1988 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1989 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1990 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 1991 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1992 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1993 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 1994 | "In vkCmdClearDepthStencilImage() call unable to update binding of image buffer %p to cmdBuffer %p", image, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1995 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1996 | loader_platform_thread_unlock_mutex(&globalLock); |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 1997 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdClearDepthStencilImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1998 | cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1999 | } |
| 2000 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2001 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage( |
| 2002 | VkCmdBuffer cmdBuffer, |
| 2003 | VkImage srcImage, |
| 2004 | VkImageLayout srcImageLayout, |
| 2005 | VkImage destImage, |
| 2006 | VkImageLayout destImageLayout, |
| 2007 | uint32_t regionCount, |
| 2008 | const VkImageResolve *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2009 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2010 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 2011 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2012 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2013 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2014 | "In vkCmdResolveImage() call unable to update binding of srcImage buffer %p to cmdBuffer %p", srcImage, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2015 | } |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 2016 | mem = get_mem_binding_from_object(cmdBuffer, destImage); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2017 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2018 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2019 | "In vkCmdResolveImage() call unable to update binding of destImage buffer %p to cmdBuffer %p", destImage, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2020 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2021 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2022 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdResolveImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2023 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2024 | } |
| 2025 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2026 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery( |
| 2027 | VkCmdBuffer cmdBuffer, |
| 2028 | VkQueryPool queryPool, |
| 2029 | uint32_t slot, |
| 2030 | VkFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2031 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2032 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 2033 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2034 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2035 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2036 | "In vkCmdBeginQuery() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2037 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2038 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2039 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2040 | } |
| 2041 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2042 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery( |
| 2043 | VkCmdBuffer cmdBuffer, |
| 2044 | VkQueryPool queryPool, |
| 2045 | uint32_t slot) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2046 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2047 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 2048 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2049 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2050 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2051 | "In vkCmdEndQuery() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2052 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2053 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2054 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdEndQuery(cmdBuffer, queryPool, slot); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2055 | } |
| 2056 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2057 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool( |
| 2058 | VkCmdBuffer cmdBuffer, |
| 2059 | VkQueryPool queryPool, |
| 2060 | uint32_t startQuery, |
| 2061 | uint32_t queryCount) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2062 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2063 | loader_platform_thread_lock_mutex(&globalLock); |
Jon Ashburn | a79828d | 2015-06-18 17:12:57 -0600 | [diff] [blame] | 2064 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2065 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2066 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2067 | "In vkCmdResetQueryPool() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2068 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2069 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2070 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2071 | } |
| 2072 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2073 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 2074 | VkInstance instance, |
| 2075 | VkFlags msgFlags, |
| 2076 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 2077 | void* pUserData, |
| 2078 | VkDbgMsgCallback* pMsgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2079 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2080 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 2081 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2082 | if (res == VK_SUCCESS) { |
| 2083 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2084 | |
| 2085 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2086 | } |
| 2087 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2088 | } |
| 2089 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2090 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 2091 | VkInstance instance, |
| 2092 | VkDbgMsgCallback msgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2093 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2094 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 2095 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
| 2096 | |
| 2097 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2098 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
| 2099 | |
| 2100 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2101 | } |
| 2102 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2103 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI( |
| 2104 | VkDevice device, |
| 2105 | const VkSwapChainCreateInfoWSI *pCreateInfo, |
| 2106 | VkSwapChainWSI *pSwapChain) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2107 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2108 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateSwapChainWSI(device, pCreateInfo, pSwapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2109 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2110 | if (VK_SUCCESS == result) { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2111 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2112 | add_swap_chain_info(*pSwapChain, pCreateInfo); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2113 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2114 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2115 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2116 | return result; |
| 2117 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2118 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2119 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI( |
| 2120 | VkSwapChainWSI swapChain) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2121 | { |
| 2122 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2123 | |
| 2124 | if (swapChainMap.find(swapChain) != swapChainMap.end()) { |
| 2125 | MT_SWAP_CHAIN_INFO* pInfo = swapChainMap[swapChain]; |
| 2126 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2127 | if (pInfo->images.size() > 0) { |
| 2128 | for (std::vector<VkSwapChainImageInfoWSI>::const_iterator it = pInfo->images.begin(); |
| 2129 | it != pInfo->images.end(); it++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2130 | clear_object_binding(it->image); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 2131 | freeMemObjInfo(swapChain, it->memory, true); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2132 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2133 | objectMap.erase(it->image); |
| 2134 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2135 | } |
| 2136 | |
| 2137 | delete pInfo; |
| 2138 | swapChainMap.erase(swapChain); |
| 2139 | } |
| 2140 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2141 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2142 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2143 | return get_dispatch_table(mem_tracker_device_table_map, swapChain)->DestroySwapChainWSI(swapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2144 | } |
| 2145 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2146 | VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI( |
| 2147 | VkSwapChainWSI swapChain, |
| 2148 | VkSwapChainInfoTypeWSI infoType, |
| 2149 | size_t *pDataSize, |
| 2150 | void *pData) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2151 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2152 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, swapChain)->GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2153 | |
| 2154 | if (infoType == VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI && result == VK_SUCCESS) { |
| 2155 | const size_t count = *pDataSize / sizeof(VkSwapChainImageInfoWSI); |
| 2156 | MT_SWAP_CHAIN_INFO *pInfo = swapChainMap[swapChain]; |
| 2157 | |
| 2158 | if (pInfo->images.empty()) { |
| 2159 | pInfo->images.resize(count); |
| 2160 | memcpy(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count); |
| 2161 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2162 | if (pInfo->images.size() > 0) { |
| 2163 | for (std::vector<VkSwapChainImageInfoWSI>::const_iterator it = pInfo->images.begin(); |
| 2164 | it != pInfo->images.end(); it++) { |
| 2165 | // Add image object, then insert the new Mem Object and then bind it to created image |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2166 | add_object_info(it->image, VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI, &pInfo->createInfo, sizeof(pInfo->createInfo), "persistent_image"); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 2167 | add_mem_obj_info(swapChain, it->memory, NULL); |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 2168 | if (VK_FALSE == set_object_binding(swapChain, it->image, it->memory)) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2169 | log_msg(mdd(swapChain), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, it->image, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2170 | "In vkGetSwapChainInfoWSI(), unable to set image %p binding to mem obj %p", (void*)it->image, (void*)it->memory); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2171 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2172 | } |
| 2173 | } |
| 2174 | } else { |
| 2175 | const bool mismatch = (pInfo->images.size() != count || |
| 2176 | memcmp(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count)); |
| 2177 | |
| 2178 | if (mismatch) { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2179 | log_msg(mdd(swapChain), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_SWAP_CHAIN_WSI, (VkObject) swapChain, 0, MEMTRACK_NONE, "SWAP_CHAIN", |
| 2180 | "vkGetSwapChainInfoWSI(%p, VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI) returned mismatching data", swapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2181 | } |
| 2182 | } |
| 2183 | } |
| 2184 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2185 | return result; |
| 2186 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2187 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2188 | VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr( |
| 2189 | VkDevice dev, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2190 | const char *funcName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2191 | { |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2192 | if (dev == NULL) { |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2193 | return NULL; |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2194 | } |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2195 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2196 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 2197 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2198 | initDeviceTable(mem_tracker_device_table_map, (const VkBaseLayerObject *) dev); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2199 | return (void *) vkGetDeviceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2200 | } |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 2201 | if (!strcmp(funcName, "vkCreateDevice")) |
| 2202 | return (void*) vkCreateDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2203 | if (!strcmp(funcName, "vkDestroyDevice")) |
| 2204 | return (void*) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2205 | if (!strcmp(funcName, "vkQueueSubmit")) |
| 2206 | return (void*) vkQueueSubmit; |
| 2207 | if (!strcmp(funcName, "vkAllocMemory")) |
| 2208 | return (void*) vkAllocMemory; |
| 2209 | if (!strcmp(funcName, "vkFreeMemory")) |
| 2210 | return (void*) vkFreeMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2211 | if (!strcmp(funcName, "vkMapMemory")) |
| 2212 | return (void*) vkMapMemory; |
| 2213 | if (!strcmp(funcName, "vkUnmapMemory")) |
| 2214 | return (void*) vkUnmapMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2215 | if (!strcmp(funcName, "vkDestroyObject")) |
| 2216 | return (void*) vkDestroyObject; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 2217 | if (!strcmp(funcName, "vkGetObjectMemoryRequirements")) |
| 2218 | return (void*) vkGetObjectMemoryRequirements; |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 2219 | if (!strcmp(funcName, "vkBindObjectMemory")) |
| 2220 | return (void*) vkBindObjectMemory; |
| 2221 | if (!strcmp(funcName, "vkQueueBindSparseBufferMemory")) |
| 2222 | return (void*) vkQueueBindSparseBufferMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2223 | if (!strcmp(funcName, "vkCreateFence")) |
| 2224 | return (void*) vkCreateFence; |
| 2225 | if (!strcmp(funcName, "vkGetFenceStatus")) |
| 2226 | return (void*) vkGetFenceStatus; |
| 2227 | if (!strcmp(funcName, "vkResetFences")) |
| 2228 | return (void*) vkResetFences; |
| 2229 | if (!strcmp(funcName, "vkWaitForFences")) |
| 2230 | return (void*) vkWaitForFences; |
| 2231 | if (!strcmp(funcName, "vkQueueWaitIdle")) |
| 2232 | return (void*) vkQueueWaitIdle; |
| 2233 | if (!strcmp(funcName, "vkDeviceWaitIdle")) |
| 2234 | return (void*) vkDeviceWaitIdle; |
| 2235 | if (!strcmp(funcName, "vkCreateEvent")) |
| 2236 | return (void*) vkCreateEvent; |
| 2237 | if (!strcmp(funcName, "vkCreateQueryPool")) |
| 2238 | return (void*) vkCreateQueryPool; |
| 2239 | if (!strcmp(funcName, "vkCreateBuffer")) |
| 2240 | return (void*) vkCreateBuffer; |
| 2241 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 2242 | return (void*) vkCreateBufferView; |
| 2243 | if (!strcmp(funcName, "vkCreateImage")) |
| 2244 | return (void*) vkCreateImage; |
| 2245 | if (!strcmp(funcName, "vkCreateImageView")) |
| 2246 | return (void*) vkCreateImageView; |
| 2247 | if (!strcmp(funcName, "vkCreateColorAttachmentView")) |
| 2248 | return (void*) vkCreateColorAttachmentView; |
| 2249 | if (!strcmp(funcName, "vkCreateDepthStencilView")) |
| 2250 | return (void*) vkCreateDepthStencilView; |
| 2251 | if (!strcmp(funcName, "vkCreateShader")) |
| 2252 | return (void*) vkCreateShader; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2253 | if (!strcmp(funcName, "vkCreateGraphicsPipelines")) |
| 2254 | return (void*) vkCreateGraphicsPipelines; |
| 2255 | if (!strcmp(funcName, "vkCreateComputePipelines")) |
| 2256 | return (void*) vkCreateComputePipelines; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2257 | if (!strcmp(funcName, "vkCreateSampler")) |
| 2258 | return (void*) vkCreateSampler; |
| 2259 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
| 2260 | return (void*) vkCreateDynamicViewportState; |
| 2261 | if (!strcmp(funcName, "vkCreateDynamicRasterState")) |
| 2262 | return (void*) vkCreateDynamicRasterState; |
| 2263 | if (!strcmp(funcName, "vkCreateDynamicColorBlendState")) |
| 2264 | return (void*) vkCreateDynamicColorBlendState; |
| 2265 | if (!strcmp(funcName, "vkCreateDynamicDepthStencilState")) |
| 2266 | return (void*) vkCreateDynamicDepthStencilState; |
| 2267 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
| 2268 | return (void*) vkCreateCommandBuffer; |
| 2269 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 2270 | return (void*) vkBeginCommandBuffer; |
| 2271 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
| 2272 | return (void*) vkEndCommandBuffer; |
| 2273 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
| 2274 | return (void*) vkResetCommandBuffer; |
| 2275 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
| 2276 | return (void*) vkCmdBindPipeline; |
| 2277 | if (!strcmp(funcName, "vkCmdBindDynamicStateObject")) |
| 2278 | return (void*) vkCmdBindDynamicStateObject; |
| 2279 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
| 2280 | return (void*) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2281 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
| 2282 | return (void*) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2283 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
| 2284 | return (void*) vkCmdBindIndexBuffer; |
| 2285 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
| 2286 | return (void*) vkCmdDrawIndirect; |
| 2287 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
| 2288 | return (void*) vkCmdDrawIndexedIndirect; |
| 2289 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
| 2290 | return (void*) vkCmdDispatchIndirect; |
| 2291 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
| 2292 | return (void*) vkCmdCopyBuffer; |
| 2293 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 2294 | return (void*) vkCmdCopyImage; |
| 2295 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 2296 | return (void*) vkCmdCopyBufferToImage; |
| 2297 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 2298 | return (void*) vkCmdCopyImageToBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2299 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
| 2300 | return (void*) vkCmdUpdateBuffer; |
| 2301 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
| 2302 | return (void*) vkCmdFillBuffer; |
| 2303 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 2304 | return (void*) vkCmdClearColorImage; |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 2305 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
| 2306 | return (void*) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2307 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 2308 | return (void*) vkCmdResolveImage; |
| 2309 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
| 2310 | return (void*) vkCmdBeginQuery; |
| 2311 | if (!strcmp(funcName, "vkCmdEndQuery")) |
| 2312 | return (void*) vkCmdEndQuery; |
| 2313 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
| 2314 | return (void*) vkCmdResetQueryPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2315 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
| 2316 | return (void*) vkGetDeviceQueue; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 2317 | |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 2318 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
| 2319 | if (my_device_data->wsi_lunarg_enabled) |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 2320 | { |
| 2321 | if (!strcmp(funcName, "vkCreateSwapChainWSI")) |
| 2322 | return (void*) vkCreateSwapChainWSI; |
| 2323 | if (!strcmp(funcName, "vkDestroySwapChainWSI")) |
| 2324 | return (void*) vkDestroySwapChainWSI; |
| 2325 | if (!strcmp(funcName, "vkGetSwapChainInfoWSI")) |
| 2326 | return (void*) vkGetSwapChainInfoWSI; |
| 2327 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2328 | |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 2329 | VkLayerDispatchTable *pDisp = get_dispatch_table(mem_tracker_device_table_map, dev); |
| 2330 | if (pDisp->GetDeviceProcAddr == NULL) |
| 2331 | return NULL; |
| 2332 | return pDisp->GetDeviceProcAddr(dev, funcName); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2333 | } |
| 2334 | |
| 2335 | VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr( |
| 2336 | VkInstance instance, |
| 2337 | const char *funcName) |
| 2338 | { |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2339 | void *fptr; |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2340 | if (instance == NULL) { |
| 2341 | return NULL; |
| 2342 | } |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 2343 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2344 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 2345 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2346 | initInstanceTable(mem_tracker_instance_table_map, (const VkBaseLayerObject *) instance); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2347 | return (void *) vkGetInstanceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2348 | } |
| 2349 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2350 | if (!strcmp(funcName, "vkDestroyInstance")) |
| 2351 | return (void *) vkDestroyInstance; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2352 | if (!strcmp(funcName, "vkCreateInstance")) |
| 2353 | return (void*) vkCreateInstance; |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 2354 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
| 2355 | return (void*) vkGetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 2356 | if (!strcmp(funcName, "vkGetGlobalLayerProperties")) |
| 2357 | return (void*) vkGetGlobalLayerProperties; |
| 2358 | if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 2359 | return (void*) vkGetGlobalExtensionProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 2360 | if (!strcmp(funcName, "vkGetPhysicalDeviceLayerProperties")) |
| 2361 | return (void*) vkGetPhysicalDeviceLayerProperties; |
| 2362 | if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) |
| 2363 | return (void*) vkGetPhysicalDeviceExtensionProperties; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2364 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2365 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2366 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2367 | if (fptr) |
| 2368 | return fptr; |
| 2369 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2370 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2371 | if (get_dispatch_table(mem_tracker_instance_table_map, instance)->GetInstanceProcAddr == NULL) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2372 | return NULL; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2373 | return get_dispatch_table(mem_tracker_instance_table_map, instance)->GetInstanceProcAddr(instance, funcName); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2374 | } |
| 2375 | } |