Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1 | /* |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 2 | * Vulkan |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 3 | * |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 4 | * Copyright (C) 2015 LunarG, Inc. |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 25 | #include <inttypes.h> |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <assert.h> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 30 | #include <list> |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 31 | #include <map> |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 32 | #include <vector> |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 33 | using namespace std; |
| 34 | |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 35 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 36 | #include "vk_dispatch_table_helper.h" |
| 37 | #include "vk_struct_string_helper_cpp.h" |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 38 | #include "mem_tracker.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 39 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 40 | #include "vk_layer_extension_utils.h" |
Ian Elliott | 655cad7 | 2015-02-12 17:08:34 -0700 | [diff] [blame] | 41 | // The following is #included again to catch certain OS-specific functions |
| 42 | // being used: |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 43 | #include "vk_loader_platform.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 44 | #include "vk_layer_table.h" |
| 45 | #include "vk_layer_data.h" |
| 46 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 47 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 48 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 49 | typedef struct _layer_data { |
| 50 | debug_report_data *report_data; |
| 51 | // TODO: put instance data here |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 52 | VkDbgMsgCallback logging_callback; |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 53 | bool wsi_enabled; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 54 | } layer_data; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 55 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 56 | static unordered_map<void *, layer_data *> layer_data_map; |
| 57 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 58 | static device_table_map mem_tracker_device_table_map; |
| 59 | static instance_table_map mem_tracker_instance_table_map; |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 60 | static VkPhysicalDeviceMemoryProperties memProps; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 61 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 62 | // TODO : This can be much smarter, using separate locks for separate global data |
| 63 | static int globalLockInitialized = 0; |
| 64 | static loader_platform_thread_mutex globalLock; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 65 | |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 66 | #define MAX_BINDING 0xFFFFFFFF |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 67 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 68 | // Maps for tracking key structs related to MemTracker state |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 69 | unordered_map<VkCmdBuffer, MT_CB_INFO> cbMap; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 70 | unordered_map<uint64_t, MT_MEM_OBJ_INFO> memObjMap; |
| 71 | unordered_map<uint64_t, MT_FENCE_INFO> fenceMap; // Map fence to fence info |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 72 | unordered_map<VkQueue, MT_QUEUE_INFO> queueMap; |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 73 | unordered_map<uint64_t, MT_SWAP_CHAIN_INFO*> swapChainMap; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 74 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 75 | // Images and Buffers are 2 objects that can have memory bound to them so they get special treatment |
| 76 | unordered_map<uint64_t, MT_OBJ_BINDING_INFO> imageMap; |
| 77 | unordered_map<uint64_t, MT_OBJ_BINDING_INFO> bufferMap; |
| 78 | |
| 79 | // Maps for non-dispatchable objects that store createInfo based on handle |
| 80 | unordered_map<uint64_t, VkAttachmentViewCreateInfo> attachmentViewMap; |
| 81 | unordered_map<uint64_t, VkImageViewCreateInfo> imageViewMap; |
| 82 | // TODO : If we ever really care about Compute pipelines, split them into own map |
| 83 | unordered_map<uint64_t, VkGraphicsPipelineCreateInfo> pipelineMap; |
| 84 | unordered_map<uint64_t, VkSamplerCreateInfo> samplerMap; |
| 85 | unordered_map<uint64_t, VkSemaphoreCreateInfo> semaphoreMap; |
| 86 | unordered_map<uint64_t, VkEventCreateInfo> eventMap; |
| 87 | unordered_map<uint64_t, VkQueryPoolCreateInfo> queryPoolMap; |
| 88 | unordered_map<uint64_t, VkBufferViewCreateInfo> bufferViewMap; |
| 89 | unordered_map<uint64_t, VkShaderModuleCreateInfo> shaderModuleMap; |
| 90 | unordered_map<uint64_t, VkShaderCreateInfo> shaderMap; |
| 91 | unordered_map<uint64_t, VkPipelineLayoutCreateInfo> pipelineLayoutMap; |
| 92 | unordered_map<uint64_t, VkDescriptorSetLayoutCreateInfo> descriptorSetLayoutMap; |
| 93 | unordered_map<uint64_t, VkDescriptorPoolCreateInfo> descriptorPoolMap; |
| 94 | unordered_map<uint64_t, VkRenderPassCreateInfo> renderPassMap; |
| 95 | unordered_map<uint64_t, VkFramebufferCreateInfo> framebufferMap; |
| 96 | //unordered_map<uint64_t, VkDescriptorSetCreateInfo> descriptorSetMap; |
| 97 | unordered_map<uint64_t, VkDynamicViewportStateCreateInfo> dynamicViewportStateMap; |
| 98 | unordered_map<uint64_t, VkDynamicRasterStateCreateInfo> dynamicRasterStateMap; |
| 99 | unordered_map<uint64_t, VkDynamicColorBlendStateCreateInfo> dynamicColorBlendStateMap; |
| 100 | unordered_map<uint64_t, VkDynamicDepthStencilStateCreateInfo> dynamicDepthStencilStateMap; |
| 101 | |
| 102 | // For a given handle and object type, return a ptr to its CreateInfo struct, or NULL if not found |
| 103 | static void* get_object_create_info(uint64_t handle, VkDbgObjectType type) |
| 104 | { |
| 105 | void* retValue = NULL; |
| 106 | switch (type) |
| 107 | { |
| 108 | case VK_OBJECT_TYPE_ATTACHMENT_VIEW: |
| 109 | { |
| 110 | auto it = attachmentViewMap.find(handle); |
| 111 | if (it != attachmentViewMap.end()) |
| 112 | return (void*)&(*it).second; |
| 113 | break; |
| 114 | } |
| 115 | case VK_OBJECT_TYPE_IMAGE_VIEW: |
| 116 | { |
| 117 | auto it = imageViewMap.find(handle); |
| 118 | if (it != imageViewMap.end()) |
| 119 | return (void*)&(*it).second; |
| 120 | break; |
| 121 | } |
| 122 | case VK_OBJECT_TYPE_IMAGE: |
| 123 | { |
| 124 | auto it = imageMap.find(handle); |
| 125 | if (it != imageMap.end()) |
| 126 | return (void*)&(*it).second; |
| 127 | break; |
| 128 | } |
| 129 | case VK_OBJECT_TYPE_PIPELINE: |
| 130 | { |
| 131 | auto it = pipelineMap.find(handle); |
| 132 | if (it != pipelineMap.end()) |
| 133 | return (void*)&(*it).second; |
| 134 | break; |
| 135 | } |
| 136 | case VK_OBJECT_TYPE_SAMPLER: |
| 137 | { |
| 138 | auto it = samplerMap.find(handle); |
| 139 | if (it != samplerMap.end()) |
| 140 | return (void*)&(*it).second; |
| 141 | break; |
| 142 | } |
| 143 | case VK_OBJECT_TYPE_BUFFER: |
| 144 | { |
| 145 | auto it = bufferMap.find(handle); |
| 146 | if (it != bufferMap.end()) |
| 147 | return (void*)&(*it).second; |
| 148 | break; |
| 149 | } |
| 150 | case VK_OBJECT_TYPE_SEMAPHORE: |
| 151 | { |
| 152 | auto it = semaphoreMap.find(handle); |
| 153 | if (it != semaphoreMap.end()) |
| 154 | return (void*)&(*it).second; |
| 155 | break; |
| 156 | } |
| 157 | case VK_OBJECT_TYPE_EVENT: |
| 158 | { |
| 159 | auto it = eventMap.find(handle); |
| 160 | if (it != eventMap.end()) |
| 161 | return (void*)&(*it).second; |
| 162 | break; |
| 163 | } |
| 164 | case VK_OBJECT_TYPE_QUERY_POOL: |
| 165 | { |
| 166 | auto it = queryPoolMap.find(handle); |
| 167 | if (it != queryPoolMap.end()) |
| 168 | return (void*)&(*it).second; |
| 169 | break; |
| 170 | } |
| 171 | case VK_OBJECT_TYPE_BUFFER_VIEW: |
| 172 | { |
| 173 | auto it = bufferViewMap.find(handle); |
| 174 | if (it != bufferViewMap.end()) |
| 175 | return (void*)&(*it).second; |
| 176 | break; |
| 177 | } |
| 178 | case VK_OBJECT_TYPE_SHADER_MODULE: |
| 179 | { |
| 180 | auto it = shaderModuleMap.find(handle); |
| 181 | if (it != shaderModuleMap.end()) |
| 182 | return (void*)&(*it).second; |
| 183 | break; |
| 184 | } |
| 185 | case VK_OBJECT_TYPE_SHADER: |
| 186 | { |
| 187 | auto it = shaderMap.find(handle); |
| 188 | if (it != shaderMap.end()) |
| 189 | return (void*)&(*it).second; |
| 190 | break; |
| 191 | } |
| 192 | case VK_OBJECT_TYPE_PIPELINE_LAYOUT: |
| 193 | { |
| 194 | auto it = pipelineLayoutMap.find(handle); |
| 195 | if (it != pipelineLayoutMap.end()) |
| 196 | return (void*)&(*it).second; |
| 197 | break; |
| 198 | } |
| 199 | case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT: |
| 200 | { |
| 201 | auto it = descriptorSetLayoutMap.find(handle); |
| 202 | if (it != descriptorSetLayoutMap.end()) |
| 203 | return (void*)&(*it).second; |
| 204 | break; |
| 205 | } |
| 206 | case VK_OBJECT_TYPE_DESCRIPTOR_POOL: |
| 207 | { |
| 208 | auto it = descriptorPoolMap.find(handle); |
| 209 | if (it != descriptorPoolMap.end()) |
| 210 | return (void*)&(*it).second; |
| 211 | break; |
| 212 | } |
| 213 | // case VK_OBJECT_TYPE_DESCRIPTOR_SET: |
| 214 | // { |
| 215 | // auto it = descriptorSetMap.find(handle); |
| 216 | // if (it != descriptorSetMap.end()) |
| 217 | // return (void*)&(*it).second; |
| 218 | // break; |
| 219 | // } |
| 220 | case VK_OBJECT_TYPE_DYNAMIC_VIEWPORT_STATE: |
| 221 | { |
| 222 | auto it = dynamicViewportStateMap.find(handle); |
| 223 | if (it != dynamicViewportStateMap.end()) |
| 224 | return (void*)&(*it).second; |
| 225 | break; |
| 226 | } |
| 227 | case VK_OBJECT_TYPE_DYNAMIC_RASTER_STATE: |
| 228 | { |
| 229 | auto it = dynamicRasterStateMap.find(handle); |
| 230 | if (it != dynamicRasterStateMap.end()) |
| 231 | return (void*)&(*it).second; |
| 232 | break; |
| 233 | } |
| 234 | case VK_OBJECT_TYPE_DYNAMIC_COLOR_BLEND_STATE: |
| 235 | { |
| 236 | auto it = dynamicColorBlendStateMap.find(handle); |
| 237 | if (it != dynamicColorBlendStateMap.end()) |
| 238 | return (void*)&(*it).second; |
| 239 | break; |
| 240 | } |
| 241 | case VK_OBJECT_TYPE_DYNAMIC_DEPTH_STENCIL_STATE: |
| 242 | { |
| 243 | auto it = dynamicDepthStencilStateMap.find(handle); |
| 244 | if (it != dynamicDepthStencilStateMap.end()) |
| 245 | return (void*)&(*it).second; |
| 246 | break; |
| 247 | } |
| 248 | case VK_OBJECT_TYPE_RENDER_PASS: |
| 249 | { |
| 250 | auto it = renderPassMap.find(handle); |
| 251 | if (it != renderPassMap.end()) |
| 252 | return (void*)&(*it).second; |
| 253 | break; |
| 254 | } |
| 255 | case VK_OBJECT_TYPE_FRAMEBUFFER: |
| 256 | { |
| 257 | auto it = framebufferMap.find(handle); |
| 258 | if (it != framebufferMap.end()) |
| 259 | return (void*)&(*it).second; |
| 260 | break; |
| 261 | } |
| 262 | default: |
| 263 | { |
| 264 | // NULL will be returned below by default |
| 265 | break; |
| 266 | } |
| 267 | } |
| 268 | return retValue; |
| 269 | } |
| 270 | |
| 271 | static MT_OBJ_BINDING_INFO* get_object_binding_info(uint64_t handle, VkDbgObjectType type) |
| 272 | { |
| 273 | MT_OBJ_BINDING_INFO* retValue = NULL; |
| 274 | switch (type) |
| 275 | { |
| 276 | case VK_OBJECT_TYPE_IMAGE: |
| 277 | { |
| 278 | auto it = imageMap.find(handle); |
| 279 | if (it != imageMap.end()) |
| 280 | return &(*it).second; |
| 281 | break; |
| 282 | } |
| 283 | case VK_OBJECT_TYPE_BUFFER: |
| 284 | { |
| 285 | auto it = bufferMap.find(handle); |
| 286 | if (it != bufferMap.end()) |
| 287 | return &(*it).second; |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | return retValue; |
| 292 | } |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 293 | // TODO : Add per-device fence completion |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 294 | static uint64_t g_currentFenceId = 1; |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 295 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 296 | template layer_data *get_my_data_ptr<layer_data>( |
| 297 | void *data_key, |
| 298 | std::unordered_map<void *, layer_data *> &data_map); |
| 299 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 300 | debug_report_data *mdd(void* object) |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 301 | { |
Courtney Goeltzenleuchter | 6211086 | 2015-06-13 21:39:35 -0600 | [diff] [blame] | 302 | dispatch_key key = get_dispatch_key(object); |
| 303 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 304 | #if DISPATCH_MAP_DEBUG |
| 305 | fprintf(stderr, "MDD: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 306 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 307 | return my_data->report_data; |
| 308 | } |
| 309 | |
| 310 | debug_report_data *mid(VkInstance object) |
| 311 | { |
Courtney Goeltzenleuchter | 6211086 | 2015-06-13 21:39:35 -0600 | [diff] [blame] | 312 | dispatch_key key = get_dispatch_key(object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 313 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(object), layer_data_map); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 314 | #if DISPATCH_MAP_DEBUG |
| 315 | fprintf(stderr, "MID: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 316 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 317 | return my_data->report_data; |
| 318 | } |
| 319 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 320 | // Add new queue for this device to map container |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 321 | static void add_queue_info(const VkQueue queue) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 322 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 323 | MT_QUEUE_INFO* pInfo = &queueMap[queue]; |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 324 | pInfo->lastRetiredId = 0; |
| 325 | pInfo->lastSubmittedId = 0; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 326 | } |
| 327 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 328 | static void delete_queue_info_list( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 329 | void) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 330 | { |
| 331 | // Process queue list, cleaning up each entry before deleting |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 332 | queueMap.clear(); |
| 333 | } |
| 334 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 335 | static void add_swap_chain_info( |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 336 | const VkSwapChainWSI swapChain, const VkSwapChainCreateInfoWSI* pCI) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 337 | { |
| 338 | MT_SWAP_CHAIN_INFO* pInfo = new MT_SWAP_CHAIN_INFO; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 339 | memcpy(&pInfo->createInfo, pCI, sizeof(VkSwapChainCreateInfoWSI)); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 340 | swapChainMap[swapChain.handle] = pInfo; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 341 | } |
| 342 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 343 | // Add new CBInfo for this cb to map container |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 344 | static void add_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 345 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 346 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 347 | cbMap[cb].cmdBuffer = cb; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 350 | // Return ptr to Info in CB map, or NULL if not found |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 351 | static MT_CB_INFO* get_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 352 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 353 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 354 | auto item = cbMap.find(cb); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 355 | if (item != cbMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 356 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 357 | } else { |
| 358 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 359 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 360 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 361 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 362 | static void add_object_binding_info(const uint64_t handle, const VkDbgObjectType type, const VkDeviceMemory mem) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 363 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 364 | switch (type) |
| 365 | { |
| 366 | // Buffers and images are unique as their CreateInfo is in container struct |
| 367 | case VK_OBJECT_TYPE_BUFFER: |
| 368 | { |
| 369 | auto pCI = &bufferMap[handle]; |
| 370 | pCI->mem = mem; |
| 371 | break; |
| 372 | } |
| 373 | case VK_OBJECT_TYPE_IMAGE: |
| 374 | { |
| 375 | auto pCI = &imageMap[handle]; |
| 376 | pCI->mem = mem; |
| 377 | break; |
| 378 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 379 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 380 | } |
| 381 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 382 | static void add_object_create_info(const uint64_t handle, const VkDbgObjectType type, const void* pCreateInfo) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 383 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 384 | // TODO : For any CreateInfo struct that has ptrs, need to deep copy them and appropriately clean up on Destroy |
| 385 | switch (type) |
| 386 | { |
| 387 | // Buffers and images are unique as their CreateInfo is in container struct |
| 388 | case VK_OBJECT_TYPE_BUFFER: |
| 389 | { |
| 390 | auto pCI = &bufferMap[handle]; |
| 391 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
| 392 | memcpy(&pCI->create_info.buffer, pCreateInfo, sizeof(VkBufferCreateInfo)); |
| 393 | break; |
| 394 | } |
| 395 | case VK_OBJECT_TYPE_IMAGE: |
| 396 | { |
| 397 | auto pCI = &imageMap[handle]; |
| 398 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
| 399 | memcpy(&pCI->create_info.image, pCreateInfo, sizeof(VkImageCreateInfo)); |
| 400 | break; |
| 401 | } |
| 402 | // Swap Chain is very unique, use imageMap, but copy in SwapChainCreatInfo |
| 403 | // This is used by vkCreateAttachmentView to distinguish swap chain images |
| 404 | case VK_OBJECT_TYPE_SWAP_CHAIN_WSI: |
| 405 | { |
| 406 | auto pCI = &imageMap[handle]; |
| 407 | memset(pCI, 0, sizeof(MT_OBJ_BINDING_INFO)); |
Tony Barbour | 791646c | 2015-07-13 16:37:21 -0600 | [diff] [blame] | 408 | // memcpy(&pCI->create_info.swapchain, pCreateInfo, sizeof(VkSwapChainCreateInfoWSI)); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 409 | break; |
| 410 | } |
| 411 | // All other non-disp objects store their Create info struct as map value |
| 412 | case VK_OBJECT_TYPE_ATTACHMENT_VIEW: |
| 413 | { |
| 414 | auto pCI = &attachmentViewMap[handle]; |
| 415 | memcpy(pCI, pCreateInfo, sizeof(VkAttachmentViewCreateInfo)); |
| 416 | break; |
| 417 | } |
| 418 | case VK_OBJECT_TYPE_IMAGE_VIEW: |
| 419 | { |
| 420 | auto pCI = &imageViewMap[handle]; |
| 421 | memcpy(pCI, pCreateInfo, sizeof(VkImageViewCreateInfo)); |
| 422 | break; |
| 423 | } |
| 424 | case VK_OBJECT_TYPE_PIPELINE: |
| 425 | { |
| 426 | auto pCI = &pipelineMap[handle]; |
| 427 | memcpy(pCI, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo)); |
| 428 | break; |
| 429 | } |
| 430 | case VK_OBJECT_TYPE_SAMPLER: |
| 431 | { |
| 432 | auto pCI = &samplerMap[handle]; |
| 433 | memcpy(pCI, pCreateInfo, sizeof(VkSamplerCreateInfo)); |
| 434 | break; |
| 435 | } |
| 436 | case VK_OBJECT_TYPE_SEMAPHORE: |
| 437 | { |
| 438 | auto pCI = &semaphoreMap[handle]; |
| 439 | memcpy(pCI, pCreateInfo, sizeof(VkSemaphoreCreateInfo)); |
| 440 | break; |
| 441 | } |
| 442 | case VK_OBJECT_TYPE_EVENT: |
| 443 | { |
| 444 | auto pCI = &eventMap[handle]; |
| 445 | memcpy(pCI, pCreateInfo, sizeof(VkEventCreateInfo)); |
| 446 | break; |
| 447 | } |
| 448 | case VK_OBJECT_TYPE_QUERY_POOL: |
| 449 | { |
| 450 | auto pCI = &queryPoolMap[handle]; |
| 451 | memcpy(pCI, pCreateInfo, sizeof(VkQueryPoolCreateInfo)); |
| 452 | break; |
| 453 | } |
| 454 | case VK_OBJECT_TYPE_BUFFER_VIEW: |
| 455 | { |
| 456 | auto pCI = &bufferViewMap[handle]; |
| 457 | memcpy(pCI, pCreateInfo, sizeof(VkBufferViewCreateInfo)); |
| 458 | break; |
| 459 | } |
| 460 | case VK_OBJECT_TYPE_SHADER_MODULE: |
| 461 | { |
| 462 | auto pCI = &shaderModuleMap[handle]; |
| 463 | memcpy(pCI, pCreateInfo, sizeof(VkShaderModuleCreateInfo)); |
| 464 | break; |
| 465 | } |
| 466 | case VK_OBJECT_TYPE_SHADER: |
| 467 | { |
| 468 | auto pCI = &shaderMap[handle]; |
| 469 | memcpy(pCI, pCreateInfo, sizeof(VkShaderCreateInfo)); |
| 470 | break; |
| 471 | } |
| 472 | case VK_OBJECT_TYPE_PIPELINE_LAYOUT: |
| 473 | { |
| 474 | auto pCI = &pipelineLayoutMap[handle]; |
| 475 | memcpy(pCI, pCreateInfo, sizeof(VkPipelineLayoutCreateInfo)); |
| 476 | break; |
| 477 | } |
| 478 | case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT: |
| 479 | { |
| 480 | auto pCI = &descriptorSetLayoutMap[handle]; |
| 481 | memcpy(pCI, pCreateInfo, sizeof(VkDescriptorSetLayoutCreateInfo)); |
| 482 | break; |
| 483 | } |
| 484 | case VK_OBJECT_TYPE_DESCRIPTOR_POOL: |
| 485 | { |
| 486 | auto pCI = &descriptorPoolMap[handle]; |
| 487 | memcpy(pCI, pCreateInfo, sizeof(VkDescriptorPoolCreateInfo)); |
| 488 | break; |
| 489 | } |
| 490 | // case VK_OBJECT_TYPE_DESCRIPTOR_SET: |
| 491 | // { |
| 492 | // auto pCI = &descriptorSetMap[handle]; |
| 493 | // memcpy(pCI, pCreateInfo, sizeof(VkDescriptorSetCreateInfo)); |
| 494 | // break; |
| 495 | // } |
| 496 | case VK_OBJECT_TYPE_RENDER_PASS: |
| 497 | { |
| 498 | auto pCI = &renderPassMap[handle]; |
| 499 | memcpy(pCI, pCreateInfo, sizeof(VkRenderPassCreateInfo)); |
| 500 | break; |
| 501 | } |
| 502 | case VK_OBJECT_TYPE_FRAMEBUFFER: |
| 503 | { |
| 504 | auto pCI = &framebufferMap[handle]; |
| 505 | memcpy(pCI, pCreateInfo, sizeof(VkFramebufferCreateInfo)); |
| 506 | break; |
| 507 | } |
| 508 | case VK_OBJECT_TYPE_DYNAMIC_VIEWPORT_STATE: |
| 509 | { |
| 510 | auto pCI = &dynamicViewportStateMap[handle]; |
| 511 | memcpy(pCI, pCreateInfo, sizeof(VkDynamicViewportStateCreateInfo)); |
| 512 | break; |
| 513 | } |
| 514 | case VK_OBJECT_TYPE_DYNAMIC_RASTER_STATE: |
| 515 | { |
| 516 | auto pCI = &dynamicRasterStateMap[handle]; |
| 517 | memcpy(pCI, pCreateInfo, sizeof(VkDynamicRasterStateCreateInfo)); |
| 518 | break; |
| 519 | } |
| 520 | case VK_OBJECT_TYPE_DYNAMIC_COLOR_BLEND_STATE: |
| 521 | { |
| 522 | auto pCI = &dynamicColorBlendStateMap[handle]; |
| 523 | memcpy(pCI, pCreateInfo, sizeof(VkDynamicColorBlendStateCreateInfo)); |
| 524 | break; |
| 525 | } |
| 526 | case VK_OBJECT_TYPE_DYNAMIC_DEPTH_STENCIL_STATE: |
| 527 | { |
| 528 | auto pCI = &dynamicDepthStencilStateMap[handle]; |
| 529 | memcpy(pCI, pCreateInfo, sizeof(VkDynamicDepthStencilStateCreateInfo)); |
| 530 | break; |
| 531 | } |
| 532 | default: |
| 533 | { |
| 534 | // NULL will be returned below by default |
| 535 | break; |
| 536 | } |
| 537 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 538 | } |
| 539 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 540 | // Add a fence, creating one if necessary to our list of fences/fenceIds |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 541 | static uint64_t add_fence_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 542 | VkFence fence, |
| 543 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 544 | { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 545 | // Create fence object |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 546 | uint64_t fenceId = g_currentFenceId++; |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 547 | // If no fence, create an internal fence to track the submissions |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 548 | if (fence.handle != 0) { |
| 549 | fenceMap[fence.handle].fenceId = fenceId; |
| 550 | fenceMap[fence.handle].queue = queue; |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 551 | // Validate that fence is in UNSIGNALED state |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 552 | VkFenceCreateInfo* pFenceCI = &(fenceMap[fence.handle].createInfo); |
| 553 | if (pFenceCI->flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
| 554 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_FENCE, fence.handle, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 555 | "Fence %#" PRIxLEAST64 " submitted in SIGNALED state. Fences must be reset before being submitted", fence.handle); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 556 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 557 | } else { |
| 558 | // 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] | 559 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 560 | // Update most recently submitted fence and fenceId for Queue |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 561 | queueMap[queue].lastSubmittedId = fenceId; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 562 | return fenceId; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 563 | } |
| 564 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 565 | // Remove a fenceInfo from our list of fences/fenceIds |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 566 | static void delete_fence_info( |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 567 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 568 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 569 | fenceMap.erase(fence.handle); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 570 | } |
| 571 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 572 | // Record information when a fence is known to be signalled |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 573 | static void update_fence_tracking( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 574 | VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 575 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 576 | auto fence_item = fenceMap.find(fence.handle); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 577 | if (fence_item != fenceMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 578 | MT_FENCE_INFO *pCurFenceInfo = &(*fence_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 579 | VkQueue queue = pCurFenceInfo->queue; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 580 | auto queue_item = queueMap.find(queue); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 581 | if (queue_item != queueMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 582 | MT_QUEUE_INFO *pQueueInfo = &(*queue_item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 583 | if (pQueueInfo->lastRetiredId < pCurFenceInfo->fenceId) { |
| 584 | pQueueInfo->lastRetiredId = pCurFenceInfo->fenceId; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 585 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 586 | } |
| 587 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 588 | |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 589 | // Update fence state in fenceCreateInfo structure |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 590 | auto pFCI = &(fenceMap[fence.handle].createInfo); |
| 591 | pFCI->flags = static_cast<VkFenceCreateFlags>(pFCI->flags | VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 592 | } |
| 593 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 594 | // Helper routine that updates the fence list for a specific queue to all-retired |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 595 | static void retire_queue_fences( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 596 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 597 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 598 | MT_QUEUE_INFO *pQueueInfo = &queueMap[queue]; |
| 599 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 600 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 603 | // Helper routine that updates all queues to all-retired |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 604 | static void retire_device_fences( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 605 | VkDevice device) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 606 | { |
| 607 | // Process each queue for device |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 608 | // TODO: Add multiple device support |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 609 | for (auto ii=queueMap.begin(); ii!=queueMap.end(); ++ii) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 610 | // Set queue's lastRetired to lastSubmitted indicating all fences completed |
| 611 | MT_QUEUE_INFO *pQueueInfo = &(*ii).second; |
| 612 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 613 | } |
| 614 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 615 | // Helper function to validate correct usage bits set for buffers or images |
| 616 | // Verify that (actual & desired) flags != 0 or, |
| 617 | // if strict is true, verify that (actual & desired) flags == desired |
| 618 | // In case of error, report it via dbg callbacks |
David Pinedo | 3831094 | 2015-07-09 16:23:44 -0600 | [diff] [blame] | 619 | static void validate_usage_flags(void* disp_obj, VkFlags actual, VkFlags desired, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 620 | VkBool32 strict, uint64_t obj_handle, VkDbgObjectType obj_type, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 621 | char const* ty_str, char const* func_name, char const* usage_str) |
| 622 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 623 | VkBool32 correct_usage = VK_FALSE; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 624 | if (strict) |
| 625 | correct_usage = ((actual & desired) == desired); |
| 626 | else |
| 627 | correct_usage = ((actual & desired) != 0); |
| 628 | if (!correct_usage) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 629 | log_msg(mdd(disp_obj), VK_DBG_REPORT_ERROR_BIT, obj_type, obj_handle, 0, MEMTRACK_INVALID_USAGE_FLAG, "MEM", |
| 630 | "Invalid usage flag for %s %#" PRIxLEAST64 " used by %s. In this case, %s should have %s set during creation.", |
| 631 | ty_str, obj_handle, func_name, ty_str, usage_str); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 632 | } |
| 633 | } |
| 634 | // Helper function to validate usage flags for images |
| 635 | // Pulls image info and then sends actual vs. desired usage off to helper above where |
| 636 | // an error will be flagged if usage is not correct |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 637 | static void validate_image_usage_flags(void* disp_obj, VkImage image, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 638 | char const* func_name, char const* usage_string) |
| 639 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 640 | MT_OBJ_BINDING_INFO* pBindInfo = get_object_binding_info(image.handle, VK_OBJECT_TYPE_IMAGE); |
| 641 | if (pBindInfo) { |
| 642 | validate_usage_flags(disp_obj, pBindInfo->create_info.image.usage, desired, strict, |
| 643 | image.handle, VK_OBJECT_TYPE_IMAGE, "image", func_name, usage_string); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 644 | } |
| 645 | } |
| 646 | // Helper function to validate usage flags for buffers |
| 647 | // Pulls buffer info and then sends actual vs. desired usage off to helper above where |
| 648 | // an error will be flagged if usage is not correct |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 649 | static void validate_buffer_usage_flags(void* disp_obj, VkBuffer buffer, VkFlags desired, VkBool32 strict, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 650 | char const* func_name, char const* usage_string) |
| 651 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 652 | MT_OBJ_BINDING_INFO* pBindInfo = get_object_binding_info(buffer.handle, VK_OBJECT_TYPE_BUFFER); |
| 653 | if (pBindInfo) { |
| 654 | validate_usage_flags(disp_obj, pBindInfo->create_info.buffer.usage, desired, strict, |
| 655 | buffer.handle, VK_OBJECT_TYPE_BUFFER, "buffer", func_name, usage_string); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 656 | } |
| 657 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 658 | // 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] | 659 | // Calls to this function should be wrapped in mutex |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 660 | static MT_MEM_OBJ_INFO* get_mem_obj_info( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 661 | const uint64_t device_mem_handle) |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 662 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 663 | auto item = memObjMap.find(device_mem_handle); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 664 | if (item != memObjMap.end()) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 665 | return &(*item).second; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 666 | } else { |
| 667 | return NULL; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 668 | } |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 671 | static void add_mem_obj_info( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 672 | void* object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 673 | const VkDeviceMemory mem, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 674 | const VkMemoryAllocInfo* pAllocInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 675 | { |
Courtney Goeltzenleuchter | 17fd5ce | 2015-06-13 21:29:26 -0600 | [diff] [blame] | 676 | assert(object != NULL); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 677 | |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 678 | memcpy(&memObjMap[mem.handle].allocInfo, pAllocInfo, sizeof(VkMemoryAllocInfo)); |
| 679 | // TODO: Update for real hardware, actually process allocation info structures |
| 680 | memObjMap[mem.handle].allocInfo.pNext = NULL; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 681 | memObjMap[mem.handle].object = object; |
| 682 | memObjMap[mem.handle].refCount = 0; |
| 683 | memObjMap[mem.handle].mem = mem; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 684 | } |
| 685 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 686 | // Find CB Info and add mem reference to list container |
| 687 | // Find Mem Obj Info and add CB reference to list container |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 688 | static VkBool32 update_cmd_buf_and_mem_references( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 689 | const VkCmdBuffer cb, |
| 690 | const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 691 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 692 | VkBool32 result = VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 693 | // First update CB binding in MemObj mini CB list |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 694 | MT_MEM_OBJ_INFO* pMemInfo = get_mem_obj_info(mem.handle); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 695 | if (!pMemInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 696 | // TODO : cb should be srcObj |
| 697 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 698 | "Trying to bind mem obj %#" PRIxLEAST64 " to CB %p but no info for that mem obj.\n " |
| 699 | "Was it correctly allocated? Did it already get freed?", mem.handle, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 700 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 701 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 702 | // Search for cmd buffer object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 703 | VkBool32 found = VK_FALSE; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 704 | if (pMemInfo->pCmdBufferBindings.size() > 0) { |
| 705 | for (list<VkCmdBuffer>::iterator it = pMemInfo->pCmdBufferBindings.begin(); it != pMemInfo->pCmdBufferBindings.end(); ++it) { |
| 706 | if ((*it) == cb) { |
| 707 | found = VK_TRUE; |
| 708 | break; |
| 709 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 710 | } |
| 711 | } |
| 712 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 713 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 714 | pMemInfo->pCmdBufferBindings.push_front(cb); |
| 715 | pMemInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 716 | } |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 717 | // Now update CBInfo's Mem reference list |
| 718 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
| 719 | // TODO: keep track of all destroyed CBs so we know if this is a stale or simply invalid object |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 720 | if (!pCBInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 721 | // TODO : cb should be srcObj |
| 722 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 723 | "Trying to bind mem obj %#" PRIxLEAST64 " to CB %p but no info for that CB. Was CB incorrectly destroyed?", mem.handle, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 724 | result = VK_FALSE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 725 | } else { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 726 | // Search for memory object in cmd buffer's reference list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 727 | VkBool32 found = VK_FALSE; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 728 | if (pCBInfo->pMemObjList.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 729 | for (auto it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 730 | if ((*it) == mem) { |
| 731 | found = VK_TRUE; |
| 732 | break; |
| 733 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 737 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 738 | pCBInfo->pMemObjList.push_front(mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 739 | } |
| 740 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 741 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 742 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 743 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 744 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 745 | // Clear the CB Binding for mem |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 746 | // Calls to this function should be wrapped in mutex |
| 747 | static void remove_cmd_buf_and_mem_reference( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 748 | const VkCmdBuffer cb, |
| 749 | const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 750 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 751 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem.handle); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 752 | // TODO : Having this check is not ideal, really if memInfo was deleted, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 753 | // its CB bindings should be cleared and then clear_cmd_buf_and_mem_references wouldn't call |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 754 | // us here with stale mem objs |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 755 | if (pInfo) { |
| 756 | pInfo->pCmdBufferBindings.remove(cb); |
| 757 | pInfo->refCount--; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 758 | } |
| 759 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 760 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 761 | // Free bindings related to CB |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 762 | static VkBool32 clear_cmd_buf_and_mem_references( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 763 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 764 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 765 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 766 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 767 | if (!pCBInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 768 | // TODO : cb should be srcObj |
| 769 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 770 | "Unable to find global CB info %p for deletion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 771 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 772 | } else { |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 773 | if (pCBInfo->pMemObjList.size() > 0) { |
| 774 | list<VkDeviceMemory> mem_obj_list = pCBInfo->pMemObjList; |
| 775 | for (list<VkDeviceMemory>::iterator it=mem_obj_list.begin(); it!=mem_obj_list.end(); ++it) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 776 | remove_cmd_buf_and_mem_reference(cb, (*it)); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 777 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 778 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 779 | pCBInfo->pMemObjList.clear(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 780 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 781 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 782 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 783 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 784 | // Delete CBInfo from list along with all of it's mini MemObjInfo |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 785 | // and also clear mem references to CB |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 786 | static VkBool32 delete_cmd_buf_info( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 787 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 788 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 789 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 790 | result = clear_cmd_buf_and_mem_references(cb); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 791 | // Delete the CBInfo info |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 792 | if (result == VK_TRUE) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 793 | cbMap.erase(cb); |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 794 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 795 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 796 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 797 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 798 | // Delete the entire CB list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 799 | static VkBool32 delete_cmd_buf_info_list( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 800 | void) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 801 | { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 802 | for (unordered_map<VkCmdBuffer, MT_CB_INFO>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 803 | clear_cmd_buf_and_mem_references((*ii).first); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 804 | } |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 805 | cbMap.clear(); |
| 806 | return VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 807 | } |
| 808 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 809 | // For given MemObjInfo, report Obj & CB bindings |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 810 | static void reportMemReferencesAndCleanUp( |
| 811 | MT_MEM_OBJ_INFO* pMemObjInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 812 | { |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 813 | size_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size(); |
| 814 | size_t objRefCount = pMemObjInfo->pObjBindings.size(); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 815 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 816 | if ((pMemObjInfo->pCmdBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 817 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, pMemObjInfo->mem.handle, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 818 | "Attempting to free memory object %#" PRIxLEAST64 " which still contains %lu references", |
| 819 | pMemObjInfo->mem.handle, (cmdBufRefCount + objRefCount)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 820 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 821 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 822 | if (cmdBufRefCount > 0 && pMemObjInfo->pCmdBufferBindings.size() > 0) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 823 | for (list<VkCmdBuffer>::const_iterator it = pMemObjInfo->pCmdBufferBindings.begin(); it != pMemObjInfo->pCmdBufferBindings.end(); ++it) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 824 | // TODO : cmdBuffer should be source Obj here |
| 825 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_NONE, "MEM", |
| 826 | "Command Buffer %p still has a reference to mem obj %#" PRIxLEAST64, (*it), pMemObjInfo->mem.handle); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 827 | } |
| 828 | // Clear the list of hanging references |
| 829 | pMemObjInfo->pCmdBufferBindings.clear(); |
| 830 | } |
| 831 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 832 | if (objRefCount > 0 && pMemObjInfo->pObjBindings.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 833 | for (auto it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
| 834 | log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_INFO_BIT, it->type, it->handle, 0, MEMTRACK_NONE, "MEM", |
| 835 | "VK Object %#" PRIxLEAST64 " still has a reference to mem obj %#" PRIxLEAST64, it->handle, pMemObjInfo->mem.handle); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 836 | } |
| 837 | // Clear the list of hanging references |
| 838 | pMemObjInfo->pObjBindings.clear(); |
| 839 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 840 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 841 | } |
| 842 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 843 | static void deleteMemObjInfo( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 844 | void* object, |
| 845 | const uint64_t device_mem_handle) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 846 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 847 | auto item = memObjMap.find(device_mem_handle); |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 848 | if (item != memObjMap.end()) { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 849 | memObjMap.erase(item); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 850 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 851 | else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 852 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, device_mem_handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 853 | "Request to delete memory object %#" PRIxLEAST64 " not present in memory Object Map", device_mem_handle); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 854 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 855 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 856 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 857 | // Check if fence for given CB is completed |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 858 | static VkBool32 checkCBCompleted( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 859 | const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 860 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 861 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 862 | MT_CB_INFO* pCBInfo = get_cmd_buf_info(cb); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 863 | if (!pCBInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 864 | // TODO : cb should be srcObj |
| 865 | log_msg(mdd(cb), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 866 | "Unable to find global CB info %p to check for completion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 867 | result = VK_FALSE; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 868 | } else if (pCBInfo->lastSubmittedQueue != NULL) { |
| 869 | VkQueue queue = pCBInfo->lastSubmittedQueue; |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 870 | MT_QUEUE_INFO *pQueueInfo = &queueMap[queue]; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 871 | if (pCBInfo->fenceId > pQueueInfo->lastRetiredId) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 872 | // TODO : cb should be srcObj and print cb handle |
| 873 | log_msg(mdd(cb), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_NONE, "MEM", |
| 874 | "fence %#" PRIxLEAST64 " for CB %p has not been checked for completion", |
| 875 | pCBInfo->lastSubmittedFence.handle, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 876 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 877 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 878 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 879 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 880 | } |
| 881 | |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 882 | static VkBool32 freeMemObjInfo( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 883 | void* object, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 884 | VkDeviceMemory mem, |
| 885 | bool internal) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 886 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 887 | VkBool32 result = VK_TRUE; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 888 | // Parse global list to find info w/ mem |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 889 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem.handle); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 890 | if (!pInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 891 | log_msg(mdd(object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 892 | "Couldn't find mem info object for %#" PRIxLEAST64 "\n Was %#" PRIxLEAST64 " never allocated or previously freed?", |
| 893 | mem.handle, mem.handle); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 894 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 895 | } else { |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 896 | if (pInfo->allocInfo.allocationSize == 0 && !internal) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 897 | log_msg(mdd(pInfo->object), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 898 | "Attempting to free memory associated with a Persistent Image, %#" PRIxLEAST64 ", " |
| 899 | "this should not be explicitly freed\n", mem.handle); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 900 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 901 | } else { |
| 902 | // Clear any CB bindings for completed CBs |
| 903 | // TODO : Is there a better place to do this? |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 904 | |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 905 | assert(pInfo->object != VK_NULL_HANDLE); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 906 | list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); |
| 907 | list<VkCmdBuffer>::iterator temp; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 908 | while (pInfo->pCmdBufferBindings.size() > 0 && it != pInfo->pCmdBufferBindings.end()) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 909 | if (VK_TRUE == checkCBCompleted(*it)) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 910 | temp = it; |
| 911 | ++temp; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 912 | clear_cmd_buf_and_mem_references(*it); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 913 | it = temp; |
| 914 | } else { |
| 915 | ++it; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 916 | } |
| 917 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 918 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 919 | // Now verify that no references to this mem obj remain |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 920 | // TODO : Is this check still valid? I don't think so |
| 921 | // Even if not, we still need to remove binding from obj |
| 922 | // if (0 != pInfo->refCount) { |
| 923 | // reportMemReferencesAndCleanUp(pInfo); |
| 924 | // result = VK_FALSE; |
| 925 | // } |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 926 | // Delete mem obj info |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 927 | deleteMemObjInfo(object, mem.handle); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 928 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 929 | } |
| 930 | return result; |
| 931 | } |
| 932 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 933 | // Remove object binding performs 3 tasks: |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 934 | // 1. Remove ObjectInfo from MemObjInfo list container of obj bindings & free it |
| 935 | // 2. Decrement refCount for MemObjInfo |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 936 | // 3. Clear mem binding for image/buffer by setting its handle to 0 |
| 937 | // TODO : This only applied to Buffer and Image objects now, how should it be updated/customized? |
| 938 | static VkBool32 clear_object_binding(void* dispObj, uint64_t handle, VkDbgObjectType type) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 939 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 940 | // TODO : Need to customize images/buffers to track mem binding and clear it here appropriately |
| 941 | VkBool32 result = VK_TRUE; |
| 942 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(handle, type); |
| 943 | if (pObjBindInfo) { |
| 944 | MT_MEM_OBJ_INFO* pMemObjInfo = get_mem_obj_info(pObjBindInfo->mem.handle); |
| 945 | if (!pMemObjInfo) { |
| 946 | log_msg(mdd(dispObj), VK_DBG_REPORT_WARN_BIT, type, handle, 0, MEMTRACK_MEM_OBJ_CLEAR_EMPTY_BINDINGS, "MEM", |
| 947 | "Attempting to clear mem binding on %s obj %#" PRIxLEAST64 " but it has no binding.", |
| 948 | (VK_OBJECT_TYPE_IMAGE == type) ? "image" : "buffer", handle); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 949 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 950 | // 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 |
| 951 | // and set the objects memory binding pointer to NULL. |
| 952 | for (auto it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
| 953 | if ((it->handle == handle) && (it->type == type)) { |
| 954 | pMemObjInfo->refCount--; |
| 955 | pMemObjInfo->pObjBindings.erase(it); |
| 956 | // TODO : Make sure this is a reasonable way to reset mem binding |
| 957 | pObjBindInfo->mem.handle = 0; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 958 | result = VK_TRUE; |
| 959 | break; |
| 960 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 961 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 962 | if (result == VK_FALSE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 963 | log_msg(mdd(dispObj), VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 964 | "While trying to clear mem binding for %s obj %#" PRIxLEAST64 ", unable to find that object referenced by mem obj %#" PRIxLEAST64, |
| 965 | (VK_OBJECT_TYPE_IMAGE == type) ? "image" : "buffer", handle, pMemObjInfo->mem.handle); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 966 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 967 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 968 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 969 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 970 | } |
| 971 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 972 | // For NULL mem case, output warning |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 973 | // Make sure given object is in global object map |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 974 | // IF a previous binding existed, output validation error |
| 975 | // Otherwise, add reference from objectInfo to memoryInfo |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 976 | // Add reference off of objInfo |
Courtney Goeltzenleuchter | 540d349 | 2015-06-13 21:37:34 -0600 | [diff] [blame] | 977 | // device is required for error logging, need a dispatchable |
| 978 | // object for that. |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 979 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 980 | static VkBool32 set_mem_binding( |
| 981 | void* dispatch_object, |
| 982 | VkDeviceMemory mem, |
| 983 | uint64_t handle, |
| 984 | VkDbgObjectType type) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 985 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 986 | VkBool32 result = VK_FALSE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 987 | // Handle NULL case separately, just clear previous binding & decrement reference |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 988 | if (mem == VK_NULL_HANDLE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 989 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_WARN_BIT, type, handle, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 990 | "Attempting to Bind Obj(%#" PRIxLEAST64 ") to NULL", handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 991 | return VK_TRUE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 992 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 993 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(handle, type); |
| 994 | if (!pObjBindInfo) { |
| 995 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 996 | "Attempting to update Binding of %s Obj(%#" PRIxLEAST64 ") that's not in global list()", (VK_OBJECT_TYPE_IMAGE == type) ? "image" : "buffer", handle); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 997 | return VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 998 | } |
| 999 | // non-null case so should have real mem obj |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1000 | MT_MEM_OBJ_INFO* pMemInfo = get_mem_obj_info(mem.handle); |
| 1001 | if (!pMemInfo) { |
| 1002 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 1003 | "While trying to bind mem for %s obj %#" PRIxLEAST64 ", couldn't find info for mem obj %#" PRIxLEAST64, (VK_OBJECT_TYPE_IMAGE == type) ? "image" : "buffer", handle, mem.handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1004 | return VK_FALSE; |
| 1005 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1006 | // TODO : Need to track mem binding for obj and report conflict here |
| 1007 | MT_MEM_OBJ_INFO* pPrevBinding = get_mem_obj_info(pObjBindInfo->mem.handle); |
| 1008 | if (pPrevBinding != NULL) { |
| 1009 | log_msg(mdd(dispatch_object), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_REBIND_OBJECT, "MEM", |
| 1010 | "Attempting to bind memory (%#" PRIxLEAST64 ") to object (%#" PRIxLEAST64 ") which has already been bound to mem object %#" PRIxLEAST64, |
| 1011 | mem.handle, handle, pPrevBinding->mem.handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1012 | return VK_FALSE; |
| 1013 | } |
| 1014 | else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1015 | MT_OBJ_HANDLE_TYPE oht; |
| 1016 | oht.handle = handle; |
| 1017 | oht.type = type; |
| 1018 | pMemInfo->pObjBindings.push_front(oht); |
| 1019 | pMemInfo->refCount++; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1020 | // For image objects, make sure default memory state is correctly set |
| 1021 | // TODO : What's the best/correct way to handle this? |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1022 | if (VK_OBJECT_TYPE_IMAGE == type) { |
| 1023 | VkImageCreateInfo ici = pObjBindInfo->create_info.image; |
| 1024 | if (ici.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 1025 | VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1026 | // TODO:: More memory state transition stuff. |
| 1027 | } |
| 1028 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1029 | pObjBindInfo->mem = mem; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | return VK_TRUE; |
| 1034 | } |
| 1035 | |
| 1036 | // For NULL mem case, clear any previous binding Else... |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1037 | // Make sure given object is in its object map |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1038 | // IF a previous binding existed, update binding |
| 1039 | // Add reference from objectInfo to memoryInfo |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1040 | // Add reference off of object's binding info |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1041 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1042 | static VkBool32 set_sparse_mem_binding( |
| 1043 | void* dispObject, |
| 1044 | VkDeviceMemory mem, |
| 1045 | uint64_t handle, |
| 1046 | VkDbgObjectType type) |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1047 | { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 1048 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1049 | // Handle NULL case separately, just clear previous binding & decrement reference |
| 1050 | if (mem == VK_NULL_HANDLE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1051 | clear_object_binding(dispObject, handle, type); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1052 | return VK_TRUE; |
| 1053 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1054 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(handle, type); |
| 1055 | if (!pObjBindInfo) { |
| 1056 | log_msg(mdd(dispObject), VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
| 1057 | "Attempting to update Binding of Obj(%#" PRIxLEAST64 ") that's not in global list()", handle); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1058 | return VK_FALSE; |
| 1059 | } |
| 1060 | // non-null case so should have real mem obj |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1061 | MT_MEM_OBJ_INFO* pInfo = get_mem_obj_info(mem.handle); |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 1062 | if (!pInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1063 | log_msg(mdd(dispObject), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", |
| 1064 | "While trying to bind mem for obj %#" PRIxLEAST64 ", couldn't find info for mem obj %#" PRIxLEAST64, handle, mem.handle); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1065 | return VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1066 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1067 | // Search for object in memory object's binding list |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 1068 | VkBool32 found = VK_FALSE; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 1069 | if (pInfo->pObjBindings.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1070 | for (auto it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
| 1071 | if (((*it).handle == handle) && ((*it).type == type)) { |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 1072 | found = VK_TRUE; |
| 1073 | break; |
| 1074 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1075 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1076 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1077 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1078 | if (found == VK_FALSE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1079 | MT_OBJ_HANDLE_TYPE oht; |
| 1080 | oht.handle = handle; |
| 1081 | oht.type = type; |
| 1082 | pInfo->pObjBindings.push_front(oht); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1083 | pInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1084 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1085 | // Need to set mem binding for this object |
| 1086 | // TODO : Do we still need to check for previous binding? |
| 1087 | MT_MEM_OBJ_INFO* pPrevBinding = get_mem_obj_info(pObjBindInfo->mem.handle); |
| 1088 | if (pPrevBinding) { |
| 1089 | clear_object_binding(dispObject, handle, type); // Need to clear the previous object binding before setting new binding |
| 1090 | log_msg(mdd(dispObject), VK_DBG_REPORT_INFO_BIT, type, handle, 0, MEMTRACK_NONE, "MEM", |
| 1091 | "Updating memory binding for object %#" PRIxLEAST64 " from mem obj %#" PRIxLEAST64 " to %#" PRIxLEAST64, handle, pPrevBinding->mem.handle, mem.handle); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1092 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1093 | pObjBindInfo->mem = mem; |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1094 | } |
| 1095 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1096 | return VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1097 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1098 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1099 | // Print details of global Obj tracking list |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1100 | //static void print_object_list( |
| 1101 | // VkObject object) |
| 1102 | //{ |
| 1103 | // MT_OBJ_INFO* pInfo = NULL; |
| 1104 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1105 | // "Details of Object list of size %lu elements", objectMap.size()); |
| 1106 | // if (objectMap.size() <= 0) |
| 1107 | // return; |
| 1108 | // for (unordered_map<VkObject, MT_OBJ_INFO>::iterator ii=objectMap.begin(); ii!=objectMap.end(); ++ii) { |
| 1109 | // pInfo = &(*ii).second; |
| 1110 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, pInfo->object, 0, MEMTRACK_NONE, "MEM", |
| 1111 | // " ObjInfo %p has object %p, pMemObjInfo %p", pInfo, pInfo->object, pInfo->pMemObjInfo); |
| 1112 | // } |
| 1113 | //} |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1114 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1115 | // For given Object, get 'mem' obj that it's bound to or NULL if no binding |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1116 | static VkDeviceMemory get_mem_binding_from_object( |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1117 | void* dispObj, const uint64_t handle, const VkDbgObjectType type) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1118 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1119 | VkDeviceMemory mem; |
| 1120 | mem.handle = 0; |
| 1121 | MT_OBJ_BINDING_INFO* pObjBindInfo = get_object_binding_info(handle, type); |
| 1122 | if (pObjBindInfo) { |
| 1123 | if (pObjBindInfo->mem) { |
| 1124 | mem = pObjBindInfo->mem; |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 1125 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1126 | log_msg(mdd(dispObj), VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", |
| 1127 | "Trying to get mem binding for object %#" PRIxLEAST64 " but object has no mem binding", handle); |
| 1128 | //print_object_list(object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1129 | } |
Courtney Goeltzenleuchter | e4171f0 | 2015-04-29 10:51:48 -0600 | [diff] [blame] | 1130 | } else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1131 | log_msg(mdd(dispObj), VK_DBG_REPORT_ERROR_BIT, type, handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 1132 | "Trying to get mem binding for object %#" PRIxLEAST64 " but no such object in %s list", handle, (VK_OBJECT_TYPE_IMAGE == type) ? "image" : "buffer"); |
| 1133 | //print_object_list(object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1134 | } |
| 1135 | return mem; |
| 1136 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1137 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1138 | // Print details of MemObjInfo list |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1139 | //static void print_mem_list( |
| 1140 | // VkObject object) |
| 1141 | //{ |
| 1142 | // MT_MEM_OBJ_INFO* pInfo = NULL; |
| 1143 | // // Just printing each msg individually for now, may want to package these into single large print |
| 1144 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1145 | // "MEM INFO : Details of Memory Object list of size %lu elements", memObjMap.size()); |
| 1146 | // |
| 1147 | // if (memObjMap.size() <= 0) |
| 1148 | // return; |
| 1149 | // |
| 1150 | // for (auto ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
| 1151 | // pInfo = &(*ii).second; |
| 1152 | // |
| 1153 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1154 | // " ===MemObjInfo at %p===", (void*)pInfo); |
| 1155 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1156 | // " Mem object: %#" PRIxLEAST64, (void*)pInfo->mem.handle); |
| 1157 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1158 | // " Ref Count: %u", pInfo->refCount); |
| 1159 | // if (0 != pInfo->allocInfo.allocationSize) { |
| 1160 | // string pAllocInfoMsg = vk_print_vkmemoryallocinfo(&pInfo->allocInfo, "{MEM}INFO : "); |
| 1161 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1162 | // " Mem Alloc info:\n%s", pAllocInfoMsg.c_str()); |
| 1163 | // } else { |
| 1164 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1165 | // " Mem Alloc info is NULL (alloc done by vkCreateSwapChainWSI())"); |
| 1166 | // } |
| 1167 | // |
| 1168 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1169 | // " VK OBJECT Binding list of size %lu elements:", pInfo->pObjBindings.size()); |
| 1170 | // if (pInfo->pObjBindings.size() > 0) { |
| 1171 | // for (list<VkObject>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
| 1172 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1173 | // " VK OBJECT %p", (*it)); |
| 1174 | // } |
| 1175 | // } |
| 1176 | // |
| 1177 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1178 | // " VK Command Buffer (CB) binding list of size %lu elements", pInfo->pCmdBufferBindings.size()); |
| 1179 | // if (pInfo->pCmdBufferBindings.size() > 0) |
| 1180 | // { |
| 1181 | // for (list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); it != pInfo->pCmdBufferBindings.end(); ++it) { |
| 1182 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1183 | // " VK CB %p", (*it)); |
| 1184 | // } |
| 1185 | // } |
| 1186 | // } |
| 1187 | //} |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1188 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1189 | //static void printCBList( |
| 1190 | // VkObject object) |
| 1191 | //{ |
| 1192 | // MT_CB_INFO* pCBInfo = NULL; |
| 1193 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1194 | // "Details of CB list of size %lu elements", cbMap.size()); |
| 1195 | // |
| 1196 | // if (cbMap.size() <= 0) |
| 1197 | // return; |
| 1198 | // |
| 1199 | // for (auto ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
| 1200 | // pCBInfo = &(*ii).second; |
| 1201 | // |
| 1202 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1203 | // " CB Info (%p) has CB %p, fenceId %" PRIx64", and fence %#" PRIxLEAST64, |
| 1204 | // (void*)pCBInfo, (void*)pCBInfo->cmdBuffer, pCBInfo->fenceId, |
| 1205 | // pCBInfo->lastSubmittedFence.handle); |
| 1206 | // |
| 1207 | // if (pCBInfo->pMemObjList.size() <= 0) |
| 1208 | // continue; |
| 1209 | // for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
| 1210 | // log_msg(mdd(object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, MEMTRACK_NONE, "MEM", |
| 1211 | // " Mem obj %p", (*it)); |
| 1212 | // } |
| 1213 | // } |
| 1214 | //} |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1215 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1216 | static void init_mem_tracker( |
| 1217 | layer_data *my_data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1218 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1219 | uint32_t report_flags = 0; |
| 1220 | uint32_t debug_action = 0; |
| 1221 | FILE *log_output = NULL; |
| 1222 | const char *option_str; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 1223 | // initialize MemTracker options |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1224 | report_flags = getLayerOptionFlags("MemTrackerReportFlags", 0); |
| 1225 | getLayerOptionEnum("MemTrackerDebugAction", (uint32_t *) &debug_action); |
Tobin Ehlis | ee70223 | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 1226 | |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1227 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 1228 | { |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1229 | option_str = getLayerOption("MemTrackerLogFilename"); |
| 1230 | if (option_str) { |
| 1231 | log_output = fopen(option_str, "w"); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 1232 | } |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1233 | if (log_output == NULL) { |
| 1234 | log_output = stdout; |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1235 | } |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1236 | |
| 1237 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &my_data->logging_callback); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 1238 | } |
| 1239 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1240 | if (!globalLockInitialized) |
| 1241 | { |
| 1242 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1243 | // suggestion is to call this during vkCreateInstance(), and then we |
| 1244 | // can clean it up during vkDestroyInstance(). However, that requires |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1245 | // that the layer have per-instance locks. We need to come back and |
| 1246 | // address this soon. |
| 1247 | loader_platform_thread_create_mutex(&globalLock); |
| 1248 | globalLockInitialized = 1; |
| 1249 | } |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1250 | |
| 1251 | // Zero out memory property data |
| 1252 | memset(&memProps, 0, sizeof(VkPhysicalDeviceMemoryProperties)); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1253 | } |
| 1254 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1255 | // hook DestroyInstance to remove tableInstanceMap entry |
| 1256 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) |
| 1257 | { |
Jeremy Hayes | 35f8afc | 2015-06-18 10:25:55 -0600 | [diff] [blame] | 1258 | // Grab the key before the instance is destroyed. |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1259 | dispatch_key key = get_dispatch_key(instance); |
| 1260 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 1261 | VkResult res = pTable->DestroyInstance(instance); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1262 | |
| 1263 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | 095e677 | 2015-06-16 16:58:52 -0600 | [diff] [blame] | 1264 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1265 | if (my_data->logging_callback) { |
| 1266 | layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback); |
| 1267 | } |
| 1268 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1269 | layer_debug_report_destroy_instance(mid(instance)); |
| 1270 | layer_data_map.erase(pTable); |
| 1271 | |
| 1272 | mem_tracker_instance_table_map.erase(key); |
| 1273 | assert(mem_tracker_instance_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1274 | return res; |
| 1275 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1276 | |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1277 | VkResult VKAPI vkCreateInstance( |
| 1278 | const VkInstanceCreateInfo* pCreateInfo, |
| 1279 | VkInstance* pInstance) |
| 1280 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1281 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, *pInstance); |
Courtney Goeltzenleuchter | d02a964 | 2015-06-08 14:58:39 -0600 | [diff] [blame] | 1282 | VkResult result = pTable->CreateInstance(pCreateInfo, pInstance); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1283 | |
| 1284 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1285 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 1286 | my_data->report_data = debug_report_create_instance( |
| 1287 | pTable, |
| 1288 | *pInstance, |
| 1289 | pCreateInfo->extensionCount, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1290 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 6f48432 | 2015-06-14 11:37:01 -0600 | [diff] [blame] | 1291 | |
| 1292 | init_mem_tracker(my_data); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1293 | } |
| 1294 | return result; |
| 1295 | } |
| 1296 | |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 1297 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 1298 | { |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 1299 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 1300 | my_device_data->wsi_enabled = false; |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 1301 | for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) { |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 1302 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_WSI_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0) |
| 1303 | my_device_data->wsi_enabled = true; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 1304 | } |
| 1305 | } |
| 1306 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1307 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( |
| 1308 | VkPhysicalDevice gpu, |
| 1309 | const VkDeviceCreateInfo *pCreateInfo, |
| 1310 | VkDevice *pDevice) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1311 | { |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 1312 | VkLayerDispatchTable *pDeviceTable = get_dispatch_table(mem_tracker_device_table_map, *pDevice); |
| 1313 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1314 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1315 | 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] | 1316 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 1317 | 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] | 1318 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1319 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1320 | return result; |
| 1321 | } |
| 1322 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1323 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice( |
| 1324 | VkDevice device) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1325 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1326 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1327 | // TODO : Need to set device as srcObj |
| 1328 | // log_msg(mdd(device), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DEVICE, 0, 0, MEMTRACK_NONE, "MEM", |
| 1329 | // "Printing List details prior to vkDestroyDevice()"); |
| 1330 | // print_mem_list(device); |
| 1331 | // printCBList(device); |
| 1332 | // print_object_list(device); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1333 | if (VK_FALSE == delete_cmd_buf_info_list()) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1334 | // TODO : Need to set device as srcObj |
| 1335 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE, 0, 0, MEMTRACK_INTERNAL_ERROR, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1336 | "Issue deleting global CB list in vkDestroyDevice()"); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1337 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 1338 | // Report any memory leaks |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1339 | MT_MEM_OBJ_INFO* pInfo = NULL; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1340 | if (memObjMap.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1341 | for (auto ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
Mike Stroyan | dd7aed7 | 2015-05-19 17:03:40 -0600 | [diff] [blame] | 1342 | pInfo = &(*ii).second; |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1343 | if (pInfo->allocInfo.allocationSize != 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1344 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, pInfo->mem.handle, 0, MEMTRACK_MEMORY_LEAK, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 1345 | "Mem Object %p has not been freed. You should clean up this memory by calling " |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1346 | "vkFreeMemory(%p) prior to vkDestroyDevice().", pInfo->mem, pInfo->mem); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1347 | } |
Mark Lobodzinski | 2f3b19b | 2015-02-18 18:06:24 -0600 | [diff] [blame] | 1348 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 1349 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1350 | // Queues persist until device is destroyed |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1351 | delete_queue_info_list(); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1352 | layer_debug_report_destroy_device(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1353 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1354 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1355 | dispatch_key key = get_dispatch_key(device); |
Courtney Goeltzenleuchter | 89d6844 | 2015-06-13 21:40:22 -0600 | [diff] [blame] | 1356 | #if DISPATCH_MAP_DEBUG |
| 1357 | fprintf(stderr, "Device: %p, key: %p\n", device, key); |
| 1358 | #endif |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 1359 | VkLayerDispatchTable *pDisp = get_dispatch_table(mem_tracker_device_table_map, device); |
| 1360 | VkResult result = pDisp->DestroyDevice(device); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1361 | mem_tracker_device_table_map.erase(key); |
Courtney Goeltzenleuchter | 1010044 | 2015-06-13 21:36:49 -0600 | [diff] [blame] | 1362 | assert(mem_tracker_device_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 1363 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1364 | return result; |
| 1365 | } |
| 1366 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1367 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceMemoryProperties( |
| 1368 | VkPhysicalDevice physicalDevice, |
| 1369 | VkPhysicalDeviceMemoryProperties *pMemoryProperties) |
| 1370 | { |
| 1371 | VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(mem_tracker_instance_table_map, physicalDevice); |
| 1372 | VkResult result = pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); |
| 1373 | if (result == VK_SUCCESS) { |
| 1374 | // copy mem props to local var... |
| 1375 | memcpy(&memProps, pMemoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)); |
| 1376 | } |
| 1377 | return result; |
| 1378 | } |
| 1379 | |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1380 | static const VkLayerProperties mtGlobalLayers[] = { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1381 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1382 | "MemTracker", |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1383 | VK_API_VERSION, |
| 1384 | VK_MAKE_VERSION(0, 1, 0), |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1385 | "Validation layer: MemTracker", |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1386 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1387 | }; |
| 1388 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1389 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1390 | const char *pLayerName, |
| 1391 | uint32_t *pCount, |
| 1392 | VkExtensionProperties* pProperties) |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1393 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1394 | /* Mem tracker does not have any global extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1395 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1396 | } |
| 1397 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1398 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties( |
| 1399 | uint32_t *pCount, |
| 1400 | VkLayerProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1401 | { |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1402 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), |
| 1403 | mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1404 | pCount, pProperties); |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1405 | } |
| 1406 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1407 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1408 | VkPhysicalDevice physicalDevice, |
| 1409 | const char* pLayerName, |
| 1410 | uint32_t* pCount, |
| 1411 | VkExtensionProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 1412 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1413 | /* Mem tracker does not have any physical device extensions */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1414 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1415 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1416 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1417 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties( |
| 1418 | VkPhysicalDevice physicalDevice, |
| 1419 | uint32_t* pCount, |
| 1420 | VkLayerProperties* pProperties) |
| 1421 | { |
| 1422 | /* Mem tracker's physical device layers are the same as global */ |
Courtney Goeltzenleuchter | e748133 | 2015-07-07 10:04:16 -0600 | [diff] [blame] | 1423 | return util_GetLayerProperties(ARRAY_SIZE(mtGlobalLayers), mtGlobalLayers, |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1424 | pCount, pProperties); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1425 | } |
| 1426 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1427 | VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue( |
| 1428 | VkDevice device, |
| 1429 | uint32_t queueNodeIndex, |
| 1430 | uint32_t queueIndex, |
| 1431 | VkQueue *pQueue) |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1432 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1433 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1434 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1435 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1436 | add_queue_info(*pQueue); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1437 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1438 | } |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1439 | return result; |
| 1440 | } |
| 1441 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1442 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( |
| 1443 | VkQueue queue, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1444 | uint32_t cmdBufferCount, |
| 1445 | const VkCmdBuffer *pCmdBuffers, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1446 | VkFence fence) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1447 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1448 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1449 | // TODO : Need to track fence and clear mem references when fence clears |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1450 | MT_CB_INFO* pCBInfo = NULL; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1451 | uint64_t fenceId = add_fence_info(fence, queue); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1452 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1453 | //print_mem_list(queue); |
| 1454 | //printCBList(queue); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1455 | for (uint32_t i = 0; i < cmdBufferCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1456 | pCBInfo = get_cmd_buf_info(pCmdBuffers[i]); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1457 | pCBInfo->fenceId = fenceId; |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 1458 | pCBInfo->lastSubmittedFence = fence; |
| 1459 | pCBInfo->lastSubmittedQueue = queue; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1460 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1461 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1462 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1463 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueSubmit( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 1464 | queue, cmdBufferCount, pCmdBuffers, fence); |
Courtney Goeltzenleuchter | d3fb955 | 2015-04-02 13:39:07 -0600 | [diff] [blame] | 1465 | return result; |
| 1466 | } |
| 1467 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1468 | VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory( |
| 1469 | VkDevice device, |
| 1470 | const VkMemoryAllocInfo *pAllocInfo, |
| 1471 | VkDeviceMemory *pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1472 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1473 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->AllocMemory(device, pAllocInfo, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1474 | // TODO : Track allocations and overall size here |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1475 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 1476 | add_mem_obj_info(device, *pMem, pAllocInfo); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1477 | //print_mem_list(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1478 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1479 | return result; |
| 1480 | } |
| 1481 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1482 | VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory( |
| 1483 | VkDevice device, |
| 1484 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1485 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1486 | /* 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] | 1487 | * freeing a memory object, an application must ensure the memory object is unbound from |
| 1488 | * all API objects referencing it and that it is not referenced by any queued command buffers |
| 1489 | */ |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1490 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 1491 | VkBool32 noerror = freeMemObjInfo(device, mem, false); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1492 | //print_mem_list(device); |
| 1493 | //print_object_list(device); |
| 1494 | //printCBList(device); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1495 | // Output an warning message for proper error/warning handling |
| 1496 | if (noerror == VK_FALSE) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1497 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_FREED_MEM_REF, "MEM", |
| 1498 | "Freeing memory object while it still has references: mem obj %#" PRIxLEAST64, mem.handle); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1499 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1500 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1501 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->FreeMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1502 | return result; |
| 1503 | } |
| 1504 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1505 | VK_LAYER_EXPORT VkResult VKAPI vkMapMemory( |
| 1506 | VkDevice device, |
| 1507 | VkDeviceMemory mem, |
| 1508 | VkDeviceSize offset, |
| 1509 | VkDeviceSize size, |
| 1510 | VkFlags flags, |
| 1511 | void **ppData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1512 | { |
| 1513 | // TODO : Track when memory is mapped |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1514 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1515 | MT_MEM_OBJ_INFO *pMemObj = get_mem_obj_info(mem.handle); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1516 | if ((memProps.memoryTypes[pMemObj->allocInfo.memoryTypeIndex].propertyFlags & |
| 1517 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1518 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE_MEMORY, mem.handle, 0, MEMTRACK_INVALID_STATE, "MEM", |
| 1519 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set: mem obj %#" PRIxLEAST64, mem.handle); |
Mark Lobodzinski | 95152dc | 2015-02-25 12:16:04 -0600 | [diff] [blame] | 1520 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1521 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1522 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1523 | return result; |
| 1524 | } |
| 1525 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1526 | VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory( |
| 1527 | VkDevice device, |
| 1528 | VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1529 | { |
| 1530 | // TODO : Track as memory gets unmapped, do we want to check what changed following map? |
| 1531 | // Make sure that memory was ever mapped to begin with |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1532 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->UnmapMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1533 | return result; |
| 1534 | } |
| 1535 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1536 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyFence(VkDevice device, VkFence fence) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1537 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1538 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1539 | delete_fence_info(fence); |
| 1540 | auto item = fenceMap.find(fence.handle); |
| 1541 | if (item != fenceMap.end()) { |
| 1542 | fenceMap.erase(item); |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1543 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1544 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1545 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyFence(device, fence); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1546 | return result; |
| 1547 | } |
| 1548 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1549 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyBuffer(VkDevice device, VkBuffer buffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1550 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1551 | loader_platform_thread_lock_mutex(&globalLock); |
| 1552 | auto item = bufferMap.find(buffer.handle); |
| 1553 | if (item != bufferMap.end()) { |
| 1554 | bufferMap.erase(item); |
| 1555 | } |
| 1556 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1557 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyBuffer(device, buffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1558 | return result; |
| 1559 | } |
| 1560 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1561 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyImage(VkDevice device, VkImage image) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1562 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1563 | loader_platform_thread_lock_mutex(&globalLock); |
| 1564 | auto item = imageMap.find(image.handle); |
| 1565 | if (item != imageMap.end()) { |
| 1566 | imageMap.erase(item); |
| 1567 | } |
| 1568 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1569 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyImage(device, image); |
| 1570 | return result; |
| 1571 | } |
| 1572 | |
| 1573 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyAttachmentView(VkDevice device, VkAttachmentView attachmentView) |
| 1574 | { |
| 1575 | loader_platform_thread_lock_mutex(&globalLock); |
| 1576 | auto item = attachmentViewMap.find(attachmentView.handle); |
| 1577 | if (item != attachmentViewMap.end()) { |
| 1578 | attachmentViewMap.erase(item); |
| 1579 | } |
| 1580 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1581 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyAttachmentView(device, attachmentView); |
| 1582 | return result; |
| 1583 | } |
| 1584 | |
| 1585 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyImageView(VkDevice device, VkImageView imageView) |
| 1586 | { |
| 1587 | loader_platform_thread_lock_mutex(&globalLock); |
| 1588 | auto item = imageViewMap.find(imageView.handle); |
| 1589 | if (item != imageViewMap.end()) { |
| 1590 | imageViewMap.erase(item); |
| 1591 | } |
| 1592 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1593 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyImageView(device, imageView); |
| 1594 | return result; |
| 1595 | } |
| 1596 | |
| 1597 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyPipeline(VkDevice device, VkPipeline pipeline) |
| 1598 | { |
| 1599 | loader_platform_thread_lock_mutex(&globalLock); |
| 1600 | auto item = pipelineMap.find(pipeline.handle); |
| 1601 | if (item != pipelineMap.end()) { |
| 1602 | pipelineMap.erase(item); |
| 1603 | } |
| 1604 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1605 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyPipeline(device, pipeline); |
| 1606 | return result; |
| 1607 | } |
| 1608 | |
| 1609 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySampler(VkDevice device, VkSampler sampler) |
| 1610 | { |
| 1611 | loader_platform_thread_lock_mutex(&globalLock); |
| 1612 | auto item = samplerMap.find(sampler.handle); |
| 1613 | if (item != samplerMap.end()) { |
| 1614 | samplerMap.erase(item); |
| 1615 | } |
| 1616 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1617 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroySampler(device, sampler); |
| 1618 | return result; |
| 1619 | } |
| 1620 | |
| 1621 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySemaphore(VkDevice device, VkSemaphore semaphore) |
| 1622 | { |
| 1623 | loader_platform_thread_lock_mutex(&globalLock); |
| 1624 | auto item = semaphoreMap.find(semaphore.handle); |
| 1625 | if (item != semaphoreMap.end()) { |
| 1626 | semaphoreMap.erase(item); |
| 1627 | } |
| 1628 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1629 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroySemaphore(device, semaphore); |
| 1630 | return result; |
| 1631 | } |
| 1632 | |
| 1633 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyEvent(VkDevice device, VkEvent event) |
| 1634 | { |
| 1635 | loader_platform_thread_lock_mutex(&globalLock); |
| 1636 | auto item = eventMap.find(event.handle); |
| 1637 | if (item != eventMap.end()) { |
| 1638 | eventMap.erase(item); |
| 1639 | } |
| 1640 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1641 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyEvent(device, event); |
| 1642 | return result; |
| 1643 | } |
| 1644 | |
| 1645 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool) |
| 1646 | { |
| 1647 | loader_platform_thread_lock_mutex(&globalLock); |
| 1648 | auto item = queryPoolMap.find(queryPool.handle); |
| 1649 | if (item != queryPoolMap.end()) { |
| 1650 | queryPoolMap.erase(item); |
| 1651 | } |
| 1652 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1653 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyQueryPool(device, queryPool); |
| 1654 | return result; |
| 1655 | } |
| 1656 | |
| 1657 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyBufferView(VkDevice device, VkBufferView bufferView) |
| 1658 | { |
| 1659 | loader_platform_thread_lock_mutex(&globalLock); |
| 1660 | auto item = bufferViewMap.find(bufferView.handle); |
| 1661 | if (item != bufferViewMap.end()) { |
| 1662 | bufferViewMap.erase(item); |
| 1663 | } |
| 1664 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1665 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyBufferView(device, bufferView); |
| 1666 | return result; |
| 1667 | } |
| 1668 | |
| 1669 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule) |
| 1670 | { |
| 1671 | loader_platform_thread_lock_mutex(&globalLock); |
| 1672 | auto item = shaderModuleMap.find(shaderModule.handle); |
| 1673 | if (item != shaderModuleMap.end()) { |
| 1674 | shaderModuleMap.erase(item); |
| 1675 | } |
| 1676 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1677 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyShaderModule(device, shaderModule); |
| 1678 | return result; |
| 1679 | } |
| 1680 | |
| 1681 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyShader(VkDevice device, VkShader shader) |
| 1682 | { |
| 1683 | loader_platform_thread_lock_mutex(&globalLock); |
| 1684 | auto item = shaderMap.find(shader.handle); |
| 1685 | if (item != shaderMap.end()) { |
| 1686 | shaderMap.erase(item); |
| 1687 | } |
| 1688 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1689 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyShader(device, shader); |
| 1690 | return result; |
| 1691 | } |
| 1692 | |
| 1693 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout) |
| 1694 | { |
| 1695 | loader_platform_thread_lock_mutex(&globalLock); |
| 1696 | auto item = pipelineLayoutMap.find(pipelineLayout.handle); |
| 1697 | if (item != pipelineLayoutMap.end()) { |
| 1698 | pipelineLayoutMap.erase(item); |
| 1699 | } |
| 1700 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1701 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyPipelineLayout(device, pipelineLayout); |
| 1702 | return result; |
| 1703 | } |
| 1704 | |
| 1705 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout) |
| 1706 | { |
| 1707 | loader_platform_thread_lock_mutex(&globalLock); |
| 1708 | auto item = descriptorSetLayoutMap.find(descriptorSetLayout.handle); |
| 1709 | if (item != descriptorSetLayoutMap.end()) { |
| 1710 | descriptorSetLayoutMap.erase(item); |
| 1711 | } |
| 1712 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1713 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDescriptorSetLayout(device, descriptorSetLayout); |
| 1714 | return result; |
| 1715 | } |
| 1716 | |
| 1717 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool) |
| 1718 | { |
| 1719 | loader_platform_thread_lock_mutex(&globalLock); |
| 1720 | auto item = descriptorPoolMap.find(descriptorPool.handle); |
| 1721 | if (item != descriptorPoolMap.end()) { |
| 1722 | descriptorPoolMap.erase(item); |
| 1723 | } |
| 1724 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1725 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool); |
| 1726 | return result; |
| 1727 | } |
| 1728 | |
| 1729 | //VK_LAYER_EXPORT VkResult VKAPI vkDestroyDescriptorSet(VkDevice device, VkDescriptorSet descriptorSet) |
| 1730 | //{ |
| 1731 | // loader_platform_thread_lock_mutex(&globalLock); |
| 1732 | // auto item = descriptorSetMap.find(descriptorSet.handle); |
| 1733 | // if (item != descriptorSetMap.end()) { |
| 1734 | // descriptorSetMap.erase(item); |
| 1735 | // } |
| 1736 | // loader_platform_thread_unlock_mutex(&globalLock); |
| 1737 | // VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDescriptorSet(device, descriptorSet); |
| 1738 | // return result; |
| 1739 | //} |
| 1740 | |
| 1741 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass) |
| 1742 | { |
| 1743 | loader_platform_thread_lock_mutex(&globalLock); |
| 1744 | auto item = renderPassMap.find(renderPass.handle); |
| 1745 | if (item != renderPassMap.end()) { |
| 1746 | renderPassMap.erase(item); |
| 1747 | } |
| 1748 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1749 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyRenderPass(device, renderPass); |
| 1750 | return result; |
| 1751 | } |
| 1752 | |
| 1753 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer) |
| 1754 | { |
| 1755 | loader_platform_thread_lock_mutex(&globalLock); |
| 1756 | auto item = framebufferMap.find(framebuffer.handle); |
| 1757 | if (item != framebufferMap.end()) { |
| 1758 | framebufferMap.erase(item); |
| 1759 | } |
| 1760 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1761 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyFramebuffer(device, framebuffer); |
Tony Barbour | 343d621 | 2015-07-10 18:32:33 -0600 | [diff] [blame] | 1762 | return result; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDynamicViewportState(VkDevice device, VkDynamicViewportState dynamicViewportState) |
| 1766 | { |
| 1767 | loader_platform_thread_lock_mutex(&globalLock); |
| 1768 | auto item = dynamicViewportStateMap.find(dynamicViewportState.handle); |
| 1769 | if (item != dynamicViewportStateMap.end()) { |
| 1770 | dynamicViewportStateMap.erase(item); |
| 1771 | } |
| 1772 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1773 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDynamicViewportState(device, dynamicViewportState); |
| 1774 | return result; |
| 1775 | } |
| 1776 | |
| 1777 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDynamicRasterState(VkDevice device, VkDynamicRasterState dynamicRasterState) |
| 1778 | { |
| 1779 | loader_platform_thread_lock_mutex(&globalLock); |
| 1780 | auto item = dynamicRasterStateMap.find(dynamicRasterState.handle); |
| 1781 | if (item != dynamicRasterStateMap.end()) { |
| 1782 | dynamicRasterStateMap.erase(item); |
| 1783 | } |
| 1784 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1785 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDynamicRasterState(device, dynamicRasterState); |
| 1786 | return result; |
| 1787 | } |
| 1788 | |
| 1789 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDynamicColorBlendState(VkDevice device, VkDynamicColorBlendState dynamicColorBlendState) |
| 1790 | { |
| 1791 | loader_platform_thread_lock_mutex(&globalLock); |
| 1792 | auto item = dynamicColorBlendStateMap.find(dynamicColorBlendState.handle); |
| 1793 | if (item != dynamicColorBlendStateMap.end()) { |
| 1794 | dynamicColorBlendStateMap.erase(item); |
| 1795 | } |
| 1796 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1797 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDynamicColorBlendState(device, dynamicColorBlendState); |
| 1798 | return result; |
| 1799 | } |
| 1800 | |
| 1801 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDynamicDepthStencilState(VkDevice device, VkDynamicDepthStencilState dynamicDepthStencilState) |
| 1802 | { |
| 1803 | loader_platform_thread_lock_mutex(&globalLock); |
| 1804 | auto item = dynamicDepthStencilStateMap.find(dynamicDepthStencilState.handle); |
| 1805 | if (item != dynamicDepthStencilStateMap.end()) { |
| 1806 | dynamicDepthStencilStateMap.erase(item); |
| 1807 | } |
| 1808 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1809 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DestroyDynamicDepthStencilState(device, dynamicDepthStencilState); |
| 1810 | return result; |
| 1811 | } |
| 1812 | |
| 1813 | VkResult VKAPI vkBindBufferMemory( |
| 1814 | VkDevice device, |
| 1815 | VkBuffer buffer, |
| 1816 | VkDeviceMemory mem, |
| 1817 | VkDeviceSize memOffset) |
| 1818 | { |
| 1819 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->BindBufferMemory(device, buffer, mem, memOffset); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1820 | loader_platform_thread_lock_mutex(&globalLock); |
| 1821 | // Track objects tied to memory |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1822 | set_mem_binding(device, mem, buffer.handle, VK_OBJECT_TYPE_BUFFER); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 1823 | add_object_binding_info(buffer.handle, VK_OBJECT_TYPE_BUFFER, mem); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1824 | //print_object_list(device); |
| 1825 | //print_mem_list(device); |
| 1826 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1827 | return result; |
| 1828 | } |
| 1829 | |
| 1830 | VkResult VKAPI vkBindImageMemory( |
| 1831 | VkDevice device, |
| 1832 | VkImage image, |
| 1833 | VkDeviceMemory mem, |
| 1834 | VkDeviceSize memOffset) |
| 1835 | { |
| 1836 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->BindImageMemory(device, image, mem, memOffset); |
| 1837 | loader_platform_thread_lock_mutex(&globalLock); |
| 1838 | // Track objects tied to memory |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1839 | set_mem_binding(device, mem, image.handle, VK_OBJECT_TYPE_IMAGE); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 1840 | add_object_binding_info(image.handle, VK_OBJECT_TYPE_IMAGE, mem); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1841 | //print_object_list(device); |
| 1842 | //print_mem_list(device); |
| 1843 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1844 | return result; |
| 1845 | } |
| 1846 | |
| 1847 | VkResult VKAPI vkGetBufferMemoryRequirements( |
| 1848 | VkDevice device, |
| 1849 | VkBuffer buffer, |
| 1850 | VkMemoryRequirements* pMemoryRequirements) |
| 1851 | { |
| 1852 | // TODO : What to track here? |
| 1853 | // Could potentially save returned mem requirements and validate values passed into BindBufferMemory |
| 1854 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); |
| 1855 | return result; |
| 1856 | } |
| 1857 | |
| 1858 | VkResult VKAPI vkGetImageMemoryRequirements( |
| 1859 | VkDevice device, |
| 1860 | VkImage image, |
| 1861 | VkMemoryRequirements* pMemoryRequirements) |
| 1862 | { |
| 1863 | // TODO : What to track here? |
| 1864 | // Could potentially save returned mem requirements and validate values passed into BindImageMemory |
| 1865 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetImageMemoryRequirements(device, image, pMemoryRequirements); |
| 1866 | return result; |
| 1867 | } |
| 1868 | |
| 1869 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseImageOpaqueMemory( |
| 1870 | VkQueue queue, |
| 1871 | VkImage image, |
| 1872 | uint32_t numBindings, |
| 1873 | const VkSparseMemoryBindInfo* pBindInfo) |
| 1874 | { |
| 1875 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueBindSparseImageOpaqueMemory( |
| 1876 | queue, image, numBindings, pBindInfo); |
| 1877 | loader_platform_thread_lock_mutex(&globalLock); |
| 1878 | // Track objects tied to memory |
| 1879 | if (VK_FALSE == set_sparse_mem_binding(queue, pBindInfo->mem, image.handle, VK_OBJECT_TYPE_IMAGE)) { |
| 1880 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, image.handle, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1881 | "In vkQueueBindSparseImageOpaqueMemory(), unable to set image %#" PRIxLEAST64 " binding to mem obj %#" PRIxLEAST64, image.handle, pBindInfo->mem.handle); |
| 1882 | } |
| 1883 | //print_object_list(queue); |
| 1884 | //print_mem_list(queue); |
| 1885 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1886 | return result; |
| 1887 | } |
| 1888 | |
| 1889 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseImageMemory( |
| 1890 | VkQueue queue, |
| 1891 | VkImage image, |
| 1892 | uint32_t numBindings, |
| 1893 | const VkSparseImageMemoryBindInfo* pBindInfo) |
| 1894 | { |
| 1895 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueBindSparseImageMemory( |
| 1896 | queue, image, numBindings, pBindInfo); |
| 1897 | loader_platform_thread_lock_mutex(&globalLock); |
| 1898 | // Track objects tied to memory |
| 1899 | if (VK_FALSE == set_sparse_mem_binding(queue, pBindInfo->mem, image.handle, VK_OBJECT_TYPE_IMAGE)) { |
| 1900 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, image.handle, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1901 | "In vkQueueBindSparseImageMemory(), unable to set image %#" PRIxLEAST64 " binding to mem obj %#" PRIxLEAST64, image.handle, pBindInfo->mem.handle); |
| 1902 | } |
| 1903 | //print_object_list(queue); |
| 1904 | //print_mem_list(queue); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1905 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1906 | return result; |
| 1907 | } |
| 1908 | |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 1909 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1910 | VkQueue queue, |
| 1911 | VkBuffer buffer, |
| 1912 | uint32_t numBindings, |
| 1913 | const VkSparseMemoryBindInfo* pBindInfo) |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1914 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1915 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueBindSparseBufferMemory( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 1916 | queue, buffer, numBindings, pBindInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1917 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1918 | // Track objects tied to memory |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1919 | if (VK_FALSE == set_sparse_mem_binding(queue, pBindInfo->mem, buffer.handle, VK_OBJECT_TYPE_BUFFER)) { |
| 1920 | log_msg(mdd(queue), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_BUFFER, buffer.handle, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 1921 | "Unable to set object %#" PRIxLEAST64 " binding to mem obj %#" PRIxLEAST64, buffer.handle, pBindInfo->mem.handle); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1922 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1923 | //print_object_list(queue); |
| 1924 | //print_mem_list(queue); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1925 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1926 | return result; |
| 1927 | } |
| 1928 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1929 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFence( |
| 1930 | VkDevice device, |
| 1931 | const VkFenceCreateInfo *pCreateInfo, |
| 1932 | VkFence *pFence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1933 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1934 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateFence(device, pCreateInfo, pFence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1935 | if (VK_SUCCESS == result) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1936 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1937 | MT_FENCE_INFO* pFI = &fenceMap[pFence->handle]; |
| 1938 | memset(pFI, 0, sizeof(MT_FENCE_INFO)); |
| 1939 | memcpy(&(pFI->createInfo), pCreateInfo, sizeof(VkFenceCreateInfo)); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1940 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1941 | } |
| 1942 | return result; |
| 1943 | } |
| 1944 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1945 | VK_LAYER_EXPORT VkResult VKAPI vkResetFences( |
| 1946 | VkDevice device, |
| 1947 | uint32_t fenceCount, |
Courtney Goeltzenleuchter | 2bf8f90 | 2015-06-18 17:28:20 -0600 | [diff] [blame] | 1948 | const VkFence *pFences) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1949 | { |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 1950 | /* |
| 1951 | * TODO: Shouldn't we check for error conditions before passing down the chain? |
| 1952 | * What if reason result is not VK_SUCCESS is something we could report as a validation error? |
| 1953 | */ |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1954 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->ResetFences(device, fenceCount, pFences); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1955 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1956 | loader_platform_thread_lock_mutex(&globalLock); |
| 1957 | // Reset fence state in fenceCreateInfo structure |
| 1958 | for (uint32_t i = 0; i < fenceCount; i++) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1959 | //MT_OBJ_INFO* pObjectInfo = get_object_info(pFences[i].handle); |
| 1960 | auto fence_item = fenceMap.find(pFences[i].handle); |
| 1961 | if (fence_item != fenceMap.end()) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1962 | // Validate fences in SIGNALED state |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1963 | if (!(fence_item->second.createInfo.flags & VK_FENCE_CREATE_SIGNALED_BIT)) { |
| 1964 | log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_FENCE, pFences[i].handle, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 1965 | "Fence %#" PRIxLEAST64 " submitted to VkResetFences in UNSIGNALED STATE", pFences[i].handle); |
| 1966 | result = VK_ERROR_INVALID_VALUE; |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1967 | } |
| 1968 | else { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 1969 | fence_item->second.createInfo.flags = |
| 1970 | static_cast<VkFenceCreateFlags>(fence_item->second.createInfo.flags & ~VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1971 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1972 | } |
| 1973 | } |
| 1974 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1975 | } |
| 1976 | return result; |
| 1977 | } |
| 1978 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1979 | VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus( |
| 1980 | VkDevice device, |
| 1981 | VkFence fence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1982 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 1983 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetFenceStatus(device, fence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1984 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1985 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1986 | update_fence_tracking(fence); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1987 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1988 | } |
| 1989 | return result; |
| 1990 | } |
| 1991 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1992 | VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences( |
| 1993 | VkDevice device, |
| 1994 | uint32_t fenceCount, |
| 1995 | const VkFence *pFences, |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 1996 | VkBool32 waitAll, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 1997 | uint64_t timeout) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1998 | { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1999 | // Verify fence status of submitted fences |
| 2000 | for(uint32_t i = 0; i < fenceCount; i++) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2001 | auto pFenceInfo = fenceMap.find(pFences[i].handle); |
| 2002 | if (pFenceInfo != fenceMap.end()) { |
| 2003 | if (pFenceInfo->second.createInfo.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
| 2004 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_FENCE, pFences[i].handle, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", |
| 2005 | "VkWaitForFences specified fence %#" PRIxLEAST64 " already in SIGNALED state.", pFences[i].handle); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 2006 | } |
| 2007 | } |
| 2008 | } |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2009 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2010 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 2011 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2012 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 2013 | if (waitAll || fenceCount == 1) { // Clear all the fences |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2014 | for(uint32_t i = 0; i < fenceCount; i++) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2015 | update_fence_tracking(pFences[i]); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2016 | } |
| 2017 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2018 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2019 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2020 | return result; |
| 2021 | } |
| 2022 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2023 | VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle( |
| 2024 | VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2025 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2026 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, queue)->QueueWaitIdle(queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2027 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2028 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2029 | retire_queue_fences(queue); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2030 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2031 | } |
| 2032 | return result; |
| 2033 | } |
| 2034 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2035 | VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle( |
| 2036 | VkDevice device) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2037 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2038 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->DeviceWaitIdle(device); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2039 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2040 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2041 | retire_device_fences(device); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2042 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2043 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2044 | return result; |
| 2045 | } |
| 2046 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2047 | VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent( |
| 2048 | VkDevice device, |
| 2049 | const VkEventCreateInfo *pCreateInfo, |
| 2050 | VkEvent *pEvent) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2051 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2052 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateEvent(device, pCreateInfo, pEvent); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2053 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2054 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2055 | add_object_create_info(pEvent->handle, VK_OBJECT_TYPE_EVENT, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2056 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 2057 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2058 | return result; |
| 2059 | } |
| 2060 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2061 | VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool( |
| 2062 | VkDevice device, |
| 2063 | const VkQueryPoolCreateInfo *pCreateInfo, |
| 2064 | VkQueryPool *pQueryPool) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2065 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2066 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateQueryPool(device, pCreateInfo, pQueryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2067 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2068 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2069 | add_object_create_info(pQueryPool->handle, VK_OBJECT_TYPE_QUERY_POOL, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2070 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 2071 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2072 | return result; |
| 2073 | } |
| 2074 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2075 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer( |
| 2076 | VkDevice device, |
| 2077 | const VkBufferCreateInfo *pCreateInfo, |
| 2078 | VkBuffer *pBuffer) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 2079 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2080 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateBuffer(device, pCreateInfo, pBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2081 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2082 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2083 | add_object_create_info(pBuffer->handle, VK_OBJECT_TYPE_BUFFER, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2084 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 2085 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 2086 | return result; |
| 2087 | } |
| 2088 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2089 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView( |
| 2090 | VkDevice device, |
| 2091 | const VkBufferViewCreateInfo *pCreateInfo, |
| 2092 | VkBufferView *pView) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 2093 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2094 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateBufferView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2095 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2096 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2097 | add_object_create_info(pView->handle, VK_OBJECT_TYPE_BUFFER_VIEW, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2098 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 2099 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 2100 | return result; |
| 2101 | } |
| 2102 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2103 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage( |
| 2104 | VkDevice device, |
| 2105 | const VkImageCreateInfo *pCreateInfo, |
| 2106 | VkImage *pImage) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2107 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2108 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateImage(device, pCreateInfo, pImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2109 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2110 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2111 | add_object_create_info(pImage->handle, VK_OBJECT_TYPE_IMAGE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2112 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2113 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2114 | return result; |
| 2115 | } |
| 2116 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2117 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView( |
| 2118 | VkDevice device, |
| 2119 | const VkImageViewCreateInfo *pCreateInfo, |
| 2120 | VkImageView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2121 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2122 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateImageView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2123 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2124 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2125 | add_object_create_info(pView->handle, VK_OBJECT_TYPE_IMAGE_VIEW, pCreateInfo); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2126 | // Validate that img has correct usage flags set |
| 2127 | validate_image_usage_flags(device, pCreateInfo->image, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, |
| 2128 | false, "vkCreateImageView()", "VK_IMAGE_USAGE_[SAMPLED|STORAGE]_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2129 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2130 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2131 | return result; |
| 2132 | } |
| 2133 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 2134 | VK_LAYER_EXPORT VkResult VKAPI vkCreateAttachmentView( |
Tobin Ehlis | c0ff3e0 | 2015-07-13 13:42:25 -0600 | [diff] [blame] | 2135 | VkDevice device, |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 2136 | const VkAttachmentViewCreateInfo *pCreateInfo, |
| 2137 | VkAttachmentView *pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2138 | { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 2139 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateAttachmentView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2140 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2141 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2142 | add_object_create_info(pView->handle, VK_OBJECT_TYPE_ATTACHMENT_VIEW, pCreateInfo); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2143 | // Validate that img has correct usage flags set |
| 2144 | // We don't use the image helper function here as it's a special case that checks struct type |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2145 | MT_OBJ_BINDING_INFO* pInfo = get_object_binding_info(pCreateInfo->image.handle, VK_OBJECT_TYPE_IMAGE); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2146 | if (pInfo) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2147 | if (VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pInfo->create_info.image.sType) { |
Tobin Ehlis | c0ff3e0 | 2015-07-13 13:42:25 -0600 | [diff] [blame] | 2148 | // TODO : Now that this is generalized for all Attachments, need to only check COLOR or DS USAGE bits |
| 2149 | // if/when we know that Image being attached to is Color or DS. Can probably do this for DS based on format |
| 2150 | // validate_usage_flags(device, pInfo->create_info.image.usage, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, true, |
| 2151 | // pCreateInfo->image.handle, VK_OBJECT_TYPE_IMAGE, "image", "vkCreateAttachmentView()", "VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT"); |
Tony Barbour | 791646c | 2015-07-13 16:37:21 -0600 | [diff] [blame] | 2152 | }// else if (VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI == pInfo->create_info.swapchain.sType) { |
| 2153 | // validate_usage_flags(device, pInfo->create_info.swapchain.imageUsageFlags, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, true, |
| 2154 | // pCreateInfo->image.handle, VK_OBJECT_TYPE_IMAGE, "image", "vkCreateAttachmentView()", "VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT"); |
| 2155 | //} |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2156 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2157 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2158 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2159 | return result; |
| 2160 | } |
| 2161 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2162 | VK_LAYER_EXPORT VkResult VKAPI vkCreateShader( |
| 2163 | VkDevice device, |
| 2164 | const VkShaderCreateInfo *pCreateInfo, |
| 2165 | VkShader *pShader) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2166 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2167 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateShader(device, pCreateInfo, pShader); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2168 | if (result == VK_SUCCESS) { |
| 2169 | loader_platform_thread_lock_mutex(&globalLock); |
| 2170 | add_object_create_info(pShader->handle, VK_OBJECT_TYPE_SHADER, pCreateInfo); |
| 2171 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2172 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2173 | return result; |
| 2174 | } |
| 2175 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2176 | //TODO do we need to intercept pipelineCache functions to track objects? |
| 2177 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelines( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2178 | VkDevice device, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2179 | VkPipelineCache pipelineCache, |
| 2180 | uint32_t count, |
| 2181 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 2182 | VkPipeline *pPipelines) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2183 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2184 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pPipelines); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2185 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2186 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2187 | /* TODO: pPipelines is now an array of pipelines */ |
| 2188 | add_object_create_info(pPipelines->handle, VK_OBJECT_TYPE_PIPELINE, &pCreateInfos[0]); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2189 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2190 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2191 | return result; |
| 2192 | } |
| 2193 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2194 | VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipelines( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2195 | VkDevice device, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2196 | VkPipelineCache pipelineCache, |
| 2197 | uint32_t count, |
| 2198 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2199 | VkPipeline *pPipelines) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2200 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2201 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateComputePipelines(device, pipelineCache, count, pCreateInfos, pPipelines); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2202 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2203 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2204 | /* TODO: pPipelines is now an array of pipelines */ |
| 2205 | add_object_create_info(pPipelines->handle, VK_OBJECT_TYPE_PIPELINE, &pCreateInfos[0]); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2206 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2207 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2208 | return result; |
| 2209 | } |
| 2210 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2211 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler( |
| 2212 | VkDevice device, |
| 2213 | const VkSamplerCreateInfo *pCreateInfo, |
| 2214 | VkSampler *pSampler) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2215 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2216 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateSampler(device, pCreateInfo, pSampler); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2217 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2218 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2219 | add_object_create_info(pSampler->handle, VK_OBJECT_TYPE_SAMPLER, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2220 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2221 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2222 | return result; |
| 2223 | } |
| 2224 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2225 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState( |
| 2226 | VkDevice device, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2227 | const VkDynamicViewportStateCreateInfo *pCreateInfo, |
| 2228 | VkDynamicViewportState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2229 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2230 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicViewportState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2231 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2232 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2233 | add_object_create_info(pState->handle, VK_OBJECT_TYPE_DYNAMIC_VIEWPORT_STATE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2234 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2235 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2236 | return result; |
| 2237 | } |
| 2238 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2239 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState( |
| 2240 | VkDevice device, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2241 | const VkDynamicRasterStateCreateInfo *pCreateInfo, |
| 2242 | VkDynamicRasterState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2243 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2244 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicRasterState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2245 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2246 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2247 | add_object_create_info(pState->handle, VK_OBJECT_TYPE_DYNAMIC_RASTER_STATE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2248 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2249 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2250 | return result; |
| 2251 | } |
| 2252 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2253 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState( |
| 2254 | VkDevice device, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2255 | const VkDynamicColorBlendStateCreateInfo *pCreateInfo, |
| 2256 | VkDynamicColorBlendState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2257 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2258 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2259 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2260 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2261 | add_object_create_info(pState->handle, VK_OBJECT_TYPE_DYNAMIC_COLOR_BLEND_STATE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2262 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2263 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2264 | return result; |
| 2265 | } |
| 2266 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2267 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState( |
| 2268 | VkDevice device, |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2269 | const VkDynamicDepthStencilStateCreateInfo *pCreateInfo, |
| 2270 | VkDynamicDepthStencilState *pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2271 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2272 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2273 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2274 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2275 | add_object_create_info(pState->handle, VK_OBJECT_TYPE_DYNAMIC_DEPTH_STENCIL_STATE, pCreateInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2276 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 2277 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2278 | return result; |
| 2279 | } |
| 2280 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2281 | VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer( |
| 2282 | VkDevice device, |
| 2283 | const VkCmdBufferCreateInfo *pCreateInfo, |
| 2284 | VkCmdBuffer *pCmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2285 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2286 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 2287 | // 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] | 2288 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2289 | if (*pCmdBuffer) |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2290 | add_cmd_buf_info(*pCmdBuffer); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2291 | //printCBList(device); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2292 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2293 | return result; |
| 2294 | } |
| 2295 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2296 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer( |
| 2297 | VkCmdBuffer cmdBuffer, |
| 2298 | const VkCmdBufferBeginInfo *pBeginInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2299 | { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2300 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2301 | // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2302 | if (!checkCBCompleted(cmdBuffer)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2303 | // TODO : want cmdBuffer to be srcObj here |
| 2304 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2305 | "Calling vkBeginCommandBuffer() on active CB %p before it has completed. " |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2306 | "You must check CB flag before this call.", cmdBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2307 | } |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2308 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2309 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2310 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2311 | clear_cmd_buf_and_mem_references(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2312 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2313 | return result; |
| 2314 | } |
| 2315 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2316 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer( |
| 2317 | VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2318 | { |
| 2319 | // TODO : Anything to do here? |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2320 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->EndCommandBuffer(cmdBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2321 | return result; |
| 2322 | } |
| 2323 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2324 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer( |
Cody Northrop | e62183e | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 2325 | VkCmdBuffer cmdBuffer, |
| 2326 | VkCmdBufferResetFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2327 | { |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2328 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2329 | // Verify that CB is complete (not in-flight) |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2330 | if (!checkCBCompleted(cmdBuffer)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2331 | // TODO : Want cmdBuffer to be srcObj here |
| 2332 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2333 | "Resetting CB %p before it has completed. You must check CB flag before " |
Mike Stroyan | 950496e | 2015-05-19 15:16:08 -0600 | [diff] [blame] | 2334 | "calling vkResetCommandBuffer().", cmdBuffer); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 2335 | } |
| 2336 | // Clear memory references as this point. |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2337 | clear_cmd_buf_and_mem_references(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2338 | loader_platform_thread_unlock_mutex(&globalLock); |
Cody Northrop | e62183e | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 2339 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->ResetCommandBuffer(cmdBuffer, flags); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2340 | return result; |
| 2341 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2342 | // TODO : For any vkCmdBind* calls that include an object which has mem bound to it, |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2343 | // need to account for that mem now having binding to given cmdBuffer |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2344 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline( |
| 2345 | VkCmdBuffer cmdBuffer, |
| 2346 | VkPipelineBindPoint pipelineBindPoint, |
| 2347 | VkPipeline pipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2348 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2349 | #if 0 |
| 2350 | // TODO : If memory bound to pipeline, then need to tie that mem to cmdBuffer |
| 2351 | if (getPipeline(pipeline)) { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2352 | MT_CB_INFO *pCBInfo = get_cmd_buf_info(cmdBuffer); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 2353 | if (pCBInfo) { |
| 2354 | pCBInfo->pipelines[pipelineBindPoint] = pipeline; |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2355 | } else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2356 | "Attempt to bind Pipeline %p to non-existant command buffer %p!", (void*)pipeline, cmdBuffer); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2357 | layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_INVALID_CB, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2358 | } |
| 2359 | } |
| 2360 | else { |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2361 | "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2362 | 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] | 2363 | } |
| 2364 | #endif |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2365 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2366 | } |
| 2367 | |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2368 | void VKAPI vkCmdBindDynamicViewportState( |
| 2369 | VkCmdBuffer cmdBuffer, |
| 2370 | VkDynamicViewportState dynamicViewportState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2371 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2372 | VkDynamicViewportStateCreateInfo* pCI; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2373 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2374 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(cmdBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2375 | if (!pCmdBuf) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2376 | // TODO : Want cmdBuffer to be srcObj here |
| 2377 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2378 | "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2379 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2380 | pCI = (VkDynamicViewportStateCreateInfo*)get_object_create_info(dynamicViewportState.handle, VK_OBJECT_TYPE_DYNAMIC_VIEWPORT_STATE); |
| 2381 | if (!pCI) { |
| 2382 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DYNAMIC_VIEWPORT_STATE, dynamicViewportState.handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 2383 | "Unable to find dynamic viewport state object %#" PRIxLEAST64 ", was it ever created?", dynamicViewportState.handle); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2384 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2385 | pCmdBuf->pLastBoundDynamicState[VK_STATE_BIND_POINT_VIEWPORT] = dynamicViewportState.handle; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2386 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2387 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDynamicViewportState(cmdBuffer, dynamicViewportState); |
| 2388 | } |
| 2389 | |
| 2390 | void VKAPI vkCmdBindDynamicRasterState( |
| 2391 | VkCmdBuffer cmdBuffer, |
| 2392 | VkDynamicRasterState dynamicRasterState) |
| 2393 | { |
| 2394 | VkDynamicRasterStateCreateInfo* pCI; |
| 2395 | loader_platform_thread_lock_mutex(&globalLock); |
| 2396 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(cmdBuffer); |
| 2397 | if (!pCmdBuf) { |
| 2398 | // TODO : Want cmdBuffer to be srcObj here |
| 2399 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
| 2400 | "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
| 2401 | } |
| 2402 | pCI = (VkDynamicRasterStateCreateInfo*)get_object_create_info(dynamicRasterState.handle, VK_OBJECT_TYPE_DYNAMIC_RASTER_STATE); |
| 2403 | if (!pCI) { |
| 2404 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DYNAMIC_RASTER_STATE, dynamicRasterState.handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 2405 | "Unable to find dynamic raster state object %#" PRIxLEAST64 ", was it ever created?", dynamicRasterState.handle); |
| 2406 | } |
| 2407 | pCmdBuf->pLastBoundDynamicState[VK_STATE_BIND_POINT_RASTER] = dynamicRasterState.handle; |
| 2408 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2409 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDynamicRasterState(cmdBuffer, dynamicRasterState); |
| 2410 | } |
| 2411 | |
| 2412 | void VKAPI vkCmdBindDynamicColorBlendState( |
| 2413 | VkCmdBuffer cmdBuffer, |
| 2414 | VkDynamicColorBlendState dynamicColorBlendState) |
| 2415 | { |
| 2416 | VkDynamicColorBlendStateCreateInfo* pCI; |
| 2417 | loader_platform_thread_lock_mutex(&globalLock); |
| 2418 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(cmdBuffer); |
| 2419 | if (!pCmdBuf) { |
| 2420 | // TODO : Want cmdBuffer to be srcObj here |
| 2421 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
| 2422 | "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
| 2423 | } |
| 2424 | pCI = (VkDynamicColorBlendStateCreateInfo*)get_object_create_info(dynamicColorBlendState.handle, VK_OBJECT_TYPE_DYNAMIC_COLOR_BLEND_STATE); |
| 2425 | if (!pCI) { |
| 2426 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DYNAMIC_COLOR_BLEND_STATE, dynamicColorBlendState.handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 2427 | "Unable to find dynamic raster state object %#" PRIxLEAST64 ", was it ever created?", dynamicColorBlendState.handle); |
| 2428 | } |
| 2429 | pCmdBuf->pLastBoundDynamicState[VK_STATE_BIND_POINT_COLOR_BLEND] = dynamicColorBlendState.handle; |
| 2430 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2431 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDynamicColorBlendState(cmdBuffer, dynamicColorBlendState); |
| 2432 | } |
| 2433 | |
| 2434 | void VKAPI vkCmdBindDynamicDepthStencilState( |
| 2435 | VkCmdBuffer cmdBuffer, |
| 2436 | VkDynamicDepthStencilState dynamicDepthStencilState) |
| 2437 | { |
| 2438 | VkDynamicDepthStencilStateCreateInfo* pCI; |
| 2439 | loader_platform_thread_lock_mutex(&globalLock); |
| 2440 | MT_CB_INFO *pCmdBuf = get_cmd_buf_info(cmdBuffer); |
| 2441 | if (!pCmdBuf) { |
| 2442 | // TODO : Want cmdBuffer to be srcObj here |
| 2443 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_INVALID_CB, "MEM", |
| 2444 | "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
| 2445 | } |
| 2446 | pCI = (VkDynamicDepthStencilStateCreateInfo*)get_object_create_info(dynamicDepthStencilState.handle, VK_OBJECT_TYPE_DYNAMIC_DEPTH_STENCIL_STATE); |
| 2447 | if (!pCI) { |
| 2448 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DYNAMIC_DEPTH_STENCIL_STATE, dynamicDepthStencilState.handle, 0, MEMTRACK_INVALID_OBJECT, "MEM", |
| 2449 | "Unable to find dynamic raster state object %#" PRIxLEAST64 ", was it ever created?", dynamicDepthStencilState.handle); |
| 2450 | } |
| 2451 | pCmdBuf->pLastBoundDynamicState[VK_STATE_BIND_POINT_DEPTH_STENCIL] = dynamicDepthStencilState.handle; |
| 2452 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2453 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDynamicDepthStencilState(cmdBuffer, dynamicDepthStencilState); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2454 | } |
| 2455 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2456 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2457 | VkCmdBuffer cmdBuffer, |
| 2458 | VkPipelineBindPoint pipelineBindPoint, |
Mark Lobodzinski | f2093b6 | 2015-06-15 13:21:21 -0600 | [diff] [blame] | 2459 | VkPipelineLayout layout, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2460 | uint32_t firstSet, |
| 2461 | uint32_t setCount, |
| 2462 | const VkDescriptorSet *pDescriptorSets, |
| 2463 | uint32_t dynamicOffsetCount, |
| 2464 | const uint32_t *pDynamicOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2465 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 2466 | // TODO : Somewhere need to verify that all textures referenced by shaders in DS are in some type of *SHADER_READ* state |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2467 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindDescriptorSets( |
Mark Lobodzinski | f2093b6 | 2015-06-15 13:21:21 -0600 | [diff] [blame] | 2468 | cmdBuffer, pipelineBindPoint, layout, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2469 | } |
| 2470 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2471 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2472 | VkCmdBuffer cmdBuffer, |
| 2473 | uint32_t startBinding, |
| 2474 | uint32_t bindingCount, |
| 2475 | const VkBuffer *pBuffers, |
| 2476 | const VkDeviceSize *pOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2477 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2478 | // TODO : Somewhere need to verify that VBs have correct usage state flagged |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2479 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Chia-I Wu | 1915682 | 2015-01-05 13:42:56 +0800 | [diff] [blame] | 2480 | } |
| 2481 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2482 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer( |
| 2483 | VkCmdBuffer cmdBuffer, |
| 2484 | VkBuffer buffer, |
| 2485 | VkDeviceSize offset, |
| 2486 | VkIndexType indexType) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2487 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2488 | // TODO : Somewhere need to verify that IBs have correct usage state flagged |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2489 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2490 | } |
| 2491 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2492 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect( |
| 2493 | VkCmdBuffer cmdBuffer, |
| 2494 | VkBuffer buffer, |
| 2495 | VkDeviceSize offset, |
| 2496 | uint32_t count, |
| 2497 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2498 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2499 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2500 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2501 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2502 | // TODO : Want cmdBuffer to be srcObj here |
| 2503 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2504 | "In vkCmdDrawIndirect() call unable to update binding of buffer %#" PRIxLEAST64 " to cmdBuffer %p", buffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2505 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2506 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2507 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2508 | } |
| 2509 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2510 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect( |
| 2511 | VkCmdBuffer cmdBuffer, |
| 2512 | VkBuffer buffer, |
| 2513 | VkDeviceSize offset, |
| 2514 | uint32_t count, |
| 2515 | uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2516 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2517 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2518 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2519 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2520 | // TODO : Want cmdBuffer to be srcObj here |
| 2521 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2522 | "In vkCmdDrawIndexedIndirect() call unable to update binding of buffer %#" PRIxLEAST64 " to cmdBuffer %p", buffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2523 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2524 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2525 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2526 | } |
| 2527 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2528 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect( |
| 2529 | VkCmdBuffer cmdBuffer, |
| 2530 | VkBuffer buffer, |
| 2531 | VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2532 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2533 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2534 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, buffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2535 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2536 | // TODO : Want cmdBuffer to be srcObj here |
| 2537 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2538 | "In vkCmdDispatchIndirect() call unable to update binding of buffer %#" PRIxLEAST64 " to cmdBuffer %p", buffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2539 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2540 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2541 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdDispatchIndirect(cmdBuffer, buffer, offset); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2542 | } |
| 2543 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2544 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer( |
| 2545 | VkCmdBuffer cmdBuffer, |
| 2546 | VkBuffer srcBuffer, |
| 2547 | VkBuffer destBuffer, |
| 2548 | uint32_t regionCount, |
| 2549 | const VkBufferCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2550 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2551 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2552 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2553 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2554 | // TODO : Want cmdBuffer to be srcObj here |
| 2555 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2556 | "In vkCmdCopyBuffer() call unable to update binding of srcBuffer %#" PRIxLEAST64 " to cmdBuffer %p", srcBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2557 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2558 | mem = get_mem_binding_from_object(cmdBuffer, destBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2559 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2560 | // TODO : Want cmdBuffer to be srcObj here |
| 2561 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2562 | "In vkCmdCopyBuffer() call unable to update binding of destBuffer %#" PRIxLEAST64 " to cmdBuffer %p", destBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2563 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2564 | // Validate that SRC & DST buffers have correct usage flags set |
| 2565 | validate_buffer_usage_flags(cmdBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT"); |
| 2566 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2567 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2568 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2569 | } |
| 2570 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2571 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage( |
| 2572 | VkCmdBuffer cmdBuffer, |
| 2573 | VkImage srcImage, |
| 2574 | VkImageLayout srcImageLayout, |
| 2575 | VkImage destImage, |
| 2576 | VkImageLayout destImageLayout, |
| 2577 | uint32_t regionCount, |
| 2578 | const VkImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2579 | { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2580 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2581 | // Validate that src & dst images have correct usage flags set |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2582 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage.handle, VK_OBJECT_TYPE_IMAGE); |
| 2583 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2584 | // TODO : Want cmdBuffer to be srcObj here |
| 2585 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2586 | "In vkCmdCopyImage() call unable to update binding of srcImage %#" PRIxLEAST64 " to cmdBuffer %p", srcImage.handle, cmdBuffer); |
| 2587 | } |
| 2588 | mem = get_mem_binding_from_object(cmdBuffer, destImage.handle, VK_OBJECT_TYPE_IMAGE); |
| 2589 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2590 | // TODO : Want cmdBuffer to be srcObj here |
| 2591 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2592 | "In vkCmdCopyImage() call unable to update binding of destImage %#" PRIxLEAST64 " to cmdBuffer %p", destImage.handle, cmdBuffer); |
| 2593 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2594 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 2595 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
| 2596 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2597 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2598 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2599 | } |
| 2600 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2601 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage( |
| 2602 | VkCmdBuffer cmdBuffer, |
| 2603 | VkImage srcImage, |
| 2604 | VkImageLayout srcImageLayout, |
| 2605 | VkImage destImage, |
| 2606 | VkImageLayout destImageLayout, |
| 2607 | uint32_t regionCount, |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 2608 | const VkImageBlit *pRegions, |
| 2609 | VkTexFilter filter) |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 2610 | { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2611 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2612 | // Validate that src & dst images have correct usage flags set |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2613 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage.handle, VK_OBJECT_TYPE_IMAGE); |
| 2614 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2615 | // TODO : Want cmdBuffer to be srcObj here |
| 2616 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2617 | "In vkCmdBlitImage() call unable to update binding of srcImage %#" PRIxLEAST64 " to cmdBuffer %p", srcImage.handle, cmdBuffer); |
| 2618 | } |
| 2619 | mem = get_mem_binding_from_object(cmdBuffer, destImage.handle, VK_OBJECT_TYPE_IMAGE); |
| 2620 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2621 | // TODO : Want cmdBuffer to be srcObj here |
| 2622 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2623 | "In vkCmdBlitImage() call unable to update binding of destImage %#" PRIxLEAST64 " to cmdBuffer %p", destImage.handle, cmdBuffer); |
| 2624 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2625 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 2626 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
| 2627 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2628 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBlitImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2629 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter); |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 2630 | } |
| 2631 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2632 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage( |
| 2633 | VkCmdBuffer cmdBuffer, |
| 2634 | VkBuffer srcBuffer, |
| 2635 | VkImage destImage, |
| 2636 | VkImageLayout destImageLayout, |
| 2637 | uint32_t regionCount, |
| 2638 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2639 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2640 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2641 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destImage.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2642 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2643 | // TODO : Want cmdBuffer to be srcObj here |
| 2644 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2645 | "In vkCmdCopyMemoryToImage() call unable to update binding of destImage %#" PRIxLEAST64 " to cmdBuffer %p", destImage.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2646 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2647 | mem = get_mem_binding_from_object(cmdBuffer, srcBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2648 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2649 | // TODO : Want cmdBuffer to be srcObj here |
| 2650 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2651 | "In vkCmdCopyMemoryToImage() call unable to update binding of srcBuffer %#" PRIxLEAST64 " to cmdBuffer %p", srcBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2652 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2653 | // Validate that src buff & dst image have correct usage flags set |
| 2654 | validate_buffer_usage_flags(cmdBuffer, srcBuffer, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyBufferToImage()", "VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT"); |
| 2655 | validate_image_usage_flags(cmdBuffer, destImage, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyBufferToImage()", "VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2656 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2657 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyBufferToImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2658 | cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2659 | } |
| 2660 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2661 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer( |
| 2662 | VkCmdBuffer cmdBuffer, |
| 2663 | VkImage srcImage, |
| 2664 | VkImageLayout srcImageLayout, |
| 2665 | VkBuffer destBuffer, |
| 2666 | uint32_t regionCount, |
| 2667 | const VkBufferImageCopy *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2668 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2669 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2670 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2671 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2672 | // TODO : Want cmdBuffer to be srcObj here |
| 2673 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2674 | "In vkCmdCopyImageToMemory() call unable to update binding of srcImage buffer %#" PRIxLEAST64 " to cmdBuffer %p", srcImage.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2675 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2676 | mem = get_mem_binding_from_object(cmdBuffer, destBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2677 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2678 | // TODO : Want cmdBuffer to be srcObj here |
| 2679 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2680 | "In vkCmdCopyImageToMemory() call unable to update binding of destBuffer %#" PRIxLEAST64 " to cmdBuffer %p", destBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2681 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2682 | // Validate that dst buff & src image have correct usage flags set |
| 2683 | validate_image_usage_flags(cmdBuffer, srcImage, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT, true, "vkCmdCopyImageToBuffer()", "VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT"); |
| 2684 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdCopyImageToBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2685 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2686 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdCopyImageToBuffer( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2687 | cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2688 | } |
| 2689 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2690 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer( |
| 2691 | VkCmdBuffer cmdBuffer, |
| 2692 | VkBuffer destBuffer, |
| 2693 | VkDeviceSize destOffset, |
| 2694 | VkDeviceSize dataSize, |
| 2695 | const uint32_t *pData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2696 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2697 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2698 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2699 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2700 | // TODO : Want cmdBuffer to be srcObj here |
| 2701 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2702 | "In vkCmdUpdateMemory() call unable to update binding of destBuffer %#" PRIxLEAST64 " to cmdBuffer %p", destBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2703 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2704 | // Validate that dst buff has correct usage flags set |
| 2705 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdUpdateBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2706 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2707 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2708 | } |
| 2709 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2710 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer( |
| 2711 | VkCmdBuffer cmdBuffer, |
| 2712 | VkBuffer destBuffer, |
| 2713 | VkDeviceSize destOffset, |
| 2714 | VkDeviceSize fillSize, |
| 2715 | uint32_t data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2716 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2717 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2718 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, destBuffer.handle, VK_OBJECT_TYPE_BUFFER); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2719 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2720 | // TODO : Want cmdBuffer to be srcObj here |
| 2721 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2722 | "In vkCmdFillMemory() call unable to update binding of destBuffer %#" PRIxLEAST64 " to cmdBuffer %p", destBuffer.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2723 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2724 | // Validate that dst buff has correct usage flags set |
| 2725 | validate_buffer_usage_flags(cmdBuffer, destBuffer, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT, true, "vkCmdFillBuffer()", "VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2726 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2727 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2728 | } |
| 2729 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2730 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
| 2731 | VkCmdBuffer cmdBuffer, |
| 2732 | VkImage image, |
| 2733 | VkImageLayout imageLayout, |
Chris Forbes | f0796e1 | 2015-06-24 14:34:53 +1200 | [diff] [blame] | 2734 | const VkClearColorValue *pColor, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2735 | uint32_t rangeCount, |
| 2736 | const VkImageSubresourceRange *pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2737 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2738 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2739 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2740 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, image.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2741 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2742 | // TODO : Want cmdBuffer to be srcObj here |
| 2743 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2744 | "In vkCmdClearColorImage() call unable to update binding of image buffer %#" PRIxLEAST64 " to cmdBuffer %p", image.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2745 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2746 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2747 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2748 | } |
| 2749 | |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 2750 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage( |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2751 | VkCmdBuffer cmdBuffer, |
| 2752 | VkImage image, |
| 2753 | VkImageLayout imageLayout, |
| 2754 | float depth, |
| 2755 | uint32_t stencil, |
| 2756 | uint32_t rangeCount, |
| 2757 | const VkImageSubresourceRange *pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2758 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2759 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2760 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2761 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, image.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2762 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2763 | // TODO : Want cmdBuffer to be srcObj here |
| 2764 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2765 | "In vkCmdClearDepthStencil() call unable to update binding of image buffer %#" PRIxLEAST64 " to cmdBuffer %p", image.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2766 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2767 | loader_platform_thread_unlock_mutex(&globalLock); |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 2768 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdClearDepthStencilImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2769 | cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2770 | } |
| 2771 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2772 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage( |
| 2773 | VkCmdBuffer cmdBuffer, |
| 2774 | VkImage srcImage, |
| 2775 | VkImageLayout srcImageLayout, |
| 2776 | VkImage destImage, |
| 2777 | VkImageLayout destImageLayout, |
| 2778 | uint32_t regionCount, |
| 2779 | const VkImageResolve *pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2780 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2781 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2782 | VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, srcImage.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2783 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2784 | // TODO : Want cmdBuffer to be srcObj here |
| 2785 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2786 | "In vkCmdResolveImage() call unable to update binding of srcImage buffer %#" PRIxLEAST64 " to cmdBuffer %p", srcImage.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2787 | } |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2788 | mem = get_mem_binding_from_object(cmdBuffer, destImage.handle, VK_OBJECT_TYPE_IMAGE); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2789 | if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2790 | // TODO : Want cmdBuffer to be srcObj here |
| 2791 | log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2792 | "In vkCmdResolveImage() call unable to update binding of destImage buffer %#" PRIxLEAST64 " to cmdBuffer %p", destImage.handle, cmdBuffer); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2793 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 2794 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2795 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdResolveImage( |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2796 | cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2797 | } |
| 2798 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2799 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery( |
| 2800 | VkCmdBuffer cmdBuffer, |
| 2801 | VkQueryPool queryPool, |
| 2802 | uint32_t slot, |
| 2803 | VkFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2804 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2805 | // loader_platform_thread_lock_mutex(&globalLock); |
| 2806 | // VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
| 2807 | // if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2808 | // log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2809 | // "In vkCmdBeginQuery() call unable to update binding of queryPool buffer %#" PRIxLEAST64 " to cmdBuffer %p", queryPool.handle, cmdBuffer); |
| 2810 | // } |
| 2811 | // loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2812 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2813 | } |
| 2814 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2815 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery( |
| 2816 | VkCmdBuffer cmdBuffer, |
| 2817 | VkQueryPool queryPool, |
| 2818 | uint32_t slot) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2819 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2820 | // loader_platform_thread_lock_mutex(&globalLock); |
| 2821 | // VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
| 2822 | // if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2823 | // // TODO : Want cmdBuffer to be srcObj here |
| 2824 | // log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2825 | // "In vkCmdEndQuery() call unable to update binding of queryPool buffer %#" PRIxLEAST64 " to cmdBuffer %p", queryPool.handle, cmdBuffer); |
| 2826 | // } |
| 2827 | // loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2828 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdEndQuery(cmdBuffer, queryPool, slot); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2829 | } |
| 2830 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2831 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool( |
| 2832 | VkCmdBuffer cmdBuffer, |
| 2833 | VkQueryPool queryPool, |
| 2834 | uint32_t startQuery, |
| 2835 | uint32_t queryCount) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2836 | { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2837 | // loader_platform_thread_lock_mutex(&globalLock); |
| 2838 | // VkDeviceMemory mem = get_mem_binding_from_object(cmdBuffer, queryPool); |
| 2839 | // if (VK_FALSE == update_cmd_buf_and_mem_references(cmdBuffer, mem)) { |
| 2840 | // // TODO : Want cmdBuffer to be srcObj here |
| 2841 | // log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", |
| 2842 | // "In vkCmdResetQueryPool() call unable to update binding of queryPool buffer %#" PRIxLEAST64 " to cmdBuffer %p", queryPool.handle, cmdBuffer); |
| 2843 | // } |
| 2844 | // loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2845 | get_dispatch_table(mem_tracker_device_table_map, cmdBuffer)->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2846 | } |
| 2847 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2848 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 2849 | VkInstance instance, |
| 2850 | VkFlags msgFlags, |
| 2851 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 2852 | void* pUserData, |
| 2853 | VkDbgMsgCallback* pMsgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2854 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2855 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 2856 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2857 | if (res == VK_SUCCESS) { |
| 2858 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2859 | |
| 2860 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 2861 | } |
| 2862 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2863 | } |
| 2864 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2865 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 2866 | VkInstance instance, |
| 2867 | VkDbgMsgCallback msgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2868 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2869 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(mem_tracker_instance_table_map, instance); |
| 2870 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
| 2871 | |
| 2872 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2873 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
| 2874 | |
| 2875 | return res; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2876 | } |
| 2877 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2878 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI( |
| 2879 | VkDevice device, |
| 2880 | const VkSwapChainCreateInfoWSI *pCreateInfo, |
| 2881 | VkSwapChainWSI *pSwapChain) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2882 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2883 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->CreateSwapChainWSI(device, pCreateInfo, pSwapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2884 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2885 | if (VK_SUCCESS == result) { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2886 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | cf48cad | 2015-07-13 18:41:17 -0600 | [diff] [blame] | 2887 | MT_SWAP_CHAIN_INFO *new_rec = new MT_SWAP_CHAIN_INFO; |
| 2888 | new_rec->createInfo = *pCreateInfo; |
| 2889 | swapChainMap[pSwapChain->handle]= new_rec; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2890 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 2891 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2892 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2893 | return result; |
| 2894 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2895 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2896 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI( |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2897 | VkDevice device, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2898 | VkSwapChainWSI swapChain) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2899 | { |
| 2900 | loader_platform_thread_lock_mutex(&globalLock); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2901 | if (swapChainMap.find(swapChain.handle) != swapChainMap.end()) { |
| 2902 | MT_SWAP_CHAIN_INFO* pInfo = swapChainMap[swapChain.handle]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2903 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2904 | if (pInfo->images.size() > 0) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2905 | for (auto it = pInfo->images.begin(); it != pInfo->images.end(); it++) { |
Courtney Goeltzenleuchter | cf48cad | 2015-07-13 18:41:17 -0600 | [diff] [blame] | 2906 | clear_object_binding(device, it->image.handle, VK_OBJECT_TYPE_SWAP_CHAIN_WSI); |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2907 | auto image_item = imageMap.find(it->image.handle); |
| 2908 | if (image_item != imageMap.end()) |
| 2909 | imageMap.erase(image_item); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2910 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2911 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2912 | delete pInfo; |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2913 | swapChainMap.erase(swapChain.handle); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2914 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2915 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | cf48cad | 2015-07-13 18:41:17 -0600 | [diff] [blame] | 2916 | return get_dispatch_table(mem_tracker_device_table_map, device)->DestroySwapChainWSI(device, swapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2917 | } |
| 2918 | |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2919 | VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI( |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2920 | VkDevice device, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2921 | VkSwapChainWSI swapChain, |
| 2922 | VkSwapChainInfoTypeWSI infoType, |
| 2923 | size_t *pDataSize, |
| 2924 | void *pData) |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2925 | { |
Courtney Goeltzenleuchter | cf48cad | 2015-07-13 18:41:17 -0600 | [diff] [blame] | 2926 | VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetSwapChainInfoWSI(device, swapChain, infoType, pDataSize, pData); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2927 | |
Courtney Goeltzenleuchter | c04704b | 2015-07-13 18:40:35 -0600 | [diff] [blame] | 2928 | if (infoType == VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI && result == VK_SUCCESS && pData != NULL) { |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2929 | const size_t count = *pDataSize / sizeof(VkSwapChainImagePropertiesWSI); |
| 2930 | MT_SWAP_CHAIN_INFO *pInfo = swapChainMap[swapChain.handle]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2931 | |
| 2932 | if (pInfo->images.empty()) { |
| 2933 | pInfo->images.resize(count); |
| 2934 | memcpy(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count); |
| 2935 | |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2936 | if (pInfo->images.size() > 0) { |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2937 | for (std::vector<VkSwapChainImagePropertiesWSI>::const_iterator it = pInfo->images.begin(); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 2938 | it != pInfo->images.end(); it++) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2939 | // Add image object binding, then insert the new Mem Object and then bind it to created image |
| 2940 | add_object_create_info(it->image.handle, VK_OBJECT_TYPE_SWAP_CHAIN_WSI, &pInfo->createInfo); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2941 | } |
| 2942 | } |
| 2943 | } else { |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 2944 | const size_t count = *pDataSize / sizeof(VkSwapChainImagePropertiesWSI); |
| 2945 | MT_SWAP_CHAIN_INFO *pInfo = swapChainMap[swapChain.handle]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2946 | const bool mismatch = (pInfo->images.size() != count || |
| 2947 | memcmp(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count)); |
| 2948 | |
| 2949 | if (mismatch) { |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2950 | // TODO : Want swapChain to be srcObj here |
Courtney Goeltzenleuchter | cf48cad | 2015-07-13 18:41:17 -0600 | [diff] [blame] | 2951 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_SWAP_CHAIN_WSI, 0, 0, MEMTRACK_NONE, "SWAP_CHAIN", |
Courtney Goeltzenleuchter | b9f0bf3 | 2015-06-14 09:50:18 -0600 | [diff] [blame] | 2952 | "vkGetSwapChainInfoWSI(%p, VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI) returned mismatching data", swapChain); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2953 | } |
| 2954 | } |
| 2955 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2956 | return result; |
| 2957 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2958 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2959 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr( |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2960 | VkDevice dev, |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2961 | const char *funcName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2962 | { |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 2963 | if (dev == NULL) { |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2964 | return NULL; |
Mark Lobodzinski | b1567a0 | 2015-04-21 15:33:04 -0600 | [diff] [blame] | 2965 | } |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 2966 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2967 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 2968 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 2969 | initDeviceTable(mem_tracker_device_table_map, (const VkBaseLayerObject *) dev); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2970 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 2971 | } |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 2972 | if (!strcmp(funcName, "vkCreateDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2973 | return (PFN_vkVoidFunction) vkCreateDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2974 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2975 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2976 | if (!strcmp(funcName, "vkQueueSubmit")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2977 | return (PFN_vkVoidFunction) vkQueueSubmit; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2978 | if (!strcmp(funcName, "vkAllocMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2979 | return (PFN_vkVoidFunction) vkAllocMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2980 | if (!strcmp(funcName, "vkFreeMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2981 | return (PFN_vkVoidFunction) vkFreeMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2982 | if (!strcmp(funcName, "vkMapMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2983 | return (PFN_vkVoidFunction) vkMapMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2984 | if (!strcmp(funcName, "vkUnmapMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2985 | return (PFN_vkVoidFunction) vkUnmapMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2986 | if (!strcmp(funcName, "vkDestroyFence")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2987 | return (PFN_vkVoidFunction) vkDestroyFence; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2988 | if (!strcmp(funcName, "vkDestroyBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2989 | return (PFN_vkVoidFunction) vkDestroyBuffer; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2990 | if (!strcmp(funcName, "vkDestroyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2991 | return (PFN_vkVoidFunction) vkDestroyImage; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2992 | if (!strcmp(funcName, "vkDestroyAttachmentView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2993 | return (PFN_vkVoidFunction) vkDestroyAttachmentView; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2994 | if (!strcmp(funcName, "vkDestroyImageView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2995 | return (PFN_vkVoidFunction) vkDestroyImageView; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2996 | if (!strcmp(funcName, "vkDestroyPipeline")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2997 | return (PFN_vkVoidFunction) vkDestroyPipeline; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 2998 | if (!strcmp(funcName, "vkDestroySampler")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 2999 | return (PFN_vkVoidFunction) vkDestroySampler; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3000 | if (!strcmp(funcName, "vkDestroySemaphore")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3001 | return (PFN_vkVoidFunction) vkDestroySemaphore; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3002 | if (!strcmp(funcName, "vkDestroyEvent")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3003 | return (PFN_vkVoidFunction) vkDestroyEvent; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3004 | if (!strcmp(funcName, "vkDestroyQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3005 | return (PFN_vkVoidFunction) vkDestroyQueryPool; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3006 | if (!strcmp(funcName, "vkDestroyBufferView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3007 | return (PFN_vkVoidFunction) vkDestroyBufferView; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3008 | if (!strcmp(funcName, "vkDestroyShaderModule")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3009 | return (PFN_vkVoidFunction) vkDestroyShaderModule; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3010 | if (!strcmp(funcName, "vkDestroyShader")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3011 | return (PFN_vkVoidFunction) vkDestroyShader; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3012 | if (!strcmp(funcName, "vkDestroyPipelineLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3013 | return (PFN_vkVoidFunction) vkDestroyPipelineLayout; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3014 | if (!strcmp(funcName, "vkDestroyDescriptorSetLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3015 | return (PFN_vkVoidFunction) vkDestroyDescriptorSetLayout; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3016 | if (!strcmp(funcName, "vkDestroyDescriptorPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3017 | return (PFN_vkVoidFunction) vkDestroyDescriptorPool; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3018 | if (!strcmp(funcName, "vkDestroyRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3019 | return (PFN_vkVoidFunction) vkDestroyRenderPass; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3020 | if (!strcmp(funcName, "vkDestroyFramebuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3021 | return (PFN_vkVoidFunction) vkDestroyFramebuffer; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3022 | if (!strcmp(funcName, "vkDestroyDynamicViewportState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3023 | return (PFN_vkVoidFunction) vkDestroyDynamicViewportState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3024 | if (!strcmp(funcName, "vkDestroyDynamicRasterState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3025 | return (PFN_vkVoidFunction) vkDestroyDynamicRasterState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3026 | if (!strcmp(funcName, "vkDestroyDynamicColorBlendState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3027 | return (PFN_vkVoidFunction) vkDestroyDynamicColorBlendState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3028 | if (!strcmp(funcName, "vkDestroyDynamicDepthStencilState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3029 | return (PFN_vkVoidFunction) vkDestroyDynamicDepthStencilState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3030 | if (!strcmp(funcName, "vkBindBufferMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3031 | return (PFN_vkVoidFunction) vkBindBufferMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3032 | if (!strcmp(funcName, "vkBindImageMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3033 | return (PFN_vkVoidFunction) vkBindImageMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3034 | if (!strcmp(funcName, "vkGetBufferMemoryRequirements")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3035 | return (PFN_vkVoidFunction) vkGetBufferMemoryRequirements; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3036 | if (!strcmp(funcName, "vkGetImageMemoryRequirements")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3037 | return (PFN_vkVoidFunction) vkGetImageMemoryRequirements; |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 3038 | if (!strcmp(funcName, "vkQueueBindSparseBufferMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3039 | return (PFN_vkVoidFunction) vkQueueBindSparseBufferMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3040 | if (!strcmp(funcName, "vkQueueBindSparseImageOpaqueMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3041 | return (PFN_vkVoidFunction) vkQueueBindSparseImageOpaqueMemory; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3042 | if (!strcmp(funcName, "vkQueueBindSparseImageMemory")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3043 | return (PFN_vkVoidFunction) vkQueueBindSparseImageMemory; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3044 | if (!strcmp(funcName, "vkCreateFence")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3045 | return (PFN_vkVoidFunction) vkCreateFence; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3046 | if (!strcmp(funcName, "vkGetFenceStatus")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3047 | return (PFN_vkVoidFunction) vkGetFenceStatus; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3048 | if (!strcmp(funcName, "vkResetFences")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3049 | return (PFN_vkVoidFunction) vkResetFences; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3050 | if (!strcmp(funcName, "vkWaitForFences")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3051 | return (PFN_vkVoidFunction) vkWaitForFences; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3052 | if (!strcmp(funcName, "vkQueueWaitIdle")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3053 | return (PFN_vkVoidFunction) vkQueueWaitIdle; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3054 | if (!strcmp(funcName, "vkDeviceWaitIdle")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3055 | return (PFN_vkVoidFunction) vkDeviceWaitIdle; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3056 | if (!strcmp(funcName, "vkCreateEvent")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3057 | return (PFN_vkVoidFunction) vkCreateEvent; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3058 | if (!strcmp(funcName, "vkCreateQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3059 | return (PFN_vkVoidFunction) vkCreateQueryPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3060 | if (!strcmp(funcName, "vkCreateBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3061 | return (PFN_vkVoidFunction) vkCreateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3062 | if (!strcmp(funcName, "vkCreateBufferView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3063 | return (PFN_vkVoidFunction) vkCreateBufferView; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3064 | if (!strcmp(funcName, "vkCreateImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3065 | return (PFN_vkVoidFunction) vkCreateImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3066 | if (!strcmp(funcName, "vkCreateImageView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3067 | return (PFN_vkVoidFunction) vkCreateImageView; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3068 | if (!strcmp(funcName, "vkCreateAttachmentView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3069 | return (PFN_vkVoidFunction) vkCreateAttachmentView; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3070 | if (!strcmp(funcName, "vkCreateShader")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3071 | return (PFN_vkVoidFunction) vkCreateShader; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3072 | if (!strcmp(funcName, "vkCreateGraphicsPipelines")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3073 | return (PFN_vkVoidFunction) vkCreateGraphicsPipelines; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3074 | if (!strcmp(funcName, "vkCreateComputePipelines")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3075 | return (PFN_vkVoidFunction) vkCreateComputePipelines; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3076 | if (!strcmp(funcName, "vkCreateSampler")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3077 | return (PFN_vkVoidFunction) vkCreateSampler; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3078 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3079 | return (PFN_vkVoidFunction) vkCreateDynamicViewportState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3080 | if (!strcmp(funcName, "vkCreateDynamicRasterState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3081 | return (PFN_vkVoidFunction) vkCreateDynamicRasterState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3082 | if (!strcmp(funcName, "vkCreateDynamicColorBlendState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3083 | return (PFN_vkVoidFunction) vkCreateDynamicColorBlendState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3084 | if (!strcmp(funcName, "vkCreateDynamicDepthStencilState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3085 | return (PFN_vkVoidFunction) vkCreateDynamicDepthStencilState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3086 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3087 | return (PFN_vkVoidFunction) vkCreateCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3088 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3089 | return (PFN_vkVoidFunction) vkBeginCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3090 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3091 | return (PFN_vkVoidFunction) vkEndCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3092 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3093 | return (PFN_vkVoidFunction) vkResetCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3094 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3095 | return (PFN_vkVoidFunction) vkCmdBindPipeline; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3096 | if (!strcmp(funcName, "vkCmdBindDynamicViewportState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3097 | return (PFN_vkVoidFunction) vkCmdBindDynamicViewportState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3098 | if (!strcmp(funcName, "vkCmdBindDynamicRasterState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3099 | return (PFN_vkVoidFunction) vkCmdBindDynamicRasterState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3100 | if (!strcmp(funcName, "vkCmdBindDynamicColorBlendState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3101 | return (PFN_vkVoidFunction) vkCmdBindDynamicColorBlendState; |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 3102 | if (!strcmp(funcName, "vkCmdBindDynamicDepthStencilState")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3103 | return (PFN_vkVoidFunction) vkCmdBindDynamicDepthStencilState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3104 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3105 | return (PFN_vkVoidFunction) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 3106 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3107 | return (PFN_vkVoidFunction) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3108 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3109 | return (PFN_vkVoidFunction) vkCmdBindIndexBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3110 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3111 | return (PFN_vkVoidFunction) vkCmdDrawIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3112 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3113 | return (PFN_vkVoidFunction) vkCmdDrawIndexedIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3114 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3115 | return (PFN_vkVoidFunction) vkCmdDispatchIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3116 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3117 | return (PFN_vkVoidFunction) vkCmdCopyBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3118 | if (!strcmp(funcName, "vkCmdCopyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3119 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3120 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3121 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3122 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3123 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3124 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3125 | return (PFN_vkVoidFunction) vkCmdUpdateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3126 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3127 | return (PFN_vkVoidFunction) vkCmdFillBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3128 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3129 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 3130 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3131 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3132 | if (!strcmp(funcName, "vkCmdResolveImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3133 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3134 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3135 | return (PFN_vkVoidFunction) vkCmdBeginQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3136 | if (!strcmp(funcName, "vkCmdEndQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3137 | return (PFN_vkVoidFunction) vkCmdEndQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3138 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3139 | return (PFN_vkVoidFunction) vkCmdResetQueryPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3140 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3141 | return (PFN_vkVoidFunction) vkGetDeviceQueue; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3142 | |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 3143 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 3144 | if (my_device_data->wsi_enabled) |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3145 | { |
Tobin Ehlis | 6bc1b8e | 2015-07-13 14:21:59 -0600 | [diff] [blame] | 3146 | // if (!strcmp(funcName, "vkGetSurfaceInfoWSI")) |
| 3147 | // return (PFN_vkVoidFunction) vkGetSurfaceInfoWSI; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3148 | if (!strcmp(funcName, "vkCreateSwapChainWSI")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3149 | return (PFN_vkVoidFunction) vkCreateSwapChainWSI; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3150 | if (!strcmp(funcName, "vkDestroySwapChainWSI")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3151 | return (PFN_vkVoidFunction) vkDestroySwapChainWSI; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3152 | if (!strcmp(funcName, "vkGetSwapChainInfoWSI")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3153 | return (PFN_vkVoidFunction) vkGetSwapChainInfoWSI; |
Tobin Ehlis | 6bc1b8e | 2015-07-13 14:21:59 -0600 | [diff] [blame] | 3154 | // if (!strcmp(funcName, "vkAcquireNextImageWSI")) |
| 3155 | // return (PFN_vkVoidFunction) vkAcquireNextImageWSI; |
| 3156 | // if (!strcmp(funcName, "vkQueuePresentWSI")) |
| 3157 | // return (PFN_vkVoidFunction) vkQueuePresentWSI; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3158 | } |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 3159 | |
Courtney Goeltzenleuchter | d54749c | 2015-07-05 11:17:01 -0600 | [diff] [blame] | 3160 | VkLayerDispatchTable *pDisp = get_dispatch_table(mem_tracker_device_table_map, dev); |
| 3161 | if (pDisp->GetDeviceProcAddr == NULL) |
| 3162 | return NULL; |
| 3163 | return pDisp->GetDeviceProcAddr(dev, funcName); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3164 | } |
| 3165 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3166 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr( |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3167 | VkInstance instance, |
| 3168 | const char *funcName) |
| 3169 | { |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3170 | PFN_vkVoidFunction fptr; |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3171 | if (instance == NULL) { |
| 3172 | return NULL; |
| 3173 | } |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 3174 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3175 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 3176 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 3177 | initInstanceTable(mem_tracker_instance_table_map, (const VkBaseLayerObject *) instance); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3178 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3179 | } |
| 3180 | |
Mark Lobodzinski | 76c991d | 2015-05-20 16:16:37 -0500 | [diff] [blame] | 3181 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3182 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 3183 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3184 | return (PFN_vkVoidFunction) vkCreateInstance; |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 3185 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3186 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 3187 | if (!strcmp(funcName, "vkGetGlobalLayerProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3188 | return (PFN_vkVoidFunction) vkGetGlobalLayerProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 3189 | if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3190 | return (PFN_vkVoidFunction) vkGetGlobalExtensionProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 3191 | if (!strcmp(funcName, "vkGetPhysicalDeviceLayerProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3192 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceLayerProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 3193 | if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3194 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceExtensionProperties; |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 3195 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 3196 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 3197 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 3198 | if (fptr) |
| 3199 | return fptr; |
| 3200 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3201 | { |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 3202 | if (get_dispatch_table(mem_tracker_instance_table_map, instance)->GetInstanceProcAddr == NULL) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3203 | return NULL; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 3204 | return get_dispatch_table(mem_tracker_instance_table_map, instance)->GetInstanceProcAddr(instance, funcName); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 3205 | } |
| 3206 | } |