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> |
| 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 | |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 35 | #include "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" |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 39 | #include "layers_config.h" |
Ian Elliott | 655cad7 | 2015-02-12 17:08:34 -0700 | [diff] [blame] | 40 | // The following is #included again to catch certain OS-specific functions |
| 41 | // being used: |
| 42 | #include "loader_platform.h" |
Jon Ashburn | 2e67289 | 2015-02-16 08:46:53 -0700 | [diff] [blame] | 43 | #include "layers_msg.h" |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 44 | |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 45 | static VkLayerDispatchTable nextTable; |
| 46 | static VkBaseLayerObject *pCurObj; |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 47 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 48 | // TODO : This can be much smarter, using separate locks for separate global data |
| 49 | static int globalLockInitialized = 0; |
| 50 | static loader_platform_thread_mutex globalLock; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 51 | |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 52 | #define MAX_BINDING 0xFFFFFFFF |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 53 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 54 | map<VkCmdBuffer, MT_CB_INFO*> cbMap; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 55 | map<VkDeviceMemory, MT_MEM_OBJ_INFO*> memObjMap; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 56 | map<VkObject, MT_OBJ_INFO*> objectMap; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 57 | map<uint64_t, MT_FENCE_INFO*> fenceMap; // Map fenceId to fence info |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 58 | map<VkQueue, MT_QUEUE_INFO*> queueMap; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 59 | map<VkSwapChainWSI, MT_SWAP_CHAIN_INFO*> swapChainMap; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 60 | |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 61 | // TODO : Add per-device fence completion |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 62 | static uint64_t g_currentFenceId = 1; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 63 | static VkDevice globalDevice = NULL; |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 64 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 65 | // Add new queue for this device to map container |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 66 | static void addQueueInfo(const VkQueue queue) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 67 | { |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 68 | MT_QUEUE_INFO* pInfo = new MT_QUEUE_INFO; |
| 69 | pInfo->lastRetiredId = 0; |
| 70 | pInfo->lastSubmittedId = 0; |
| 71 | queueMap[queue] = pInfo; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static void deleteQueueInfoList(void) |
| 75 | { |
| 76 | // Process queue list, cleaning up each entry before deleting |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 77 | for (map<VkQueue, MT_QUEUE_INFO*>::iterator ii=queueMap.begin(); ii!=queueMap.end(); ++ii) { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 78 | (*ii).second->pQueueCmdBuffers.clear(); |
| 79 | } |
| 80 | queueMap.clear(); |
| 81 | } |
| 82 | |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 83 | static void addSwapChainInfo(const VkSwapChainWSI swapChain) |
| 84 | { |
| 85 | MT_SWAP_CHAIN_INFO* pInfo = new MT_SWAP_CHAIN_INFO; |
| 86 | swapChainMap[swapChain] = pInfo; |
| 87 | } |
| 88 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 89 | // Add new CBInfo for this cb to map container |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 90 | static void addCBInfo(const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 91 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 92 | MT_CB_INFO* pInfo = new MT_CB_INFO; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 93 | memset(pInfo, 0, (sizeof(MT_CB_INFO) - sizeof(list<VkDeviceMemory>))); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 94 | pInfo->cmdBuffer = cb; |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 95 | cbMap[cb] = pInfo; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 98 | // Return ptr to Info in CB map, or NULL if not found |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 99 | static MT_CB_INFO* getCBInfo(const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 100 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 101 | MT_CB_INFO* pCBInfo = NULL; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 102 | if (cbMap.find(cb) != cbMap.end()) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 103 | pCBInfo = cbMap[cb]; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 104 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 105 | return pCBInfo; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 106 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 107 | |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 108 | // Return object info for 'object' or return NULL if no info exists |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 109 | static MT_OBJ_INFO* getObjectInfo(const VkObject object) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 110 | { |
| 111 | MT_OBJ_INFO* pObjInfo = NULL; |
| 112 | |
| 113 | if (objectMap.find(object) != objectMap.end()) { |
| 114 | pObjInfo = objectMap[object]; |
| 115 | } |
| 116 | return pObjInfo; |
| 117 | } |
| 118 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 119 | static MT_OBJ_INFO* addObjectInfo(VkObject object, VkStructureType sType, const void *pCreateInfo, const int struct_size, const char *name_prefix) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 120 | { |
| 121 | MT_OBJ_INFO* pInfo = new MT_OBJ_INFO; |
| 122 | memset(pInfo, 0, sizeof(MT_OBJ_INFO)); |
| 123 | memcpy(&pInfo->create_info, pCreateInfo, struct_size); |
| 124 | sprintf(pInfo->object_name, "%s_%p", name_prefix, object); |
| 125 | |
| 126 | pInfo->object = object; |
| 127 | pInfo->ref_count = 1; |
| 128 | pInfo->sType = sType; |
| 129 | objectMap[object] = pInfo; |
| 130 | |
| 131 | return pInfo; |
| 132 | } |
| 133 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 134 | // Add a fence, creating one if necessary to our list of fences/fenceIds |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 135 | static uint64_t addFenceInfo(VkFence fence, VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 136 | { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 137 | // Create fence object |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 138 | MT_FENCE_INFO* pFenceInfo = new MT_FENCE_INFO; |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 139 | MT_QUEUE_INFO* pQueueInfo = queueMap[queue]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 140 | uint64_t fenceId = g_currentFenceId++; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 141 | memset(pFenceInfo, 0, sizeof(MT_FENCE_INFO)); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 142 | // If no fence, create an internal fence to track the submissions |
| 143 | if (fence == NULL) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 144 | VkFenceCreateInfo fci; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 145 | fci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 146 | fci.pNext = NULL; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 147 | fci.flags = static_cast<VkFenceCreateFlags>(0); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 148 | nextTable.CreateFence(globalDevice, &fci, &pFenceInfo->fence); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 149 | addObjectInfo(pFenceInfo->fence, fci.sType, &fci, sizeof(VkFenceCreateInfo), "internalFence"); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 150 | pFenceInfo->localFence = VK_TRUE; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 151 | } else { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 152 | // Validate that fence is in UNSIGNALED state |
| 153 | MT_OBJ_INFO* pObjectInfo = getObjectInfo(fence); |
| 154 | if (pObjectInfo != NULL) { |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 155 | if (pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 156 | char str[1024]; |
| 157 | sprintf(str, "Fence %p submitted in SIGNALED state. Fences must be reset before being submitted", fence); |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 158 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, fence, 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", str); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 159 | } |
| 160 | } |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 161 | pFenceInfo->localFence = VK_FALSE; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 162 | pFenceInfo->fence = fence; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 163 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 164 | pFenceInfo->queue = queue; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 165 | fenceMap[fenceId] = pFenceInfo; |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 166 | // Update most recently submitted fenceId for Queue |
| 167 | pQueueInfo->lastSubmittedId = fenceId; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 168 | return fenceId; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 169 | } |
| 170 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 171 | // Remove a fenceInfo from our list of fences/fenceIds |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 172 | static void deleteFenceInfo(uint64_t fenceId) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 173 | { |
| 174 | if (fenceId != 0) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 175 | if (fenceMap.find(fenceId) != fenceMap.end()) { |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 176 | map<uint64_t, MT_FENCE_INFO*>::iterator item; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 177 | MT_FENCE_INFO* pDelInfo = fenceMap[fenceId]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 178 | if (pDelInfo != NULL) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 179 | if (pDelInfo->localFence == VK_TRUE) { |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 180 | nextTable.DestroyObject(globalDevice, VK_OBJECT_TYPE_FENCE, pDelInfo->fence); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 181 | } |
| 182 | delete pDelInfo; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 183 | } |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 184 | item = fenceMap.find(fenceId); |
| 185 | fenceMap.erase(item); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 190 | // Search through list for this fence, deleting all items before it (with lower IDs) and updating lastRetiredId |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 191 | static void updateFenceTracking(VkFence fence) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 192 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 193 | MT_FENCE_INFO *pCurFenceInfo = NULL; |
| 194 | uint64_t fenceId = 0; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 195 | VkQueue queue = NULL; |
Mike Stroyan | 8fbeea9 | 2015-04-15 15:37:47 -0600 | [diff] [blame] | 196 | bool found = false; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 197 | |
Mike Stroyan | 8fbeea9 | 2015-04-15 15:37:47 -0600 | [diff] [blame] | 198 | for (map<uint64_t, MT_FENCE_INFO*>::iterator ii=fenceMap.begin(); !found && ii!=fenceMap.end(); ++ii) { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 199 | if ((*ii).second != NULL) { |
| 200 | if (fence == ((*ii).second)->fence) { |
| 201 | queue = ((*ii).second)->queue; |
| 202 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 203 | pQueueInfo->lastRetiredId = (*ii).first; |
Mike Stroyan | 8fbeea9 | 2015-04-15 15:37:47 -0600 | [diff] [blame] | 204 | found = true; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 205 | } else { |
| 206 | deleteFenceInfo((*ii).first); |
| 207 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 208 | // Update fence state in fenceCreateInfo structure |
| 209 | MT_OBJ_INFO* pObjectInfo = getObjectInfo(fence); |
| 210 | if (pObjectInfo != NULL) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 211 | pObjectInfo->create_info.fence_create_info.flags = |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 212 | static_cast<VkFenceCreateFlags>(pObjectInfo->create_info.fence_create_info.flags | VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 213 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // Utility function that determines if a fenceId has been retired yet |
| 219 | static bool32_t fenceRetired(uint64_t fenceId) |
| 220 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 221 | bool32_t result = VK_FALSE; |
Courtney Goeltzenleuchter | 0c55f3a | 2015-04-15 14:10:51 -0600 | [diff] [blame] | 222 | if (fenceMap.find(fenceId) != fenceMap.end()) { |
| 223 | MT_FENCE_INFO* pFenceInfo = fenceMap[fenceId]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 224 | MT_QUEUE_INFO* pQueueInfo = queueMap[pFenceInfo->queue]; |
Mark Lobodzinski | 3bc3f6e | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 225 | if (fenceId <= pQueueInfo->lastRetiredId) |
| 226 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 227 | result = VK_TRUE; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 228 | } |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 229 | } else { // If not in list, fence has been retired and deleted |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 230 | result = VK_TRUE; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 231 | } |
| 232 | return result; |
| 233 | } |
| 234 | |
| 235 | // Return the fence associated with a fenceId |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 236 | static VkFence getFenceFromId(uint64_t fenceId) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 237 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 238 | VkFence fence = NULL; |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 239 | if (fenceId != 0) { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 240 | // Search for an item with this fenceId |
| 241 | if (fenceMap.find(fenceId) != fenceMap.end()) { |
| 242 | MT_FENCE_INFO* pFenceInfo = fenceMap[fenceId]; |
| 243 | if (pFenceInfo != NULL) { |
| 244 | MT_QUEUE_INFO* pQueueInfo = queueMap[pFenceInfo->queue]; |
| 245 | if (fenceId > pQueueInfo->lastRetiredId) { |
| 246 | fence = pFenceInfo->fence; |
| 247 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | } |
| 251 | return fence; |
| 252 | } |
| 253 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 254 | // Helper routine that updates the fence list for a specific queue to all-retired |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 255 | static void retireQueueFences(VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 256 | { |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 257 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 258 | pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; |
| 259 | // Set Queue's lastRetired to lastSubmitted, free items in queue's fence list |
| 260 | map<uint64_t, MT_FENCE_INFO*>::iterator it = fenceMap.begin(); |
| 261 | map<uint64_t, MT_FENCE_INFO*>::iterator temp; |
| 262 | while (it != fenceMap.end()) { |
Tobin Ehlis | 5d37f70 | 2015-04-15 14:25:02 -0600 | [diff] [blame] | 263 | if ((((*it).second) != NULL) && ((*it).second)->queue == queue) { |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 264 | temp = it; |
| 265 | ++temp; |
| 266 | deleteFenceInfo((*it).first); |
| 267 | it = temp; |
| 268 | } else { |
| 269 | ++it; |
| 270 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 271 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 274 | // Helper routine that updates fence list for all queues to all-retired |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 275 | static void retireDeviceFences(VkDevice device) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 276 | { |
| 277 | // Process each queue for device |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 278 | // TODO: Add multiple device support |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 279 | for (map<VkQueue, MT_QUEUE_INFO*>::iterator ii=queueMap.begin(); ii!=queueMap.end(); ++ii) { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 280 | retireQueueFences((*ii).first); |
| 281 | } |
| 282 | } |
| 283 | |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 284 | // Returns True if a memory reference is present in a Queue's memory reference list |
| 285 | // Queue is validated by caller |
| 286 | static bool32_t checkMemRef( |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 287 | VkQueue queue, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 288 | VkDeviceMemory mem) |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 289 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 290 | bool32_t result = VK_FALSE; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 291 | list<VkDeviceMemory>::iterator it; |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 292 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 293 | for (it = pQueueInfo->pMemRefList.begin(); it != pQueueInfo->pMemRefList.end(); ++it) { |
| 294 | if ((*it) == mem) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 295 | result = VK_TRUE; |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 296 | break; |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | return result; |
| 300 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 301 | |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 302 | static bool32_t validateQueueMemRefs( |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 303 | VkQueue queue, |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 304 | uint32_t cmdBufferCount, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 305 | const VkCmdBuffer *pCmdBuffers) |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 306 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 307 | bool32_t result = VK_TRUE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 308 | |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 309 | // Verify Queue |
| 310 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 311 | if (pQueueInfo == NULL) { |
| 312 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 313 | sprintf(str, "Unknown Queue %p specified in vkQueueSubmit", queue); |
| 314 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_INVALID_QUEUE, "MEM", str); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 315 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 316 | else { |
| 317 | // Iterate through all CBs in pCmdBuffers |
| 318 | for (uint32_t i = 0; i < cmdBufferCount; i++) { |
| 319 | MT_CB_INFO* pCBInfo = getCBInfo(pCmdBuffers[i]); |
| 320 | if (!pCBInfo) { |
| 321 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 322 | sprintf(str, "Unable to find info for CB %p in order to check memory references in vkQueueSubmit for queue %p", (void*)pCmdBuffers[i], queue); |
| 323 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_INVALID_CB, "MEM", str); |
| 324 | result = VK_FALSE; |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 325 | } else { |
| 326 | // Validate that all actual references are accounted for in pMemRefs |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 327 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 328 | // Search for each memref in queues memreflist. |
| 329 | if (checkMemRef(queue, *it)) { |
| 330 | char str[1024]; |
| 331 | sprintf(str, "Found Mem Obj %p binding to CB %p for queue %p", (*it), pCmdBuffers[i], queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 332 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 333 | } |
| 334 | else { |
| 335 | char str[1024]; |
| 336 | sprintf(str, "Queue %p Memory reference list for Command Buffer %p is missing ref to mem obj %p", queue, pCmdBuffers[i], (*it)); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 337 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_INVALID_MEM_REF, "MEM", str); |
| 338 | result = VK_FALSE; |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | } |
| 342 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 343 | if (result == VK_TRUE) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 344 | char str[1024]; |
| 345 | sprintf(str, "Verified all memory dependencies for Queue %p are included in pMemRefs list", queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 346 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 347 | // TODO : Could report mem refs in pMemRefs that AREN'T in mem list, that would be primarily informational |
| 348 | // Currently just noting that there is a difference |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return result; |
| 353 | } |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 354 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 355 | // 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] | 356 | // Calls to this function should be wrapped in mutex |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 357 | static MT_MEM_OBJ_INFO* getMemObjInfo(const VkDeviceMemory mem) |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 358 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 359 | MT_MEM_OBJ_INFO* pMemObjInfo = NULL; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 360 | |
| 361 | if (memObjMap.find(mem) != memObjMap.end()) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 362 | pMemObjInfo = memObjMap[mem]; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 363 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 364 | return pMemObjInfo; |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 367 | static void addMemObjInfo(const VkDeviceMemory mem, const VkMemoryAllocInfo* pAllocInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 368 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 369 | MT_MEM_OBJ_INFO* pInfo = new MT_MEM_OBJ_INFO; |
| 370 | pInfo->refCount = 0; |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 371 | memset(&pInfo->allocInfo, 0, sizeof(VkMemoryAllocInfo)); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 372 | |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 373 | if (pAllocInfo) { // MEM alloc created by vkCreateSwapChainWSI() doesn't have alloc info struct |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 374 | memcpy(&pInfo->allocInfo, pAllocInfo, sizeof(VkMemoryAllocInfo)); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 375 | // TODO: Update for real hardware, actually process allocation info structures |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 376 | pInfo->allocInfo.pNext = NULL; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 377 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 378 | pInfo->mem = mem; |
| 379 | memObjMap[mem] = pInfo; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 380 | } |
| 381 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 382 | // Find CB Info and add mem binding to list container |
| 383 | // Find Mem Obj Info and add CB binding to list container |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 384 | static bool32_t updateCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 385 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 386 | bool32_t result = VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 387 | // First update CB binding in MemObj mini CB list |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 388 | MT_MEM_OBJ_INFO* pMemInfo = getMemObjInfo(mem); |
| 389 | if (!pMemInfo) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 390 | char str[1024]; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 391 | sprintf(str, "Trying to bind mem obj %p to CB %p but no info for that mem obj.\n Was it correctly allocated? Did it already get freed?", mem, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 392 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
| 393 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 394 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 395 | // Search for cmd buffer object in memory object's binding list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 396 | bool32_t found = VK_FALSE; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 397 | for (list<VkCmdBuffer>::iterator it = pMemInfo->pCmdBufferBindings.begin(); it != pMemInfo->pCmdBufferBindings.end(); ++it) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 398 | if ((*it) == cb) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 399 | found = VK_TRUE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 400 | break; |
| 401 | } |
| 402 | } |
| 403 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 404 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 405 | pMemInfo->pCmdBufferBindings.push_front(cb); |
| 406 | pMemInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 407 | } |
| 408 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 409 | // Now update CBInfo's Mem binding list |
| 410 | MT_CB_INFO* pCBInfo = getCBInfo(cb); |
| 411 | if (!pCBInfo) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 412 | char str[1024]; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 413 | sprintf(str, "Trying to bind mem obj %p to CB %p but no info for that CB. Was it CB incorrectly destroyed?", mem, cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 414 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
| 415 | result = VK_FALSE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 416 | } else { |
| 417 | // Search for memory object in cmd buffer's binding list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 418 | bool32_t found = VK_FALSE; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 419 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 420 | if ((*it) == mem) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 421 | found = VK_TRUE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 422 | break; |
| 423 | } |
| 424 | } |
| 425 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 426 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 427 | pCBInfo->pMemObjList.push_front(mem); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 428 | } |
| 429 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 430 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 431 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 432 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 433 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 434 | // Clear the CB Binding for mem |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 435 | // Calls to this function should be wrapped in mutex |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 436 | static void clearCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 437 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 438 | MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 439 | // TODO : Having this check is not ideal, really if memInfo was deleted, |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 440 | // its CB bindings should be cleared and then freeCBBindings wouldn't call |
| 441 | // us here with stale mem objs |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 442 | if (pInfo) { |
| 443 | pInfo->pCmdBufferBindings.remove(cb); |
| 444 | pInfo->refCount--; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 445 | } |
| 446 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 447 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 448 | // Free bindings related to CB |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 449 | static bool32_t freeCBBindings(const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 450 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 451 | bool32_t result = VK_TRUE; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 452 | MT_CB_INFO* pCBInfo = getCBInfo(cb); |
| 453 | if (!pCBInfo) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 454 | char str[1024]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 455 | sprintf(str, "Unable to find global CB info %p for deletion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 456 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_CB, "MEM", str); |
| 457 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 458 | } else { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 459 | if (!fenceRetired(pCBInfo->fenceId)) { |
| 460 | deleteFenceInfo(pCBInfo->fenceId); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 461 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 462 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 463 | for (list<VkDeviceMemory>::iterator it=pCBInfo->pMemObjList.begin(); it!=pCBInfo->pMemObjList.end(); ++it) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 464 | clearCBBinding(cb, (*it)); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 465 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 466 | pCBInfo->pMemObjList.clear(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 467 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 468 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 469 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 470 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 471 | // Delete CBInfo from list along with all of it's mini MemObjInfo |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 472 | // and also clear mem references to CB |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 473 | // TODO : When should this be called? There's no Destroy of CBs that I see |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 474 | static bool32_t deleteCBInfo(const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 475 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 476 | bool32_t result = VK_TRUE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 477 | result = freeCBBindings(cb); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 478 | // Delete the CBInfo info |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 479 | if (result == VK_TRUE) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 480 | if (cbMap.find(cb) != cbMap.end()) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 481 | MT_CB_INFO* pDelInfo = cbMap[cb]; |
| 482 | delete pDelInfo; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 483 | cbMap.erase(cb); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 484 | } |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 485 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 486 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 487 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 488 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 489 | // Delete the entire CB list |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 490 | static bool32_t deleteCBInfoList() |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 491 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 492 | bool32_t result = VK_TRUE; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 493 | for (map<VkCmdBuffer, MT_CB_INFO*>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 494 | freeCBBindings((*ii).first); |
| 495 | delete (*ii).second; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 496 | } |
| 497 | return result; |
| 498 | } |
| 499 | |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 500 | // For given MemObjInfo, report Obj & CB bindings |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 501 | static void reportMemReferencesAndCleanUp(MT_MEM_OBJ_INFO* pMemObjInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 502 | { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 503 | uint32_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size(); |
| 504 | uint32_t objRefCount = pMemObjInfo->pObjBindings.size(); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 505 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 506 | if ((pMemObjInfo->pCmdBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 507 | char str[1024]; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 508 | sprintf(str, "Attempting to free memory object %p which still contains %d references", pMemObjInfo->mem, (cmdBufRefCount + objRefCount)); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 509 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pMemObjInfo->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 510 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 511 | |
| 512 | if (cmdBufRefCount > 0) { |
| 513 | for (list<VkCmdBuffer>::const_iterator it = pMemObjInfo->pCmdBufferBindings.begin(); it != pMemObjInfo->pCmdBufferBindings.end(); ++it) { |
| 514 | char str[1024]; |
| 515 | sprintf(str, "Command Buffer %p still has a reference to mem obj %p", (*it), pMemObjInfo->mem); |
| 516 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, (*it), 0, MEMTRACK_NONE, "MEM", str); |
| 517 | } |
| 518 | // Clear the list of hanging references |
| 519 | pMemObjInfo->pCmdBufferBindings.clear(); |
| 520 | } |
| 521 | |
| 522 | if (objRefCount > 0) { |
| 523 | for (list<VkObject>::const_iterator it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { |
| 524 | char str[1024]; |
| 525 | sprintf(str, "VK Object %p still has a reference to mem obj %p", (*it), pMemObjInfo->mem); |
| 526 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, (*it), 0, MEMTRACK_NONE, "MEM", str); |
| 527 | } |
| 528 | // Clear the list of hanging references |
| 529 | pMemObjInfo->pObjBindings.clear(); |
| 530 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 533 | static void deleteMemObjInfo(VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 534 | { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 535 | if (memObjMap.find(mem) != memObjMap.end()) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 536 | MT_MEM_OBJ_INFO* pDelInfo = memObjMap[mem]; |
| 537 | delete pDelInfo; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 538 | memObjMap.erase(mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 539 | } |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 540 | else { |
| 541 | char str[1024]; |
| 542 | sprintf(str, "Request to delete memory object %p not present in memory Object Map", mem); |
| 543 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
| 544 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 545 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 546 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 547 | // Check if fence for given CB is completed |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 548 | static bool32_t checkCBCompleted(const VkCmdBuffer cb) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 549 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 550 | bool32_t result = VK_TRUE; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 551 | MT_CB_INFO* pCBInfo = getCBInfo(cb); |
| 552 | if (!pCBInfo) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 553 | char str[1024]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 554 | sprintf(str, "Unable to find global CB info %p to check for completion", cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 555 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_CB, "MEM", str); |
| 556 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 557 | } else { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 558 | if (!fenceRetired(pCBInfo->fenceId)) { |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 559 | char str[1024]; |
| 560 | sprintf(str, "FenceId %" PRIx64", fence %p for CB %p has not been checked for completion", pCBInfo->fenceId, getFenceFromId(pCBInfo->fenceId), cb); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 561 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_NONE, "MEM", str); |
| 562 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 563 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 564 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 565 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 566 | } |
| 567 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 568 | static bool32_t freeMemObjInfo(VkDeviceMemory mem, bool internal) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 569 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 570 | bool32_t result = VK_TRUE; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 571 | // Parse global list to find info w/ mem |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 572 | MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); |
| 573 | if (!pInfo) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 574 | char str[1024]; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 575 | sprintf(str, "Couldn't find mem info object for %p\n Was %p never allocated or previously freed?", (void*)mem, (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 576 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
| 577 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 578 | } else { |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 579 | if (pInfo->allocInfo.allocationSize == 0 && !internal) { |
Mark Lobodzinski | 2f3b19b | 2015-02-18 18:06:24 -0600 | [diff] [blame] | 580 | char str[1024]; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 581 | sprintf(str, "Attempting to free memory associated with a Persistent Image, %p, this should not be explicitly freed\n", (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 582 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
| 583 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 584 | } else { |
| 585 | // Clear any CB bindings for completed CBs |
| 586 | // TODO : Is there a better place to do this? |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 587 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 588 | list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); |
| 589 | list<VkCmdBuffer>::iterator temp; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 590 | while (it != pInfo->pCmdBufferBindings.end()) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 591 | if (VK_TRUE == checkCBCompleted(*it)) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 592 | temp = it; |
| 593 | ++temp; |
| 594 | freeCBBindings(*it); |
| 595 | it = temp; |
| 596 | } else { |
| 597 | ++it; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 598 | } |
| 599 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 600 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 601 | // Now verify that no references to this mem obj remain |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 602 | if (0 != pInfo->refCount) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 603 | // If references remain, report the error and can search CB list to find references |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 604 | char str[1024]; |
| 605 | sprintf(str, "Freeing mem obj %p while it still has references", (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 606 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_FREED_MEM_REF, "MEM", str); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 607 | reportMemReferencesAndCleanUp(pInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 608 | result = VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 609 | } |
Courtney Goeltzenleuchter | 2f3f8a2 | 2015-04-14 00:01:21 -0600 | [diff] [blame] | 610 | // Delete mem obj info |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 611 | deleteMemObjInfo(mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 612 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 613 | } |
| 614 | return result; |
| 615 | } |
| 616 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 617 | // Remove object binding performs 3 tasks: |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 618 | // 1. Remove ObjectInfo from MemObjInfo list container of obj bindings & free it |
| 619 | // 2. Decrement refCount for MemObjInfo |
| 620 | // 3. Clear MemObjInfo ptr from ObjectInfo |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 621 | static bool32_t clearObjectBinding(VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 622 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 623 | bool32_t result = VK_FALSE; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 624 | MT_OBJ_INFO* pObjInfo = getObjectInfo(object); |
| 625 | if (!pObjInfo) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 626 | char str[1024]; |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 627 | sprintf(str, "Attempting to clear mem binding for object %p: devices, queues, command buffers, shaders and memory objects do not have external memory requirements and it is unneccessary to call bind/unbindObjectMemory on them.", object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 628 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INVALID_OBJECT, "MEM", str); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 629 | } else { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 630 | if (!pObjInfo->pMemObjInfo) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 631 | char str[1024]; |
| 632 | sprintf(str, "Attempting to clear mem binding on obj %p but it has no binding.", (void*)object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 633 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_MEM_OBJ_CLEAR_EMPTY_BINDINGS, "MEM", str); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 634 | } else { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 635 | // 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 |
| 636 | // and set the objects memory binding pointer to NULL. |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 637 | for (list<VkObject>::iterator it = pObjInfo->pMemObjInfo->pObjBindings.begin(); it != pObjInfo->pMemObjInfo->pObjBindings.end(); ++it) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 638 | if ((*it) == object) { |
| 639 | pObjInfo->pMemObjInfo->refCount--; |
| 640 | pObjInfo->pMemObjInfo->pObjBindings.erase(it); |
| 641 | pObjInfo->pMemObjInfo = NULL; |
| 642 | result = VK_TRUE; |
| 643 | break; |
| 644 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 645 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 646 | if (result == VK_FALSE) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 647 | char str[1024]; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 648 | sprintf(str, "While trying to clear mem binding for object %p, unable to find that object referenced by mem obj %p", |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 649 | object, pObjInfo->pMemObjInfo->mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 650 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 651 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 652 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 653 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 654 | return result; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | // For NULL mem case, clear any previous binding Else... |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 658 | // Make sure given object is in global object map |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 659 | // IF a previous binding existed, clear it |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 660 | // Add reference from objectInfo to memoryInfo |
| 661 | // Add reference off of objInfo |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 662 | // Return VK_TRUE if addition is successful, VK_FALSE otherwise |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 663 | static bool32_t updateObjectBinding(VkObject object, VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 664 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 665 | bool32_t result = VK_FALSE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 666 | // Handle NULL case separately, just clear previous binding & decrement reference |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 667 | if (mem == VK_NULL_HANDLE) { |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 668 | clearObjectBinding(object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 669 | result = VK_TRUE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 670 | } else { |
| 671 | char str[1024]; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 672 | MT_OBJ_INFO* pObjInfo = getObjectInfo(object); |
| 673 | if (!pObjInfo) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 674 | sprintf(str, "Attempting to update Binding of Obj(%p) that's not in global list()", (void*)object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 675 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); |
| 676 | return VK_FALSE; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 677 | } |
| 678 | // non-null case so should have real mem obj |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 679 | MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); |
| 680 | if (!pInfo) { |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 681 | sprintf(str, "While trying to bind mem for obj %p, couldn't find info for mem obj %p", (void*)object, (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 682 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 683 | } else { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 684 | // Search for object in memory object's binding list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 685 | bool32_t found = VK_FALSE; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 686 | for (list<VkObject>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 687 | if ((*it) == object) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 688 | found = VK_TRUE; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 689 | break; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 690 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 691 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 692 | // If not present, add to list |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 693 | if (found == VK_FALSE) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 694 | pInfo->pObjBindings.push_front(object); |
| 695 | pInfo->refCount++; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 696 | } |
| 697 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 698 | if (pObjInfo->pMemObjInfo) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 699 | clearObjectBinding(object); // Need to clear the previous object binding before setting new binding |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 700 | sprintf(str, "Updating memory binding for object %p from mem obj %p to %p", object, pObjInfo->pMemObjInfo->mem, mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 701 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 702 | } |
| 703 | // For image objects, make sure default memory state is correctly set |
| 704 | // TODO : What's the best/correct way to handle this? |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 705 | if (VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pObjInfo->sType) { |
| 706 | if (pObjInfo->create_info.image_create_info.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 707 | // TODO:: More memory state transition stuff. |
| 708 | } |
| 709 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 710 | pObjInfo->pMemObjInfo = pInfo; |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 711 | } |
| 712 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 713 | return VK_TRUE; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 714 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 715 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 716 | // Print details of global Obj tracking list |
| 717 | static void printObjList() |
| 718 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 719 | MT_OBJ_INFO* pInfo = NULL; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 720 | char str[1024]; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 721 | sprintf(str, "Details of Object list of size %lu elements", objectMap.size()); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 722 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 723 | for (map<VkObject, MT_OBJ_INFO*>::iterator ii=objectMap.begin(); ii!=objectMap.end(); ++ii) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 724 | pInfo = (*ii).second; |
| 725 | sprintf(str, " ObjInfo %p has object %p, pMemObjInfo %p", pInfo, pInfo->object, pInfo->pMemObjInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 726 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pInfo->object, 0, MEMTRACK_NONE, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 727 | } |
| 728 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 729 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 730 | // For given Object, get 'mem' obj that it's bound to or NULL if no binding |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 731 | static VkDeviceMemory getMemBindingFromObject(const VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 732 | { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 733 | VkDeviceMemory mem = NULL; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 734 | MT_OBJ_INFO* pObjInfo = getObjectInfo(object); |
| 735 | if (pObjInfo) { |
| 736 | if (pObjInfo->pMemObjInfo) { |
| 737 | mem = pObjInfo->pMemObjInfo->mem; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 738 | } |
| 739 | else { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 740 | char str[1024]; |
| 741 | sprintf(str, "Trying to get mem binding for object %p but object has no mem binding", (void*)object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 742 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_MISSING_MEM_BINDINGS, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 743 | printObjList(); |
| 744 | } |
| 745 | } |
| 746 | else { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 747 | char str[1024]; |
| 748 | sprintf(str, "Trying to get mem binding for object %p but no such object in global list", (void*)object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 749 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INVALID_OBJECT, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 750 | printObjList(); |
| 751 | } |
| 752 | return mem; |
| 753 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 754 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 755 | // Print details of MemObjInfo list |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 756 | static void printMemList() |
| 757 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 758 | MT_MEM_OBJ_INFO* pInfo = NULL; |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 759 | // Just printing each msg individually for now, may want to package these into single large print |
| 760 | char str[1024]; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 761 | sprintf(str, "MEM INFO : Details of Memory Object list of size %lu elements", memObjMap.size()); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 762 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 763 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 764 | for (map<VkDeviceMemory, MT_MEM_OBJ_INFO*>::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 765 | pInfo = (*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 766 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 767 | sprintf(str, " ===MemObjInfo at %p===", (void*)pInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 768 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 769 | sprintf(str, " Mem object: %p", (void*)pInfo->mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 770 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 771 | sprintf(str, " Ref Count: %u", pInfo->refCount); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 772 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 773 | if (0 != pInfo->allocInfo.allocationSize) { |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 774 | string pAllocInfoMsg = vk_print_vkmemoryallocinfo(&pInfo->allocInfo, "{MEM}INFO : "); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 775 | sprintf(str, " Mem Alloc info:\n%s", pAllocInfoMsg.c_str()); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 776 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 777 | } else { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 778 | sprintf(str, " Mem Alloc info is NULL (alloc done by vkCreateSwapChainWSI())"); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 779 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 780 | } |
| 781 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 782 | sprintf(str, " VK OBJECT Binding list of size %lu elements:", pInfo->pObjBindings.size()); |
| 783 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 784 | for (list<VkObject>::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 785 | sprintf(str, " VK OBJECT %p", (*it)); |
| 786 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 787 | } |
| 788 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 789 | sprintf(str, " VK Command Buffer (CB) binding list of size %lu elements", pInfo->pCmdBufferBindings.size()); |
| 790 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 791 | for (list<VkCmdBuffer>::iterator it = pInfo->pCmdBufferBindings.begin(); it != pInfo->pCmdBufferBindings.end(); ++it) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 792 | sprintf(str, " VK CB %p", (*it)); |
| 793 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 798 | static void printCBList() |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 799 | { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 800 | char str[1024] = {0}; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 801 | MT_CB_INFO* pCBInfo = NULL; |
| 802 | sprintf(str, "Details of CB list of size %lu elements", cbMap.size()); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 803 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 804 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 805 | for (map<VkCmdBuffer, MT_CB_INFO*>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 806 | pCBInfo = (*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 807 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 808 | sprintf(str, " CB Info (%p) has CB %p, fenceId %" PRIx64", and fence %p", |
| 809 | (void*)pCBInfo, (void*)pCBInfo->cmdBuffer, pCBInfo->fenceId, |
| 810 | (void*)getFenceFromId(pCBInfo->fenceId)); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 811 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 812 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 813 | for (list<VkDeviceMemory>::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 814 | sprintf(str, " Mem obj %p", (*it)); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 815 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 820 | static void initMemTracker(void) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 821 | { |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 822 | const char *strOpt; |
| 823 | // initialize MemTracker options |
Ian Elliott | e782671 | 2015-03-06 13:50:05 -0700 | [diff] [blame] | 824 | getLayerOptionEnum("MemTrackerReportLevel", (uint32_t *) &g_reportingLevel); |
| 825 | g_actionIsDefault = getLayerOptionEnum("MemTrackerDebugAction", (uint32_t *) &g_debugAction); |
Tobin Ehlis | ee70223 | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 826 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 827 | if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG) |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 828 | { |
| 829 | strOpt = getLayerOption("MemTrackerLogFilename"); |
| 830 | if (strOpt) |
| 831 | { |
| 832 | g_logFile = fopen(strOpt, "w"); |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 833 | } |
| 834 | if (g_logFile == NULL) |
| 835 | g_logFile = stdout; |
| 836 | } |
| 837 | |
| 838 | // initialize Layer dispatch table |
| 839 | // TODO handle multiple GPUs |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 840 | PFN_vkGetProcAddr fpNextGPA; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 841 | fpNextGPA = pCurObj->pGPA; |
| 842 | assert(fpNextGPA); |
| 843 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 844 | layer_initialize_dispatch_table(&nextTable, fpNextGPA, (VkPhysicalDevice) pCurObj->nextObject); |
Chia-I Wu | aa4121f | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 845 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 846 | if (!globalLockInitialized) |
| 847 | { |
| 848 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 849 | // suggestion is to call this during vkCreateInstance(), and then we |
| 850 | // can clean it up during vkDestroyInstance(). However, that requires |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 851 | // that the layer have per-instance locks. We need to come back and |
| 852 | // address this soon. |
| 853 | loader_platform_thread_create_mutex(&globalLock); |
| 854 | globalLockInitialized = 1; |
| 855 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 856 | } |
| 857 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 858 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 859 | { |
Jon Ashburn | 4d9f465 | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 860 | pCurObj = (VkBaseLayerObject *) gpu; |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 861 | loader_platform_thread_once(&g_initOnce, initMemTracker); |
Jon Ashburn | 4d9f465 | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 862 | VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 863 | // Save off device in case we need it to create Fences |
| 864 | globalDevice = *pDevice; |
| 865 | return result; |
| 866 | } |
| 867 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 868 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 869 | { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 870 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 871 | sprintf(str, "Printing List details prior to vkDestroyDevice()"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 872 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 873 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, device, 0, MEMTRACK_NONE, "MEM", str); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 874 | printMemList(); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 875 | printCBList(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 876 | printObjList(); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 877 | if (VK_FALSE == deleteCBInfoList()) { |
| 878 | sprintf(str, "Issue deleting global CB list in vkDestroyDevice()"); |
| 879 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, device, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 880 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 881 | // Report any memory leaks |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 882 | MT_MEM_OBJ_INFO* pInfo = NULL; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 883 | for (map<VkDeviceMemory, MT_MEM_OBJ_INFO*>::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 884 | pInfo = (*ii).second; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 885 | |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 886 | if (pInfo->allocInfo.allocationSize != 0) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 887 | sprintf(str, "Mem Object %p has not been freed. You should clean up this memory by calling vkFreeMemory(%p) prior to vkDestroyDevice().", |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 888 | pInfo->mem, pInfo->mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 889 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pInfo->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", str); |
Mark Lobodzinski | 2f3b19b | 2015-02-18 18:06:24 -0600 | [diff] [blame] | 890 | } |
Tobin Ehlis | b54ef78 | 2014-11-25 18:01:12 -0700 | [diff] [blame] | 891 | } |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 892 | |
| 893 | // Queues persist until device is destroyed |
| 894 | deleteQueueInfoList(); |
| 895 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 896 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 897 | VkResult result = nextTable.DestroyDevice(device); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 898 | return result; |
| 899 | } |
| 900 | |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 901 | struct extProps { |
| 902 | uint32_t version; |
| 903 | const char * const name; |
| 904 | }; |
Jon Ashburn | 120cfbe | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 905 | #define MEM_TRACKER_LAYER_EXT_ARRAY_SIZE 2 |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 906 | static const struct extProps mtExts[MEM_TRACKER_LAYER_EXT_ARRAY_SIZE] = { |
| 907 | // TODO what is the version? |
Jon Ashburn | 120cfbe | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 908 | 0x10, "MemTracker", |
| 909 | 0x10, "Validation" |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 910 | }; |
| 911 | |
| 912 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( |
| 913 | VkExtensionInfoType infoType, |
| 914 | uint32_t extensionIndex, |
| 915 | size_t* pDataSize, |
| 916 | void* pData) |
| 917 | { |
| 918 | VkResult result; |
| 919 | |
| 920 | /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ |
| 921 | VkExtensionProperties *ext_props; |
| 922 | uint32_t *count; |
| 923 | |
| 924 | if (pDataSize == NULL) |
| 925 | return VK_ERROR_INVALID_POINTER; |
| 926 | |
| 927 | switch (infoType) { |
| 928 | case VK_EXTENSION_INFO_TYPE_COUNT: |
| 929 | *pDataSize = sizeof(uint32_t); |
| 930 | if (pData == NULL) |
| 931 | return VK_SUCCESS; |
| 932 | count = (uint32_t *) pData; |
| 933 | *count = MEM_TRACKER_LAYER_EXT_ARRAY_SIZE; |
| 934 | break; |
| 935 | case VK_EXTENSION_INFO_TYPE_PROPERTIES: |
| 936 | *pDataSize = sizeof(VkExtensionProperties); |
| 937 | if (pData == NULL) |
| 938 | return VK_SUCCESS; |
| 939 | if (extensionIndex >= MEM_TRACKER_LAYER_EXT_ARRAY_SIZE) |
| 940 | return VK_ERROR_INVALID_VALUE; |
| 941 | ext_props = (VkExtensionProperties *) pData; |
| 942 | ext_props->version = mtExts[extensionIndex].version; |
| 943 | strncpy(ext_props->extName, mtExts[extensionIndex].name, |
| 944 | VK_MAX_EXTENSION_NAME); |
| 945 | ext_props->extName[VK_MAX_EXTENSION_NAME - 1] = '\0'; |
| 946 | break; |
| 947 | default: |
| 948 | return VK_ERROR_INVALID_VALUE; |
| 949 | }; |
| 950 | |
| 951 | return VK_SUCCESS; |
| 952 | } |
| 953 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 954 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, size_t maxLayerCount, |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 955 | size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 956 | { |
Jon Ashburn | f7a0874 | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 957 | if (gpu != NULL) |
| 958 | { |
Jon Ashburn | 4d9f465 | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 959 | pCurObj = (VkBaseLayerObject *) gpu; |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 960 | loader_platform_thread_once(&g_initOnce, initMemTracker); |
Jon Ashburn | 4d9f465 | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 961 | VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount, |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 962 | maxStringSize, pOutLayerCount, pOutLayers, pReserved); |
Jon Ashburn | f7a0874 | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 963 | return result; |
| 964 | } else |
| 965 | { |
| 966 | if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 967 | return VK_ERROR_INVALID_POINTER; |
Jon Ashburn | f7a0874 | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 968 | // This layer compatible with all GPUs |
| 969 | *pOutLayerCount = 1; |
Chia-I Wu | 1da4b9f | 2014-12-16 10:47:33 +0800 | [diff] [blame] | 970 | strncpy((char *) pOutLayers[0], "MemTracker", maxStringSize); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 971 | return VK_SUCCESS; |
Jon Ashburn | f7a0874 | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 972 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 975 | VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue) |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 976 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 977 | VkResult result = nextTable.GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 978 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 979 | loader_platform_thread_lock_mutex(&globalLock); |
| 980 | addQueueInfo(*pQueue); |
| 981 | loader_platform_thread_unlock_mutex(&globalLock); |
| 982 | } |
Mark Lobodzinski | 748eddf | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 983 | return result; |
| 984 | } |
| 985 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 986 | VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences(VkQueue queue, uint32_t count, const VkDeviceMemory* pMems) |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 987 | { |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 988 | VkResult result = nextTable.QueueAddMemReferences(queue, count, pMems); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 989 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 990 | loader_platform_thread_lock_mutex(&globalLock); |
| 991 | |
| 992 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 993 | if (pQueueInfo == NULL) { |
| 994 | char str[1024]; |
| 995 | sprintf(str, "Unknown Queue %p", queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 996 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_INVALID_QUEUE, "MEM", str); |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 997 | } else { |
| 998 | for (int i = 0; i < count; i++) { |
| 999 | if (checkMemRef(queue, pMems[i]) == VK_TRUE) { |
| 1000 | // Alread in list, just warn |
| 1001 | char str[1024]; |
| 1002 | sprintf(str, "Request to add a memory reference (%p) to Queue %p -- ref is already present in the queue's reference list", pMems[i], queue); |
| 1003 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pMems[i], 0, MEMTRACK_INVALID_MEM_REF, "MEM", str); |
| 1004 | } else { |
| 1005 | // Add to queue's memory reference list |
| 1006 | pQueueInfo->pMemRefList.push_front(pMems[i]); |
| 1007 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1008 | } |
| 1009 | } |
| 1010 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1011 | } |
| 1012 | return result; |
| 1013 | } |
| 1014 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1015 | VK_LAYER_EXPORT VkResult VKAPI vkQueueRemoveMemReferences(VkQueue queue, uint32_t count, const VkDeviceMemory* pMems) |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1016 | { |
| 1017 | // TODO : Decrement ref count for this memory reference on this queue. Remove if ref count is zero. |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1018 | VkResult result = nextTable.QueueRemoveMemReferences(queue, count, pMems); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1019 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1020 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1021 | |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1022 | MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; |
| 1023 | if (pQueueInfo == NULL) { |
| 1024 | char str[1024]; |
| 1025 | sprintf(str, "Unknown Queue %p", queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1026 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_INVALID_QUEUE, "MEM", str); |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1027 | } else { |
| 1028 | for (int i = 0; i < count; i++) { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1029 | for (list<VkDeviceMemory>::iterator it = pQueueInfo->pMemRefList.begin(); it != pQueueInfo->pMemRefList.end(); ++it) { |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1030 | if ((*it) == pMems[i]) { |
| 1031 | it = pQueueInfo->pMemRefList.erase(it); |
| 1032 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1037 | } |
| 1038 | return result; |
| 1039 | } |
| 1040 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1041 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( |
| 1042 | VkQueue queue, |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1043 | uint32_t cmdBufferCount, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1044 | const VkCmdBuffer *pCmdBuffers, |
| 1045 | VkFence fence) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1046 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1047 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1048 | // TODO : Need to track fence and clear mem references when fence clears |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1049 | MT_CB_INFO* pCBInfo = NULL; |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1050 | uint64_t fenceId = addFenceInfo(fence, queue); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1051 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1052 | printMemList(); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1053 | printCBList(); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1054 | for (uint32_t i = 0; i < cmdBufferCount; i++) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1055 | pCBInfo = getCBInfo(pCmdBuffers[i]); |
| 1056 | pCBInfo->fenceId = fenceId; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1057 | } |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1058 | |
Mark Lobodzinski | e01252d | 2015-04-17 11:44:25 -0500 | [diff] [blame] | 1059 | validateQueueMemRefs(queue, cmdBufferCount, pCmdBuffers); |
Mark Lobodzinski | ed450b0 | 2015-04-07 13:38:21 -0500 | [diff] [blame] | 1060 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1061 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1062 | VkResult result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, getFenceFromId(fenceId)); |
Courtney Goeltzenleuchter | d3fb955 | 2015-04-02 13:39:07 -0600 | [diff] [blame] | 1063 | return result; |
| 1064 | } |
| 1065 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1066 | VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1067 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1068 | VkResult result = nextTable.AllocMemory(device, pAllocInfo, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1069 | // TODO : Track allocations and overall size here |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1070 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1071 | addMemObjInfo(*pMem, pAllocInfo); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1072 | printMemList(); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1073 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1074 | return result; |
| 1075 | } |
| 1076 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1077 | VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1078 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1079 | /* 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] | 1080 | * freeing a memory object, an application must ensure the memory object is unbound from |
| 1081 | * all API objects referencing it and that it is not referenced by any queued command buffers |
| 1082 | */ |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1083 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1084 | if (VK_FALSE == freeMemObjInfo(mem, false)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1085 | char str[1024]; |
| 1086 | sprintf(str, "Issue while freeing mem obj %p", (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1087 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_FREE_MEM_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1088 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1089 | printMemList(); |
| 1090 | printObjList(); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1091 | printCBList(); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1092 | loader_platform_thread_unlock_mutex(&globalLock); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1093 | VkResult result = nextTable.FreeMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1094 | return result; |
| 1095 | } |
| 1096 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1097 | VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkDeviceMemory mem, VkMemoryPriority priority) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1098 | { |
| 1099 | // TODO : Update tracking for this alloc |
| 1100 | // Make sure memory is not pinned, which can't have priority set |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1101 | VkResult result = nextTable.SetMemoryPriority(device, mem, priority); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1102 | return result; |
| 1103 | } |
| 1104 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1105 | VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1106 | { |
| 1107 | // TODO : Track when memory is mapped |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1108 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1109 | MT_MEM_OBJ_INFO *pMemObj = getMemObjInfo(mem); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1110 | if ((pMemObj->allocInfo.memProps & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) { |
Mark Lobodzinski | 95152dc | 2015-02-25 12:16:04 -0600 | [diff] [blame] | 1111 | char str[1024]; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1112 | sprintf(str, "Mapping Memory (%p) without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set", (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1113 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_STATE, "MEM", str); |
Mark Lobodzinski | 95152dc | 2015-02-25 12:16:04 -0600 | [diff] [blame] | 1114 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1115 | loader_platform_thread_unlock_mutex(&globalLock); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1116 | VkResult result = nextTable.MapMemory(device, mem, offset, size, flags, ppData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1117 | return result; |
| 1118 | } |
| 1119 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1120 | VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1121 | { |
| 1122 | // TODO : Track as memory gets unmapped, do we want to check what changed following map? |
| 1123 | // Make sure that memory was ever mapped to begin with |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1124 | VkResult result = nextTable.UnmapMemory(device, mem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1125 | return result; |
| 1126 | } |
| 1127 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1128 | VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSysMem, size_t memSize, VkDeviceMemory* pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1129 | { |
| 1130 | // TODO : Track this |
| 1131 | // Verify that memory is actually pinnable |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1132 | VkResult result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1133 | return result; |
| 1134 | } |
| 1135 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1136 | VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1137 | { |
| 1138 | // TODO : Track this |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1139 | VkResult result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1140 | return result; |
| 1141 | } |
| 1142 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1143 | VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory(VkDevice device, const VkPeerMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1144 | { |
| 1145 | // TODO : Track this |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1146 | VkResult result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1147 | return result; |
| 1148 | } |
| 1149 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1150 | VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage(VkDevice device, const VkPeerImageOpenInfo* pOpenInfo, VkImage* pImage, VkDeviceMemory* pMem) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1151 | { |
| 1152 | // TODO : Track this |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1153 | VkResult result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1154 | return result; |
| 1155 | } |
| 1156 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1157 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1158 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1159 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1160 | |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1161 | // First check if this is a CmdBuffer |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1162 | if (NULL != getCBInfo((VkCmdBuffer)object)) { |
| 1163 | deleteCBInfo((VkCmdBuffer)object); |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1164 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1165 | |
| 1166 | if (objectMap.find(object) != objectMap.end()) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1167 | MT_OBJ_INFO* pDelInfo = objectMap[object]; |
| 1168 | if (pDelInfo->pMemObjInfo) { |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1169 | // Wsi allocated Memory is tied to image object so clear the binding and free that memory automatically |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1170 | if (0 == pDelInfo->pMemObjInfo->allocInfo.allocationSize) { // Wsi allocated memory has NULL allocInfo w/ 0 size |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1171 | VkDeviceMemory memToFree = pDelInfo->pMemObjInfo->mem; |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1172 | clearObjectBinding(object); |
Courtney Goeltzenleuchter | 1c943a7 | 2015-03-26 16:15:39 -0600 | [diff] [blame] | 1173 | freeMemObjInfo(memToFree, true); |
| 1174 | } |
| 1175 | else { |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1176 | char str[1024]; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 1177 | sprintf(str, "Destroying obj %p that is still bound to memory object %p\nYou should first clear binding by calling vkQueueBindObjectMemory(queue, %p, 0, VK_NULL_HANDLE, 0)", object, (void*)pDelInfo->pMemObjInfo->mem, object); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1178 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_DESTROY_OBJECT_ERROR, "MEM", str); |
Tobin Ehlis | a98df73 | 2014-11-27 07:52:04 -0700 | [diff] [blame] | 1179 | // From the spec : If an object has previous memory binding, it is required to unbind memory from an API object before it is destroyed. |
| 1180 | clearObjectBinding(object); |
| 1181 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1182 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1183 | delete pDelInfo; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1184 | objectMap.erase(object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1185 | } |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1186 | |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1187 | loader_platform_thread_unlock_mutex(&globalLock); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1188 | VkResult result = nextTable.DestroyObject(device, objType, object); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1189 | return result; |
| 1190 | } |
| 1191 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1192 | VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1193 | { |
| 1194 | // TODO : What to track here? |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 1195 | // Could potentially save returned mem requirements and validate values passed into QueueBindObjectMemory for this object |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1196 | // From spec : The only objects that are guaranteed to have no external memory requirements are devices, queues, command buffers, shaders and memory objects. |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1197 | VkResult result = nextTable.GetObjectInfo(device, objType, object, infoType, pDataSize, pData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1198 | return result; |
| 1199 | } |
| 1200 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1201 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemory(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceMemory mem, VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1202 | { |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1203 | VkResult result = nextTable.QueueBindObjectMemory(queue, objType, object, allocationIdx, mem, offset); |
| 1204 | loader_platform_thread_lock_mutex(&globalLock); |
| 1205 | // Track objects tied to memory |
| 1206 | if (VK_FALSE == updateObjectBinding(object, mem)) { |
| 1207 | char str[1024]; |
| 1208 | sprintf(str, "Unable to set object %p binding to mem obj %p", (void*)object, (void*)mem); |
| 1209 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
| 1210 | } |
| 1211 | printObjList(); |
| 1212 | printMemList(); |
| 1213 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1214 | return result; |
| 1215 | } |
| 1216 | |
| 1217 | VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemoryRange(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset) |
| 1218 | { |
| 1219 | VkResult result = nextTable.QueueBindObjectMemoryRange(queue, objType, object, allocationIdx, rangeOffset, rangeSize, mem, memOffset); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1220 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1221 | // Track objects tied to memory |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1222 | if (VK_FALSE == updateObjectBinding(object, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1223 | char str[1024]; |
| 1224 | sprintf(str, "Unable to set object %p binding to mem obj %p", (void*)object, (void*)mem); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1225 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1226 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1227 | printObjList(); |
| 1228 | printMemList(); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1229 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1230 | return result; |
| 1231 | } |
| 1232 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1233 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1234 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1235 | VkResult result = nextTable.CreateFence(device, pCreateInfo, pFence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1236 | if (VK_SUCCESS == result) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1237 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1238 | addObjectInfo(*pFence, pCreateInfo->sType, pCreateInfo, sizeof(VkFenceCreateInfo), "fence"); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1239 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1240 | } |
| 1241 | return result; |
| 1242 | } |
| 1243 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1244 | VK_LAYER_EXPORT VkResult VKAPI vkResetFences(VkDevice device, uint32_t fenceCount, VkFence* pFences) |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1245 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1246 | VkResult result = nextTable.ResetFences(device, fenceCount, pFences); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1247 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1248 | loader_platform_thread_lock_mutex(&globalLock); |
| 1249 | // Reset fence state in fenceCreateInfo structure |
| 1250 | for (uint32_t i = 0; i < fenceCount; i++) { |
| 1251 | MT_OBJ_INFO* pObjectInfo = getObjectInfo(pFences[i]); |
| 1252 | if (pObjectInfo != NULL) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1253 | // Validate fences in SIGNALED state |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1254 | if (!(pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT)) { |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1255 | char str[1024]; |
Mark Lobodzinski | b268921 | 2015-04-14 14:09:32 -0500 | [diff] [blame] | 1256 | sprintf(str, "Fence %p submitted to VkResetFences in UNSIGNALED STATE", pFences[i]); |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1257 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pFences[i], 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", str); |
| 1258 | result = VK_ERROR_INVALID_VALUE; |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1259 | } |
| 1260 | else { |
| 1261 | pObjectInfo->create_info.fence_create_info.flags = |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1262 | static_cast<VkFenceCreateFlags>(pObjectInfo->create_info.fence_create_info.flags & ~VK_FENCE_CREATE_SIGNALED_BIT); |
Mark Lobodzinski | abc1bc4 | 2015-04-09 13:46:09 -0500 | [diff] [blame] | 1263 | } |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1264 | } |
| 1265 | } |
| 1266 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1267 | } |
| 1268 | return result; |
| 1269 | } |
| 1270 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1271 | VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1272 | { |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 1273 | VkResult result = nextTable.GetFenceStatus(device, fence); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1274 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1275 | loader_platform_thread_lock_mutex(&globalLock); |
| 1276 | updateFenceTracking(fence); |
| 1277 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1278 | } |
| 1279 | return result; |
| 1280 | } |
| 1281 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1282 | VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, bool32_t waitAll, uint64_t timeout) |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1283 | { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1284 | // Verify fence status of submitted fences |
| 1285 | for(uint32_t i = 0; i < fenceCount; i++) { |
| 1286 | MT_OBJ_INFO* pObjectInfo = getObjectInfo(pFences[i]); |
| 1287 | if (pObjectInfo != NULL) { |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1288 | if (pObjectInfo->create_info.fence_create_info.flags & VK_FENCE_CREATE_SIGNALED_BIT) { |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1289 | char str[1024]; |
Mark Lobodzinski | b268921 | 2015-04-14 14:09:32 -0500 | [diff] [blame] | 1290 | sprintf(str, "VkWaitForFences specified fence %p already in SIGNALED state.", pFences[i]); |
Tobin Ehlis | b870cbb | 2015-04-15 07:46:12 -0600 | [diff] [blame] | 1291 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pFences[i], 0, MEMTRACK_INVALID_FENCE_STATE, "MEM", str); |
Mark Lobodzinski | 148e158 | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1292 | } |
| 1293 | } |
| 1294 | } |
| 1295 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1296 | VkResult result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1297 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1298 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1299 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1300 | if (waitAll || fenceCount == 1) { // Clear all the fences |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1301 | for(uint32_t i = 0; i < fenceCount; i++) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1302 | updateFenceTracking(pFences[i]); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1303 | } |
| 1304 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1305 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1306 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1307 | return result; |
| 1308 | } |
| 1309 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1310 | VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1311 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1312 | VkResult result = nextTable.QueueWaitIdle(queue); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1313 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1314 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1315 | retireQueueFences(queue); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1316 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1317 | } |
| 1318 | return result; |
| 1319 | } |
| 1320 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1321 | VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1322 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1323 | VkResult result = nextTable.DeviceWaitIdle(device); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1324 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1325 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 5093297 | 2015-04-02 20:49:09 -0500 | [diff] [blame] | 1326 | retireDeviceFences(device); |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1327 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1328 | } |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1329 | return result; |
| 1330 | } |
| 1331 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1332 | VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1333 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1334 | VkResult result = nextTable.CreateEvent(device, pCreateInfo, pEvent); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1335 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1336 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1337 | addObjectInfo(*pEvent, pCreateInfo->sType, pCreateInfo, sizeof(VkEventCreateInfo), "event"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1338 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1339 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1340 | return result; |
| 1341 | } |
| 1342 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1343 | VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1344 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1345 | VkResult result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1346 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1347 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1348 | addObjectInfo(*pQueryPool, pCreateInfo->sType, pCreateInfo, sizeof(VkQueryPoolCreateInfo), "query_pool"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1349 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1350 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1351 | return result; |
| 1352 | } |
| 1353 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1354 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1355 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1356 | VkResult result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1357 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1358 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1359 | addObjectInfo(*pBuffer, pCreateInfo->sType, pCreateInfo, sizeof(VkBufferCreateInfo), "buffer"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1360 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1361 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1362 | return result; |
| 1363 | } |
| 1364 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1365 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView) |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1366 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1367 | VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1368 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1369 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1370 | addObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkBufferViewCreateInfo), "buffer_view"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1371 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1372 | } |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1373 | return result; |
| 1374 | } |
| 1375 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1376 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1377 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1378 | VkResult result = nextTable.CreateImage(device, pCreateInfo, pImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1379 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1380 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1381 | addObjectInfo(*pImage, pCreateInfo->sType, pCreateInfo, sizeof(VkImageCreateInfo), "image"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1382 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1383 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1384 | return result; |
| 1385 | } |
| 1386 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1387 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1388 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1389 | VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1390 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1391 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1392 | addObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkImageViewCreateInfo), "image_view"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1393 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1394 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1395 | return result; |
| 1396 | } |
| 1397 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1398 | VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, |
| 1399 | VkColorAttachmentView* pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1400 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1401 | VkResult result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1402 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1403 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1404 | addObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkColorAttachmentViewCreateInfo), "color_attachment_view"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1405 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1406 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1407 | return result; |
| 1408 | } |
| 1409 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1410 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1411 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1412 | VkResult result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1413 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1414 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1415 | addObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(VkDepthStencilViewCreateInfo), "ds_view"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1416 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1417 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1418 | return result; |
| 1419 | } |
| 1420 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1421 | VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1422 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1423 | VkResult result = nextTable.CreateShader(device, pCreateInfo, pShader); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1424 | return result; |
| 1425 | } |
| 1426 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1427 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1428 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1429 | VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1430 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1431 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1432 | addObjectInfo(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo), "graphics_pipeline"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1433 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1434 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1435 | return result; |
| 1436 | } |
| 1437 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1438 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( |
| 1439 | VkDevice device, |
| 1440 | const VkGraphicsPipelineCreateInfo* pCreateInfo, |
| 1441 | VkPipeline basePipeline, |
| 1442 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 0d40f15 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1443 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1444 | VkResult result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1445 | if (result == VK_SUCCESS) { |
Courtney Goeltzenleuchter | 0d40f15 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1446 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1447 | addObjectInfo(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo), "graphics_pipeline"); |
Courtney Goeltzenleuchter | 0d40f15 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1448 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1449 | } |
| 1450 | return result; |
| 1451 | } |
| 1452 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1453 | VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1454 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1455 | VkResult result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1456 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1457 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1458 | addObjectInfo(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(VkComputePipelineCreateInfo), "compute_pipeline"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1459 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1460 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1461 | return result; |
| 1462 | } |
| 1463 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1464 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1465 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1466 | VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1467 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1468 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1469 | addObjectInfo(*pSampler, pCreateInfo->sType, pCreateInfo, sizeof(VkSamplerCreateInfo), "sampler"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1470 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1471 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1472 | return result; |
| 1473 | } |
| 1474 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1475 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1476 | VkDynamicVpState* pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1477 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1478 | VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1479 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1480 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1481 | addObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicVpStateCreateInfo), "viewport_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1482 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1483 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1484 | return result; |
| 1485 | } |
| 1486 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1487 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1488 | VkDynamicRsState* pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1489 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1490 | VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1491 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1492 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1493 | addObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicRsStateCreateInfo), "raster_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1494 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1495 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1496 | return result; |
| 1497 | } |
| 1498 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1499 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1500 | VkDynamicCbState* pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1501 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1502 | VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1503 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1504 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1505 | addObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicCbStateCreateInfo), "cb_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1506 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1507 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1508 | return result; |
| 1509 | } |
| 1510 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1511 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1512 | VkDynamicDsState* pState) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1513 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1514 | VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1515 | if (result == VK_SUCCESS) { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1516 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1517 | addObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(VkDynamicDsStateCreateInfo), "ds_state"); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1518 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 8be20fd | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1519 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1520 | return result; |
| 1521 | } |
| 1522 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1523 | VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1524 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1525 | VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1526 | // 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] | 1527 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1528 | if (*pCmdBuffer) |
Mark Lobodzinski | 223ca20 | 2015-04-02 08:52:53 -0500 | [diff] [blame] | 1529 | addCBInfo(*pCmdBuffer); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1530 | printCBList(); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1531 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1532 | return result; |
| 1533 | } |
| 1534 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1535 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1536 | { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1537 | // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1538 | MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); |
| 1539 | if (pCBInfo && (!fenceRetired(pCBInfo->fenceId))) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1540 | bool32_t cbDone = checkCBCompleted(cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1541 | if (VK_FALSE == cbDone) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1542 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1543 | sprintf(str, "Calling vkBeginCommandBuffer() on active CB %p before it has completed. You must check CB flag before this call.", cmdBuffer); |
| 1544 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", str); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1545 | } |
| 1546 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1547 | VkResult result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1548 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1549 | freeCBBindings(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1550 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1551 | return result; |
| 1552 | } |
| 1553 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1554 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1555 | { |
| 1556 | // TODO : Anything to do here? |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1557 | VkResult result = nextTable.EndCommandBuffer(cmdBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1558 | return result; |
| 1559 | } |
| 1560 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1561 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1562 | { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1563 | // Verify that CB is complete (not in-flight) |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1564 | MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); |
| 1565 | if (pCBInfo && (!fenceRetired(pCBInfo->fenceId))) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1566 | bool32_t cbDone = checkCBCompleted(cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1567 | if (VK_FALSE == cbDone) { |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1568 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1569 | sprintf(str, "Resetting CB %p before it has completed. You must check CB flag before calling vkResetCommandBuffer().", cmdBuffer); |
| 1570 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", str); |
Tobin Ehlis | c9dbcd5 | 2015-03-04 08:38:22 -0700 | [diff] [blame] | 1571 | } |
| 1572 | } |
| 1573 | // Clear memory references as this point. |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1574 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1575 | freeCBBindings(cmdBuffer); |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1576 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1577 | VkResult result = nextTable.ResetCommandBuffer(cmdBuffer); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1578 | return result; |
| 1579 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1580 | // 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] | 1581 | // need to account for that mem now having binding to given cmdBuffer |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1582 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1583 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1584 | #if 0 |
| 1585 | // TODO : If memory bound to pipeline, then need to tie that mem to cmdBuffer |
| 1586 | if (getPipeline(pipeline)) { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1587 | MT_CB_INFO *pCBInfo = getCBInfo(cmdBuffer); |
| 1588 | if (pCBInfo) { |
| 1589 | pCBInfo->pipelines[pipelineBindPoint] = pipeline; |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1590 | } else { |
| 1591 | char str[1024]; |
| 1592 | sprintf(str, "Attempt to bind Pipeline %p to non-existant command buffer %p!", (void*)pipeline, cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1593 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_INVALID_CB, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1594 | } |
| 1595 | } |
| 1596 | else { |
| 1597 | char str[1024]; |
| 1598 | sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1599 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pipeline, 0, MEMTRACK_INVALID_OBJECT, (char *) "DS", (char *) str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1600 | } |
| 1601 | #endif |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1602 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
| 1603 | } |
| 1604 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1605 | VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1606 | { |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1607 | MT_OBJ_INFO *pObjInfo; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1608 | loader_platform_thread_lock_mutex(&globalLock); |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1609 | MT_CB_INFO *pCmdBuf = getCBInfo(cmdBuffer); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1610 | if (!pCmdBuf) { |
| 1611 | char str[1024]; |
| 1612 | sprintf(str, "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1613 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_INVALID_CB, "DD", str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1614 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1615 | pObjInfo = getObjectInfo(state); |
| 1616 | if (!pObjInfo) { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1617 | char str[1024]; |
| 1618 | sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1619 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, state, 0, MEMTRACK_INVALID_OBJECT, "DD", str); |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1620 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1621 | pCmdBuf->pDynamicState[stateBindPoint] = pObjInfo; |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1622 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1623 | nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1624 | } |
| 1625 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1626 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets( |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1627 | VkCmdBuffer cmdBuffer, |
| 1628 | VkPipelineBindPoint pipelineBindPoint, |
Cody Northrop | d4c1a50 | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 1629 | uint32_t firstSet, |
| 1630 | uint32_t setCount, |
| 1631 | const VkDescriptorSet* pDescriptorSets, |
| 1632 | uint32_t dynamicOffsetCount, |
| 1633 | const uint32_t* pDynamicOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1634 | { |
Tobin Ehlis | c145be8 | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 1635 | // TODO : Somewhere need to verify that all textures referenced by shaders in DS are in some type of *SHADER_READ* state |
Cody Northrop | d4c1a50 | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 1636 | nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1637 | } |
| 1638 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1639 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
| 1640 | VkCmdBuffer cmdBuffer, |
| 1641 | uint32_t startBinding, |
| 1642 | uint32_t bindingCount, |
| 1643 | const VkBuffer* pBuffers, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1644 | const VkDeviceSize* pOffsets) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1645 | { |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 1646 | nextTable.CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Chia-I Wu | 1915682 | 2015-01-05 13:42:56 +0800 | [diff] [blame] | 1647 | } |
| 1648 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1649 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1650 | { |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1651 | nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1652 | } |
| 1653 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1654 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1655 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1656 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1657 | VkDeviceMemory mem = getMemBindingFromObject(buffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1658 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1659 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1660 | sprintf(str, "In vkCmdDrawIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
| 1661 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1662 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1663 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1664 | nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1665 | } |
| 1666 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1667 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1668 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1669 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1670 | VkDeviceMemory mem = getMemBindingFromObject(buffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1671 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1672 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1673 | sprintf(str, "In vkCmdDrawIndexedIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
| 1674 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1675 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1676 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1677 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1680 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1681 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1682 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1683 | VkDeviceMemory mem = getMemBindingFromObject(buffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1684 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1685 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1686 | sprintf(str, "In vkCmdDispatchIndirect() call unable to update binding of buffer %p to cmdBuffer %p", buffer, cmdBuffer); |
| 1687 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1688 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1689 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1690 | nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1691 | } |
| 1692 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1693 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, |
| 1694 | uint32_t regionCount, const VkBufferCopy* pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1695 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1696 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1697 | VkDeviceMemory mem = getMemBindingFromObject(srcBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1698 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1699 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1700 | sprintf(str, "In vkCmdCopyBuffer() call unable to update binding of srcBuffer %p to cmdBuffer %p", srcBuffer, cmdBuffer); |
| 1701 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1702 | } |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1703 | mem = getMemBindingFromObject(destBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1704 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1705 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1706 | sprintf(str, "In vkCmdCopyBuffer() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
| 1707 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1708 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1709 | loader_platform_thread_unlock_mutex(&globalLock); |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1710 | nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1713 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, |
| 1714 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 1715 | VkImage destImage, VkImageLayout destImageLayout, |
| 1716 | uint32_t regionCount, const VkImageCopy* pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1717 | { |
| 1718 | // TODO : Each image will have mem mapping so track them |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1719 | nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1720 | } |
| 1721 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1722 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer, |
| 1723 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 1724 | VkImage destImage, VkImageLayout destImageLayout, |
| 1725 | uint32_t regionCount, const VkImageBlit* pRegions) |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 1726 | { |
| 1727 | // TODO : Each image will have mem mapping so track them |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1728 | nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Courtney Goeltzenleuchter | 89299fa | 2015-03-08 17:02:18 -0600 | [diff] [blame] | 1729 | } |
| 1730 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1731 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, |
| 1732 | VkBuffer srcBuffer, |
| 1733 | VkImage destImage, VkImageLayout destImageLayout, |
| 1734 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1735 | { |
| 1736 | // TODO : Track this |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1737 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1738 | VkDeviceMemory mem = getMemBindingFromObject(destImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1739 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1740 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1741 | sprintf(str, "In vkCmdCopyMemoryToImage() call unable to update binding of destImage buffer %p to cmdBuffer %p", destImage, cmdBuffer); |
| 1742 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1743 | } |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1744 | |
| 1745 | mem = getMemBindingFromObject(srcBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1746 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1747 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1748 | sprintf(str, "In vkCmdCopyMemoryToImage() call unable to update binding of srcBuffer %p to cmdBuffer %p", srcBuffer, cmdBuffer); |
| 1749 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1750 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1751 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1752 | nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1753 | } |
| 1754 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1755 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, |
| 1756 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 1757 | VkBuffer destBuffer, |
| 1758 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1759 | { |
| 1760 | // TODO : Track this |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1761 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1762 | VkDeviceMemory mem = getMemBindingFromObject(srcImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1763 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1764 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1765 | sprintf(str, "In vkCmdCopyImageToMemory() call unable to update binding of srcImage buffer %p to cmdBuffer %p", srcImage, cmdBuffer); |
| 1766 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1767 | } |
Mark Lobodzinski | c52b775 | 2015-02-18 16:38:17 -0600 | [diff] [blame] | 1768 | mem = getMemBindingFromObject(destBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1769 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1770 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1771 | sprintf(str, "In vkCmdCopyImageToMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
| 1772 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1773 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1774 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1775 | nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1776 | } |
| 1777 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1778 | VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1779 | VkImage destImage, VkImageLayout destImageLayout) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1780 | { |
| 1781 | // TODO : Each image will have mem mapping so track them |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1782 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1783 | VkDeviceMemory mem = getMemBindingFromObject(srcImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1784 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1785 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1786 | sprintf(str, "In vkCmdCloneImageData() call unable to update binding of srcImage buffer %p to cmdBuffer %p", srcImage, cmdBuffer); |
| 1787 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1788 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1789 | mem = getMemBindingFromObject(destImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1790 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1791 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1792 | sprintf(str, "In vkCmdCloneImageData() call unable to update binding of destImage buffer %p to cmdBuffer %p", destImage, cmdBuffer); |
| 1793 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1794 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1795 | loader_platform_thread_unlock_mutex(&globalLock); |
Mike Stroyan | fb80d5f | 2014-12-04 11:08:39 +0000 | [diff] [blame] | 1796 | nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1797 | } |
| 1798 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1799 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1800 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1801 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1802 | VkDeviceMemory mem = getMemBindingFromObject(destBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1803 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1804 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1805 | sprintf(str, "In vkCmdUpdateMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
| 1806 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1807 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1808 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1809 | nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1810 | } |
| 1811 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1812 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1813 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1814 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1815 | VkDeviceMemory mem = getMemBindingFromObject(destBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1816 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1817 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1818 | sprintf(str, "In vkCmdFillMemory() call unable to update binding of destBuffer %p to cmdBuffer %p", destBuffer, cmdBuffer); |
| 1819 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1820 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1821 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 1822 | nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1823 | } |
| 1824 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1825 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, |
| 1826 | VkImage image, VkImageLayout imageLayout, |
| 1827 | VkClearColor color, |
| 1828 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1829 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1830 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1831 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1832 | VkDeviceMemory mem = getMemBindingFromObject(image); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1833 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1834 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1835 | sprintf(str, "In vkCmdClearColorImage() call unable to update binding of image buffer %p to cmdBuffer %p", image, cmdBuffer); |
| 1836 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1837 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1838 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1839 | nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, color, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1840 | } |
| 1841 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1842 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, |
| 1843 | VkImage image, VkImageLayout imageLayout, |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1844 | float depth, uint32_t stencil, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1845 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1846 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1847 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1848 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1849 | VkDeviceMemory mem = getMemBindingFromObject(image); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1850 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1851 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1852 | sprintf(str, "In vkCmdClearDepthStencil() call unable to update binding of image buffer %p to cmdBuffer %p", image, cmdBuffer); |
| 1853 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1854 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1855 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | b3efe9b | 2015-03-25 11:25:10 -0600 | [diff] [blame] | 1856 | nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1857 | } |
| 1858 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1859 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, |
| 1860 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 1861 | VkImage destImage, VkImageLayout destImageLayout, |
Tony Barbour | 6865d4a | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 1862 | uint32_t regionCount, const VkImageResolve* pRegions) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1863 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1864 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1865 | VkDeviceMemory mem = getMemBindingFromObject(srcImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1866 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1867 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1868 | sprintf(str, "In vkCmdResolveImage() call unable to update binding of srcImage buffer %p to cmdBuffer %p", srcImage, cmdBuffer); |
| 1869 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1870 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1871 | mem = getMemBindingFromObject(destImage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1872 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1873 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1874 | sprintf(str, "In vkCmdResolveImage() call unable to update binding of destImage buffer %p to cmdBuffer %p", destImage, cmdBuffer); |
| 1875 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1876 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1877 | loader_platform_thread_unlock_mutex(&globalLock); |
Tony Barbour | 6865d4a | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 1878 | nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1879 | } |
| 1880 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1881 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1882 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1883 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1884 | VkDeviceMemory mem = getMemBindingFromObject(queryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1885 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1886 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1887 | sprintf(str, "In vkCmdBeginQuery() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
| 1888 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1889 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1890 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1891 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 1892 | } |
| 1893 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1894 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1895 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1896 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1897 | VkDeviceMemory mem = getMemBindingFromObject(queryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1898 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1899 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1900 | sprintf(str, "In vkCmdEndQuery() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
| 1901 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1902 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1903 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1904 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 1905 | } |
| 1906 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1907 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1908 | { |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1909 | loader_platform_thread_lock_mutex(&globalLock); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1910 | VkDeviceMemory mem = getMemBindingFromObject(queryPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1911 | if (VK_FALSE == updateCBBinding(cmdBuffer, mem)) { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1912 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1913 | sprintf(str, "In vkCmdResetQueryPool() call unable to update binding of queryPool buffer %p to cmdBuffer %p", queryPool, cmdBuffer); |
| 1914 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1915 | } |
Mark Lobodzinski | 93f494b | 2015-03-02 20:23:52 -0600 | [diff] [blame] | 1916 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1917 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 1918 | } |
| 1919 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1920 | VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1921 | { |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1922 | // This layer intercepts callbacks |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1923 | VK_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (VK_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(VK_LAYER_DBG_FUNCTION_NODE)); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1924 | if (!pNewDbgFuncNode) |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1925 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1926 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 1927 | pNewDbgFuncNode->pUserData = pUserData; |
Jon Ashburn | 7d7b3cf | 2014-12-22 13:24:15 -0700 | [diff] [blame] | 1928 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 1929 | g_pDbgFunctionHead = pNewDbgFuncNode; |
Jon Ashburn | a8aa837 | 2015-03-03 15:07:15 -0700 | [diff] [blame] | 1930 | // force callbacks if DebugAction hasn't been set already other than initial value |
Courtney Goeltzenleuchter | 90d9320 | 2015-03-04 15:47:34 -0700 | [diff] [blame] | 1931 | if (g_actionIsDefault) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1932 | g_debugAction = VK_DBG_LAYER_ACTION_CALLBACK; |
Courtney Goeltzenleuchter | 90d9320 | 2015-03-04 15:47:34 -0700 | [diff] [blame] | 1933 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1934 | VkResult result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1935 | return result; |
| 1936 | } |
| 1937 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1938 | VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1939 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1940 | VK_LAYER_DBG_FUNCTION_NODE *pInfo = g_pDbgFunctionHead; |
| 1941 | VK_LAYER_DBG_FUNCTION_NODE *pPrev = pInfo; |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1942 | while (pInfo) { |
| 1943 | if (pInfo->pfnMsgCallback == pfnMsgCallback) { |
| 1944 | pPrev->pNext = pInfo->pNext; |
| 1945 | if (g_pDbgFunctionHead == pInfo) |
| 1946 | g_pDbgFunctionHead = pInfo->pNext; |
| 1947 | free(pInfo); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1948 | break; |
| 1949 | } |
Mark Lobodzinski | 6434eff | 2015-03-31 16:05:35 -0500 | [diff] [blame] | 1950 | pPrev = pInfo; |
| 1951 | pInfo = pInfo->pNext; |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1952 | } |
Jon Ashburn | a8aa837 | 2015-03-03 15:07:15 -0700 | [diff] [blame] | 1953 | if (g_pDbgFunctionHead == NULL) |
| 1954 | { |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1955 | if (g_actionIsDefault) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1956 | g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1957 | } else { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1958 | g_debugAction = (VK_LAYER_DBG_ACTION)(g_debugAction & ~((uint32_t)VK_DBG_LAYER_ACTION_CALLBACK)); |
Mark Lobodzinski | b6ddb46 | 2015-03-24 16:29:24 -0500 | [diff] [blame] | 1959 | } |
Jon Ashburn | a8aa837 | 2015-03-03 15:07:15 -0700 | [diff] [blame] | 1960 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1961 | VkResult result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1962 | return result; |
| 1963 | } |
| 1964 | |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1965 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1966 | { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1967 | VkResult result = nextTable.CreateSwapChainWSI(device, pCreateInfo, pSwapChain); |
| 1968 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1969 | if (VK_SUCCESS == result) { |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1970 | loader_platform_thread_lock_mutex(&globalLock); |
| 1971 | addSwapChainInfo(*pSwapChain); |
| 1972 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | cd9223b | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1973 | } |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1974 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 1975 | return result; |
| 1976 | } |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1977 | |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1978 | VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI(VkSwapChainWSI swapChain) |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1979 | { |
| 1980 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 1981 | |
| 1982 | if (swapChainMap.find(swapChain) != swapChainMap.end()) { |
| 1983 | MT_SWAP_CHAIN_INFO* pInfo = swapChainMap[swapChain]; |
| 1984 | |
| 1985 | for (std::vector<VkSwapChainImageInfoWSI>::const_iterator it = pInfo->images.begin(); |
| 1986 | it != pInfo->images.end(); it++) { |
| 1987 | clearObjectBinding(it->image); |
| 1988 | freeMemObjInfo(it->memory, true); |
| 1989 | |
| 1990 | MT_OBJ_INFO* pDelInfo = objectMap[it->image]; |
| 1991 | delete pDelInfo; |
| 1992 | objectMap.erase(it->image); |
| 1993 | } |
| 1994 | |
| 1995 | delete pInfo; |
| 1996 | swapChainMap.erase(swapChain); |
| 1997 | } |
| 1998 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 1999 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2000 | |
| 2001 | return nextTable.DestroySwapChainWSI(swapChain); |
| 2002 | } |
| 2003 | |
| 2004 | VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData) |
| 2005 | { |
| 2006 | VkResult result = nextTable.GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData); |
| 2007 | |
| 2008 | if (infoType == VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI && result == VK_SUCCESS) { |
| 2009 | const size_t count = *pDataSize / sizeof(VkSwapChainImageInfoWSI); |
| 2010 | MT_SWAP_CHAIN_INFO *pInfo = swapChainMap[swapChain]; |
| 2011 | |
| 2012 | if (pInfo->images.empty()) { |
| 2013 | pInfo->images.resize(count); |
| 2014 | memcpy(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count); |
| 2015 | |
| 2016 | for (std::vector<VkSwapChainImageInfoWSI>::const_iterator it = pInfo->images.begin(); |
| 2017 | it != pInfo->images.end(); it++) { |
| 2018 | // Add image object, then insert the new Mem Object and then bind it to created image |
| 2019 | addObjectInfo(it->image, VK_STRUCTURE_TYPE_MAX_ENUM, &pInfo->createInfo, sizeof(pInfo->createInfo), "persistent_image"); |
| 2020 | addMemObjInfo(it->memory, NULL); |
| 2021 | if (VK_FALSE == updateObjectBinding(it->image, it->memory)) { |
| 2022 | char str[1024]; |
| 2023 | sprintf(str, "In vkGetSwapChainInfoWSI(), unable to set image %p binding to mem obj %p", (void*)it->image, (void*)it->memory); |
| 2024 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, it->image, 0, MEMTRACK_MEMORY_BINDING_ERROR, "MEM", str); |
| 2025 | } |
| 2026 | } |
| 2027 | } else { |
| 2028 | const bool mismatch = (pInfo->images.size() != count || |
| 2029 | memcmp(&pInfo->images[0], pData, sizeof(pInfo->images[0]) * count)); |
| 2030 | |
| 2031 | if (mismatch) { |
| 2032 | char str[1024]; |
| 2033 | sprintf(str, "vkGetSwapChainInfoWSI(%p, VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI) returned mismatching data", swapChain); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 2034 | layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, (VkObject) swapChain, 0, MEMTRACK_NONE, "SWAP_CHAIN", str); |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2035 | } |
| 2036 | } |
| 2037 | } |
| 2038 | |
Mark Lobodzinski | e61ebe7 | 2015-03-17 10:53:12 -0500 | [diff] [blame] | 2039 | return result; |
| 2040 | } |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2041 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2042 | VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalDevice gpu, const char* funcName) |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2043 | { |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 2044 | VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu; |
Chia-I Wu | 4d11dcc | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 2045 | |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2046 | if (gpu == NULL) |
| 2047 | return NULL; |
| 2048 | pCurObj = gpuw; |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 2049 | loader_platform_thread_once(&g_initOnce, initMemTracker); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2050 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2051 | if (!strcmp(funcName, "vkGetProcAddr")) |
| 2052 | return (void *) vkGetProcAddr; |
| 2053 | if (!strcmp(funcName, "vkCreateDevice")) |
| 2054 | return (void*) vkCreateDevice; |
| 2055 | if (!strcmp(funcName, "vkDestroyDevice")) |
| 2056 | return (void*) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2057 | if (!strcmp(funcName, "vkEnumerateLayers")) |
| 2058 | return (void*) vkEnumerateLayers; |
| 2059 | if (!strcmp(funcName, "vkQueueSubmit")) |
| 2060 | return (void*) vkQueueSubmit; |
| 2061 | if (!strcmp(funcName, "vkAllocMemory")) |
| 2062 | return (void*) vkAllocMemory; |
| 2063 | if (!strcmp(funcName, "vkFreeMemory")) |
| 2064 | return (void*) vkFreeMemory; |
| 2065 | if (!strcmp(funcName, "vkSetMemoryPriority")) |
| 2066 | return (void*) vkSetMemoryPriority; |
| 2067 | if (!strcmp(funcName, "vkMapMemory")) |
| 2068 | return (void*) vkMapMemory; |
| 2069 | if (!strcmp(funcName, "vkUnmapMemory")) |
| 2070 | return (void*) vkUnmapMemory; |
| 2071 | if (!strcmp(funcName, "vkPinSystemMemory")) |
| 2072 | return (void*) vkPinSystemMemory; |
| 2073 | if (!strcmp(funcName, "vkOpenSharedMemory")) |
| 2074 | return (void*) vkOpenSharedMemory; |
| 2075 | if (!strcmp(funcName, "vkOpenPeerMemory")) |
| 2076 | return (void*) vkOpenPeerMemory; |
| 2077 | if (!strcmp(funcName, "vkOpenPeerImage")) |
| 2078 | return (void*) vkOpenPeerImage; |
| 2079 | if (!strcmp(funcName, "vkDestroyObject")) |
| 2080 | return (void*) vkDestroyObject; |
| 2081 | if (!strcmp(funcName, "vkGetObjectInfo")) |
| 2082 | return (void*) vkGetObjectInfo; |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 2083 | if (!strcmp(funcName, "vkQueueBindObjectMemory")) |
| 2084 | return (void*) vkQueueBindObjectMemory; |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame^] | 2085 | if (!strcmp(funcName, "vkQueueBindObjectMemoryRange")) |
| 2086 | return (void*) vkQueueBindObjectMemoryRange; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2087 | if (!strcmp(funcName, "vkCreateFence")) |
| 2088 | return (void*) vkCreateFence; |
| 2089 | if (!strcmp(funcName, "vkGetFenceStatus")) |
| 2090 | return (void*) vkGetFenceStatus; |
| 2091 | if (!strcmp(funcName, "vkResetFences")) |
| 2092 | return (void*) vkResetFences; |
| 2093 | if (!strcmp(funcName, "vkWaitForFences")) |
| 2094 | return (void*) vkWaitForFences; |
| 2095 | if (!strcmp(funcName, "vkQueueWaitIdle")) |
| 2096 | return (void*) vkQueueWaitIdle; |
| 2097 | if (!strcmp(funcName, "vkDeviceWaitIdle")) |
| 2098 | return (void*) vkDeviceWaitIdle; |
| 2099 | if (!strcmp(funcName, "vkCreateEvent")) |
| 2100 | return (void*) vkCreateEvent; |
| 2101 | if (!strcmp(funcName, "vkCreateQueryPool")) |
| 2102 | return (void*) vkCreateQueryPool; |
| 2103 | if (!strcmp(funcName, "vkCreateBuffer")) |
| 2104 | return (void*) vkCreateBuffer; |
| 2105 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 2106 | return (void*) vkCreateBufferView; |
| 2107 | if (!strcmp(funcName, "vkCreateImage")) |
| 2108 | return (void*) vkCreateImage; |
| 2109 | if (!strcmp(funcName, "vkCreateImageView")) |
| 2110 | return (void*) vkCreateImageView; |
| 2111 | if (!strcmp(funcName, "vkCreateColorAttachmentView")) |
| 2112 | return (void*) vkCreateColorAttachmentView; |
| 2113 | if (!strcmp(funcName, "vkCreateDepthStencilView")) |
| 2114 | return (void*) vkCreateDepthStencilView; |
| 2115 | if (!strcmp(funcName, "vkCreateShader")) |
| 2116 | return (void*) vkCreateShader; |
| 2117 | if (!strcmp(funcName, "vkCreateGraphicsPipeline")) |
| 2118 | return (void*) vkCreateGraphicsPipeline; |
| 2119 | if (!strcmp(funcName, "vkCreateGraphicsPipelineDerivative")) |
| 2120 | return (void*) vkCreateGraphicsPipelineDerivative; |
| 2121 | if (!strcmp(funcName, "vkCreateComputePipeline")) |
| 2122 | return (void*) vkCreateComputePipeline; |
| 2123 | if (!strcmp(funcName, "vkCreateSampler")) |
| 2124 | return (void*) vkCreateSampler; |
| 2125 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
| 2126 | return (void*) vkCreateDynamicViewportState; |
| 2127 | if (!strcmp(funcName, "vkCreateDynamicRasterState")) |
| 2128 | return (void*) vkCreateDynamicRasterState; |
| 2129 | if (!strcmp(funcName, "vkCreateDynamicColorBlendState")) |
| 2130 | return (void*) vkCreateDynamicColorBlendState; |
| 2131 | if (!strcmp(funcName, "vkCreateDynamicDepthStencilState")) |
| 2132 | return (void*) vkCreateDynamicDepthStencilState; |
| 2133 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
| 2134 | return (void*) vkCreateCommandBuffer; |
| 2135 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 2136 | return (void*) vkBeginCommandBuffer; |
| 2137 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
| 2138 | return (void*) vkEndCommandBuffer; |
| 2139 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
| 2140 | return (void*) vkResetCommandBuffer; |
| 2141 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
| 2142 | return (void*) vkCmdBindPipeline; |
| 2143 | if (!strcmp(funcName, "vkCmdBindDynamicStateObject")) |
| 2144 | return (void*) vkCmdBindDynamicStateObject; |
| 2145 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
| 2146 | return (void*) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2147 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
| 2148 | return (void*) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2149 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
| 2150 | return (void*) vkCmdBindIndexBuffer; |
| 2151 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
| 2152 | return (void*) vkCmdDrawIndirect; |
| 2153 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
| 2154 | return (void*) vkCmdDrawIndexedIndirect; |
| 2155 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
| 2156 | return (void*) vkCmdDispatchIndirect; |
| 2157 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
| 2158 | return (void*) vkCmdCopyBuffer; |
| 2159 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 2160 | return (void*) vkCmdCopyImage; |
| 2161 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 2162 | return (void*) vkCmdCopyBufferToImage; |
| 2163 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 2164 | return (void*) vkCmdCopyImageToBuffer; |
| 2165 | if (!strcmp(funcName, "vkCmdCloneImageData")) |
| 2166 | return (void*) vkCmdCloneImageData; |
| 2167 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
| 2168 | return (void*) vkCmdUpdateBuffer; |
| 2169 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
| 2170 | return (void*) vkCmdFillBuffer; |
| 2171 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 2172 | return (void*) vkCmdClearColorImage; |
| 2173 | if (!strcmp(funcName, "vkCmdClearDepthStencil")) |
| 2174 | return (void*) vkCmdClearDepthStencil; |
| 2175 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 2176 | return (void*) vkCmdResolveImage; |
| 2177 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
| 2178 | return (void*) vkCmdBeginQuery; |
| 2179 | if (!strcmp(funcName, "vkCmdEndQuery")) |
| 2180 | return (void*) vkCmdEndQuery; |
| 2181 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
| 2182 | return (void*) vkCmdResetQueryPool; |
| 2183 | if (!strcmp(funcName, "vkDbgRegisterMsgCallback")) |
| 2184 | return (void*) vkDbgRegisterMsgCallback; |
| 2185 | if (!strcmp(funcName, "vkDbgUnregisterMsgCallback")) |
| 2186 | return (void*) vkDbgUnregisterMsgCallback; |
| 2187 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
| 2188 | return (void*) vkGetDeviceQueue; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2189 | if (!strcmp(funcName, "vkQueueAddMemReferences")) |
| 2190 | return (void*) vkQueueAddMemReferences; |
| 2191 | if (!strcmp(funcName, "vkQueueRemoveMemReferences")) |
| 2192 | return (void*) vkQueueRemoveMemReferences; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 2193 | if (!strcmp(funcName, "vkCreateSwapChainWSI")) |
| 2194 | return (void*) vkCreateSwapChainWSI; |
| 2195 | if (!strcmp(funcName, "vkDestroySwapChainWSI")) |
| 2196 | return (void*) vkDestroySwapChainWSI; |
| 2197 | if (!strcmp(funcName, "vkGetSwapChainInfoWSI")) |
| 2198 | return (void*) vkGetSwapChainInfoWSI; |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2199 | else { |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2200 | if (gpuw->pGPA == NULL) |
| 2201 | return NULL; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2202 | return gpuw->pGPA((VkPhysicalDevice)gpuw->nextObject, funcName); |
Tobin Ehlis | 6663f49 | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 2203 | } |
| 2204 | } |