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. |
Michael Lentine | 1195ed2 | 2015-09-23 17:43:16 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Google, Inc. |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * 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] | 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | * DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 26 | #include <inttypes.h> |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <string.h> |
| 30 | #include <assert.h> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 31 | #include <list> |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 32 | #include <map> |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 33 | #include <vector> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 34 | using namespace std; |
| 35 | |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 36 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 37 | #include "vk_dispatch_table_helper.h" |
| 38 | #include "vk_struct_string_helper_cpp.h" |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 39 | #include "mem_tracker.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 40 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 41 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_table.h" |
| 43 | #include "vk_layer_data.h" |
| 44 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 45 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 46 | |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 47 | // WSI Image Objects bypass usual Image Object creation methods. A special Memory |
| 48 | // Object value will be used to identify them internally. |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 49 | static const VkDeviceMemory MEMTRACKER_SWAP_CHAIN_IMAGE_KEY = (VkDeviceMemory)(-1); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 50 | |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 51 | struct layer_data { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 52 | debug_report_data *report_data; |
Courtney Goeltzenleuchter | 0036b57 | 2015-10-05 15:59:26 -0600 | [diff] [blame] | 53 | std::vector<VkDbgMsgCallback> logging_callback; |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 54 | VkLayerDispatchTable* device_dispatch_table; |
| 55 | VkLayerInstanceDispatchTable* instance_dispatch_table; |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 56 | bool wsi_enabled; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 57 | uint64_t currentFenceId; |
| 58 | // Maps for tracking key structs related to MemTracker state |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 59 | unordered_map<VkCommandBuffer, MT_CB_INFO> cbMap; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 60 | unordered_map<VkDeviceMemory, MT_MEM_OBJ_INFO> memObjMap; |
| 61 | unordered_map<VkFence, MT_FENCE_INFO> fenceMap; // Map fence to fence info |
| 62 | unordered_map<VkQueue, MT_QUEUE_INFO> queueMap; |
| 63 | unordered_map<VkSwapchainKHR, MT_SWAP_CHAIN_INFO*> swapchainMap; |
| 64 | unordered_map<VkSemaphore, MtSemaphoreState> semaphoreMap; |
| 65 | // Images and Buffers are 2 objects that can have memory bound to them so they get special treatment |
| 66 | unordered_map<uint64_t, MT_OBJ_BINDING_INFO> imageMap; |
| 67 | unordered_map<uint64_t, MT_OBJ_BINDING_INFO> bufferMap; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 68 | |
| 69 | layer_data() : |
| 70 | report_data(nullptr), |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 71 | device_dispatch_table(nullptr), |
| 72 | instance_dispatch_table(nullptr), |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 73 | wsi_enabled(false), |
| 74 | currentFenceId(1) |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 75 | {}; |
| 76 | }; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 77 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 78 | static unordered_map<void *, layer_data *> layer_data_map; |
| 79 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 80 | static VkPhysicalDeviceMemoryProperties memProps; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 81 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 82 | // TODO : This can be much smarter, using separate locks for separate global data |
| 83 | static int globalLockInitialized = 0; |
| 84 | static loader_platform_thread_mutex globalLock; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 85 | |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 86 | #define MAX_BINDING 0xFFFFFFFF |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 87 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 88 | static MT_OBJ_BINDING_INFO* get_object_binding_info(layer_data* my_data, uint64_t handle, VkDbgObjectType type) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 89 | { |
| 90 | MT_OBJ_BINDING_INFO* retValue = NULL; |
| 91 | switch (type) |
| 92 | { |
| 93 | case VK_OBJECT_TYPE_IMAGE: |
| 94 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 95 | auto it = my_data->imageMap.find(handle); |
| 96 | if (it != my_data->imageMap.end()) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 97 | return &(*it).second; |
| 98 | break; |
| 99 | } |
| 100 | case VK_OBJECT_TYPE_BUFFER: |
| 101 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 102 | auto it = my_data->bufferMap.find(handle); |
| 103 | if (it != my_data->bufferMap.end()) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 104 | return &(*it).second; |
| 105 | break; |
| 106 | } |
| 107 | } |
| 108 | return retValue; |
| 109 | } |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 110 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 111 | template layer_data *get_my_data_ptr<layer_data>( |
| 112 | void *data_key, |
| 113 | std::unordered_map<void *, layer_data *> &data_map); |
| 114 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 115 | // Add new queue for this device to map container |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 116 | static void add_queue_info(layer_data* my_data, const VkQueue queue) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 117 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 118 | MT_QUEUE_INFO* pInfo = &my_data->queueMap[queue]; |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 119 | pInfo->lastRetiredId = 0; |
| 120 | pInfo->lastSubmittedId = 0; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 121 | } |
| 122 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 123 | static void delete_queue_info_list(layer_data* my_data) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 124 | { |
| 125 | // Process queue list, cleaning up each entry before deleting |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 126 | my_data->queueMap.clear(); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 127 | } |
| 128 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 129 | static void add_swap_chain_info(layer_data* my_data, |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 130 | const VkSwapchainKHR swapchain, const VkSwapchainCreateInfoKHR* pCI) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 131 | { |
| 132 | MT_SWAP_CHAIN_INFO* pInfo = new MT_SWAP_CHAIN_INFO; |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 133 | memcpy(&pInfo->createInfo, pCI, sizeof(VkSwapchainCreateInfoKHR)); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 134 | my_data->swapchainMap[swapchain] = pInfo; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 135 | } |
| 136 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 137 | // Add new CBInfo for this cb to map container |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 138 | static void add_cmd_buf_info(layer_data* my_data, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 139 | const VkCommandBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 140 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 141 | my_data->cbMap[cb].commandBuffer = cb; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 144 | // Return ptr to Info in CB map, or NULL if not found |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 145 | static MT_CB_INFO* get_cmd_buf_info(layer_data* my_data, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 146 | const VkCommandBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 147 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 148 | auto item = my_data->cbMap.find(cb); |
| 149 | if (item != my_data->cbMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 150 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 151 | } else { |
| 152 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 153 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 154 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 155 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 156 | static void add_object_binding_info(layer_data* my_data, const uint64_t handle, const VkDbgObjectType type, const VkDeviceMemory mem) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 157 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 158 | switch (type) |
| 159 | { |
| 160 | // Buffers and images are unique as their CreateInfo is in container struct |
| 161 | case VK_OBJECT_TYPE_BUFFER: |
| 162 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 163 | auto pCI = &my_data->bufferMap[handle]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 164 | pCI->mem = mem; |
| 165 | break; |
| 166 | } |
| 167 | case VK_OBJECT_TYPE_IMAGE: |
| 168 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 169 | auto pCI = &my_data->imageMap[handle]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 170 | pCI->mem = mem; |
| 171 | break; |
| 172 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 173 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 174 | } |
| 175 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 176 | static void add_object_create_info(layer_data* my_data, const uint64_t handle, const VkDbgObjectType type, const void* pCreateInfo) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 177 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 178 | // TODO : For any CreateInfo struct that has ptrs, need to deep copy them and appropriately clean up on Destroy |
| 179 | switch (type) |
| 180 | { |
| 181 | // Buffers and images are unique as their CreateInfo is in container struct |
| 182 | case VK_OBJECT_TYPE_BUFFER: |
| 183 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 184 | auto pCI = &my_data->bufferMap[handle]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 185 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
| 186 | memcpy(&pCI->create_info.buffer, pCreateInfo, sizeof(VkBufferCreateInfo)); |
| 187 | break; |
| 188 | } |
| 189 | case VK_OBJECT_TYPE_IMAGE: |
| 190 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 191 | auto pCI = &my_data->imageMap[handle]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 192 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
| 193 | memcpy(&pCI->create_info.image, pCreateInfo, sizeof(VkImageCreateInfo)); |
| 194 | break; |
| 195 | } |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 196 | // Swap Chain is very unique, use my_data->imageMap, but copy in |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 197 | // SwapChainCreatInfo's usage flags and set the mem value to a unique key. These is used by |
| 198 | // vkCreateImageView and internal MemTracker routines to distinguish swap chain images |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 199 | case VK_OBJECT_TYPE_SWAPCHAIN_KHR: |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 200 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 201 | auto pCI = &my_data->imageMap[handle]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 202 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 203 | pCI->mem = MEMTRACKER_SWAP_CHAIN_IMAGE_KEY; |
Mark Lobodzinski | a50a5cb | 2015-09-01 11:19:08 -0600 | [diff] [blame] | 204 | pCI->create_info.image.usage = |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 205 | const_cast<VkSwapchainCreateInfoKHR*>(static_cast<const VkSwapchainCreateInfoKHR *>(pCreateInfo))->imageUsageFlags; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 206 | break; |
| 207 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 208 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 209 | } |
| 210 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 211 | // Add a fence, creating one if necessary to our list of fences/fenceIds |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 212 | static VkBool32 add_fence_info(layer_data* my_data, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 213 | VkFence fence, |
| 214 | VkQueue queue, |
| 215 | uint64_t *fenceId) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 216 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 217 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 218 | *fenceId = my_data->currentFenceId++; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 219 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 220 | // If no fence, create an internal fence to track the submissions |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 221 | if (fence != VK_NULL_HANDLE) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 222 | my_data->fenceMap[fence].fenceId = *fenceId; |
| 223 | my_data->fenceMap[fence].queue = queue; |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 224 | // Validate that fence is in UNSIGNALED state |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 225 | VkFenceCreateInfo* pFenceCI = &(my_data->fenceMap[fence].createInfo); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 226 | if (pFenceCI->flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 227 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_FENCE, (uint64_t) fence, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 228 | "Fence %#" PRIxLEAST64 " submitted in SIGNALED state. Fences must be reset before being submitted", (uint64_t) fence); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 229 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 230 | } else { |
| 231 | // TODO : Do we need to create an internal fence here for tracking purposes? |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 232 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 233 | // Update most recently submitted fence and fenceId for Queue |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 234 | my_data->queueMap[queue].lastSubmittedId = *fenceId; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 235 | return skipCall; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 236 | } |
| 237 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 238 | // Remove a fenceInfo from our list of fences/fenceIds |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 239 | static void delete_fence_info(layer_data* my_data, |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 240 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 241 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 242 | my_data->fenceMap.erase(fence); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 243 | } |
| 244 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 245 | // Record information when a fence is known to be signalled |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 246 | static void update_fence_tracking(layer_data* my_data, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 247 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 248 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 249 | auto fence_item = my_data->fenceMap.find(fence); |
| 250 | if (fence_item != my_data->fenceMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 251 | MT_FENCE_INFO *pCurFenceInfo = &(*fence_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 252 | VkQueue queue = pCurFenceInfo->queue; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 253 | auto queue_item = my_data->queueMap.find(queue); |
| 254 | if (queue_item != my_data->queueMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 255 | MT_QUEUE_INFO *pQueueInfo = &(*queue_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 256 | if (pQueueInfo->lastRetiredId < pCurFenceInfo->fenceId) { |
| 257 | pQueueInfo->lastRetiredId = pCurFenceInfo->fenceId; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 258 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 259 | } |
| 260 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 261 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 262 | // Update fence state in fenceCreateInfo structure |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 263 | auto pFCI = &(my_data->fenceMap[fence].createInfo); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 264 | pFCI->flags = static_cast<VkFenceCreateFlags>(pFCI->flags | VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 265 | } |
| 266 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 267 | // Helper routine that updates the fence list for a specific queue to all-retired |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 268 | static void retire_queue_fences(layer_data* my_data, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 269 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 270 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 271 | MT_QUEUE_INFO *pQueueInfo = &my_data->queueMap[queue]; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 272 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 273 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 276 | // Helper routine that updates all queues to all-retired |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 277 | static void retire_device_fences(layer_data* my_data, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 278 | VkDevice device) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 279 | { |
| 280 | // Process each queue for device |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 281 | // TODO: Add multiple device support |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 282 | for (auto ii=my_data->queueMap.begin(); ii!=my_data->queueMap.end(); ++ii) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 283 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
| 284 | MT_QUEUE_INFO *pQueueInfo = &(*ii).second; |
| 285 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 286 | } |
| 287 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 288 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 289 | // Helper function to validate correct usage bits set for buffers or images |
| 290 | // Verify that (actual & desired) flags != 0 or, |
| 291 | // if strict is true, verify that (actual & desired) flags == desired |
| 292 | // In case of error, report it via dbg callbacks |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 293 | static VkBool32 validate_usage_flags(layer_data* my_data, void* disp_obj, VkFlags actual, VkFlags desired, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 294 | VkBool32 strict, uint64_t obj_handle, VkDbgObjectType obj_type, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 295 | char const* ty_str, char const* func_name, char const* usage_str) |
| 296 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 297 | VkBool32 correct_usage = VK_FALSE; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 298 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 299 | if (strict) |
| 300 | correct_usage = ((actual & desired) == desired); |
| 301 | else |
| 302 | correct_usage = ((actual & desired) != 0); |
| 303 | if (!correct_usage) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 304 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, obj_type, obj_handle, 0, MEMTRACK_INVALID_USAGE_FLAG, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 305 | "Invalid usage flag for %s %#" PRIxLEAST64 " used by %s. In this case, %s should have %s set during creation.", |
| 306 | ty_str, obj_handle, func_name, ty_str, usage_str); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 307 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 308 | return skipCall; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 309 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 310 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 311 | // Helper function to validate usage flags for images |
| 312 | // Pulls image info and then sends actual vs. desired usage off to helper above where |
| 313 | // an error will be flagged if usage is not correct |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 314 | static VkBool32 validate_image_usage_flags(layer_data* my_data, void* disp_obj, VkImage image, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 315 | char const* func_name, char const* usage_string) |
| 316 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 317 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 318 | MT_OBJ_BINDING_INFO* pBindInfo = get_object_binding_info(my_data, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 319 | if (pBindInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 320 | skipCall = validate_usage_flags(my_data, disp_obj, pBindInfo->create_info.image.usage, desired, strict, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 321 | (uint64_t) image, VK_OBJECT_TYPE_IMAGE, "image", func_name, usage_string); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 322 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 323 | return skipCall; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 324 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 325 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 326 | // Helper function to validate usage flags for buffers |
| 327 | // Pulls buffer info and then sends actual vs. desired usage off to helper above where |
| 328 | // an error will be flagged if usage is not correct |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 329 | static VkBool32 validate_buffer_usage_flags(layer_data* my_data, void* disp_obj, VkBuffer buffer, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 330 | char const* func_name, char const* usage_string) |
| 331 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 332 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 333 | MT_OBJ_BINDING_INFO* pBindInfo = get_object_binding_info(my_data, (uint64_t) buffer, VK_OBJECT_TYPE_BUFFER); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 334 | if (pBindInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 335 | skipCall = validate_usage_flags(my_data, disp_obj, pBindInfo->create_info.buffer.usage, desired, strict, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 336 | (uint64_t) buffer, VK_OBJECT_TYPE_BUFFER, "buffer", func_name, usage_string); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 337 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 338 | return skipCall; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 339 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 340 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 341 | // 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] | 342 | // Calls to this function should be wrapped in mutex |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 343 | static MT_MEM_OBJ_INFO* get_mem_obj_info(layer_data* my_data, |
| 344 | const VkDeviceMemory mem) |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 345 | { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 346 | auto item = my_data->memObjMap.find(mem); |
| 347 | if (item != my_data->memObjMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 348 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 349 | } else { |
| 350 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 351 | } |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 354 | static void add_mem_obj_info(layer_data* my_data, |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 355 | void* object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 356 | const VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 357 | const VkMemoryAllocateInfo* pAllocateInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 358 | { |
Courtney Goeltzenleuchter | 17fd5ce | 2015-06-13 21:29:26 -0600 | [diff] [blame] | 359 | assert(object != NULL); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 360 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | memcpy(&my_data->memObjMap[mem].allocInfo, pAllocateInfo, sizeof(VkMemoryAllocateInfo)); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 362 | // TODO: Update for real hardware, actually process allocation info structures |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 363 | my_data->memObjMap[mem].allocInfo.pNext = NULL; |
| 364 | my_data->memObjMap[mem].object = object; |
| 365 | my_data->memObjMap[mem].refCount = 0; |
| 366 | my_data->memObjMap[mem].mem = mem; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 369 | // Find CB Info and add mem reference to list container |
| 370 | // Find Mem Obj Info and add CB reference to list container |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 371 | static VkBool32 update_cmd_buf_and_mem_references( |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 372 | layer_data *my_data, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 373 | const VkCommandBuffer cb, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 374 | const VkDeviceMemory mem, |
| 375 | const char *apiName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 376 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 377 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 378 | |
| 379 | // Skip validation if this image was created through WSI |
| 380 | if (mem != MEMTRACKER_SWAP_CHAIN_IMAGE_KEY) { |
| 381 | |
| 382 | // First update CB binding in MemObj mini CB list |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 383 | MT_MEM_OBJ_INFO* pMemInfo = get_mem_obj_info(my_data, mem); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 384 | if (!pMemInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 385 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 386 | "In %s, trying to bind mem obj %#" PRIxLEAST64 " to CB %p but no info for that mem obj.\n " |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 387 | "Was it correctly allocated? Did it already get freed?", apiName, (uint64_t) mem, cb); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 388 | } else { |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 389 | // Search for cmd buffer object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 390 | VkBool32 found = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 391 | if (pMemInfo->pCommandBufferBindings.size() > 0) { |
| 392 | for (list<VkCommandBuffer>::iterator it = pMemInfo->pCommandBufferBindings.begin(); it != pMemInfo->pCommandBufferBindings.end(); ++it) { |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 393 | if ((*it) == cb) { |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 394 | found = VK_TRUE; |
| 395 | break; |
| 396 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 400 | if (found == VK_FALSE) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 401 | pMemInfo->pCommandBufferBindings.push_front(cb); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 402 | pMemInfo->refCount++; |
| 403 | } |
| 404 | // Now update CBInfo's Mem reference list |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 405 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(my_data, cb); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 406 | // TODO: keep track of all destroyed CBs so we know if this is a stale or simply invalid object |
| 407 | if (!pCBInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 408 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 409 | "Trying to bind mem obj %#" PRIxLEAST64 " to CB %p but no info for that CB. Was CB incorrectly destroyed?", (uint64_t) mem, cb); |
Mark Lobodzinski | 348803a | 2015-09-11 15:56:51 -0600 | [diff] [blame] | 410 | } else { |
| 411 | // Search for memory object in cmd buffer's reference list |
| 412 | VkBool32 found = VK_FALSE; |
| 413 | if (pCBInfo->pMemObjList.size() > 0) { |
| 414 | for (auto it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
| 415 | if ((*it) == mem) { |
| 416 | found = VK_TRUE; |
| 417 | break; |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | // If not present, add to list |
| 422 | if (found == VK_FALSE) { |
| 423 | pCBInfo->pMemObjList.push_front(mem); |
| 424 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 425 | } |
| 426 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 427 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 428 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 429 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 430 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 431 | // Free bindings related to CB |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 432 | static VkBool32 clear_cmd_buf_and_mem_references(layer_data* my_data, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 433 | const VkCommandBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 434 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 435 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 436 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(my_data, cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 437 | if (!pCBInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 438 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cb, 0, MEMTRACK_INVALID_CB, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 439 | "Unable to find global CB info %p for deletion", cb); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 440 | } else { |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 441 | if (pCBInfo->pMemObjList.size() > 0) { |
| 442 | list<VkDeviceMemory> mem_obj_list = pCBInfo->pMemObjList; |
| 443 | for (list<VkDeviceMemory>::iterator it=mem_obj_list.begin(); it!=mem_obj_list.end(); ++it) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 444 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(my_data, *it); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 445 | pInfo->pCommandBufferBindings.remove(cb); |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 446 | pInfo->refCount--; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 447 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 448 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 449 | pCBInfo->pMemObjList.clear(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 450 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 451 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 452 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 453 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 454 | // Delete the entire CB list |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 455 | static VkBool32 delete_cmd_buf_info_list(layer_data* my_data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 456 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 457 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 458 | for (unordered_map<VkCommandBuffer, MT_CB_INFO>::iterator ii=my_data->cbMap.begin(); ii!=my_data->cbMap.end(); ++ii) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 459 | skipCall |= clear_cmd_buf_and_mem_references(my_data, (*ii).first); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 460 | } |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 461 | my_data->cbMap.clear(); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 462 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 465 | // For given MemObjInfo, report Obj & CB bindings |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 466 | static VkBool32 reportMemReferencesAndCleanUp(layer_data* my_data, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 467 | MT_MEM_OBJ_INFO* pMemObjInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 468 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 469 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 470 | size_t cmdBufRefCount = pMemObjInfo->pCommandBufferBindings.size(); |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 471 | size_t objRefCount = pMemObjInfo->pObjBindings.size(); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 472 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 473 | if ((pMemObjInfo->pCommandBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 474 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) pMemObjInfo->mem, 0, MEMTRACK_FREED_MEM_REF, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 475 | "Attempting to free memory object %#" PRIxLEAST64 " which still contains %lu references", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 476 | (uint64_t) pMemObjInfo->mem, (cmdBufRefCount + objRefCount)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 477 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 478 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 479 | if (cmdBufRefCount > 0 && pMemObjInfo->pCommandBufferBindings.size() > 0) { |
| 480 | for (list<VkCommandBuffer>::const_iterator it = pMemObjInfo->pCommandBufferBindings.begin(); it != pMemObjInfo->pCommandBufferBindings.end(); ++it) { |
| 481 | // TODO : CommandBuffer should be source Obj here |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 482 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)(*it), 0, MEMTRACK_FREED_MEM_REF, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 483 | "Command Buffer %p still has a reference to mem obj %#" PRIxLEAST64, (*it), (uint64_t) pMemObjInfo->mem); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 484 | } |
| 485 | // Clear the list of hanging references |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 486 | pMemObjInfo->pCommandBufferBindings.clear(); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 487 | } |
| 488 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 489 | if (objRefCount > 0 && pMemObjInfo->pObjBindings.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 490 | for (auto it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 491 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, it->type, it->handle, 0, MEMTRACK_FREED_MEM_REF, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 492 | "VK Object %#" PRIxLEAST64 " still has a reference to mem obj %#" PRIxLEAST64, it->handle, (uint64_t) pMemObjInfo->mem); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 493 | } |
| 494 | // Clear the list of hanging references |
| 495 | pMemObjInfo->pObjBindings.clear(); |
| 496 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 497 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 500 | static VkBool32 deleteMemObjInfo(layer_data* my_data, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 501 | void* object, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 502 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 503 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 504 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 505 | auto item = my_data->memObjMap.find(mem); |
| 506 | if (item != my_data->memObjMap.end()) { |
| 507 | my_data->memObjMap.erase(item); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 508 | } else { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 509 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 510 | "Request to delete memory object %#" PRIxLEAST64 " not present in memory Object Map", (uint64_t) mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 511 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 512 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 513 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 514 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 515 | // Check if fence for given CB is completed |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 516 | static VkBool32 checkCBCompleted(layer_data* my_data, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 517 | const VkCommandBuffer cb, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 518 | VkBool32 *complete) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 519 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 520 | VkBool32 skipCall = VK_FALSE; |
| 521 | *complete = VK_TRUE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 522 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(my_data, cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 523 | if (!pCBInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 524 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cb, 0, |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 525 | MEMTRACK_INVALID_CB, "MEM", "Unable to find global CB info %p to check for completion", cb); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 526 | *complete = VK_FALSE; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 527 | } else if (pCBInfo->lastSubmittedQueue != NULL) { |
| 528 | VkQueue queue = pCBInfo->lastSubmittedQueue; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 529 | MT_QUEUE_INFO *pQueueInfo = &my_data->queueMap[queue]; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 530 | if (pCBInfo->fenceId > pQueueInfo->lastRetiredId) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 531 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cb, 0, |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 532 | MEMTRACK_NONE, "MEM", "fence %#" PRIxLEAST64 " for CB %p has not been checked for completion", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 533 | (uint64_t) pCBInfo->lastSubmittedFence, cb); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 534 | *complete = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 535 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 536 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 537 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 538 | } |
| 539 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 540 | static VkBool32 freeMemObjInfo(layer_data* my_data, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 541 | void* object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 542 | VkDeviceMemory mem, |
| 543 | bool internal) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 544 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 545 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 546 | // Parse global list to find info w/ mem |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 547 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(my_data, mem); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 548 | if (!pInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 549 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 550 | "Couldn't find mem info object for %#" PRIxLEAST64 "\n Was %#" PRIxLEAST64 " never allocated or previously freed?", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 551 | (uint64_t) mem, (uint64_t) mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 552 | } else { |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 553 | if (pInfo->allocInfo.allocationSize == 0 && !internal) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 554 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 555 | "Attempting to free memory associated with a Persistent Image, %#" PRIxLEAST64 ", " |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 556 | "this should not be explicitly freed\n", (uint64_t) mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 557 | } else { |
| 558 | // Clear any CB bindings for completed CBs |
| 559 | // TODO : Is there a better place to do this? |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 560 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 561 | VkBool32 commandBufferComplete = VK_FALSE; |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 562 | assert(pInfo->object != VK_NULL_HANDLE); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 563 | list<VkCommandBuffer>::iterator it = pInfo->pCommandBufferBindings.begin(); |
| 564 | list<VkCommandBuffer>::iterator temp; |
| 565 | while (pInfo->pCommandBufferBindings.size() > 0 && it != pInfo->pCommandBufferBindings.end()) { |
| 566 | skipCall |= checkCBCompleted(my_data, *it, &commandBufferComplete); |
| 567 | if (VK_TRUE == commandBufferComplete) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 568 | temp = it; |
| 569 | ++temp; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 570 | skipCall |= clear_cmd_buf_and_mem_references(my_data, *it); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 571 | it = temp; |
| 572 | } else { |
| 573 | ++it; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 574 | } |
| 575 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 576 | |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 577 | // Now verify that no references to this mem obj remain and remove bindings |
Mark Lobodzinski | 7b77233 | 2015-09-10 08:15:23 -0600 | [diff] [blame] | 578 | if (0 != pInfo->refCount) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 579 | skipCall |= reportMemReferencesAndCleanUp(my_data, pInfo); |
Mark Lobodzinski | 7b77233 | 2015-09-10 08:15:23 -0600 | [diff] [blame] | 580 | } |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 581 | // Delete mem obj info |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 582 | skipCall |= deleteMemObjInfo(my_data, object, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 583 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 584 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 585 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 586 | } |
| 587 | |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 588 | static const char *object_type_to_string(VkDbgObjectType type) { |
| 589 | switch (type) |
| 590 | { |
| 591 | case VK_OBJECT_TYPE_IMAGE: |
| 592 | return "image"; |
| 593 | break; |
| 594 | case VK_OBJECT_TYPE_BUFFER: |
| 595 | return "image"; |
| 596 | break; |
| 597 | case VK_OBJECT_TYPE_SWAPCHAIN_KHR: |
| 598 | return "swapchain"; |
| 599 | break; |
| 600 | default: |
| 601 | return "unknown"; |
| 602 | } |
| 603 | } |
| 604 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 605 | // Remove object binding performs 3 tasks: |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 606 | // 1. Remove ObjectInfo from MemObjInfo list container of obj bindings & free it |
| 607 | // 2. Decrement refCount for MemObjInfo |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 608 | // 3. Clear mem binding for image/buffer by setting its handle to 0 |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 609 | // TODO : This only applied to Buffer, Image, and Swapchain objects now, how should it be updated/customized? |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 610 | static VkBool32 clear_object_binding(layer_data* my_data, void* dispObj, uint64_t handle, VkDbgObjectType type) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 611 | { |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 612 | // TODO : Need to customize images/buffers/swapchains to track mem binding and clear it here appropriately |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 613 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 614 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(my_data, handle, type); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 615 | if (pObjBindInfo) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 616 | MT_MEM_OBJ_INFO* pMemObjInfo = get_mem_obj_info(my_data, pObjBindInfo->mem); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 617 | if (!pMemObjInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 618 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, type, handle, 0, MEMTRACK_MEM_OBJ_CLEAR_EMPTY_BINDINGS, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 619 | "Attempting to clear mem binding on %s obj %#" PRIxLEAST64 " but it has no binding.", |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 620 | object_type_to_string(type), handle); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 621 | } else { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 622 | // 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 |
| 623 | // and set the objects memory binding pointer to NULL. |
| 624 | VkBool32 clearSucceeded = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 625 | for (auto it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
| 626 | if ((it->handle == handle) && (it->type == type)) { |
| 627 | pMemObjInfo->refCount--; |
| 628 | pMemObjInfo->pObjBindings.erase(it); |
| 629 | // TODO : Make sure this is a reasonable way to reset mem binding |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 630 | pObjBindInfo->mem = VK_NULL_HANDLE; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 631 | clearSucceeded = VK_TRUE; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 632 | break; |
| 633 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 634 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 635 | if (VK_FALSE == clearSucceeded ) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 636 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 637 | "While trying to clear mem binding for %s obj %#" PRIxLEAST64 ", unable to find that object referenced by mem obj %#" PRIxLEAST64, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 638 | object_type_to_string(type), handle, (uint64_t) pMemObjInfo->mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 639 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 640 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 641 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 642 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 643 | } |
| 644 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 645 | // For NULL mem case, output warning |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 646 | // Make sure given object is in global object map |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 647 | // IF a previous binding existed, output validation error |
| 648 | // Otherwise, add reference from objectInfo to memoryInfo |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 649 | // Add reference off of objInfo |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 650 | // device is required for error logging, need a dispatchable |
| 651 | // object for that. |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 652 | static VkBool32 set_mem_binding(layer_data* my_data, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 653 | void* dispatch_object, |
| 654 | VkDeviceMemory mem, |
| 655 | uint64_t handle, |
| 656 | VkDbgObjectType type, |
| 657 | const char *apiName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 658 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 659 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 660 | // Handle NULL case separately, just clear previous binding & decrement reference |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 661 | if (mem == VK_NULL_HANDLE) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 662 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, type, handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 663 | "In %s, attempting to Bind Obj(%#" PRIxLEAST64 ") to NULL", apiName, handle); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 664 | } else { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 665 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(my_data, handle, type); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 666 | if (!pObjBindInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 667 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 668 | "In %s, attempting to update Binding of %s Obj(%#" PRIxLEAST64 ") that's not in global list()", |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 669 | object_type_to_string(type), apiName, handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 670 | } else { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 671 | // non-null case so should have real mem obj |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 672 | MT_MEM_OBJ_INFO* pMemInfo = get_mem_obj_info(my_data, mem); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 673 | if (!pMemInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 674 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 675 | 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", "In %s, while trying to bind mem for %s obj %#" PRIxLEAST64 ", couldn't find info for mem obj %#" PRIxLEAST64, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 676 | object_type_to_string(type), apiName, handle, (uint64_t) mem); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 677 | } else { |
| 678 | // TODO : Need to track mem binding for obj and report conflict here |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 679 | MT_MEM_OBJ_INFO* pPrevBinding = get_mem_obj_info(my_data, pObjBindInfo->mem); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 680 | if (pPrevBinding != NULL) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 681 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_REBIND_OBJECT, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 682 | "In %s, attempting to bind memory (%#" PRIxLEAST64 ") to object (%#" PRIxLEAST64 ") which has already been bound to mem object %#" PRIxLEAST64, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 683 | apiName, (uint64_t) mem, handle, (uint64_t) pPrevBinding->mem); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 684 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 685 | else { |
| 686 | MT_OBJ_HANDLE_TYPE oht; |
| 687 | oht.handle = handle; |
| 688 | oht.type = type; |
| 689 | pMemInfo->pObjBindings.push_front(oht); |
| 690 | pMemInfo->refCount++; |
| 691 | // For image objects, make sure default memory state is correctly set |
| 692 | // TODO : What's the best/correct way to handle this? |
| 693 | if (VK_OBJECT_TYPE_IMAGE == type) { |
| 694 | VkImageCreateInfo ici = pObjBindInfo->create_info.image; |
| 695 | if (ici.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 696 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) { |
| 697 | // TODO:: More memory state transition stuff. |
| 698 | } |
| 699 | } |
| 700 | pObjBindInfo->mem = mem; |
| 701 | } |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 702 | } |
| 703 | } |
| 704 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 705 | return skipCall; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | // For NULL mem case, clear any previous binding Else... |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 709 | // Make sure given object is in its object map |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 710 | // IF a previous binding existed, update binding |
| 711 | // Add reference from objectInfo to memoryInfo |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 712 | // Add reference off of object's binding info |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 713 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 714 | static VkBool32 set_sparse_mem_binding(layer_data* my_data, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 715 | void* dispObject, |
| 716 | VkDeviceMemory mem, |
| 717 | uint64_t handle, |
| 718 | VkDbgObjectType type, |
| 719 | const char *apiName) |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 720 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 721 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 722 | // Handle NULL case separately, just clear previous binding & decrement reference |
| 723 | if (mem == VK_NULL_HANDLE) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 724 | skipCall = clear_object_binding(my_data, dispObject, handle, type); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 725 | } else { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 726 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(my_data, handle, type); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 727 | if (!pObjBindInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 728 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 729 | "In %s, attempting to update Binding of Obj(%#" PRIxLEAST64 ") that's not in global list()", apiName, handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 730 | } |
| 731 | // non-null case so should have real mem obj |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 732 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(my_data, mem); |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 733 | if (!pInfo) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 734 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 735 | "In %s, While trying to bind mem for obj %#" PRIxLEAST64 ", couldn't find info for mem obj %#" PRIxLEAST64, apiName, handle, (uint64_t) mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 736 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 737 | // Search for object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 738 | VkBool32 found = VK_FALSE; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 739 | if (pInfo->pObjBindings.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 740 | for (auto it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
| 741 | if (((*it).handle == handle) && ((*it).type == type)) { |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 742 | found = VK_TRUE; |
| 743 | break; |
| 744 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 745 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 746 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 747 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 748 | if (found == VK_FALSE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 749 | MT_OBJ_HANDLE_TYPE oht; |
| 750 | oht.handle = handle; |
| 751 | oht.type = type; |
| 752 | pInfo->pObjBindings.push_front(oht); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 753 | pInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 754 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 755 | // Need to set mem binding for this object |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 756 | MT_MEM_OBJ_INFO* pPrevBinding = get_mem_obj_info(my_data, pObjBindInfo->mem); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 757 | pObjBindInfo->mem = mem; |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 758 | } |
| 759 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 760 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 761 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 762 | |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 763 | template <typename T> |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 764 | void print_object_map_members(layer_data* my_data, |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 765 | void* dispObj, |
| 766 | T const& objectName, |
| 767 | VkDbgObjectType objectType, |
| 768 | const char *objectStr) |
| 769 | { |
| 770 | for (auto const& element : objectName) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 771 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, objectType, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 772 | " %s Object list contains %s Object %#" PRIxLEAST64 " ", objectStr, objectStr, element.first); |
| 773 | } |
| 774 | } |
| 775 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 776 | // For given Object, get 'mem' obj that it's bound to or NULL if no binding |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 777 | static VkBool32 get_mem_binding_from_object(layer_data* my_data, |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 778 | void* dispObj, const uint64_t handle, const VkDbgObjectType type, VkDeviceMemory *mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 779 | { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 780 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 781 | *mem = VK_NULL_HANDLE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 782 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(my_data, handle, type); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 783 | if (pObjBindInfo) { |
| 784 | if (pObjBindInfo->mem) { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 785 | *mem = pObjBindInfo->mem; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 786 | } else { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 787 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 788 | "Trying to get mem binding for object %#" PRIxLEAST64 " but object has no mem binding", handle); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 789 | } |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 790 | } else { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 791 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 792 | "Trying to get mem binding for object %#" PRIxLEAST64 " but no such object in %s list", |
| 793 | handle, object_type_to_string(type)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 794 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 795 | return skipCall; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 796 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 797 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 798 | // Print details of MemObjInfo list |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 799 | static void print_mem_list(layer_data* my_data, |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 800 | void* dispObj) |
| 801 | { |
| 802 | MT_MEM_OBJ_INFO* pInfo = NULL; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 803 | |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 804 | // Early out if info is not requested |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 805 | if (!(my_data->report_data->active_flags & VK_DBG_REPORT_INFO_BIT)) { |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 806 | return; |
| 807 | } |
| 808 | |
| 809 | // Just printing each msg individually for now, may want to package these into single large print |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 810 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 811 | "Details of Memory Object list (of size %lu elements)", my_data->memObjMap.size()); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 812 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 813 | "============================="); |
| 814 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 815 | if (my_data->memObjMap.size() <= 0) |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 816 | return; |
| 817 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 818 | for (auto ii=my_data->memObjMap.begin(); ii!=my_data->memObjMap.end(); ++ii) { |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 819 | pInfo = &(*ii).second; |
| 820 | |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 821 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 822 | " ===MemObjInfo at %p===", (void*)pInfo); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 823 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 824 | " Mem object: %#" PRIxLEAST64, (void*)pInfo->mem); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 825 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 826 | " Ref Count: %u", pInfo->refCount); |
| 827 | if (0 != pInfo->allocInfo.allocationSize) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 828 | string pAllocInfoMsg = vk_print_vkmemoryallocateinfo(&pInfo->allocInfo, "MEM(INFO): "); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 829 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 830 | " Mem Alloc info:\n%s", pAllocInfoMsg.c_str()); |
| 831 | } else { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 832 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 833 | " Mem Alloc info is NULL (alloc done by vkCreateSwapchainKHR())"); |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 834 | } |
| 835 | |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 836 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 837 | " VK OBJECT Binding list of size %lu elements:", pInfo->pObjBindings.size()); |
| 838 | if (pInfo->pObjBindings.size() > 0) { |
| 839 | for (list<MT_OBJ_HANDLE_TYPE>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 840 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 841 | " VK OBJECT %p", (*it)); |
| 842 | } |
| 843 | } |
| 844 | |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 845 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 846 | " VK Command Buffer (CB) binding list of size %lu elements", pInfo->pCommandBufferBindings.size()); |
| 847 | if (pInfo->pCommandBufferBindings.size() > 0) |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 848 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 849 | for (list<VkCommandBuffer>::iterator it = pInfo->pCommandBufferBindings.begin(); it != pInfo->pCommandBufferBindings.end(); ++it) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 850 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 851 | " VK CB %p", (*it)); |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 857 | static void printCBList(layer_data* my_data, |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 858 | void* dispObj) |
| 859 | { |
| 860 | MT_CB_INFO* pCBInfo = NULL; |
| 861 | |
| 862 | // Early out if info is not requested |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 863 | if (!(my_data->report_data->active_flags & VK_DBG_REPORT_INFO_BIT)) { |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 864 | return; |
| 865 | } |
| 866 | |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 867 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 868 | "Details of CB list (of size %lu elements)", my_data->cbMap.size()); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 869 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 870 | "=================="); |
| 871 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 872 | if (my_data->cbMap.size() <= 0) |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 873 | return; |
| 874 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 875 | for (auto ii=my_data->cbMap.begin(); ii!=my_data->cbMap.end(); ++ii) { |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 876 | pCBInfo = &(*ii).second; |
| 877 | |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 878 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 879 | " CB Info (%p) has CB %p, fenceId %" PRIx64", and fence %#" PRIxLEAST64, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 880 | (void*)pCBInfo, (void*)pCBInfo->commandBuffer, pCBInfo->fenceId, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 881 | (uint64_t) pCBInfo->lastSubmittedFence); |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 882 | |
| 883 | if (pCBInfo->pMemObjList.size() <= 0) |
| 884 | continue; |
| 885 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 886 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, 0, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 887 | " Mem obj %p", (*it)); |
| 888 | } |
| 889 | } |
| 890 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 891 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 892 | static void init_mem_tracker( |
| 893 | layer_data *my_data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 894 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 895 | uint32_t report_flags = 0; |
| 896 | uint32_t debug_action = 0; |
| 897 | FILE *log_output = NULL; |
| 898 | const char *option_str; |
Courtney Goeltzenleuchter | 0036b57 | 2015-10-05 15:59:26 -0600 | [diff] [blame] | 899 | VkDbgMsgCallback callback; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 900 | // initialize MemTracker options |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 901 | report_flags = getLayerOptionFlags("MemTrackerReportFlags", 0); |
| 902 | getLayerOptionEnum("MemTrackerDebugAction", (uint32_t *) &debug_action); |
Tobin Ehlis | ee70223 | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 903 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 904 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 905 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 906 | option_str = getLayerOption("MemTrackerLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 907 | log_output = getLayerLogOutput(option_str, "MemTracker"); |
Courtney Goeltzenleuchter | 0036b57 | 2015-10-05 15:59:26 -0600 | [diff] [blame] | 908 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback); |
| 909 | my_data->logging_callback.push_back(callback); |
| 910 | } |
| 911 | |
| 912 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
| 913 | layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); |
| 914 | my_data->logging_callback.push_back(callback); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 917 | if (!globalLockInitialized) |
| 918 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 919 | loader_platform_thread_create_mutex(&globalLock); |
| 920 | globalLockInitialized = 1; |
| 921 | } |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 922 | |
| 923 | // Zero out memory property data |
| 924 | memset(&memProps, 0, sizeof(VkPhysicalDeviceMemoryProperties)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 925 | } |
| 926 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 927 | // hook DestroyInstance to remove tableInstanceMap entry |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 928 | VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 929 | { |
Jeremy Hayes | 35f8afc | 2015-06-18 10:25:55 -0600 | [diff] [blame] | 930 | // Grab the key before the instance is destroyed. |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 931 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 932 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 933 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 934 | pTable->DestroyInstance(instance, pAllocator); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 935 | |
| 936 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | 0036b57 | 2015-10-05 15:59:26 -0600 | [diff] [blame] | 937 | while (my_data->logging_callback.size() > 0) { |
| 938 | VkDbgMsgCallback callback = my_data->logging_callback.back(); |
| 939 | layer_destroy_msg_callback(my_data->report_data, callback); |
| 940 | my_data->logging_callback.pop_back(); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 941 | } |
| 942 | |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 943 | layer_debug_report_destroy_instance(my_data->report_data); |
| 944 | delete my_data->instance_dispatch_table; |
| 945 | layer_data_map.erase(key); |
| 946 | if (layer_data_map.empty()) { |
| 947 | // Release mutex when destroying last instance |
| 948 | loader_platform_thread_delete_mutex(&globalLock); |
| 949 | globalLockInitialized = 0; |
| 950 | } |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 951 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 952 | |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 953 | VkResult VKAPI vkCreateInstance( |
| 954 | const VkInstanceCreateInfo* pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 955 | const VkAllocationCallbacks* pAllocator, |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 956 | VkInstance* pInstance) |
| 957 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 958 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 959 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 960 | VkResult result = pTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 961 | |
| 962 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 963 | my_data->report_data = debug_report_create_instance( |
| 964 | pTable, |
| 965 | *pInstance, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 966 | pCreateInfo->enabledExtensionNameCount, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 967 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 968 | |
| 969 | init_mem_tracker(my_data); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 970 | } |
| 971 | return result; |
| 972 | } |
| 973 | |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 974 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 975 | { |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 976 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 977 | VkLayerDispatchTable *pDisp = my_device_data->device_dispatch_table; |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 978 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
| 979 | pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR"); |
| 980 | pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR"); |
| 981 | pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR"); |
| 982 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); |
| 983 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); |
| 984 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); |
| 985 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); |
| 986 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 987 | my_device_data->wsi_enabled = false; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 988 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 989 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0) |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 990 | my_device_data->wsi_enabled = true; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 991 | } |
| 992 | } |
| 993 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 994 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( |
| 995 | VkPhysicalDevice gpu, |
| 996 | const VkDeviceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 997 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 998 | VkDevice *pDevice) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 999 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1000 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 1001 | VkLayerDispatchTable *pDeviceTable = my_device_data->device_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1002 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1003 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1004 | 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] | 1005 | 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] | 1006 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1007 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1008 | return result; |
| 1009 | } |
| 1010 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1011 | VK_LAYER_EXPORT void VKAPI vkDestroyDevice( |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1012 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1013 | const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1014 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1015 | dispatch_key key = get_dispatch_key(device); |
| 1016 | layer_data *my_device_data = get_my_data_ptr(key, layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1017 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1018 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1019 | log_msg(my_device_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE, (uint64_t)device, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 1020 | "Printing List details prior to vkDestroyDevice()"); |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1021 | log_msg(my_device_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE, (uint64_t)device, 0, MEMTRACK_NONE, "MEM", |
Mark Lobodzinski | 524df11 | 2015-08-10 14:37:52 -0600 | [diff] [blame] | 1022 | "================================================"); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1023 | print_mem_list(my_device_data, device); |
| 1024 | printCBList(my_device_data, device); |
| 1025 | skipCall = delete_cmd_buf_info_list(my_device_data); |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 1026 | // Report any memory leaks |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1027 | MT_MEM_OBJ_INFO* pInfo = NULL; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1028 | if (my_device_data->memObjMap.size() > 0) { |
| 1029 | for (auto ii=my_device_data->memObjMap.begin(); ii!=my_device_data->memObjMap.end(); ++ii) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 1030 | pInfo = &(*ii).second; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1031 | if (pInfo->allocInfo.allocationSize != 0) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1032 | skipCall |= log_msg(my_device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) pInfo->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1033 | "Mem Object %p has not been freed. You should clean up this memory by calling " |
| 1034 | "vkFreeMemory(%p) prior to vkDestroyDevice().", pInfo->mem, pInfo->mem); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1035 | } |
Mark Lobodzinski | 2f3b19b | 2015-02-18 18:06:24 -0600 | [diff] [blame] | 1036 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 1037 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1038 | // Queues persist until device is destroyed |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1039 | delete_queue_info_list(my_device_data); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1040 | layer_debug_report_destroy_device(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1041 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1042 | |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 1043 | #if DISPATCH_MAP_DEBUG |
| 1044 | fprintf(stderr, "Device: %p, key: %p\n", device, key); |
| 1045 | #endif |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1046 | VkLayerDispatchTable *pDisp = my_device_data->device_dispatch_table; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1047 | if (VK_FALSE == skipCall) { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1048 | pDisp->DestroyDevice(device, pAllocator); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1049 | } |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1050 | delete my_device_data->device_dispatch_table; |
| 1051 | layer_data_map.erase(key); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1052 | } |
| 1053 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1054 | VK_LAYER_EXPORT void VKAPI vkGetPhysicalDeviceMemoryProperties( |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1055 | VkPhysicalDevice physicalDevice, |
| 1056 | VkPhysicalDeviceMemoryProperties *pMemoryProperties) |
| 1057 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1058 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1059 | VkLayerInstanceDispatchTable *pInstanceTable = my_data->instance_dispatch_table; |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1060 | pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); |
| 1061 | memcpy(&memProps, pMemoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1062 | } |
| 1063 | |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1064 | static const VkLayerProperties mtGlobalLayers[] = { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1065 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1066 | "MemTracker", |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1067 | VK_API_VERSION, |
| 1068 | VK_MAKE_VERSION(0, 1, 0), |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1069 | "Validation layer: MemTracker", |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1070 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1071 | }; |
| 1072 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1073 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1074 | const char *pLayerName, |
| 1075 | uint32_t *pCount, |
| 1076 | VkExtensionProperties* pProperties) |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1077 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1078 | /* Mem tracker does not have any global extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1079 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1080 | } |
| 1081 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1082 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceLayerProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1083 | uint32_t *pCount, |
| 1084 | VkLayerProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1085 | { |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1086 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), |
| 1087 | mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1088 | pCount, pProperties); |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1089 | } |
| 1090 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1091 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1092 | VkPhysicalDevice physicalDevice, |
| 1093 | const char* pLayerName, |
| 1094 | uint32_t* pCount, |
| 1095 | VkExtensionProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1096 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1097 | /* Mem tracker does not have any physical device extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1098 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1099 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1100 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1101 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceLayerProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1102 | VkPhysicalDevice physicalDevice, |
| 1103 | uint32_t* pCount, |
| 1104 | VkLayerProperties* pProperties) |
| 1105 | { |
| 1106 | /* Mem tracker's physical device layers are the same as global */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1107 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1108 | pCount, pProperties); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1109 | } |
| 1110 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1111 | VK_LAYER_EXPORT void VKAPI vkGetDeviceQueue( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1112 | VkDevice device, |
| 1113 | uint32_t queueNodeIndex, |
| 1114 | uint32_t queueIndex, |
| 1115 | VkQueue *pQueue) |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1116 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1117 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1118 | my_data->device_dispatch_table->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1119 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1120 | add_queue_info(my_data, *pQueue); |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1121 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1122 | } |
| 1123 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1124 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( |
| 1125 | VkQueue queue, |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1126 | uint32_t submitCount, |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1127 | const VkSubmitInfo *pSubmits, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1128 | VkFence fence) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1129 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1130 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1131 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
| 1132 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1133 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1134 | // TODO : Need to track fence and clear mem references when fence clears |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1135 | MT_CB_INFO* pCBInfo = NULL; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1136 | uint64_t fenceId = 0; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1137 | VkBool32 skipCall = add_fence_info(my_data, fence, queue, &fenceId); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1138 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1139 | print_mem_list(my_data, queue); |
| 1140 | printCBList(my_data, queue); |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1141 | for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1142 | const VkSubmitInfo *submit = &pSubmits[submit_idx]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1143 | for (uint32_t i = 0; i < submit->commandBufferCount; i++) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1144 | pCBInfo = get_cmd_buf_info(my_data, submit->pCommandBuffers[i]); |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1145 | pCBInfo->fenceId = fenceId; |
| 1146 | pCBInfo->lastSubmittedFence = fence; |
| 1147 | pCBInfo->lastSubmittedQueue = queue; |
| 1148 | } |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1149 | |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1150 | for (uint32_t i = 0; i < submit->waitSemaphoreCount; i++) { |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1151 | VkSemaphore sem = submit->pWaitSemaphores[i]; |
| 1152 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1153 | if (my_data->semaphoreMap.find(sem) != my_data->semaphoreMap.end()) { |
| 1154 | if (my_data->semaphoreMap[sem] != MEMTRACK_SEMAPHORE_STATE_SIGNALLED) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1155 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SEMAPHORE, (uint64_t) sem, |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1156 | 0, MEMTRACK_NONE, "SEMAPHORE", |
| 1157 | "vkQueueSubmit: Semaphore must be in signaled state before passing to pWaitSemaphores"); |
| 1158 | } |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1159 | my_data->semaphoreMap[sem] = MEMTRACK_SEMAPHORE_STATE_WAIT; |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1160 | } |
| 1161 | } |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1162 | for (uint32_t i = 0; i < submit->signalSemaphoreCount; i++) { |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1163 | VkSemaphore sem = submit->pWaitSemaphores[i]; |
| 1164 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1165 | if (my_data->semaphoreMap.find(sem) != my_data->semaphoreMap.end()) { |
| 1166 | if (my_data->semaphoreMap[sem] != MEMTRACK_SEMAPHORE_STATE_UNSET) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1167 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SEMAPHORE, (uint64_t) sem, |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1168 | 0, MEMTRACK_NONE, "SEMAPHORE", |
| 1169 | "vkQueueSubmit: Semaphore must not be currently signaled or in a wait state"); |
| 1170 | } |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1171 | my_data->semaphoreMap[sem] = MEMTRACK_SEMAPHORE_STATE_SIGNALLED; |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1172 | } |
| 1173 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1174 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1175 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1176 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1177 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1178 | result = my_data->device_dispatch_table->QueueSubmit( |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1179 | queue, submitCount, pSubmits, fence); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1180 | } |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1181 | |
| 1182 | loader_platform_thread_lock_mutex(&globalLock); |
| 1183 | for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1184 | const VkSubmitInfo *submit = &pSubmits[submit_idx]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1185 | for (uint32_t i = 0; i < submit->waitSemaphoreCount; i++) { |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1186 | VkSemaphore sem = submit->pWaitSemaphores[i]; |
| 1187 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1188 | if (my_data->semaphoreMap.find(sem) != my_data->semaphoreMap.end()) { |
| 1189 | my_data->semaphoreMap[sem] = MEMTRACK_SEMAPHORE_STATE_UNSET; |
Chia-I Wu | a690b41 | 2015-10-29 22:01:53 +0800 | [diff] [blame] | 1190 | } |
| 1191 | } |
| 1192 | } |
| 1193 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1194 | |
Courtney Goeltzenleuchter | d3fb955 | 2015-04-02 13:39:07 -0600 | [diff] [blame] | 1195 | return result; |
| 1196 | } |
| 1197 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1198 | VK_LAYER_EXPORT VkResult VKAPI vkAllocateMemory( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1199 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1200 | const VkMemoryAllocateInfo *pAllocateInfo, |
| 1201 | const VkAllocationCallbacks* pAllocator, |
| 1202 | VkDeviceMemory *pMemory) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1203 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1204 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1205 | VkResult result = my_data->device_dispatch_table->AllocateMemory(device, pAllocateInfo, pAllocator, pMemory); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1206 | // TODO : Track allocations and overall size here |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1207 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1208 | add_mem_obj_info(my_data, device, *pMemory, pAllocateInfo); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1209 | print_mem_list(my_data, device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1210 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1211 | return result; |
| 1212 | } |
| 1213 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1214 | VK_LAYER_EXPORT void VKAPI vkFreeMemory( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1215 | VkDevice device, |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1216 | VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1217 | const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1218 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1219 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1220 | /* 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] | 1221 | * freeing a memory object, an application must ensure the memory object is unbound from |
| 1222 | * all API objects referencing it and that it is not referenced by any queued command buffers |
| 1223 | */ |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1224 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1225 | freeMemObjInfo(my_data, device, mem, false); |
| 1226 | print_mem_list(my_data, device); |
| 1227 | printCBList(my_data, device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1228 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1229 | my_data->device_dispatch_table->FreeMemory(device, mem, pAllocator); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1230 | } |
| 1231 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1232 | VK_LAYER_EXPORT VkResult VKAPI vkMapMemory( |
| 1233 | VkDevice device, |
| 1234 | VkDeviceMemory mem, |
| 1235 | VkDeviceSize offset, |
| 1236 | VkDeviceSize size, |
| 1237 | VkFlags flags, |
| 1238 | void **ppData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1239 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1240 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1241 | // TODO : Track when memory is mapped |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1242 | VkBool32 skipCall = VK_FALSE; |
| 1243 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1244 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1245 | MT_MEM_OBJ_INFO *pMemObj = get_mem_obj_info(my_data, mem); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1246 | if ((memProps.memoryTypes[pMemObj->allocInfo.memoryTypeIndex].propertyFlags & |
| 1247 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1248 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t) mem, 0, MEMTRACK_INVALID_STATE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1249 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set: mem obj %#" PRIxLEAST64, (uint64_t) mem); |
Mark Lobodzinski | 95152dc | 2015-02-25 12:16:04 -0600 | [diff] [blame] | 1250 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1251 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1252 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1253 | result = my_data->device_dispatch_table->MapMemory(device, mem, offset, size, flags, ppData); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1254 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1255 | return result; |
| 1256 | } |
| 1257 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1258 | VK_LAYER_EXPORT void VKAPI vkUnmapMemory( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1259 | VkDevice device, |
| 1260 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1261 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1262 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1263 | // TODO : Track as memory gets unmapped, do we want to check what changed following map? |
| 1264 | // Make sure that memory was ever mapped to begin with |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1265 | my_data->device_dispatch_table->UnmapMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1268 | VK_LAYER_EXPORT void VKAPI vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1269 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1270 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1271 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1272 | delete_fence_info(my_data, fence); |
| 1273 | auto item = my_data->fenceMap.find(fence); |
| 1274 | if (item != my_data->fenceMap.end()) { |
| 1275 | my_data->fenceMap.erase(item); |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1276 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1277 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1278 | my_data->device_dispatch_table->DestroyFence(device, fence, pAllocator); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1279 | } |
| 1280 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1281 | VK_LAYER_EXPORT void VKAPI vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1282 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1283 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1284 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1285 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1286 | auto item = my_data->bufferMap.find((uint64_t)buffer); |
| 1287 | if (item != my_data->bufferMap.end()) { |
| 1288 | skipCall = clear_object_binding(my_data, device, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); |
| 1289 | my_data->bufferMap.erase(item); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1290 | } |
| 1291 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1292 | if (VK_FALSE == skipCall) { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1293 | my_data->device_dispatch_table->DestroyBuffer(device, buffer, pAllocator); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1294 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1297 | VK_LAYER_EXPORT void VKAPI vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1298 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1299 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1300 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1301 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1302 | auto item = my_data->imageMap.find((uint64_t)image); |
| 1303 | if (item != my_data->imageMap.end()) { |
| 1304 | skipCall = clear_object_binding(my_data, device, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); |
| 1305 | my_data->imageMap.erase(item); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1306 | } |
| 1307 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1308 | if (VK_FALSE == skipCall) { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1309 | my_data->device_dispatch_table->DestroyImage(device, image, pAllocator); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1310 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1311 | } |
| 1312 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1313 | VkResult VKAPI vkBindBufferMemory( |
| 1314 | VkDevice device, |
| 1315 | VkBuffer buffer, |
| 1316 | VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1317 | VkDeviceSize memoryOffset) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1318 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1319 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1320 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1321 | loader_platform_thread_lock_mutex(&globalLock); |
| 1322 | // Track objects tied to memory |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1323 | VkBool32 skipCall = set_mem_binding(my_data, device, mem, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, "vkBindBufferMemory"); |
| 1324 | add_object_binding_info(my_data, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, mem); |
| 1325 | print_mem_list(my_data, device); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1326 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1327 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1328 | result = my_data->device_dispatch_table->BindBufferMemory(device, buffer, mem, memoryOffset); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1329 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1330 | return result; |
| 1331 | } |
| 1332 | |
| 1333 | VkResult VKAPI vkBindImageMemory( |
| 1334 | VkDevice device, |
| 1335 | VkImage image, |
| 1336 | VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1337 | VkDeviceSize memoryOffset) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1338 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1339 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1340 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1341 | loader_platform_thread_lock_mutex(&globalLock); |
| 1342 | // Track objects tied to memory |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1343 | VkBool32 skipCall = set_mem_binding(my_data, device, mem, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, "vkBindImageMemory"); |
| 1344 | add_object_binding_info(my_data, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, mem); |
| 1345 | print_mem_list(my_data, device); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1346 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1347 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1348 | result = my_data->device_dispatch_table->BindImageMemory(device, image, mem, memoryOffset); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1349 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1350 | return result; |
| 1351 | } |
| 1352 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1353 | void VKAPI vkGetBufferMemoryRequirements( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1354 | VkDevice device, |
| 1355 | VkBuffer buffer, |
| 1356 | VkMemoryRequirements* pMemoryRequirements) |
| 1357 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1358 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1359 | // TODO : What to track here? |
| 1360 | // Could potentially save returned mem requirements and validate values passed into BindBufferMemory |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1361 | my_data->device_dispatch_table->GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1362 | } |
| 1363 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1364 | void VKAPI vkGetImageMemoryRequirements( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1365 | VkDevice device, |
| 1366 | VkImage image, |
| 1367 | VkMemoryRequirements* pMemoryRequirements) |
| 1368 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1369 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1370 | // TODO : What to track here? |
| 1371 | // Could potentially save returned mem requirements and validate values passed into BindImageMemory |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1372 | my_data->device_dispatch_table->GetImageMemoryRequirements(device, image, pMemoryRequirements); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1373 | } |
| 1374 | |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1375 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparse( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1376 | VkQueue queue, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1377 | uint32_t bindInfoCount, |
| 1378 | const VkBindSparseInfo* pBindInfo, |
| 1379 | VkFence fence) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1380 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1381 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1382 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1383 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1384 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1385 | loader_platform_thread_lock_mutex(&globalLock); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1386 | |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1387 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 1388 | // Track objects tied to memory |
| 1389 | for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++) { |
| 1390 | for (uint32_t k = 0; k < pBindInfo[i].pBufferBinds[j].bindCount; k++) { |
| 1391 | if (set_sparse_mem_binding(my_data, queue, |
Chia-I Wu | bb7fad9 | 2015-10-27 17:53:18 +0800 | [diff] [blame] | 1392 | pBindInfo[i].pBufferBinds[j].pBinds[k].memory, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1393 | (uint64_t) pBindInfo[i].pBufferBinds[j].buffer, |
| 1394 | VK_OBJECT_TYPE_BUFFER, "vkQueueBindSparse")) |
| 1395 | skipCall = VK_TRUE; |
| 1396 | } |
| 1397 | } |
| 1398 | for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++) { |
| 1399 | for (uint32_t k = 0; k < pBindInfo[i].pImageOpaqueBinds[j].bindCount; k++) { |
| 1400 | if (set_sparse_mem_binding(my_data, queue, |
Chia-I Wu | bb7fad9 | 2015-10-27 17:53:18 +0800 | [diff] [blame] | 1401 | pBindInfo[i].pImageOpaqueBinds[j].pBinds[k].memory, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1402 | (uint64_t) pBindInfo[i].pImageOpaqueBinds[j].image, |
| 1403 | VK_OBJECT_TYPE_IMAGE, "vkQueueBindSparse")) |
| 1404 | skipCall = VK_TRUE; |
| 1405 | } |
| 1406 | } |
| 1407 | for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++) { |
| 1408 | for (uint32_t k = 0; k < pBindInfo[i].pImageBinds[j].bindCount; k++) { |
| 1409 | if (set_sparse_mem_binding(my_data, queue, |
Chia-I Wu | bb7fad9 | 2015-10-27 17:53:18 +0800 | [diff] [blame] | 1410 | pBindInfo[i].pImageBinds[j].pBinds[k].memory, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1411 | (uint64_t) pBindInfo[i].pImageBinds[j].image, |
| 1412 | VK_OBJECT_TYPE_IMAGE, "vkQueueBindSparse")) |
| 1413 | skipCall = VK_TRUE; |
| 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1418 | print_mem_list(my_data, queue); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1419 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1420 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 1421 | result = my_data->device_dispatch_table->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1422 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1423 | return result; |
| 1424 | } |
| 1425 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1426 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFence( |
| 1427 | VkDevice device, |
| 1428 | const VkFenceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1429 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1430 | VkFence *pFence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1431 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1432 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1433 | VkResult result = my_data->device_dispatch_table->CreateFence(device, pCreateInfo, pAllocator, pFence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1434 | if (VK_SUCCESS == result) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1435 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1436 | MT_FENCE_INFO* pFI = &my_data->fenceMap[*pFence]; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1437 | memset(pFI, 0, sizeof(MT_FENCE_INFO)); |
| 1438 | memcpy(&(pFI->createInfo), pCreateInfo, sizeof(VkFenceCreateInfo)); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1439 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1440 | } |
| 1441 | return result; |
| 1442 | } |
| 1443 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1444 | VK_LAYER_EXPORT VkResult VKAPI vkResetFences( |
| 1445 | VkDevice device, |
| 1446 | uint32_t fenceCount, |
Courtney Goeltzenleuchter | 2bf8f90 | 2015-06-18 17:28:20 -0600 | [diff] [blame] | 1447 | const VkFence *pFences) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1448 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1449 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1450 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
| 1451 | VkBool32 skipCall = VK_FALSE; |
| 1452 | |
| 1453 | loader_platform_thread_lock_mutex(&globalLock); |
| 1454 | // Reset fence state in fenceCreateInfo structure |
| 1455 | for (uint32_t i = 0; i < fenceCount; i++) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1456 | auto fence_item = my_data->fenceMap.find(pFences[i]); |
| 1457 | if (fence_item != my_data->fenceMap.end()) { |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1458 | // Validate fences in SIGNALED state |
| 1459 | if (!(fence_item->second.createInfo.flags & VK_FENCE_CREATE_SIGNALED_BIT)) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1460 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_FENCE, (uint64_t) pFences[i], 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1461 | "Fence %#" PRIxLEAST64 " submitted to VkResetFences in UNSIGNALED STATE", (uint64_t) pFences[i]); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1462 | } |
| 1463 | else { |
| 1464 | fence_item->second.createInfo.flags = |
| 1465 | static_cast<VkFenceCreateFlags>(fence_item->second.createInfo.flags & ~VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1466 | } |
| 1467 | } |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1468 | } |
| 1469 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1470 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1471 | result = my_data->device_dispatch_table->ResetFences(device, fenceCount, pFences); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1472 | } |
| 1473 | return result; |
| 1474 | } |
| 1475 | |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1476 | static inline VkBool32 verifyFenceStatus(VkDevice device, VkFence fence, const char* apiCall) |
| 1477 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1478 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1479 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1480 | auto pFenceInfo = my_data->fenceMap.find(fence); |
| 1481 | if (pFenceInfo != my_data->fenceMap.end()) { |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1482 | if (pFenceInfo->second.createInfo.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1483 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_FENCE, (uint64_t) fence, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1484 | "%s specified fence %#" PRIxLEAST64 " already in SIGNALED state.", apiCall, (uint64_t) fence); |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1485 | } |
| 1486 | if (!pFenceInfo->second.queue) { // Checking status of unsubmitted fence |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 1487 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_FENCE, (uint64_t) fence, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1488 | "%s called for fence %#" PRIxLEAST64 " which has not been submitted on a Queue.", apiCall, (uint64_t) fence); |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1489 | } |
| 1490 | } |
| 1491 | return skipCall; |
| 1492 | } |
| 1493 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1494 | VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus( |
| 1495 | VkDevice device, |
| 1496 | VkFence fence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1497 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1498 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1499 | VkBool32 skipCall = verifyFenceStatus(device, fence, "vkGetFenceStatus"); |
| 1500 | if (skipCall) |
| 1501 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1502 | VkResult result = my_data->device_dispatch_table->GetFenceStatus(device, fence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1503 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1504 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1505 | update_fence_tracking(my_data, fence); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1506 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1507 | } |
| 1508 | return result; |
| 1509 | } |
| 1510 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1511 | VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences( |
| 1512 | VkDevice device, |
| 1513 | uint32_t fenceCount, |
| 1514 | const VkFence *pFences, |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 1515 | VkBool32 waitAll, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1516 | uint64_t timeout) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1517 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1518 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1519 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1520 | // Verify fence status of submitted fences |
| 1521 | for(uint32_t i = 0; i < fenceCount; i++) { |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1522 | skipCall |= verifyFenceStatus(device, pFences[i], "vkWaitForFences"); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1523 | } |
Tobin Ehlis | c4f105d | 2015-09-14 13:25:57 -0600 | [diff] [blame] | 1524 | if (skipCall) |
| 1525 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1526 | VkResult result = my_data->device_dispatch_table->WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1527 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1528 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1529 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1530 | if (waitAll || fenceCount == 1) { // Clear all the fences |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1531 | for(uint32_t i = 0; i < fenceCount; i++) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1532 | update_fence_tracking(my_data, pFences[i]); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1533 | } |
| 1534 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1535 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1536 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1537 | return result; |
| 1538 | } |
| 1539 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1540 | VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle( |
| 1541 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1542 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1543 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); |
| 1544 | VkResult result = my_data->device_dispatch_table->QueueWaitIdle(queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1545 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1546 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1547 | retire_queue_fences(my_data, queue); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1548 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1549 | } |
| 1550 | return result; |
| 1551 | } |
| 1552 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1553 | VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle( |
| 1554 | VkDevice device) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1555 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1556 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1557 | VkResult result = my_data->device_dispatch_table->DeviceWaitIdle(device); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1558 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1559 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1560 | retire_device_fences(my_data, device); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1561 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1562 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1563 | return result; |
| 1564 | } |
| 1565 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1566 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer( |
| 1567 | VkDevice device, |
| 1568 | const VkBufferCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1569 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1570 | VkBuffer *pBuffer) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1571 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1572 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1573 | VkResult result = my_data->device_dispatch_table->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1574 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1575 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1576 | add_object_create_info(my_data, (uint64_t)*pBuffer, VK_OBJECT_TYPE_BUFFER, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1577 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1578 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1579 | return result; |
| 1580 | } |
| 1581 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1582 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage( |
| 1583 | VkDevice device, |
| 1584 | const VkImageCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1585 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1586 | VkImage *pImage) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1587 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1588 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1589 | VkResult result = my_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1590 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1591 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1592 | add_object_create_info(my_data, (uint64_t)*pImage, VK_OBJECT_TYPE_IMAGE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1593 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1594 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1595 | return result; |
| 1596 | } |
| 1597 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1598 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView( |
| 1599 | VkDevice device, |
| 1600 | const VkImageViewCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1601 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1602 | VkImageView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1603 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1604 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1605 | VkResult result = my_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1606 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1607 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1608 | // Validate that img has correct usage flags set |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1609 | validate_image_usage_flags(my_data, device, pCreateInfo->image, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 1610 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
Courtney Goeltzenleuchter | 5861a1b | 2015-09-01 17:30:39 -0600 | [diff] [blame] | 1611 | false, "vkCreateImageView()", "VK_IMAGE_USAGE_[SAMPLED|STORAGE|COLOR_ATTACHMENT]_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1612 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1613 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1614 | return result; |
| 1615 | } |
| 1616 | |
Mark Lobodzinski | 50b51e6 | 2015-10-27 09:53:00 -0600 | [diff] [blame] | 1617 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView( |
| 1618 | VkDevice device, |
| 1619 | const VkBufferViewCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1620 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | 50b51e6 | 2015-10-27 09:53:00 -0600 | [diff] [blame] | 1621 | VkBufferView *pView) |
| 1622 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1623 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1624 | VkResult result = my_data->device_dispatch_table->CreateBufferView(device, pCreateInfo, pAllocator, pView); |
Mark Lobodzinski | 50b51e6 | 2015-10-27 09:53:00 -0600 | [diff] [blame] | 1625 | if (result == VK_SUCCESS) { |
| 1626 | loader_platform_thread_lock_mutex(&globalLock); |
| 1627 | // In order to create a valid buffer view, the buffer must have been created with at least one of the |
| 1628 | // following flags: UNIFORM_TEXEL_BUFFER_BIT or STORAGE_TEXEL_BUFFER_BIT |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1629 | validate_buffer_usage_flags(my_data, device, pCreateInfo->buffer, |
Mark Lobodzinski | 50b51e6 | 2015-10-27 09:53:00 -0600 | [diff] [blame] | 1630 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT, |
| 1631 | false, "vkCreateBufferView()", "VK_BUFFER_USAGE_[STORAGE|UNIFORM]_TEXEL_BUFFER_BIT"); |
| 1632 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1633 | } |
| 1634 | return result; |
| 1635 | } |
| 1636 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1637 | VK_LAYER_EXPORT VkResult VKAPI vkAllocateCommandBuffers( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1638 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1639 | const VkCommandBufferAllocateInfo *pCreateInfo, |
| 1640 | VkCommandBuffer *pCommandBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1641 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1642 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1643 | VkResult result = my_data->device_dispatch_table->AllocateCommandBuffers(device, pCreateInfo, pCommandBuffer); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1644 | // 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] | 1645 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1646 | if (*pCommandBuffer) |
| 1647 | add_cmd_buf_info(my_data, *pCommandBuffer); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 1648 | printCBList(my_data, device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1649 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1650 | return result; |
| 1651 | } |
| 1652 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1653 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1654 | VkCommandBuffer commandBuffer, |
| 1655 | const VkCommandBufferBeginInfo *pBeginInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1656 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1657 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1658 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
| 1659 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1660 | VkBool32 commandBufferComplete = VK_FALSE; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1661 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1662 | // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1663 | skipCall = checkCBCompleted(my_data, commandBuffer, &commandBufferComplete); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1664 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1665 | if (VK_FALSE == commandBufferComplete) { |
| 1666 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 1667 | MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", "Calling vkBeginCommandBuffer() on active CB %p before it has completed. " |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1668 | "You must check CB flag before this call.", commandBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1669 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1670 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1671 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1672 | result = my_data->device_dispatch_table->BeginCommandBuffer(commandBuffer, pBeginInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1673 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1674 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1675 | clear_cmd_buf_and_mem_references(my_data, commandBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1676 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1677 | return result; |
| 1678 | } |
| 1679 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1680 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1681 | VkCommandBuffer commandBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1682 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1683 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1684 | // TODO : Anything to do here? |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1685 | VkResult result = my_data->device_dispatch_table->EndCommandBuffer(commandBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1686 | return result; |
| 1687 | } |
| 1688 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1689 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1690 | VkCommandBuffer commandBuffer, |
| 1691 | VkCommandBufferResetFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1692 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1693 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1694 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
| 1695 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1696 | VkBool32 commandBufferComplete = VK_FALSE; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1697 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1698 | // Verify that CB is complete (not in-flight) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1699 | skipCall = checkCBCompleted(my_data, commandBuffer, &commandBufferComplete); |
| 1700 | if (VK_FALSE == commandBufferComplete) { |
| 1701 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
Mark Lobodzinski | e8229fb | 2015-09-15 16:10:17 -0600 | [diff] [blame] | 1702 | MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", "Resetting CB %p before it has completed. You must check CB " |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1703 | "flag before calling vkResetCommandBuffer().", commandBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1704 | } |
| 1705 | // Clear memory references as this point. |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1706 | skipCall |= clear_cmd_buf_and_mem_references(my_data, commandBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1707 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1708 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1709 | result = my_data->device_dispatch_table->ResetCommandBuffer(commandBuffer, flags); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 1710 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1711 | return result; |
| 1712 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1713 | // TODO : For any vkCmdBind* calls that include an object which has mem bound to it, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1714 | // need to account for that mem now having binding to given commandBuffer |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1715 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1716 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1717 | VkPipelineBindPoint pipelineBindPoint, |
| 1718 | VkPipeline pipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1719 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1720 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1721 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1722 | // TODO : If memory bound to pipeline, then need to tie that mem to commandBuffer |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1723 | if (getPipeline(pipeline)) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1724 | MT_CB_INFO *pCBInfo = get_cmd_buf_info(my_data, commandBuffer); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1725 | if (pCBInfo) { |
| 1726 | pCBInfo->pipelines[pipelineBindPoint] = pipeline; |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1727 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1728 | "Attempt to bind Pipeline %p to non-existant command buffer %p!", (void*)pipeline, commandBuffer); |
| 1729 | layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, commandBuffer, 0, MEMTRACK_INVALID_CB, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1730 | } |
| 1731 | } |
| 1732 | else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1733 | "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1734 | 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] | 1735 | } |
| 1736 | #endif |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1737 | my_data->device_dispatch_table->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1738 | } |
| 1739 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1740 | VK_LAYER_EXPORT void VKAPI vkCmdSetViewport( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1741 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1742 | uint32_t viewportCount, |
| 1743 | const VkViewport* pViewports) |
| 1744 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1745 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1746 | VkBool32 skipCall = VK_FALSE; |
| 1747 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1748 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1749 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1750 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1751 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1752 | } |
| 1753 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1754 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1755 | my_data->device_dispatch_table->CmdSetViewport(commandBuffer, viewportCount, pViewports); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1756 | } |
| 1757 | } |
| 1758 | |
| 1759 | VK_LAYER_EXPORT void VKAPI vkCmdSetScissor( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1760 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 1761 | uint32_t scissorCount, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1762 | const VkRect2D* pScissors) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1763 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1764 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1765 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1766 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1767 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1768 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1769 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1770 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1771 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1772 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1773 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1774 | my_data->device_dispatch_table->CmdSetScissor(commandBuffer, scissorCount, pScissors); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1775 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1776 | } |
| 1777 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1778 | VK_LAYER_EXPORT void VKAPI vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1779 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1780 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1781 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1782 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1783 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1784 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1785 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1786 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1787 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1788 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1789 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1790 | my_data->device_dispatch_table->CmdSetLineWidth(commandBuffer, lineWidth); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1791 | } |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1792 | } |
| 1793 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1794 | VK_LAYER_EXPORT void VKAPI vkCmdSetDepthBias( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1795 | VkCommandBuffer commandBuffer, |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 1796 | float depthBiasConstantFactor, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1797 | float depthBiasClamp, |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 1798 | float depthBiasSlopeFactor) |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1799 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1800 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1801 | VkBool32 skipCall = VK_FALSE; |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1802 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1803 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1804 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1805 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1806 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1807 | } |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 1808 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1809 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1810 | my_data->device_dispatch_table->CmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1811 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1812 | } |
| 1813 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1814 | VK_LAYER_EXPORT void VKAPI vkCmdSetBlendConstants( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1815 | VkCommandBuffer commandBuffer, |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1816 | const float blendConstants[4]) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1817 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1818 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1819 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1820 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1821 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1822 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1823 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1824 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1825 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1826 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1827 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1828 | my_data->device_dispatch_table->CmdSetBlendConstants(commandBuffer, blendConstants); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1829 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1830 | } |
| 1831 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1832 | VK_LAYER_EXPORT void VKAPI vkCmdSetDepthBounds( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1833 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1834 | float minDepthBounds, |
| 1835 | float maxDepthBounds) |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1836 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1837 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1838 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1839 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1840 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1841 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1842 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1843 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1844 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1845 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1846 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1847 | my_data->device_dispatch_table->CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1848 | } |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1849 | } |
| 1850 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1851 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilCompareMask( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1852 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1853 | VkStencilFaceFlags faceMask, |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1854 | uint32_t compareMask) |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1855 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1856 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1857 | VkBool32 skipCall = VK_FALSE; |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1858 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1859 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1860 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1861 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1862 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1863 | } |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1864 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1865 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1866 | my_data->device_dispatch_table->CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1867 | } |
| 1868 | } |
| 1869 | |
| 1870 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilWriteMask( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1871 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1872 | VkStencilFaceFlags faceMask, |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1873 | uint32_t writeMask) |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1874 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1875 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1876 | VkBool32 skipCall = VK_FALSE; |
| 1877 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1878 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1879 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1880 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1881 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1882 | } |
| 1883 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1884 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1885 | my_data->device_dispatch_table->CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1886 | } |
| 1887 | } |
| 1888 | |
| 1889 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilReference( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1890 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1891 | VkStencilFaceFlags faceMask, |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1892 | uint32_t reference) |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1893 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1894 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1895 | VkBool32 skipCall = VK_FALSE; |
| 1896 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1897 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(my_data, commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1898 | if (!pCmdBuf) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1899 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, |
| 1900 | MEMTRACK_INVALID_CB, "MEM", "Unable to find command buffer object %p, was it ever created?", (void*)commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 1901 | } |
| 1902 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1903 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1904 | my_data->device_dispatch_table->CmdSetStencilReference(commandBuffer, faceMask, reference); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1905 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1906 | } |
| 1907 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1908 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1909 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1910 | VkPipelineBindPoint pipelineBindPoint, |
Mark Lobodzinski | f2093b6 | 2015-06-15 13:21:21 -0600 | [diff] [blame] | 1911 | VkPipelineLayout layout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1912 | uint32_t firstSet, |
| 1913 | uint32_t setCount, |
| 1914 | const VkDescriptorSet *pDescriptorSets, |
| 1915 | uint32_t dynamicOffsetCount, |
| 1916 | const uint32_t *pDynamicOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1917 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1918 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1919 | // TODO : Somewhere need to verify that all textures referenced by shaders in DS are in some type of *SHADER_READ* state |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 1920 | my_data->device_dispatch_table->CmdBindDescriptorSets( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1921 | commandBuffer, pipelineBindPoint, layout, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1922 | } |
| 1923 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1924 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1925 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1926 | uint32_t startBinding, |
| 1927 | uint32_t bindingCount, |
| 1928 | const VkBuffer *pBuffers, |
| 1929 | const VkDeviceSize *pOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1930 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1931 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1932 | // TODO : Somewhere need to verify that VBs have correct usage state flagged |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1933 | my_data->device_dispatch_table->CmdBindVertexBuffers(commandBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Chia-I Wu | 1915682 | 2015-01-05 13:42:56 +0800 | [diff] [blame] | 1934 | } |
| 1935 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1936 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1937 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1938 | VkBuffer buffer, |
| 1939 | VkDeviceSize offset, |
| 1940 | VkIndexType indexType) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1941 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1942 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1943 | // TODO : Somewhere need to verify that IBs have correct usage state flagged |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1944 | my_data->device_dispatch_table->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1945 | } |
| 1946 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1947 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1948 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1949 | VkBuffer buffer, |
| 1950 | VkDeviceSize offset, |
| 1951 | uint32_t count, |
| 1952 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1953 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1954 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1955 | VkDeviceMemory mem; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1956 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1957 | VkBool32 skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 1958 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdDrawIndirect"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1959 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1960 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1961 | my_data->device_dispatch_table->CmdDrawIndirect(commandBuffer, buffer, offset, count, stride); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1962 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1963 | } |
| 1964 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1965 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1966 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1967 | VkBuffer buffer, |
| 1968 | VkDeviceSize offset, |
| 1969 | uint32_t count, |
| 1970 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1971 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1972 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1973 | VkDeviceMemory mem; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1974 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1975 | VkBool32 skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 1976 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdDrawIndexedIndirect"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1977 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1978 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1979 | my_data->device_dispatch_table->CmdDrawIndexedIndirect(commandBuffer, buffer, offset, count, stride); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1980 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1981 | } |
| 1982 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1983 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1984 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1985 | VkBuffer buffer, |
| 1986 | VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1987 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1988 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1989 | VkDeviceMemory mem; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1990 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1991 | VkBool32 skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 1992 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdDispatchIndirect"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1993 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1994 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1995 | my_data->device_dispatch_table->CmdDispatchIndirect(commandBuffer, buffer, offset); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1996 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1997 | } |
| 1998 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1999 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2000 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2001 | VkBuffer srcBuffer, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2002 | VkBuffer dstBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2003 | uint32_t regionCount, |
| 2004 | const VkBufferCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2005 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2006 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2007 | VkDeviceMemory mem; |
| 2008 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2009 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2010 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2011 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyBuffer"); |
| 2012 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2013 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyBuffer"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2014 | // Validate that SRC & DST buffers have correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2015 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT"); |
| 2016 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, dstBuffer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2017 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2018 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2019 | my_data->device_dispatch_table->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2020 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2021 | } |
| 2022 | |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2023 | VK_LAYER_EXPORT void VKAPI vkCmdCopyQueryPoolResults( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2024 | VkCommandBuffer commandBuffer, |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2025 | VkQueryPool queryPool, |
| 2026 | uint32_t startQuery, |
| 2027 | uint32_t queryCount, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2028 | VkBuffer dstBuffer, |
| 2029 | VkDeviceSize dstOffset, |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2030 | VkDeviceSize destStride, |
| 2031 | VkQueryResultFlags flags) |
| 2032 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2033 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2034 | VkDeviceMemory mem; |
| 2035 | VkBool32 skipCall = VK_FALSE; |
| 2036 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2037 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2038 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyQueryPoolResults"); |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2039 | // Validate that DST buffer has correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2040 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, dstBuffer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, "vkCmdCopyQueryPoolResults()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2041 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2042 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2043 | my_data->device_dispatch_table->CmdCopyQueryPoolResults(commandBuffer, queryPool, startQuery, queryCount, dstBuffer, dstOffset, destStride, flags); |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2044 | } |
| 2045 | } |
| 2046 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2047 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2048 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2049 | VkImage srcImage, |
| 2050 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2051 | VkImage dstImage, |
| 2052 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2053 | uint32_t regionCount, |
| 2054 | const VkImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2055 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2056 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2057 | VkDeviceMemory mem; |
| 2058 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2059 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2060 | // Validate that src & dst images have correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2061 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2062 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyImage"); |
| 2063 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2064 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyImage"); |
| 2065 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
| 2066 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, dstImage, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2067 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2068 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2069 | my_data->device_dispatch_table->CmdCopyImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2070 | commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2071 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2072 | } |
| 2073 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2074 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2075 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2076 | VkImage srcImage, |
| 2077 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2078 | VkImage dstImage, |
| 2079 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2080 | uint32_t regionCount, |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 2081 | const VkImageBlit *pRegions, |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2082 | VkFilter filter) |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 2083 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2084 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2085 | VkDeviceMemory mem; |
| 2086 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2087 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2088 | // Validate that src & dst images have correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2089 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2090 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdBlitImage"); |
| 2091 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2092 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdBlitImage"); |
| 2093 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
| 2094 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, dstImage, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2095 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2096 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2097 | my_data->device_dispatch_table->CmdBlitImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2098 | commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2099 | } |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 2100 | } |
| 2101 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2102 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2103 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2104 | VkBuffer srcBuffer, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2105 | VkImage dstImage, |
| 2106 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2107 | uint32_t regionCount, |
| 2108 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2109 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2110 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2111 | VkDeviceMemory mem; |
| 2112 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2113 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2114 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2115 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyBufferToImage"); |
| 2116 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2117 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyBufferToImage"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2118 | // Validate that src buff & dst image have correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2119 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, "vkCmdCopyBufferToImage()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT"); |
| 2120 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, dstImage, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, "vkCmdCopyBufferToImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2121 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2122 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2123 | my_data->device_dispatch_table->CmdCopyBufferToImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2124 | commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2125 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2126 | } |
| 2127 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2128 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2129 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2130 | VkImage srcImage, |
| 2131 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2132 | VkBuffer dstBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2133 | uint32_t regionCount, |
| 2134 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2135 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2136 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2137 | VkDeviceMemory mem; |
| 2138 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2139 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2140 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2141 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyImageToBuffer"); |
| 2142 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2143 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdCopyImageToBuffer"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2144 | // Validate that dst buff & src image have correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2145 | skipCall |= validate_image_usage_flags(my_data, commandBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, "vkCmdCopyImageToBuffer()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
| 2146 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, dstBuffer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, "vkCmdCopyImageToBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2147 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2148 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2149 | my_data->device_dispatch_table->CmdCopyImageToBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2150 | commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2151 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2152 | } |
| 2153 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2154 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2155 | VkCommandBuffer commandBuffer, |
| 2156 | VkBuffer dstBuffer, |
| 2157 | VkDeviceSize dstOffset, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2158 | VkDeviceSize dataSize, |
| 2159 | const uint32_t *pData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2160 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2161 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2162 | VkDeviceMemory mem; |
| 2163 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2164 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2165 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2166 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdUpdateBuffer"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2167 | // Validate that dst buff has correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2168 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, dstBuffer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, "vkCmdUpdateBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2169 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2170 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2171 | my_data->device_dispatch_table->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2172 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2173 | } |
| 2174 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2175 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2176 | VkCommandBuffer commandBuffer, |
| 2177 | VkBuffer dstBuffer, |
| 2178 | VkDeviceSize dstOffset, |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2179 | VkDeviceSize size, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2180 | uint32_t data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2181 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2182 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2183 | VkDeviceMemory mem; |
| 2184 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2185 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2186 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstBuffer, VK_OBJECT_TYPE_BUFFER, &mem); |
| 2187 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdFillBuffer"); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2188 | // Validate that dst buff has correct usage flags set |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2189 | skipCall |= validate_buffer_usage_flags(my_data, commandBuffer, dstBuffer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, "vkCmdFillBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2190 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2191 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2192 | my_data->device_dispatch_table->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2193 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2194 | } |
| 2195 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2196 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2197 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2198 | VkImage image, |
| 2199 | VkImageLayout imageLayout, |
Chris Forbes | f0796e1 | 2015-06-24 14:34:53 +1200 | [diff] [blame] | 2200 | const VkClearColorValue *pColor, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2201 | uint32_t rangeCount, |
| 2202 | const VkImageSubresourceRange *pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2203 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2204 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2205 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2206 | VkDeviceMemory mem; |
| 2207 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2208 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2209 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2210 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdClearColorImage"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2211 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2212 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2213 | my_data->device_dispatch_table->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2214 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2215 | } |
| 2216 | |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 2217 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2218 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 45df9e1 | 2015-09-15 18:03:22 -0600 | [diff] [blame] | 2219 | VkImage image, |
| 2220 | VkImageLayout imageLayout, |
| 2221 | const VkClearDepthStencilValue* pDepthStencil, |
| 2222 | uint32_t rangeCount, |
| 2223 | const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2224 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2225 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2226 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2227 | VkDeviceMemory mem; |
| 2228 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2229 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2230 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2231 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdClearDepthStencilImage"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2232 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2233 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2234 | my_data->device_dispatch_table->CmdClearDepthStencilImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2235 | commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2236 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2237 | } |
| 2238 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2239 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2240 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2241 | VkImage srcImage, |
| 2242 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2243 | VkImage dstImage, |
| 2244 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2245 | uint32_t regionCount, |
| 2246 | const VkImageResolve *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2247 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2248 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2249 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2250 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2251 | VkDeviceMemory mem; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2252 | skipCall = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)srcImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2253 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdResolveImage"); |
| 2254 | skipCall |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)dstImage, VK_OBJECT_TYPE_IMAGE, &mem); |
| 2255 | skipCall |= update_cmd_buf_and_mem_references(my_data, commandBuffer, mem, "vkCmdResolveImage"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2256 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2257 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2258 | my_data->device_dispatch_table->CmdResolveImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2259 | commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2260 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2261 | } |
| 2262 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2263 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2264 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2265 | VkQueryPool queryPool, |
| 2266 | uint32_t slot, |
| 2267 | VkFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2268 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2269 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2270 | my_data->device_dispatch_table->CmdBeginQuery(commandBuffer, queryPool, slot, flags); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2271 | } |
| 2272 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2273 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2274 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2275 | VkQueryPool queryPool, |
| 2276 | uint32_t slot) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2277 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2278 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2279 | my_data->device_dispatch_table->CmdEndQuery(commandBuffer, queryPool, slot); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2280 | } |
| 2281 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2282 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2283 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2284 | VkQueryPool queryPool, |
| 2285 | uint32_t startQuery, |
| 2286 | uint32_t queryCount) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2287 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2288 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2289 | my_data->device_dispatch_table->CmdResetQueryPool(commandBuffer, queryPool, startQuery, queryCount); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2290 | } |
| 2291 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2292 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 2293 | VkInstance instance, |
| 2294 | VkFlags msgFlags, |
| 2295 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 2296 | void* pUserData, |
| 2297 | VkDbgMsgCallback* pMsgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2298 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2299 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2300 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2301 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2302 | if (res == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2303 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2304 | } |
| 2305 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2306 | } |
| 2307 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2308 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 2309 | VkInstance instance, |
| 2310 | VkDbgMsgCallback msgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2311 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2312 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2313 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
| 2314 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2315 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
| 2316 | |
| 2317 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2318 | } |
| 2319 | |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2320 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapchainKHR( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2321 | VkDevice device, |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2322 | const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 2323 | VkSwapchainKHR *pSwapchain) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2324 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2325 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 2326 | VkResult result = my_data->device_dispatch_table->CreateSwapchainKHR(device, pCreateInfo, pSwapchain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2327 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2328 | if (VK_SUCCESS == result) { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2329 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2330 | add_swap_chain_info(my_data, *pSwapchain, pCreateInfo); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2331 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2332 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2333 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2334 | return result; |
| 2335 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2336 | |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2337 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapchainKHR( |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2338 | VkDevice device, |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2339 | VkSwapchainKHR swapchain) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2340 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2341 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2342 | VkBool32 skipCall = VK_FALSE; |
| 2343 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2344 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2345 | if (my_data->swapchainMap.find(swapchain) != my_data->swapchainMap.end()) { |
| 2346 | MT_SWAP_CHAIN_INFO* pInfo = my_data->swapchainMap[swapchain]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2347 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2348 | if (pInfo->images.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2349 | for (auto it = pInfo->images.begin(); it != pInfo->images.end(); it++) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2350 | skipCall = clear_object_binding(my_data, device, (uint64_t)*it, VK_OBJECT_TYPE_SWAPCHAIN_KHR); |
| 2351 | auto image_item = my_data->imageMap.find((uint64_t)*it); |
| 2352 | if (image_item != my_data->imageMap.end()) |
| 2353 | my_data->imageMap.erase(image_item); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2354 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2355 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2356 | delete pInfo; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2357 | my_data->swapchainMap.erase(swapchain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2358 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2359 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2360 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2361 | result = my_data->device_dispatch_table->DestroySwapchainKHR(device, swapchain); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2362 | } |
| 2363 | return result; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2364 | } |
| 2365 | |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2366 | VK_LAYER_EXPORT VkResult VKAPI vkGetSwapchainImagesKHR( |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2367 | VkDevice device, |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2368 | VkSwapchainKHR swapchain, |
Ian Elliott | 2b6b68a | 2015-08-07 14:11:14 -0600 | [diff] [blame] | 2369 | uint32_t* pCount, |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2370 | VkImage* pSwapchainImages) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2371 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2372 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 2373 | VkResult result = my_data->device_dispatch_table->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2374 | |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2375 | if (result == VK_SUCCESS && pSwapchainImages != NULL) { |
Ian Elliott | 2b6b68a | 2015-08-07 14:11:14 -0600 | [diff] [blame] | 2376 | const size_t count = *pCount; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2377 | MT_SWAP_CHAIN_INFO *pInfo = my_data->swapchainMap[swapchain]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2378 | |
| 2379 | if (pInfo->images.empty()) { |
| 2380 | pInfo->images.resize(count); |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2381 | memcpy(&pInfo->images[0], pSwapchainImages, sizeof(pInfo->images[0]) * count); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2382 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2383 | if (pInfo->images.size() > 0) { |
Ian Elliott | 2b6b68a | 2015-08-07 14:11:14 -0600 | [diff] [blame] | 2384 | for (std::vector<VkImage>::const_iterator it = pInfo->images.begin(); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2385 | it != pInfo->images.end(); it++) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2386 | // Add image object binding, then insert the new Mem Object and then bind it to created image |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2387 | add_object_create_info(my_data, (uint64_t)*it, VK_OBJECT_TYPE_SWAPCHAIN_KHR, &pInfo->createInfo); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2388 | } |
| 2389 | } |
| 2390 | } else { |
Ian Elliott | 2b6b68a | 2015-08-07 14:11:14 -0600 | [diff] [blame] | 2391 | const size_t count = *pCount; |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2392 | MT_SWAP_CHAIN_INFO *pInfo = my_data->swapchainMap[swapchain]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2393 | const bool mismatch = (pInfo->images.size() != count || |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2394 | memcmp(&pInfo->images[0], pSwapchainImages, sizeof(pInfo->images[0]) * count)); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2395 | |
| 2396 | if (mismatch) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 2397 | log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_SWAPCHAIN_KHR, (uint64_t) swapchain, 0, MEMTRACK_NONE, "SWAP_CHAIN", |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2398 | "vkGetSwapchainInfoKHR(%p, VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_KHR) returned mismatching data", swapchain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2399 | } |
| 2400 | } |
| 2401 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2402 | return result; |
| 2403 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2404 | |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2405 | VK_LAYER_EXPORT VkResult VKAPI vkAcquireNextImageKHR( |
| 2406 | VkDevice device, |
| 2407 | VkSwapchainKHR swapchain, |
| 2408 | uint64_t timeout, |
| 2409 | VkSemaphore semaphore, |
| 2410 | uint32_t *pImageIndex) |
| 2411 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2412 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2413 | VkResult result = VK_ERROR_VALIDATION_FAILED; |
| 2414 | VkBool32 skipCall = VK_FALSE; |
| 2415 | |
| 2416 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2417 | if (my_data->semaphoreMap.find(semaphore) != my_data->semaphoreMap.end()) { |
| 2418 | if (my_data->semaphoreMap[semaphore] != MEMTRACK_SEMAPHORE_STATE_UNSET) { |
Tobin Ehlis | 39fce0f | 2015-10-29 09:55:19 -0600 | [diff] [blame] | 2419 | skipCall = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SEMAPHORE, (uint64_t)semaphore, |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2420 | 0, MEMTRACK_NONE, "SEMAPHORE", |
| 2421 | "vkAcquireNextImageKHR: Semaphore must not be currently signaled or in a wait state"); |
| 2422 | } |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2423 | my_data->semaphoreMap[semaphore] = MEMTRACK_SEMAPHORE_STATE_SIGNALLED; |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2424 | } |
| 2425 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2426 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2427 | result = my_data->device_dispatch_table->AcquireNextImageKHR(device, |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2428 | swapchain, timeout, semaphore, pImageIndex); |
| 2429 | } |
| 2430 | return result; |
| 2431 | } |
| 2432 | |
| 2433 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSemaphore( |
| 2434 | VkDevice device, |
| 2435 | const VkSemaphoreCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2436 | const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2437 | VkSemaphore *pSemaphore) |
| 2438 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2439 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2440 | VkResult result = my_data->device_dispatch_table->CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore); |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2441 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2442 | if (*pSemaphore != VK_NULL_HANDLE) { |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2443 | my_data->semaphoreMap[*pSemaphore] = MEMTRACK_SEMAPHORE_STATE_UNSET; |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2444 | } |
| 2445 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2446 | return result; |
| 2447 | } |
| 2448 | |
| 2449 | VK_LAYER_EXPORT void VKAPI vkDestroySemaphore( |
| 2450 | VkDevice device, |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2451 | VkSemaphore semaphore, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2452 | const VkAllocationCallbacks* pAllocator) |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2453 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2454 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2455 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 57b5508 | 2015-10-29 09:03:52 -0600 | [diff] [blame] | 2456 | auto item = my_data->semaphoreMap.find(semaphore); |
| 2457 | if (item != my_data->semaphoreMap.end()) { |
| 2458 | my_data->semaphoreMap.erase(item); |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2459 | } |
| 2460 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2461 | my_data->device_dispatch_table->DestroySemaphore(device, semaphore, pAllocator); |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2462 | } |
| 2463 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2464 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr( |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2465 | VkDevice dev, |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2466 | const char *funcName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2467 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2468 | if (dev == NULL) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2469 | return NULL; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2470 | |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2471 | layer_data *my_data; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2472 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 2473 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2474 | VkBaseLayerObject* wrapped_dev = (VkBaseLayerObject*) dev; |
| 2475 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_dev->baseObject), layer_data_map); |
| 2476 | my_data->device_dispatch_table = new VkLayerDispatchTable; |
| 2477 | layer_initialize_dispatch_table(my_data->device_dispatch_table, wrapped_dev); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2478 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2479 | } |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 2480 | if (!strcmp(funcName, "vkCreateDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2481 | return (PFN_vkVoidFunction) vkCreateDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2482 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2483 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2484 | if (!strcmp(funcName, "vkQueueSubmit")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2485 | return (PFN_vkVoidFunction) vkQueueSubmit; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2486 | if (!strcmp(funcName, "vkAllocateMemory")) |
| 2487 | return (PFN_vkVoidFunction) vkAllocateMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2488 | if (!strcmp(funcName, "vkFreeMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2489 | return (PFN_vkVoidFunction) vkFreeMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2490 | if (!strcmp(funcName, "vkMapMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2491 | return (PFN_vkVoidFunction) vkMapMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2492 | if (!strcmp(funcName, "vkUnmapMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2493 | return (PFN_vkVoidFunction) vkUnmapMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2494 | if (!strcmp(funcName, "vkDestroyFence")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2495 | return (PFN_vkVoidFunction) vkDestroyFence; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2496 | if (!strcmp(funcName, "vkDestroyBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2497 | return (PFN_vkVoidFunction) vkDestroyBuffer; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2498 | if (!strcmp(funcName, "vkDestroyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2499 | return (PFN_vkVoidFunction) vkDestroyImage; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2500 | if (!strcmp(funcName, "vkBindBufferMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2501 | return (PFN_vkVoidFunction) vkBindBufferMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2502 | if (!strcmp(funcName, "vkBindImageMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2503 | return (PFN_vkVoidFunction) vkBindImageMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2504 | if (!strcmp(funcName, "vkGetBufferMemoryRequirements")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2505 | return (PFN_vkVoidFunction) vkGetBufferMemoryRequirements; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2506 | if (!strcmp(funcName, "vkGetImageMemoryRequirements")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2507 | return (PFN_vkVoidFunction) vkGetImageMemoryRequirements; |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 2508 | if (!strcmp(funcName, "vkQueueBindSparse")) |
| 2509 | return (PFN_vkVoidFunction) vkQueueBindSparse; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2510 | if (!strcmp(funcName, "vkCreateFence")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2511 | return (PFN_vkVoidFunction) vkCreateFence; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2512 | if (!strcmp(funcName, "vkGetFenceStatus")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2513 | return (PFN_vkVoidFunction) vkGetFenceStatus; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2514 | if (!strcmp(funcName, "vkResetFences")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2515 | return (PFN_vkVoidFunction) vkResetFences; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2516 | if (!strcmp(funcName, "vkWaitForFences")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2517 | return (PFN_vkVoidFunction) vkWaitForFences; |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2518 | if (!strcmp(funcName, "vkCreateSemaphore")) |
| 2519 | return (PFN_vkVoidFunction) vkCreateSemaphore; |
| 2520 | if (!strcmp(funcName, "vkDestroySemaphore")) |
| 2521 | return (PFN_vkVoidFunction) vkDestroySemaphore; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2522 | if (!strcmp(funcName, "vkQueueWaitIdle")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2523 | return (PFN_vkVoidFunction) vkQueueWaitIdle; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2524 | if (!strcmp(funcName, "vkDeviceWaitIdle")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2525 | return (PFN_vkVoidFunction) vkDeviceWaitIdle; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2526 | if (!strcmp(funcName, "vkCreateBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2527 | return (PFN_vkVoidFunction) vkCreateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2528 | if (!strcmp(funcName, "vkCreateImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2529 | return (PFN_vkVoidFunction) vkCreateImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2530 | if (!strcmp(funcName, "vkCreateImageView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2531 | return (PFN_vkVoidFunction) vkCreateImageView; |
Mark Lobodzinski | 50b51e6 | 2015-10-27 09:53:00 -0600 | [diff] [blame] | 2532 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 2533 | return (PFN_vkVoidFunction) vkCreateBufferView; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2534 | if (!strcmp(funcName, "vkAllocateCommandBuffers")) |
| 2535 | return (PFN_vkVoidFunction) vkAllocateCommandBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2536 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2537 | return (PFN_vkVoidFunction) vkBeginCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2538 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2539 | return (PFN_vkVoidFunction) vkEndCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2540 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2541 | return (PFN_vkVoidFunction) vkResetCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2542 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2543 | return (PFN_vkVoidFunction) vkCmdBindPipeline; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2544 | if (!strcmp(funcName, "vkCmdSetViewport")) |
| 2545 | return (PFN_vkVoidFunction) vkCmdSetViewport; |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2546 | if (!strcmp(funcName, "vkCmdSetScissor")) |
| 2547 | return (PFN_vkVoidFunction) vkCmdSetScissor; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2548 | if (!strcmp(funcName, "vkCmdSetLineWidth")) |
| 2549 | return (PFN_vkVoidFunction) vkCmdSetLineWidth; |
| 2550 | if (!strcmp(funcName, "vkCmdSetDepthBias")) |
| 2551 | return (PFN_vkVoidFunction) vkCmdSetDepthBias; |
| 2552 | if (!strcmp(funcName, "vkCmdSetBlendConstants")) |
| 2553 | return (PFN_vkVoidFunction) vkCmdSetBlendConstants; |
| 2554 | if (!strcmp(funcName, "vkCmdSetDepthBounds")) |
| 2555 | return (PFN_vkVoidFunction) vkCmdSetDepthBounds; |
| 2556 | if (!strcmp(funcName, "vkCmdSetStencilCompareMask")) |
| 2557 | return (PFN_vkVoidFunction) vkCmdSetStencilCompareMask; |
| 2558 | if (!strcmp(funcName, "vkCmdSetStencilWriteMask")) |
| 2559 | return (PFN_vkVoidFunction) vkCmdSetStencilWriteMask; |
| 2560 | if (!strcmp(funcName, "vkCmdSetStencilReference")) |
| 2561 | return (PFN_vkVoidFunction) vkCmdSetStencilReference; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2562 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2563 | return (PFN_vkVoidFunction) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2564 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2565 | return (PFN_vkVoidFunction) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2566 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2567 | return (PFN_vkVoidFunction) vkCmdBindIndexBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2568 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2569 | return (PFN_vkVoidFunction) vkCmdDrawIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2570 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2571 | return (PFN_vkVoidFunction) vkCmdDrawIndexedIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2572 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2573 | return (PFN_vkVoidFunction)vkCmdDispatchIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2574 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
Mike Stroyan | 2ed3927 | 2015-10-15 08:42:32 -0600 | [diff] [blame] | 2575 | return (PFN_vkVoidFunction)vkCmdCopyBuffer; |
| 2576 | if (!strcmp(funcName, "vkCmdCopyQueryPoolResults")) |
| 2577 | return (PFN_vkVoidFunction)vkCmdCopyQueryPoolResults; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2578 | if (!strcmp(funcName, "vkCmdCopyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2579 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2580 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2581 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2582 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2583 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2584 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2585 | return (PFN_vkVoidFunction) vkCmdUpdateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2586 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2587 | return (PFN_vkVoidFunction) vkCmdFillBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2588 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2589 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 2590 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2591 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2592 | if (!strcmp(funcName, "vkCmdResolveImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2593 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2594 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2595 | return (PFN_vkVoidFunction) vkCmdBeginQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2596 | if (!strcmp(funcName, "vkCmdEndQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2597 | return (PFN_vkVoidFunction) vkCmdEndQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2598 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2599 | return (PFN_vkVoidFunction) vkCmdResetQueryPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2600 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2601 | return (PFN_vkVoidFunction) vkGetDeviceQueue; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 2602 | |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2603 | my_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
| 2604 | if (my_data->wsi_enabled) |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 2605 | { |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 2606 | if (!strcmp(funcName, "vkCreateSwapchainKHR")) |
| 2607 | return (PFN_vkVoidFunction) vkCreateSwapchainKHR; |
| 2608 | if (!strcmp(funcName, "vkDestroySwapchainKHR")) |
| 2609 | return (PFN_vkVoidFunction) vkDestroySwapchainKHR; |
| 2610 | if (!strcmp(funcName, "vkGetSwapchainImagesKHR")) |
| 2611 | return (PFN_vkVoidFunction) vkGetSwapchainImagesKHR; |
Mark Lobodzinski | b9644ee | 2015-10-08 10:44:07 -0600 | [diff] [blame] | 2612 | if (!strcmp(funcName, "vkAcquireNextImageKHR")) |
| 2613 | return (PFN_vkVoidFunction)vkAcquireNextImageKHR; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 2614 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2615 | |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2616 | VkLayerDispatchTable *pDisp = my_data->device_dispatch_table; |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 2617 | if (pDisp->GetDeviceProcAddr == NULL) |
| 2618 | return NULL; |
| 2619 | return pDisp->GetDeviceProcAddr(dev, funcName); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2620 | } |
| 2621 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2622 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr( |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2623 | VkInstance instance, |
| 2624 | const char *funcName) |
| 2625 | { |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2626 | PFN_vkVoidFunction fptr; |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2627 | if (instance == NULL) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2628 | return NULL; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 2629 | |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2630 | layer_data *my_data; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2631 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 2632 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2633 | VkBaseLayerObject* wrapped_inst = (VkBaseLayerObject*) instance; |
| 2634 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_inst->baseObject), layer_data_map); |
| 2635 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 2636 | layer_init_instance_dispatch_table(my_data->instance_dispatch_table, wrapped_inst); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2637 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2638 | } |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2639 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2640 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2641 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2642 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2643 | return (PFN_vkVoidFunction) vkCreateInstance; |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 2644 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2645 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 2646 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
| 2647 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
| 2648 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
| 2649 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
| 2650 | if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) |
| 2651 | return (PFN_vkVoidFunction) vkEnumerateDeviceLayerProperties; |
| 2652 | if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) |
| 2653 | return (PFN_vkVoidFunction) vkEnumerateDeviceExtensionProperties; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2654 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2655 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 2656 | if (fptr) |
| 2657 | return fptr; |
| 2658 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2659 | { |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2660 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
| 2661 | if (pTable->GetInstanceProcAddr == NULL) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 2662 | return NULL; |
Tobin Ehlis | cdd7327 | 2015-10-28 16:25:11 -0600 | [diff] [blame] | 2663 | return pTable->GetInstanceProcAddr(instance, funcName); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2664 | } |
| 2665 | } |