blob: c924355e560eeac19f738cd6983954a8a98f6e6c [file] [log] [blame]
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001/*
2 * GLAVE & vulkan
3 *
4 * Copyright (C) 2015 LunarG, Inc. and Valve Corporation
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
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include "loader_platform.h"
Peter Lohrmann333d68f2015-03-24 16:30:17 -070029#include "glave_snapshot.h"
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060030#include "vk_struct_string_helper.h"
Peter Lohrmannd67314b2015-03-24 16:14:01 -070031
32#define LAYER_NAME_STR "GlaveSnapshot"
33#define LAYER_ABBREV_STR "GLVSnap"
34
Jon Ashburnbacb0f52015-04-06 10:58:22 -060035static VkLayerDispatchTable nextTable;
Tobin Ehlisb870cbb2015-04-15 07:46:12 -060036static VkBaseLayerObject *pCurObj;
Peter Lohrmann506bbda2015-03-25 20:37:02 -070037
Peter Lohrmannd67314b2015-03-24 16:14:01 -070038// The following is #included again to catch certain OS-specific functions being used:
39#include "loader_platform.h"
40#include "layers_config.h"
41#include "layers_msg.h"
Peter Lohrmann506bbda2015-03-25 20:37:02 -070042
Peter Lohrmannd67314b2015-03-24 16:14:01 -070043static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);
Peter Lohrmannd67314b2015-03-24 16:14:01 -070044static int objLockInitialized = 0;
45static loader_platform_thread_mutex objLock;
46
Peter Lohrmann623be4e2015-03-26 20:38:12 -070047// The 'masterSnapshot' which gets the delta merged into it when 'GetSnapshot()' is called.
48static GLV_VK_SNAPSHOT s_snapshot = {0};
49
50// The 'deltaSnapshot' which tracks all object creation and deletion.
51static GLV_VK_SNAPSHOT s_delta = {0};
52
Peter Lohrmann6d849232015-04-01 13:54:18 -070053
54//=============================================================================
55// Helper structure for a GLAVE vulkan snapshot.
56// These can probably be auto-generated at some point.
57//=============================================================================
58
59void glv_vk_malloc_and_copy(void** ppDest, size_t size, const void* pSrc)
60{
61 *ppDest = malloc(size);
62 memcpy(*ppDest, pSrc, size);
63}
64
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060065VkDeviceCreateInfo* glv_deepcopy_VkDeviceCreateInfo(const VkDeviceCreateInfo* pSrcCreateInfo)
Peter Lohrmann6d849232015-04-01 13:54:18 -070066{
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060067 VkDeviceCreateInfo* pDestCreateInfo;
Peter Lohrmann6d849232015-04-01 13:54:18 -070068
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060069 // NOTE: partially duplicated code from add_VkDeviceCreateInfo_to_packet(...)
Peter Lohrmann6d849232015-04-01 13:54:18 -070070 {
71 uint32_t i;
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060072 glv_vk_malloc_and_copy((void**)&pDestCreateInfo, sizeof(VkDeviceCreateInfo), pSrcCreateInfo);
73 glv_vk_malloc_and_copy((void**)&pDestCreateInfo->pRequestedQueues, pSrcCreateInfo->queueRecordCount*sizeof(VkDeviceQueueCreateInfo), pSrcCreateInfo->pRequestedQueues);
Peter Lohrmann6d849232015-04-01 13:54:18 -070074
75 if (pSrcCreateInfo->extensionCount > 0)
76 {
77 glv_vk_malloc_and_copy((void**)&pDestCreateInfo->ppEnabledExtensionNames, pSrcCreateInfo->extensionCount * sizeof(char *), pSrcCreateInfo->ppEnabledExtensionNames);
78 for (i = 0; i < pSrcCreateInfo->extensionCount; i++)
79 {
80 glv_vk_malloc_and_copy((void**)&pDestCreateInfo->ppEnabledExtensionNames[i], strlen(pSrcCreateInfo->ppEnabledExtensionNames[i]) + 1, pSrcCreateInfo->ppEnabledExtensionNames[i]);
81 }
82 }
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060083 VkLayerCreateInfo *pSrcNext = ( VkLayerCreateInfo *) pSrcCreateInfo->pNext;
84 VkLayerCreateInfo **ppDstNext = ( VkLayerCreateInfo **) &pDestCreateInfo->pNext;
Peter Lohrmann6d849232015-04-01 13:54:18 -070085 while (pSrcNext != NULL)
86 {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060087 if ((pSrcNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pSrcNext->layerCount > 0)
Peter Lohrmann6d849232015-04-01 13:54:18 -070088 {
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060089 glv_vk_malloc_and_copy((void**)ppDstNext, sizeof(VkLayerCreateInfo), pSrcNext);
Peter Lohrmann6d849232015-04-01 13:54:18 -070090 glv_vk_malloc_and_copy((void**)&(*ppDstNext)->ppActiveLayerNames, pSrcNext->layerCount * sizeof(char*), pSrcNext->ppActiveLayerNames);
91 for (i = 0; i < pSrcNext->layerCount; i++)
92 {
93 glv_vk_malloc_and_copy((void**)&(*ppDstNext)->ppActiveLayerNames[i], strlen(pSrcNext->ppActiveLayerNames[i]) + 1, pSrcNext->ppActiveLayerNames[i]);
94 }
95
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060096 ppDstNext = (VkLayerCreateInfo**) &(*ppDstNext)->pNext;
Peter Lohrmann6d849232015-04-01 13:54:18 -070097 }
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060098 pSrcNext = (VkLayerCreateInfo*) pSrcNext->pNext;
Peter Lohrmann6d849232015-04-01 13:54:18 -070099 }
100 }
101
102 return pDestCreateInfo;
103}
104
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600105void glv_deepfree_VkDeviceCreateInfo(VkDeviceCreateInfo* pCreateInfo)
Peter Lohrmann6d849232015-04-01 13:54:18 -0700106{
107 uint32_t i;
108 if (pCreateInfo->pRequestedQueues != NULL)
109 {
110 free((void*)pCreateInfo->pRequestedQueues);
111 }
112
113 if (pCreateInfo->ppEnabledExtensionNames != NULL)
114 {
115 for (i = 0; i < pCreateInfo->extensionCount; i++)
116 {
117 free((void*)pCreateInfo->ppEnabledExtensionNames[i]);
118 }
119 free((void*)pCreateInfo->ppEnabledExtensionNames);
120 }
121
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600122 VkLayerCreateInfo *pSrcNext = (VkLayerCreateInfo*)pCreateInfo->pNext;
Peter Lohrmann6d849232015-04-01 13:54:18 -0700123 while (pSrcNext != NULL)
124 {
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600125 VkLayerCreateInfo* pTmp = (VkLayerCreateInfo*)pSrcNext->pNext;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600126 if ((pSrcNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pSrcNext->layerCount > 0)
Peter Lohrmann6d849232015-04-01 13:54:18 -0700127 {
128 for (i = 0; i < pSrcNext->layerCount; i++)
129 {
130 free((void*)pSrcNext->ppActiveLayerNames[i]);
131 }
132
133 free((void*)pSrcNext->ppActiveLayerNames);
134 free(pSrcNext);
135 }
136 pSrcNext = pTmp;
137 }
138
139 free(pCreateInfo);
140}
141
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600142void glv_vk_snapshot_copy_createdevice_params(GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS* pDest, VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
Peter Lohrmann6d849232015-04-01 13:54:18 -0700143{
144 pDest->gpu = gpu;
145
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600146 pDest->pCreateInfo = glv_deepcopy_VkDeviceCreateInfo(pCreateInfo);
Peter Lohrmann6d849232015-04-01 13:54:18 -0700147
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600148 pDest->pDevice = (VkDevice*)malloc(sizeof(VkDevice));
Peter Lohrmann6d849232015-04-01 13:54:18 -0700149 *pDest->pDevice = *pDevice;
150}
151
152void glv_vk_snapshot_destroy_createdevice_params(GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS* pSrc)
153{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600154 memset(&pSrc->gpu, 0, sizeof(VkPhysicalGpu));
Peter Lohrmann6d849232015-04-01 13:54:18 -0700155
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600156 glv_deepfree_VkDeviceCreateInfo(pSrc->pCreateInfo);
Peter Lohrmann6d849232015-04-01 13:54:18 -0700157 pSrc->pCreateInfo = NULL;
158
159 free(pSrc->pDevice);
160 pSrc->pDevice = NULL;
161}
162
163
164
Peter Lohrmann05069502015-03-30 12:58:50 -0700165// add a new node to the global and object lists, then return it so the caller can populate the object information.
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600166static GLV_VK_SNAPSHOT_LL_NODE* snapshot_insert_object(GLV_VK_SNAPSHOT* pSnapshot, void* pObject, VK_OBJECT_TYPE type)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700167{
Peter Lohrmann05069502015-03-30 12:58:50 -0700168 // Create a new node
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700169 GLV_VK_SNAPSHOT_LL_NODE* pNewObjNode = (GLV_VK_SNAPSHOT_LL_NODE*)malloc(sizeof(GLV_VK_SNAPSHOT_LL_NODE));
Peter Lohrmann05069502015-03-30 12:58:50 -0700170 memset(pNewObjNode, 0, sizeof(GLV_VK_SNAPSHOT_LL_NODE));
171 pNewObjNode->obj.pVkObject = pObject;
172 pNewObjNode->obj.objType = type;
173 pNewObjNode->obj.status = OBJSTATUS_NONE;
174
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700175 // insert at front of global list
Peter Lohrmann05069502015-03-30 12:58:50 -0700176 pNewObjNode->pNextGlobal = pSnapshot->pGlobalObjs;
177 pSnapshot->pGlobalObjs = pNewObjNode;
178
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700179 // insert at front of object list
Peter Lohrmann05069502015-03-30 12:58:50 -0700180 pNewObjNode->pNextObj = pSnapshot->pObjectHead[type];
181 pSnapshot->pObjectHead[type] = pNewObjNode;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700182
183 // increment count
Peter Lohrmann05069502015-03-30 12:58:50 -0700184 pSnapshot->globalObjCount++;
185 pSnapshot->numObjs[type]++;
186
187 return pNewObjNode;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700188}
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700189
Peter Lohrmann05069502015-03-30 12:58:50 -0700190// This is just a helper function to snapshot_remove_object(..). It is not intended for this to be called directly.
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600191static void snapshot_remove_obj_type(GLV_VK_SNAPSHOT* pSnapshot, void* pObj, VK_OBJECT_TYPE objType) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700192 GLV_VK_SNAPSHOT_LL_NODE *pTrav = pSnapshot->pObjectHead[objType];
193 GLV_VK_SNAPSHOT_LL_NODE *pPrev = pSnapshot->pObjectHead[objType];
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700194 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700195 if (pTrav->obj.pVkObject == pObj) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700196 pPrev->pNextObj = pTrav->pNextObj;
197 // update HEAD of Obj list as needed
Peter Lohrmann05069502015-03-30 12:58:50 -0700198 if (pSnapshot->pObjectHead[objType] == pTrav)
199 {
200 pSnapshot->pObjectHead[objType] = pTrav->pNextObj;
201 }
202 assert(pSnapshot->numObjs[objType] > 0);
203 pSnapshot->numObjs[objType]--;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700204 return;
205 }
206 pPrev = pTrav;
207 pTrav = pTrav->pNextObj;
208 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700209 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600210 sprintf(str, "OBJ INTERNAL ERROR : Obj %p was in global list but not in %s list", pObj, string_VK_OBJECT_TYPE(objType));
211 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pObj, 0, GLVSNAPSHOT_INTERNAL_ERROR, LAYER_ABBREV_STR, str);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700212}
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700213
Peter Lohrmann05069502015-03-30 12:58:50 -0700214// Search global list to find object,
215// if found:
216// remove object from obj_type list using snapshot_remove_obj_type()
217// remove object from global list,
218// return object.
219// else:
220// Report message that we didn't see it get created,
221// return NULL.
222static GLV_VK_SNAPSHOT_LL_NODE* snapshot_remove_object(GLV_VK_SNAPSHOT* pSnapshot, void* pObject)
223{
224 GLV_VK_SNAPSHOT_LL_NODE *pTrav = pSnapshot->pGlobalObjs;
225 GLV_VK_SNAPSHOT_LL_NODE *pPrev = pSnapshot->pGlobalObjs;
226 while (pTrav)
227 {
228 if (pTrav->obj.pVkObject == pObject)
229 {
230 snapshot_remove_obj_type(pSnapshot, pObject, pTrav->obj.objType);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700231 pPrev->pNextGlobal = pTrav->pNextGlobal;
232 // update HEAD of global list if needed
Peter Lohrmann05069502015-03-30 12:58:50 -0700233 if (pSnapshot->pGlobalObjs == pTrav)
234 {
235 pSnapshot->pGlobalObjs = pTrav->pNextGlobal;
236 }
237 assert(pSnapshot->globalObjCount > 0);
238 pSnapshot->globalObjCount--;
239 return pTrav;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700240 }
241 pPrev = pTrav;
242 pTrav = pTrav->pNextGlobal;
243 }
Peter Lohrmann05069502015-03-30 12:58:50 -0700244
245 // Object not found.
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700246 char str[1024];
Peter Lohrmann05069502015-03-30 12:58:50 -0700247 sprintf(str, "Object %p was not found in the created object list. It should be added as a deleted object.", pObject);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600248 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pObject, 0, GLVSNAPSHOT_UNKNOWN_OBJECT, LAYER_ABBREV_STR, str);
Peter Lohrmann05069502015-03-30 12:58:50 -0700249 return NULL;
250}
251
252// Add a new deleted object node to the list
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600253static void snapshot_insert_deleted_object(GLV_VK_SNAPSHOT* pSnapshot, void* pObject, VK_OBJECT_TYPE type)
Peter Lohrmann05069502015-03-30 12:58:50 -0700254{
255 // Create a new node
256 GLV_VK_SNAPSHOT_DELETED_OBJ_NODE* pNewObjNode = (GLV_VK_SNAPSHOT_DELETED_OBJ_NODE*)malloc(sizeof(GLV_VK_SNAPSHOT_DELETED_OBJ_NODE));
257 memset(pNewObjNode, 0, sizeof(GLV_VK_SNAPSHOT_DELETED_OBJ_NODE));
258 pNewObjNode->objType = type;
259 pNewObjNode->pVkObject = pObject;
260
261 // insert at front of list
262 pNewObjNode->pNextObj = pSnapshot->pDeltaDeletedObjects;
263 pSnapshot->pDeltaDeletedObjects = pNewObjNode;
264
265 // increment count
266 pSnapshot->deltaDeletedObjectCount++;
267}
268
269// Note: the parameters after pSnapshot match the order of vkCreateDevice(..)
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600270static void snapshot_insert_device(GLV_VK_SNAPSHOT* pSnapshot, VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
Peter Lohrmann05069502015-03-30 12:58:50 -0700271{
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600272 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(pSnapshot, *pDevice, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmann05069502015-03-30 12:58:50 -0700273 pNode->obj.pStruct = malloc(sizeof(GLV_VK_SNAPSHOT_DEVICE_NODE));
274
275 GLV_VK_SNAPSHOT_DEVICE_NODE* pDevNode = (GLV_VK_SNAPSHOT_DEVICE_NODE*)pNode->obj.pStruct;
Peter Lohrmann6d849232015-04-01 13:54:18 -0700276 glv_vk_snapshot_copy_createdevice_params(&pDevNode->params, gpu, pCreateInfo, pDevice);
Peter Lohrmann05069502015-03-30 12:58:50 -0700277
278 // insert at front of device list
279 pNode->pNextObj = pSnapshot->pDevices;
280 pSnapshot->pDevices = pNode;
281
282 // increment count
283 pSnapshot->deviceCount++;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700284}
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700285
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600286static void snapshot_remove_device(GLV_VK_SNAPSHOT* pSnapshot, VkDevice device)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700287{
Peter Lohrmann05069502015-03-30 12:58:50 -0700288 GLV_VK_SNAPSHOT_LL_NODE* pFoundObject = snapshot_remove_object(pSnapshot, device);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700289
Peter Lohrmann05069502015-03-30 12:58:50 -0700290 if (pFoundObject != NULL)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700291 {
Peter Lohrmann05069502015-03-30 12:58:50 -0700292 GLV_VK_SNAPSHOT_LL_NODE *pTrav = pSnapshot->pDevices;
293 GLV_VK_SNAPSHOT_LL_NODE *pPrev = pSnapshot->pDevices;
294 while (pTrav != NULL)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700295 {
Peter Lohrmann05069502015-03-30 12:58:50 -0700296 if (pTrav->obj.pVkObject == device)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700297 {
Peter Lohrmann05069502015-03-30 12:58:50 -0700298 pPrev->pNextObj = pTrav->pNextObj;
299 // update HEAD of Obj list as needed
300 if (pSnapshot->pDevices == pTrav)
301 pSnapshot->pDevices = pTrav->pNextObj;
302
303 // delete the object
304 if (pTrav->obj.pStruct != NULL)
305 {
306 GLV_VK_SNAPSHOT_DEVICE_NODE* pDevNode = (GLV_VK_SNAPSHOT_DEVICE_NODE*)pTrav->obj.pStruct;
Peter Lohrmann6d849232015-04-01 13:54:18 -0700307 glv_vk_snapshot_destroy_createdevice_params(&pDevNode->params);
Peter Lohrmann05069502015-03-30 12:58:50 -0700308 free(pDevNode);
309 }
310 free(pTrav);
311
312 if (pSnapshot->deviceCount > 0)
313 {
314 pSnapshot->deviceCount--;
315 }
316 else
317 {
318 // TODO: Callback WARNING that too many devices were deleted
319 assert(!"DeviceCount <= 0 means that too many devices were deleted.");
320 }
321 return;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700322 }
Peter Lohrmann05069502015-03-30 12:58:50 -0700323 pPrev = pTrav;
324 pTrav = pTrav->pNextObj;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700325 }
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700326 }
327
328 // If the code got here, then the device wasn't in the devices list.
Peter Lohrmann05069502015-03-30 12:58:50 -0700329 // That means we should add this device to the deleted items list.
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600330 snapshot_insert_deleted_object(&s_delta, device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700331}
332
333// Traverse global list and return type for given object
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600334static VK_OBJECT_TYPE ll_get_obj_type(VkObject object) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700335 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pGlobalObjs;
336 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700337 if (pTrav->obj.pVkObject == object)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700338 return pTrav->obj.objType;
339 pTrav = pTrav->pNextGlobal;
340 }
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700341 char str[1024];
342 sprintf(str, "Attempting look-up on obj %p but it is NOT in the global list!", (void*)object);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600343 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, GLVSNAPSHOT_MISSING_OBJECT, LAYER_ABBREV_STR, str);
344 return VK_OBJECT_TYPE_UNKNOWN;
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700345}
346
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600347static void ll_increment_use_count(void* pObj, VK_OBJECT_TYPE objType) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700348 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pObjectHead[objType];
349 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700350 if (pTrav->obj.pVkObject == pObj) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700351 pTrav->obj.numUses++;
352 return;
353 }
354 pTrav = pTrav->pNextObj;
355 }
Peter Lohrmann05069502015-03-30 12:58:50 -0700356
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700357 // If we do not find obj, insert it and then increment count
Peter Lohrmann05069502015-03-30 12:58:50 -0700358 // TODO: we can't just create the object, because we don't know what it was created with.
359 // Instead, we need to make a list of referenced objects. When the delta is merged with a snapshot, we'll need
360 // to confirm that the referenced objects actually exist in the snapshot; otherwise I guess the merge should fail.
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700361 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600362 sprintf(str, "Unable to increment count for obj %p, will add to list as %s type and increment count", pObj, string_VK_OBJECT_TYPE(objType));
363 layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pObj, 0, GLVSNAPSHOT_UNKNOWN_OBJECT, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700364
Peter Lohrmann05069502015-03-30 12:58:50 -0700365// ll_insert_obj(pObj, objType);
366// ll_increment_use_count(pObj, objType);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700367}
368
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700369// Set selected flag state for an object node
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600370static void set_status(void* pObj, VK_OBJECT_TYPE objType, OBJECT_STATUS status_flag) {
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700371 if (pObj != NULL) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700372 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pObjectHead[objType];
373 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700374 if (pTrav->obj.pVkObject == pObj) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700375 pTrav->obj.status |= status_flag;
376 return;
377 }
378 pTrav = pTrav->pNextObj;
379 }
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700380
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700381 // If we do not find it print an error
382 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600383 sprintf(str, "Unable to set status for non-existent object %p of %s type", pObj, string_VK_OBJECT_TYPE(objType));
384 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pObj, 0, GLVSNAPSHOT_UNKNOWN_OBJECT, LAYER_ABBREV_STR, str);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700385 }
386}
387
388// Track selected state for an object node
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600389static void track_object_status(void* pObj, VkStateBindPoint stateBindPoint) {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600390 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pObjectHead[VK_OBJECT_TYPE_CMD_BUFFER];
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700391
392 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700393 if (pTrav->obj.pVkObject == pObj) {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600394 if (stateBindPoint == VK_STATE_BIND_VIEWPORT) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700395 pTrav->obj.status |= OBJSTATUS_VIEWPORT_BOUND;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600396 } else if (stateBindPoint == VK_STATE_BIND_RASTER) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700397 pTrav->obj.status |= OBJSTATUS_RASTER_BOUND;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600398 } else if (stateBindPoint == VK_STATE_BIND_COLOR_BLEND) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700399 pTrav->obj.status |= OBJSTATUS_COLOR_BLEND_BOUND;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600400 } else if (stateBindPoint == VK_STATE_BIND_DEPTH_STENCIL) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700401 pTrav->obj.status |= OBJSTATUS_DEPTH_STENCIL_BOUND;
402 }
403 return;
404 }
405 pTrav = pTrav->pNextObj;
406 }
Peter Lohrmann45221412015-03-27 17:31:17 -0700407
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700408 // If we do not find it print an error
409 char str[1024];
410 sprintf(str, "Unable to track status for non-existent Command Buffer object %p", pObj);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600411 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pObj, 0, GLVSNAPSHOT_UNKNOWN_OBJECT, LAYER_ABBREV_STR, str);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700412}
413
414// Reset selected flag state for an object node
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600415static void reset_status(void* pObj, VK_OBJECT_TYPE objType, OBJECT_STATUS status_flag) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700416 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pObjectHead[objType];
417 while (pTrav) {
Peter Lohrmann05069502015-03-30 12:58:50 -0700418 if (pTrav->obj.pVkObject == pObj) {
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700419 pTrav->obj.status &= ~status_flag;
420 return;
421 }
422 pTrav = pTrav->pNextObj;
423 }
Peter Lohrmann45221412015-03-27 17:31:17 -0700424
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700425 // If we do not find it print an error
426 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600427 sprintf(str, "Unable to reset status for non-existent object %p of %s type", pObj, string_VK_OBJECT_TYPE(objType));
428 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pObj, 0, GLVSNAPSHOT_UNKNOWN_OBJECT, LAYER_ABBREV_STR, str);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700429}
430
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600431#include "vk_dispatch_table_helper.h"
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700432static void initGlaveSnapshot(void)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700433{
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700434 const char *strOpt;
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700435 // initialize GlaveSnapshot options
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700436 getLayerOptionEnum(LAYER_NAME_STR "ReportLevel", (uint32_t *) &g_reportingLevel);
437 g_actionIsDefault = getLayerOptionEnum(LAYER_NAME_STR "DebugAction", (uint32_t *) &g_debugAction);
438
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600439 if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700440 {
441 strOpt = getLayerOption(LAYER_NAME_STR "LogFilename");
442 if (strOpt)
443 {
444 g_logFile = fopen(strOpt, "w");
445 }
446 if (g_logFile == NULL)
447 g_logFile = stdout;
448 }
449
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600450 PFN_vkGetProcAddr fpNextGPA;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700451 fpNextGPA = pCurObj->pGPA;
452 assert(fpNextGPA);
453
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600454 layer_initialize_dispatch_table(&nextTable, fpNextGPA, (VkPhysicalGpu) pCurObj->nextObject);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700455 if (!objLockInitialized)
456 {
457 // TODO/TBD: Need to delete this mutex sometime. How???
458 loader_platform_thread_create_mutex(&objLock);
459 objLockInitialized = 1;
460 }
461}
462
Peter Lohrmann506bbda2015-03-25 20:37:02 -0700463//=============================================================================
464// vulkan entrypoints
465//=============================================================================
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600466VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700467{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600468 VkResult result = nextTable.CreateInstance(pCreateInfo, pInstance);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700469 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600470 snapshot_insert_object(&s_delta, *pInstance, VK_OBJECT_TYPE_INSTANCE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700471 loader_platform_thread_unlock_mutex(&objLock);
472 return result;
473}
474
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600475VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700476{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600477 VkResult result = nextTable.DestroyInstance(instance);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700478 loader_platform_thread_lock_mutex(&objLock);
Peter Lohrmann05069502015-03-30 12:58:50 -0700479 snapshot_remove_object(&s_delta, (void*)instance);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700480 loader_platform_thread_unlock_mutex(&objLock);
481 return result;
482}
483
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600484VK_LAYER_EXPORT VkResult VKAPI vkEnumerateGpus(VkInstance instance, uint32_t maxGpus, uint32_t* pGpuCount, VkPhysicalGpu* pGpus)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700485{
486 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600487 ll_increment_use_count((void*)instance, VK_OBJECT_TYPE_INSTANCE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700488 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600489 VkResult result = nextTable.EnumerateGpus(instance, maxGpus, pGpuCount, pGpus);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700490 return result;
491}
492
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600493VK_LAYER_EXPORT VkResult VKAPI vkGetGpuInfo(VkPhysicalGpu gpu, VkPhysicalGpuInfoType infoType, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700494{
Tobin Ehlisb870cbb2015-04-15 07:46:12 -0600495 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700496 pCurObj = gpuw;
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700497 loader_platform_thread_once(&tabOnce, initGlaveSnapshot);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600498 VkResult result = nextTable.GetGpuInfo((VkPhysicalGpu)gpuw->nextObject, infoType, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700499 return result;
500}
501
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600502VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700503{
Tobin Ehlisb870cbb2015-04-15 07:46:12 -0600504 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700505 pCurObj = gpuw;
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700506 loader_platform_thread_once(&tabOnce, initGlaveSnapshot);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600507 VkResult result = nextTable.CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600508 if (result == VK_SUCCESS)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700509 {
510 loader_platform_thread_lock_mutex(&objLock);
511 snapshot_insert_device(&s_delta, gpu, pCreateInfo, pDevice);
512 loader_platform_thread_unlock_mutex(&objLock);
513 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700514 return result;
515}
516
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600517VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700518{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600519 VkResult result = nextTable.DestroyDevice(device);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700520 loader_platform_thread_lock_mutex(&objLock);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700521 snapshot_remove_device(&s_delta, device);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700522 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700523
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700524 // Report any remaining objects in LL
525 GLV_VK_SNAPSHOT_LL_NODE *pTrav = s_delta.pGlobalObjs;
526 while (pTrav != NULL)
527 {
Chia-I Wuf8693382015-04-16 22:02:10 +0800528 if (pTrav->obj.objType == VK_OBJECT_TYPE_SWAP_CHAIN_IMAGE_WSI ||
529 pTrav->obj.objType == VK_OBJECT_TYPE_SWAP_CHAIN_MEMORY_WSI)
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700530 {
531 GLV_VK_SNAPSHOT_LL_NODE *pDel = pTrav;
532 pTrav = pTrav->pNextGlobal;
Peter Lohrmann05069502015-03-30 12:58:50 -0700533 snapshot_remove_object(&s_delta, (void*)(pDel->obj.pVkObject));
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700534 } else {
535 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600536 sprintf(str, "OBJ ERROR : %s object %p has not been destroyed (was used %lu times).", string_VK_OBJECT_TYPE(pTrav->obj.objType), pTrav->obj.pVkObject, pTrav->obj.numUses);
537 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, device, 0, GLVSNAPSHOT_OBJECT_LEAK, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -0700538 pTrav = pTrav->pNextGlobal;
539 }
540 }
Peter Lohrmann45221412015-03-27 17:31:17 -0700541
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700542 return result;
543}
544
Courtney Goeltzenleuchterd9dc0c72015-04-20 11:04:54 -0600545VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalGpu gpu, size_t maxStringSize, size_t* pLayerCount, char* const* pOutLayers, void* pReserved)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700546{
547 if (gpu != NULL) {
Tobin Ehlisb870cbb2015-04-15 07:46:12 -0600548 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700549 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd9dc0c72015-04-20 11:04:54 -0600550 ll_increment_use_count((void*)gpu, VK_OBJECT_TYPE_PHYSICAL_GPU);
551 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700552 pCurObj = gpuw;
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700553 loader_platform_thread_once(&tabOnce, initGlaveSnapshot);
Courtney Goeltzenleuchterd9dc0c72015-04-20 11:04:54 -0600554 VkResult result = nextTable.EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxStringSize, pLayerCount, pOutLayers, pReserved);
555 return result;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700556 } else {
Courtney Goeltzenleuchterd9dc0c72015-04-20 11:04:54 -0600557 if (pLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600558 return VK_ERROR_INVALID_POINTER;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700559 // This layer compatible with all GPUs
Courtney Goeltzenleuchterd9dc0c72015-04-20 11:04:54 -0600560 *pLayerCount = 1;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700561 strncpy((char *) pOutLayers[0], LAYER_NAME_STR, maxStringSize);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600562 return VK_SUCCESS;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700563 }
564}
565
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600566VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700567{
568 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600569 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700570 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600571 VkResult result = nextTable.GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700572 return result;
573}
574
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600575VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700576{
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600577 set_status((void*)fence, VK_OBJECT_TYPE_FENCE, OBJSTATUS_FENCE_IS_SUBMITTED);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600578 VkResult result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700579 return result;
580}
581
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600582VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700583{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600584 VkResult result = nextTable.QueueWaitIdle(queue);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700585 return result;
586}
587
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600588VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700589{
590 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600591 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700592 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600593 VkResult result = nextTable.DeviceWaitIdle(device);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700594 return result;
595}
596
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600597VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkGpuMemory* pMem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700598{
599 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600600 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700601 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600602 VkResult result = nextTable.AllocMemory(device, pAllocInfo, pMem);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600603 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700604 {
605 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600606 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pMem, VK_OBJECT_TYPE_GPU_MEMORY);
Peter Lohrmann05069502015-03-30 12:58:50 -0700607 pNode->obj.pStruct = NULL;
608 loader_platform_thread_unlock_mutex(&objLock);
609 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700610 return result;
611}
612
Mike Stroyanb050c682015-04-17 12:36:38 -0600613VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkGpuMemory mem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700614{
Mike Stroyanb050c682015-04-17 12:36:38 -0600615 VkResult result = nextTable.FreeMemory(device, mem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700616 loader_platform_thread_lock_mutex(&objLock);
Peter Lohrmann05069502015-03-30 12:58:50 -0700617 snapshot_remove_object(&s_delta, (void*)mem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700618 loader_platform_thread_unlock_mutex(&objLock);
619 return result;
620}
621
Mike Stroyanb050c682015-04-17 12:36:38 -0600622VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkGpuMemory mem, VkMemoryPriority priority)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700623{
624 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600625 ll_increment_use_count((void*)mem, VK_OBJECT_TYPE_GPU_MEMORY);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700626 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600627 VkResult result = nextTable.SetMemoryPriority(device, mem, priority);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700628 return result;
629}
630
Mike Stroyanb050c682015-04-17 12:36:38 -0600631VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkGpuMemory mem, VkFlags flags, void** ppData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700632{
633 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600634 ll_increment_use_count((void*)mem, VK_OBJECT_TYPE_GPU_MEMORY);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700635 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600636 set_status((void*)mem, VK_OBJECT_TYPE_GPU_MEMORY, OBJSTATUS_GPU_MEM_MAPPED);
Mike Stroyanb050c682015-04-17 12:36:38 -0600637 VkResult result = nextTable.MapMemory(device, mem, flags, ppData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700638 return result;
639}
640
Mike Stroyanb050c682015-04-17 12:36:38 -0600641VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkGpuMemory mem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700642{
643 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600644 ll_increment_use_count((void*)mem, VK_OBJECT_TYPE_GPU_MEMORY);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700645 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600646 reset_status((void*)mem, VK_OBJECT_TYPE_GPU_MEMORY, OBJSTATUS_GPU_MEM_MAPPED);
Mike Stroyanb050c682015-04-17 12:36:38 -0600647 VkResult result = nextTable.UnmapMemory(device, mem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700648 return result;
649}
650
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600651VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSysMem, size_t memSize, VkGpuMemory* pMem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700652{
653 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600654 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700655 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600656 VkResult result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700657 return result;
658}
659
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600660VK_LAYER_EXPORT VkResult VKAPI vkGetMultiGpuCompatibility(VkPhysicalGpu gpu0, VkPhysicalGpu gpu1, VkGpuCompatibilityInfo* pInfo)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700661{
Tobin Ehlisb870cbb2015-04-15 07:46:12 -0600662 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu0;
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700663 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600664 ll_increment_use_count((void*)gpu0, VK_OBJECT_TYPE_PHYSICAL_GPU);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700665 loader_platform_thread_unlock_mutex(&objLock);
666 pCurObj = gpuw;
Peter Lohrmann0582ed32015-03-24 17:15:03 -0700667 loader_platform_thread_once(&tabOnce, initGlaveSnapshot);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600668 VkResult result = nextTable.GetMultiGpuCompatibility((VkPhysicalGpu)gpuw->nextObject, gpu1, pInfo);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700669 return result;
670}
671
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600672VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkGpuMemory* pMem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700673{
674 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600675 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700676 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600677 VkResult result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700678 return result;
679}
680
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600681VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedSemaphore(VkDevice device, const VkSemaphoreOpenInfo* pOpenInfo, VkSemaphore* pSemaphore)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700682{
683 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600684 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700685 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600686 VkResult result = nextTable.OpenSharedSemaphore(device, pOpenInfo, pSemaphore);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700687 return result;
688}
689
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600690VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory(VkDevice device, const VkPeerMemoryOpenInfo* pOpenInfo, VkGpuMemory* pMem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700691{
692 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600693 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700694 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600695 VkResult result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700696 return result;
697}
698
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600699VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage(VkDevice device, const VkPeerImageOpenInfo* pOpenInfo, VkImage* pImage, VkGpuMemory* pMem)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700700{
701 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600702 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700703 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600704 VkResult result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700705 return result;
706}
707
Mike Stroyanb050c682015-04-17 12:36:38 -0600708VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700709{
Mike Stroyanb050c682015-04-17 12:36:38 -0600710 VkResult result = nextTable.DestroyObject(device, objType, object);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700711 loader_platform_thread_lock_mutex(&objLock);
Peter Lohrmann05069502015-03-30 12:58:50 -0700712 snapshot_remove_object(&s_delta, (void*)object);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700713 loader_platform_thread_unlock_mutex(&objLock);
714 return result;
715}
716
Mike Stroyanb050c682015-04-17 12:36:38 -0600717VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700718{
719 loader_platform_thread_lock_mutex(&objLock);
720 ll_increment_use_count((void*)object, ll_get_obj_type(object));
721 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600722 VkResult result = nextTable.GetObjectInfo(device, objType, object, infoType, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700723 return result;
724}
725
Mike Stroyanb050c682015-04-17 12:36:38 -0600726VK_LAYER_EXPORT VkResult VKAPI vkBindObjectMemory(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkGpuMemory mem, VkGpuSize offset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700727{
728 loader_platform_thread_lock_mutex(&objLock);
729 ll_increment_use_count((void*)object, ll_get_obj_type(object));
730 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600731 VkResult result = nextTable.BindObjectMemory(queue, objType, object, allocationIdx, mem, offset);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700732 return result;
733}
734
Mike Stroyanb050c682015-04-17 12:36:38 -0600735VK_LAYER_EXPORT VkResult VKAPI vkBindObjectMemoryRange(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkGpuSize rangeOffset, VkGpuSize rangeSize, VkGpuMemory mem, VkGpuSize memOffset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700736{
737 loader_platform_thread_lock_mutex(&objLock);
738 ll_increment_use_count((void*)object, ll_get_obj_type(object));
739 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600740 VkResult result = nextTable.BindObjectMemoryRange(queue, objType, object, allocationIdx, rangeOffset, rangeSize, mem, memOffset);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700741 return result;
742}
743
Jeremy Hayesaf0d72c2015-04-15 15:20:03 -0600744VK_LAYER_EXPORT VkResult VKAPI vkBindImageMemoryRange(VkImage image, uint32_t allocationIdx, const VkImageMemoryBindInfo* pBindInfo, VkGpuMemory mem, VkGpuSize memOffset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700745{
746 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600747 ll_increment_use_count((void*)image, VK_OBJECT_TYPE_IMAGE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700748 loader_platform_thread_unlock_mutex(&objLock);
Jeremy Hayesaf0d72c2015-04-15 15:20:03 -0600749 VkResult result = nextTable.BindImageMemoryRange(image, allocationIdx, pBindInfo, mem, memOffset);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700750 return result;
751}
752
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600753VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700754{
755 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600756 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700757 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600758 VkResult result = nextTable.CreateFence(device, pCreateInfo, pFence);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600759 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700760 {
761 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600762 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pFence, VK_OBJECT_TYPE_FENCE);
Peter Lohrmann05069502015-03-30 12:58:50 -0700763 pNode->obj.pStruct = NULL;
764 loader_platform_thread_unlock_mutex(&objLock);
765 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700766 return result;
767}
768
Mike Stroyanb050c682015-04-17 12:36:38 -0600769VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700770{
771 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600772 ll_increment_use_count((void*)fence, VK_OBJECT_TYPE_FENCE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700773 loader_platform_thread_unlock_mutex(&objLock);
774 // Warn if submitted_flag is not set
Mike Stroyanb050c682015-04-17 12:36:38 -0600775 VkResult result = nextTable.GetFenceStatus(device, fence);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700776 return result;
777}
778
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600779VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, bool32_t waitAll, uint64_t timeout)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700780{
781 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600782 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700783 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600784 VkResult result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700785 return result;
786}
787
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600788VK_LAYER_EXPORT VkResult VKAPI vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700789{
790 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600791 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700792 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600793 VkResult result = nextTable.CreateSemaphore(device, pCreateInfo, pSemaphore);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600794 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700795 {
796 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600797 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pSemaphore, VK_OBJECT_TYPE_QUEUE_SEMAPHORE);
Peter Lohrmann05069502015-03-30 12:58:50 -0700798 pNode->obj.pStruct = NULL;
799 loader_platform_thread_unlock_mutex(&objLock);
800 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700801 return result;
802}
803
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600804VK_LAYER_EXPORT VkResult VKAPI vkQueueSignalSemaphore(VkQueue queue, VkSemaphore semaphore)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700805{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600806 VkResult result = nextTable.QueueSignalSemaphore(queue, semaphore);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700807 return result;
808}
809
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600810VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitSemaphore(VkQueue queue, VkSemaphore semaphore)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700811{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600812 VkResult result = nextTable.QueueWaitSemaphore(queue, semaphore);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700813 return result;
814}
815
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600816VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700817{
818 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600819 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700820 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600821 VkResult result = nextTable.CreateEvent(device, pCreateInfo, pEvent);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600822 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700823 {
824 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600825 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pEvent, VK_OBJECT_TYPE_EVENT);
Peter Lohrmann05069502015-03-30 12:58:50 -0700826 pNode->obj.pStruct = NULL;
827 loader_platform_thread_unlock_mutex(&objLock);
828 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700829 return result;
830}
831
Mike Stroyanb050c682015-04-17 12:36:38 -0600832VK_LAYER_EXPORT VkResult VKAPI vkGetEventStatus(VkDevice device, VkEvent event)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700833{
834 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600835 ll_increment_use_count((void*)event, VK_OBJECT_TYPE_EVENT);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700836 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600837 VkResult result = nextTable.GetEventStatus(device, event);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700838 return result;
839}
840
Mike Stroyanb050c682015-04-17 12:36:38 -0600841VK_LAYER_EXPORT VkResult VKAPI vkSetEvent(VkDevice device, VkEvent event)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700842{
843 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600844 ll_increment_use_count((void*)event, VK_OBJECT_TYPE_EVENT);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700845 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600846 VkResult result = nextTable.SetEvent(device, event);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700847 return result;
848}
849
Mike Stroyanb050c682015-04-17 12:36:38 -0600850VK_LAYER_EXPORT VkResult VKAPI vkResetEvent(VkDevice device, VkEvent event)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700851{
852 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600853 ll_increment_use_count((void*)event, VK_OBJECT_TYPE_EVENT);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700854 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600855 VkResult result = nextTable.ResetEvent(device, event);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700856 return result;
857}
858
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600859VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700860{
861 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600862 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700863 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600864 VkResult result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600865 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700866 {
867 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600868 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pQueryPool, VK_OBJECT_TYPE_QUERY_POOL);
Peter Lohrmann05069502015-03-30 12:58:50 -0700869 pNode->obj.pStruct = NULL;
870 loader_platform_thread_unlock_mutex(&objLock);
871 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700872 return result;
873}
874
Mike Stroyanb050c682015-04-17 12:36:38 -0600875VK_LAYER_EXPORT VkResult VKAPI vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700876{
877 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600878 ll_increment_use_count((void*)queryPool, VK_OBJECT_TYPE_QUERY_POOL);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700879 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600880 VkResult result = nextTable.GetQueryPoolResults(device, queryPool, startQuery, queryCount, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700881 return result;
882}
883
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600884VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700885{
886 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600887 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700888 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600889 VkResult result = nextTable.GetFormatInfo(device, format, infoType, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700890 return result;
891}
892
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600893VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700894{
895 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600896 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700897 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600898 VkResult result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600899 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700900 {
901 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600902 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pBuffer, VK_OBJECT_TYPE_BUFFER);
Peter Lohrmann05069502015-03-30 12:58:50 -0700903 pNode->obj.pStruct = NULL;
904 loader_platform_thread_unlock_mutex(&objLock);
905 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700906 return result;
907}
908
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600909VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700910{
911 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600912 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700913 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600914 VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600915 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700916 {
917 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600918 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pView, VK_OBJECT_TYPE_BUFFER_VIEW);
Peter Lohrmann05069502015-03-30 12:58:50 -0700919 pNode->obj.pStruct = NULL;
920 loader_platform_thread_unlock_mutex(&objLock);
921 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700922 return result;
923}
924
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600925VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700926{
927 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600928 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700929 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600930 VkResult result = nextTable.CreateImage(device, pCreateInfo, pImage);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600931 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700932 {
933 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600934 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pImage, VK_OBJECT_TYPE_IMAGE);
Peter Lohrmann05069502015-03-30 12:58:50 -0700935 pNode->obj.pStruct = NULL;
936 loader_platform_thread_unlock_mutex(&objLock);
937 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700938 return result;
939}
940
Mike Stroyanb050c682015-04-17 12:36:38 -0600941VK_LAYER_EXPORT VkResult VKAPI vkGetImageSubresourceInfo(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceInfoType infoType, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700942{
943 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600944 ll_increment_use_count((void*)image, VK_OBJECT_TYPE_IMAGE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700945 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -0600946 VkResult result = nextTable.GetImageSubresourceInfo(device, image, pSubresource, infoType, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700947 return result;
948}
949
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600950VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700951{
952 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600953 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700954 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600955 VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600956 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700957 {
958 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600959 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pView, VK_OBJECT_TYPE_IMAGE_VIEW);
Peter Lohrmann05069502015-03-30 12:58:50 -0700960 pNode->obj.pStruct = NULL;
961 loader_platform_thread_unlock_mutex(&objLock);
962 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700963 return result;
964}
965
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600966VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, VkColorAttachmentView* pView)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700967{
968 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600969 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700970 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600971 VkResult result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600972 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700973 {
974 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600975 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pView, VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW);
Peter Lohrmann05069502015-03-30 12:58:50 -0700976 pNode->obj.pStruct = NULL;
977 loader_platform_thread_unlock_mutex(&objLock);
978 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700979 return result;
980}
981
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600982VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700983{
984 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600985 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700986 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600987 VkResult result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600988 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -0700989 {
990 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600991 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pView, VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW);
Peter Lohrmann05069502015-03-30 12:58:50 -0700992 pNode->obj.pStruct = NULL;
993 loader_platform_thread_unlock_mutex(&objLock);
994 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700995 return result;
996}
997
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600998VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader)
Peter Lohrmannd67314b2015-03-24 16:14:01 -0700999{
1000 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001001 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001002 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001003 VkResult result = nextTable.CreateShader(device, pCreateInfo, pShader);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001004 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001005 {
1006 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001007 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pShader, VK_OBJECT_TYPE_SHADER);
Peter Lohrmann05069502015-03-30 12:58:50 -07001008 pNode->obj.pStruct = NULL;
1009 loader_platform_thread_unlock_mutex(&objLock);
1010 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001011 return result;
1012}
1013
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001014VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001015{
1016 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001017 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001018 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001019 VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001020 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001021 {
1022 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001023 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pPipeline, VK_OBJECT_TYPE_PIPELINE);
Peter Lohrmann05069502015-03-30 12:58:50 -07001024 pNode->obj.pStruct = NULL;
1025 loader_platform_thread_unlock_mutex(&objLock);
1026 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001027 return result;
1028}
1029
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001030VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001031{
1032 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001033 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001034 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001035 VkResult result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001036 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001037 {
1038 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001039 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pPipeline, VK_OBJECT_TYPE_PIPELINE);
Peter Lohrmann05069502015-03-30 12:58:50 -07001040 pNode->obj.pStruct = NULL;
1041 loader_platform_thread_unlock_mutex(&objLock);
1042 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001043 return result;
1044}
1045
Mike Stroyanb050c682015-04-17 12:36:38 -06001046VK_LAYER_EXPORT VkResult VKAPI vkStorePipeline(VkDevice device, VkPipeline pipeline, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001047{
1048 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001049 ll_increment_use_count((void*)pipeline, VK_OBJECT_TYPE_PIPELINE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001050 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -06001051 VkResult result = nextTable.StorePipeline(device, pipeline, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001052 return result;
1053}
1054
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001055VK_LAYER_EXPORT VkResult VKAPI vkLoadPipeline(VkDevice device, size_t dataSize, const void* pData, VkPipeline* pPipeline)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001056{
1057 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001058 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001059 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001060 VkResult result = nextTable.LoadPipeline(device, dataSize, pData, pPipeline);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001061 return result;
1062}
1063
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001064VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001065{
1066 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001067 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001068 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001069 VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001070 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001071 {
1072 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001073 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pSampler, VK_OBJECT_TYPE_SAMPLER);
Peter Lohrmann05069502015-03-30 12:58:50 -07001074 pNode->obj.pStruct = NULL;
1075 loader_platform_thread_unlock_mutex(&objLock);
1076 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001077 return result;
1078}
1079
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001080VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout( VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001081{
1082 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001083 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001084 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001085 VkResult result = nextTable.CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001086 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001087 {
1088 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001089 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
Peter Lohrmann05069502015-03-30 12:58:50 -07001090 pNode->obj.pStruct = NULL;
1091 loader_platform_thread_unlock_mutex(&objLock);
1092 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001093 return result;
1094}
1095
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001096VK_LAYER_EXPORT VkResult VKAPI vkBeginDescriptorPoolUpdate(VkDevice device, VkDescriptorUpdateMode updateMode)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001097{
1098 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001099 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001100 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001101 VkResult result = nextTable.BeginDescriptorPoolUpdate(device, updateMode);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001102 return result;
1103}
1104
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001105VK_LAYER_EXPORT VkResult VKAPI vkEndDescriptorPoolUpdate(VkDevice device, VkCmdBuffer cmd)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001106{
1107 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001108 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001109 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001110 VkResult result = nextTable.EndDescriptorPoolUpdate(device, cmd);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001111 return result;
1112}
1113
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001114VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001115{
1116 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001117 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001118 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001119 VkResult result = nextTable.CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001120 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001121 {
1122 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001123 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
Peter Lohrmann05069502015-03-30 12:58:50 -07001124 pNode->obj.pStruct = NULL;
1125 loader_platform_thread_unlock_mutex(&objLock);
1126 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001127 return result;
1128}
1129
Mike Stroyanb050c682015-04-17 12:36:38 -06001130VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001131{
1132 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001133 ll_increment_use_count((void*)descriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001134 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -06001135 VkResult result = nextTable.ResetDescriptorPool(device, descriptorPool);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001136 return result;
1137}
1138
Mike Stroyanb050c682015-04-17 12:36:38 -06001139VK_LAYER_EXPORT VkResult VKAPI vkAllocDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001140{
1141 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001142 ll_increment_use_count((void*)descriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001143 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -06001144 VkResult result = nextTable.AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001145 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001146 {
1147 for (uint32_t i = 0; i < *pCount; i++) {
1148 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001149 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, pDescriptorSets[i], VK_OBJECT_TYPE_DESCRIPTOR_SET);
Peter Lohrmann05069502015-03-30 12:58:50 -07001150 pNode->obj.pStruct = NULL;
1151 loader_platform_thread_unlock_mutex(&objLock);
1152 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001153 }
1154 return result;
1155}
1156
Mike Stroyanb050c682015-04-17 12:36:38 -06001157VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001158{
1159 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001160 ll_increment_use_count((void*)descriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001161 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -06001162 nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001163}
1164
Mike Stroyanb050c682015-04-17 12:36:38 -06001165VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001166{
1167 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001168 ll_increment_use_count((void*)descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001169 loader_platform_thread_unlock_mutex(&objLock);
Mike Stroyanb050c682015-04-17 12:36:38 -06001170 nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001171}
1172
Tobin Ehlisb870cbb2015-04-15 07:46:12 -06001173VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001174{
1175 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001176 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001177 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001178 VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001179 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001180 {
1181 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001182 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pState, VK_OBJECT_TYPE_DYNAMIC_VP_STATE_OBJECT);
Peter Lohrmann05069502015-03-30 12:58:50 -07001183 pNode->obj.pStruct = NULL;
1184 loader_platform_thread_unlock_mutex(&objLock);
1185 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001186 return result;
1187}
1188
Tobin Ehlisb870cbb2015-04-15 07:46:12 -06001189VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001190{
1191 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001192 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001193 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001194 VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001195 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001196 {
1197 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001198 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pState, VK_OBJECT_TYPE_DYNAMIC_RS_STATE_OBJECT);
Peter Lohrmann05069502015-03-30 12:58:50 -07001199 pNode->obj.pStruct = NULL;
1200 loader_platform_thread_unlock_mutex(&objLock);
1201 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001202 return result;
1203}
1204
Tobin Ehlisb870cbb2015-04-15 07:46:12 -06001205VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001206{
1207 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001208 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001209 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001210 VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001211 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001212 {
1213 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001214 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pState, VK_OBJECT_TYPE_DYNAMIC_CB_STATE_OBJECT);
Peter Lohrmann05069502015-03-30 12:58:50 -07001215 pNode->obj.pStruct = NULL;
1216 loader_platform_thread_unlock_mutex(&objLock);
1217 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001218 return result;
1219}
1220
Tobin Ehlisb870cbb2015-04-15 07:46:12 -06001221VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001222{
1223 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001224 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001225 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001226 VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001227 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001228 {
1229 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001230 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pState, VK_OBJECT_TYPE_DYNAMIC_DS_STATE_OBJECT);
Peter Lohrmann05069502015-03-30 12:58:50 -07001231 pNode->obj.pStruct = NULL;
1232 loader_platform_thread_unlock_mutex(&objLock);
1233 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001234 return result;
1235}
1236
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001237VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001238{
1239 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001240 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001241 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001242 VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001243 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001244 {
1245 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001246 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pCmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmann05069502015-03-30 12:58:50 -07001247 pNode->obj.pStruct = NULL;
1248 loader_platform_thread_unlock_mutex(&objLock);
1249 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001250 return result;
1251}
1252
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001253VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001254{
1255 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001256 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001257 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001258 VkResult result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001259 return result;
1260}
1261
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001262VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001263{
1264 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001265 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001266 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001267 reset_status((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER, (OBJSTATUS_VIEWPORT_BOUND |
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001268 OBJSTATUS_RASTER_BOUND |
1269 OBJSTATUS_COLOR_BLEND_BOUND |
1270 OBJSTATUS_DEPTH_STENCIL_BOUND));
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001271 VkResult result = nextTable.EndCommandBuffer(cmdBuffer);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001272 return result;
1273}
1274
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001275VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001276{
1277 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001278 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001279 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001280 VkResult result = nextTable.ResetCommandBuffer(cmdBuffer);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001281 return result;
1282}
1283
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001284VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001285{
1286 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001287 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001288 loader_platform_thread_unlock_mutex(&objLock);
1289 nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
1290}
1291
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001292VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001293{
1294 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001295 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001296 loader_platform_thread_unlock_mutex(&objLock);
1297 track_object_status((void*)cmdBuffer, stateBindPoint);
1298 nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
1299}
1300
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001301VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkDescriptorSetLayoutChain layoutChain, uint32_t layoutChainSlot, uint32_t count, const VkDescriptorSet* pDescriptorSets, const uint32_t* pUserData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001302{
1303 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001304 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001305 loader_platform_thread_unlock_mutex(&objLock);
Jon Ashburn2112d6b2015-04-01 13:30:06 -06001306 nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, layoutChain, layoutChainSlot, count, pDescriptorSets, pUserData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001307}
1308
Courtney Goeltzenleuchterf68ad722015-04-16 13:38:46 -06001309VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers(
1310 VkCmdBuffer cmdBuffer,
1311 uint32_t startBinding,
1312 uint32_t bindingCount,
1313 const VkBuffer* pBuffers
1314 const VkGpuSize* pOffsets)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001315{
1316 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001317 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001318 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterf68ad722015-04-16 13:38:46 -06001319 nextTable.CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001320}
1321
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001322VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, VkIndexType indexType)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001323{
1324 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001325 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001326 loader_platform_thread_unlock_mutex(&objLock);
1327 nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
1328}
1329
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001330VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCmdBuffer cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001331{
1332 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001333 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001334 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001335 nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
1336}
1337
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001338VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001339{
1340 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001341 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001342 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001343 nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
1344}
1345
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001346VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, uint32_t count, uint32_t stride)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001347{
1348 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001349 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001350 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001351 nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
1352}
1353
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001354VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, uint32_t count, uint32_t stride)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001355{
1356 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001357 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001358 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001359 nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
1360}
1361
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001362VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001363{
1364 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001365 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001366 loader_platform_thread_unlock_mutex(&objLock);
1367 nextTable.CmdDispatch(cmdBuffer, x, y, z);
1368}
1369
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001370VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001371{
1372 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001373 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001374 loader_platform_thread_unlock_mutex(&objLock);
1375 nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset);
1376}
1377
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001378VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001379{
1380 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001381 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001382 loader_platform_thread_unlock_mutex(&objLock);
1383 nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
1384}
1385
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001386VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001387{
1388 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001389 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001390 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter9e433bb2015-03-25 11:25:10 -06001391 nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001392}
1393
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001394VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001395{
1396 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001397 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001398 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter9e433bb2015-03-25 11:25:10 -06001399 nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001400}
1401
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001402VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001403{
1404 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001405 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001406 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter9e433bb2015-03-25 11:25:10 -06001407 nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001408}
1409
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001410VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001411{
1412 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001413 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001414 loader_platform_thread_unlock_mutex(&objLock);
1415 nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout);
1416}
1417
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001418VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkGpuSize destOffset, VkGpuSize dataSize, const uint32_t* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001419{
1420 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001421 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001422 loader_platform_thread_unlock_mutex(&objLock);
1423 nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
1424}
1425
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001426VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkGpuSize destOffset, VkGpuSize fillSize, uint32_t data)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001427{
1428 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001429 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001430 loader_platform_thread_unlock_mutex(&objLock);
1431 nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
1432}
1433
Courtney Goeltzenleuchterd7a5cff2015-04-23 17:49:22 -06001434VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColor* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001435{
1436 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001437 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001438 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterd7a5cff2015-04-23 17:49:22 -06001439 nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001440}
1441
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001442VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, float depth, uint32_t stencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001443{
1444 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001445 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001446 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter9e433bb2015-03-25 11:25:10 -06001447 nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001448}
1449
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001450VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t rectCount, const VkImageResolve* pRects)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001451{
1452 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001453 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001454 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter9e433bb2015-03-25 11:25:10 -06001455 nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, rectCount, pRects);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001456}
1457
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001458VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001459{
1460 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001461 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001462 loader_platform_thread_unlock_mutex(&objLock);
1463 nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent);
1464}
1465
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001466VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001467{
1468 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001469 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001470 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter1e8f3be2015-03-24 18:02:34 -06001471 nextTable.CmdResetEvent(cmdBuffer, event, pipeEvent);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001472}
1473
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001474VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, const VkEventWaitInfo* pWaitInfo)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001475{
1476 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001477 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001478 loader_platform_thread_unlock_mutex(&objLock);
1479 nextTable.CmdWaitEvents(cmdBuffer, pWaitInfo);
1480}
1481
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001482VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, const VkPipelineBarrier* pBarrier)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001483{
1484 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001485 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001486 loader_platform_thread_unlock_mutex(&objLock);
1487 nextTable.CmdPipelineBarrier(cmdBuffer, pBarrier);
1488}
1489
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001490VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001491{
1492 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001493 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001494 loader_platform_thread_unlock_mutex(&objLock);
1495 nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
1496}
1497
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001498VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001499{
1500 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001501 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001502 loader_platform_thread_unlock_mutex(&objLock);
1503 nextTable.CmdEndQuery(cmdBuffer, queryPool, slot);
1504}
1505
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001506VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001507{
1508 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001509 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001510 loader_platform_thread_unlock_mutex(&objLock);
1511 nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
1512}
1513
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001514VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkGpuSize destOffset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001515{
1516 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001517 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001518 loader_platform_thread_unlock_mutex(&objLock);
1519 nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
1520}
1521
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001522VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001523{
1524 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001525 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001526 loader_platform_thread_unlock_mutex(&objLock);
1527 nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
1528}
1529
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001530VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkGpuSize srcOffset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001531{
1532 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001533 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001534 loader_platform_thread_unlock_mutex(&objLock);
1535 nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
1536}
1537
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001538VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkGpuSize destOffset)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001539{
1540 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001541 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001542 loader_platform_thread_unlock_mutex(&objLock);
1543 nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
1544}
1545
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001546VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001547{
1548 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001549 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001550 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001551 VkResult result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001552 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001553 {
1554 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001555 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER);
Peter Lohrmann05069502015-03-30 12:58:50 -07001556 pNode->obj.pStruct = NULL;
1557 loader_platform_thread_unlock_mutex(&objLock);
1558 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001559 return result;
1560}
1561
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001562VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001563{
1564 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001565 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001566 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001567 VkResult result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001568 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001569 {
1570 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001571 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pRenderPass, VK_OBJECT_TYPE_RENDER_PASS);
Peter Lohrmann05069502015-03-30 12:58:50 -07001572 pNode->obj.pStruct = NULL;
1573 loader_platform_thread_unlock_mutex(&objLock);
1574 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001575 return result;
1576}
1577
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001578VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin *pRenderPassBegin)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001579{
1580 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001581 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001582 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchter69894b72015-04-03 15:25:24 -06001583 nextTable.CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001584}
1585
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001586VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001587{
1588 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001589 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001590 loader_platform_thread_unlock_mutex(&objLock);
1591 nextTable.CmdEndRenderPass(cmdBuffer, renderPass);
1592}
1593
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001594VK_LAYER_EXPORT VkResult VKAPI vkDbgSetValidationLevel(VkDevice device, VkValidationLevel validationLevel)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001595{
1596 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001597 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001598 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001599 VkResult result = nextTable.DbgSetValidationLevel(device, validationLevel);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001600 return result;
1601}
1602
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001603VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001604{
1605 // This layer intercepts callbacks
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001606 VK_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (VK_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(VK_LAYER_DBG_FUNCTION_NODE));
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001607 if (!pNewDbgFuncNode)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001608 return VK_ERROR_OUT_OF_MEMORY;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001609 pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback;
1610 pNewDbgFuncNode->pUserData = pUserData;
1611 pNewDbgFuncNode->pNext = g_pDbgFunctionHead;
1612 g_pDbgFunctionHead = pNewDbgFuncNode;
1613 // force callbacks if DebugAction hasn't been set already other than initial value
1614 if (g_actionIsDefault) {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001615 g_debugAction = VK_DBG_LAYER_ACTION_CALLBACK;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001616 } VkResult result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001617 return result;
1618}
1619
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001620VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001621{
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001622 VK_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead;
1623 VK_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001624 while (pTrav) {
1625 if (pTrav->pfnMsgCallback == pfnMsgCallback) {
1626 pPrev->pNext = pTrav->pNext;
1627 if (g_pDbgFunctionHead == pTrav)
1628 g_pDbgFunctionHead = pTrav->pNext;
1629 free(pTrav);
1630 break;
1631 }
1632 pPrev = pTrav;
1633 pTrav = pTrav->pNext;
1634 }
1635 if (g_pDbgFunctionHead == NULL)
1636 {
1637 if (g_actionIsDefault)
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001638 g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001639 else
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001640 g_debugAction &= ~VK_DBG_LAYER_ACTION_CALLBACK;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001641 }
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001642 VkResult result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001643 return result;
1644}
1645
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001646VK_LAYER_EXPORT VkResult VKAPI vkDbgSetMessageFilter(VkDevice device, int32_t msgCode, VK_DBG_MSG_FILTER filter)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001647{
1648 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001649 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001650 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001651 VkResult result = nextTable.DbgSetMessageFilter(device, msgCode, filter);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001652 return result;
1653}
1654
Mike Stroyanb050c682015-04-17 12:36:38 -06001655VK_LAYER_EXPORT VkResult VKAPI vkDbgSetObjectTag(VkObject object, size_t tagSize, const void* pTag)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001656{
1657 loader_platform_thread_lock_mutex(&objLock);
1658 ll_increment_use_count((void*)object, ll_get_obj_type(object));
1659 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001660 VkResult result = nextTable.DbgSetObjectTag(object, tagSize, pTag);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001661 return result;
1662}
1663
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001664VK_LAYER_EXPORT VkResult VKAPI vkDbgSetGlobalOption(VkInstance instance, VK_DBG_GLOBAL_OPTION dbgOption, size_t dataSize, const void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001665{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001666 VkResult result = nextTable.DbgSetGlobalOption(instance, dbgOption, dataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001667 return result;
1668}
1669
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001670VK_LAYER_EXPORT VkResult VKAPI vkDbgSetDeviceOption(VkDevice device, VK_DBG_DEVICE_OPTION dbgOption, size_t dataSize, const void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001671{
1672 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001673 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001674 loader_platform_thread_unlock_mutex(&objLock);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001675 VkResult result = nextTable.DbgSetDeviceOption(device, dbgOption, dataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001676 return result;
1677}
1678
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001679VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001680{
1681 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001682 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001683 loader_platform_thread_unlock_mutex(&objLock);
1684 nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker);
1685}
1686
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001687VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001688{
1689 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001690 ll_increment_use_count((void*)cmdBuffer, VK_OBJECT_TYPE_CMD_BUFFER);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001691 loader_platform_thread_unlock_mutex(&objLock);
1692 nextTable.CmdDbgMarkerEnd(cmdBuffer);
1693}
1694
Chia-I Wuf8693382015-04-16 22:02:10 +08001695VK_LAYER_EXPORT VkResult VKAPI xglGetDisplayInfoWSI(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001696{
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001697 loader_platform_thread_lock_mutex(&objLock);
Chia-I Wuf8693382015-04-16 22:02:10 +08001698 ll_increment_use_count((void*)display, VK_OBJECT_TYPE_DISPLAY_WSI);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001699 loader_platform_thread_unlock_mutex(&objLock);
Chia-I Wuf8693382015-04-16 22:02:10 +08001700 VkResult result = nextTable.GetDisplayInfoWSI(display, infoType, pDataSize, pData);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001701 return result;
1702}
1703
Chia-I Wuf8693382015-04-16 22:02:10 +08001704VK_LAYER_EXPORT VkResult VKAPI xglCreateSwapChainWSI(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001705{
1706 loader_platform_thread_lock_mutex(&objLock);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001707 ll_increment_use_count((void*)device, VK_OBJECT_TYPE_DEVICE);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001708 loader_platform_thread_unlock_mutex(&objLock);
Chia-I Wuf8693382015-04-16 22:02:10 +08001709 VkResult result = nextTable.CreateSwapChainWSI(device, pCreateInfo, pSwapChain);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001710 if (result == VK_SUCCESS)
Peter Lohrmann05069502015-03-30 12:58:50 -07001711 {
1712 loader_platform_thread_lock_mutex(&objLock);
1713
Chia-I Wuf8693382015-04-16 22:02:10 +08001714#if 0
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001715 GLV_VK_SNAPSHOT_LL_NODE* pNode = snapshot_insert_object(&s_delta, *pImage, VK_OBJECT_TYPE_IMAGE);
Peter Lohrmann05069502015-03-30 12:58:50 -07001716 pNode->obj.pStruct = NULL;
1717
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001718 GLV_VK_SNAPSHOT_LL_NODE* pMemNode = snapshot_insert_object(&s_delta, *pMem, VK_OBJECT_TYPE_PRESENTABLE_IMAGE_MEMORY);
Peter Lohrmann05069502015-03-30 12:58:50 -07001719 pMemNode->obj.pStruct = NULL;
Chia-I Wuf8693382015-04-16 22:02:10 +08001720#else
1721 snapshot_insert_object(&s_delta, (void*)*pSwapChain, VK_OBJECT_TYPE_SWAP_CHAIN_WSI);
1722#endif
Peter Lohrmann05069502015-03-30 12:58:50 -07001723
1724 loader_platform_thread_unlock_mutex(&objLock);
1725 }
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001726 return result;
Chia-I Wuf8693382015-04-16 22:02:10 +08001727
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001728}
1729
Chia-I Wuf8693382015-04-16 22:02:10 +08001730VK_LAYER_EXPORT VkResult VKAPI xglDestroySwapChainWSI(VkSwapChainWSI swapChain)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001731{
Chia-I Wuf8693382015-04-16 22:02:10 +08001732 VkResult result = nextTable.DestroySwapChainWSI(swapChain);
1733 loader_platform_thread_lock_mutex(&objLock);
1734 snapshot_remove_object(&s_delta, (void*)swapChain);
1735 loader_platform_thread_unlock_mutex(&objLock);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001736 return result;
1737}
1738
Chia-I Wuf8693382015-04-16 22:02:10 +08001739VK_LAYER_EXPORT VkResult VKAPI xglGetSwapChainInfoWSI(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData)
1740{
1741 loader_platform_thread_lock_mutex(&objLock);
1742 ll_increment_use_count((void*)swapChain, VK_OBJECT_TYPE_SWAP_CHAIN_WSI);
1743 loader_platform_thread_unlock_mutex(&objLock);
1744 VkResult result = nextTable.GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData);
1745 return result;
1746}
1747
1748VK_LAYER_EXPORT VkResult VKAPI xglQueuePresentWSI(VkQueue queue, const VkPresentInfoWSI* pPresentInfo)
1749{
1750 loader_platform_thread_lock_mutex(&objLock);
1751 ll_increment_use_count((void*)queue, VK_OBJECT_TYPE_QUEUE);
1752 loader_platform_thread_unlock_mutex(&objLock);
1753 VkResult result = nextTable.QueuePresentWSI(queue, pPresentInfo);
1754 return result;
1755}
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001756
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001757//=================================================================================================
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001758// Exported methods
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001759//=================================================================================================
1760void glvSnapshotStartTracking(void)
1761{
1762 assert(!"Not Implemented");
1763}
1764
1765//=================================================================================================
1766GLV_VK_SNAPSHOT glvSnapshotGetDelta(void)
1767{
1768 // copy the delta by merging it into an empty snapshot
1769 GLV_VK_SNAPSHOT empty;
1770 memset(&empty, 0, sizeof(GLV_VK_SNAPSHOT));
1771
1772 return glvSnapshotMerge(&s_delta, &empty);
1773}
1774
1775//=================================================================================================
1776GLV_VK_SNAPSHOT glvSnapshotGetSnapshot(void)
1777{
1778 // copy the master snapshot by merging it into an empty snapshot
1779 GLV_VK_SNAPSHOT empty;
1780 memset(&empty, 0, sizeof(GLV_VK_SNAPSHOT));
1781
1782 return glvSnapshotMerge(&s_snapshot, &empty);
1783}
1784
1785//=================================================================================================
1786void glvSnapshotPrintDelta()
1787{
Peter Lohrmann6d849232015-04-01 13:54:18 -07001788 char str[2048];
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001789 GLV_VK_SNAPSHOT_LL_NODE* pTrav = s_delta.pGlobalObjs;
1790 sprintf(str, "==== DELTA SNAPSHOT contains %lu objects, %lu devices, and %lu deleted objects", s_delta.globalObjCount, s_delta.deviceCount, s_delta.deltaDeletedObjectCount);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001791 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001792
1793 // print all objects
1794 if (s_delta.globalObjCount > 0)
1795 {
1796 sprintf(str, "======== DELTA SNAPSHOT Created Objects:");
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001797 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pTrav->obj.pVkObject, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001798 while (pTrav != NULL)
1799 {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001800 sprintf(str, "\t%s obj %p", string_VK_OBJECT_TYPE(pTrav->obj.objType), pTrav->obj.pVkObject);
1801 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pTrav->obj.pVkObject, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001802 pTrav = pTrav->pNextGlobal;
1803 }
1804 }
1805
1806 // print devices
1807 if (s_delta.deviceCount > 0)
1808 {
Peter Lohrmann05069502015-03-30 12:58:50 -07001809 GLV_VK_SNAPSHOT_LL_NODE* pDeviceNode = s_delta.pDevices;
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001810 sprintf(str, "======== DELTA SNAPSHOT Devices:");
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001811 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001812 while (pDeviceNode != NULL)
1813 {
Peter Lohrmann6d849232015-04-01 13:54:18 -07001814 GLV_VK_SNAPSHOT_DEVICE_NODE* pDev = (GLV_VK_SNAPSHOT_DEVICE_NODE*)pDeviceNode->obj.pStruct;
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -06001815 char * createInfoStr = vk_print_vkdevicecreateinfo(pDev->params.pCreateInfo, "\t\t");
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001816 sprintf(str, "\t%s obj %p:\n%s", string_VK_OBJECT_TYPE(VK_OBJECT_TYPE_DEVICE), pDeviceNode->obj.pVkObject, createInfoStr);
1817 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDeviceNode->obj.pVkObject, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann05069502015-03-30 12:58:50 -07001818 pDeviceNode = pDeviceNode->pNextObj;
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001819 }
1820 }
1821
1822 // print deleted objects
1823 if (s_delta.deltaDeletedObjectCount > 0)
1824 {
Peter Lohrmann05069502015-03-30 12:58:50 -07001825 GLV_VK_SNAPSHOT_DELETED_OBJ_NODE* pDelObjNode = s_delta.pDeltaDeletedObjects;
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001826 sprintf(str, "======== DELTA SNAPSHOT Deleted Objects:");
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001827 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001828 while (pDelObjNode != NULL)
1829 {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001830 sprintf(str, " %s obj %p", string_VK_OBJECT_TYPE(pDelObjNode->objType), pDelObjNode->pVkObject);
1831 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDelObjNode->pVkObject, 0, GLVSNAPSHOT_SNAPSHOT_DATA, LAYER_ABBREV_STR, str);
Peter Lohrmann05069502015-03-30 12:58:50 -07001832 pDelObjNode = pDelObjNode->pNextObj;
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001833 }
1834 }
1835}
1836
1837void glvSnapshotStopTracking(void)
1838{
1839 assert(!"Not Implemented");
1840}
1841
1842void glvSnapshotClear(void)
1843{
1844 assert(!"Not Implemented");
1845}
1846
1847GLV_VK_SNAPSHOT glvSnapshotMerge(const GLV_VK_SNAPSHOT* const pDelta, const GLV_VK_SNAPSHOT* const pSnapshot)
1848{
1849 assert(!"Not Implemented");
1850}
1851
1852
1853
1854
1855//=============================================================================
1856// Old Exported methods
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001857//=============================================================================
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001858uint64_t glvSnapshotGetObjectCount(VK_OBJECT_TYPE type)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001859{
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001860 uint64_t retVal = (type == VK_OBJECT_TYPE_ANY) ? s_delta.globalObjCount : s_delta.numObjs[type];
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001861 return retVal;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001862}
1863
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001864VkResult glvSnapshotGetObjects(VK_OBJECT_TYPE type, uint64_t objCount, GLV_VK_SNAPSHOT_OBJECT_NODE *pObjNodeArray)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001865{
1866 // This bool flags if we're pulling all objs or just a single class of objs
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001867 bool32_t bAllObjs = (type == VK_OBJECT_TYPE_ANY);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001868 // Check the count first thing
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001869 uint64_t maxObjCount = (bAllObjs) ? s_delta.globalObjCount : s_delta.numObjs[type];
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001870 if (objCount > maxObjCount) {
1871 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001872 sprintf(str, "OBJ ERROR : Received objTrackGetObjects() request for %lu objs, but there are only %lu objs of type %s", objCount, maxObjCount, string_VK_OBJECT_TYPE(type));
1873 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, 0, 0, GLVSNAPSHOT_OBJCOUNT_MAX_EXCEEDED, LAYER_ABBREV_STR, str);
1874 return VK_ERROR_INVALID_VALUE;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001875 }
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001876
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001877 GLV_VK_SNAPSHOT_LL_NODE* pTrav = (bAllObjs) ? s_delta.pGlobalObjs : s_delta.pObjectHead[type];
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001878
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001879 for (uint64_t i = 0; i < objCount; i++) {
1880 if (!pTrav) {
1881 char str[1024];
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001882 sprintf(str, "OBJ INTERNAL ERROR : Ran out of %s objs! Should have %lu, but only copied %lu and not the requested %lu.", string_VK_OBJECT_TYPE(type), maxObjCount, i, objCount);
1883 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, 0, 0, GLVSNAPSHOT_INTERNAL_ERROR, LAYER_ABBREV_STR, str);
1884 return VK_ERROR_UNKNOWN;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001885 }
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001886 memcpy(&pObjNodeArray[i], pTrav, sizeof(GLV_VK_SNAPSHOT_OBJECT_NODE));
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001887 pTrav = (bAllObjs) ? pTrav->pNextGlobal : pTrav->pNextObj;
1888 }
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001889 return VK_SUCCESS;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001890}
1891
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001892void glvSnapshotPrintObjects(void)
1893{
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001894 glvSnapshotPrintDelta();
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001895}
1896
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001897#include "vk_generic_intercept_proc_helper.h"
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001898VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalGpu gpu, const char* funcName)
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001899{
Tobin Ehlisb870cbb2015-04-15 07:46:12 -06001900 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001901 void* addr;
1902 if (gpu == NULL)
1903 return NULL;
1904 pCurObj = gpuw;
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001905 loader_platform_thread_once(&tabOnce, initGlaveSnapshot);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001906
1907 addr = layer_intercept_proc(funcName);
1908 if (addr)
1909 return addr;
Peter Lohrmann0582ed32015-03-24 17:15:03 -07001910 else if (!strncmp("glvSnapshotGetObjectCount", funcName, sizeof("glvSnapshotGetObjectCount")))
1911 return glvSnapshotGetObjectCount;
1912 else if (!strncmp("glvSnapshotGetObjects", funcName, sizeof("glvSnapshotGetObjects")))
1913 return glvSnapshotGetObjects;
1914 else if (!strncmp("glvSnapshotPrintObjects", funcName, sizeof("glvSnapshotPrintObjects")))
1915 return glvSnapshotPrintObjects;
Peter Lohrmann623be4e2015-03-26 20:38:12 -07001916 else if (!strncmp("glvSnapshotStartTracking", funcName, sizeof("glvSnapshotStartTracking")))
1917 return glvSnapshotStartTracking;
1918 else if (!strncmp("glvSnapshotGetDelta", funcName, sizeof("glvSnapshotGetDelta")))
1919 return glvSnapshotGetDelta;
1920 else if (!strncmp("glvSnapshotGetSnapshot", funcName, sizeof("glvSnapshotGetSnapshot")))
1921 return glvSnapshotGetSnapshot;
1922 else if (!strncmp("glvSnapshotPrintDelta", funcName, sizeof("glvSnapshotPrintDelta")))
1923 return glvSnapshotPrintDelta;
1924 else if (!strncmp("glvSnapshotStopTracking", funcName, sizeof("glvSnapshotStopTracking")))
1925 return glvSnapshotStopTracking;
1926 else if (!strncmp("glvSnapshotClear", funcName, sizeof("glvSnapshotClear")))
1927 return glvSnapshotClear;
1928 else if (!strncmp("glvSnapshotMerge", funcName, sizeof("glvSnapshotMerge")))
1929 return glvSnapshotMerge;
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001930 else {
1931 if (gpuw->pGPA == NULL)
1932 return NULL;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -06001933 return gpuw->pGPA((VkPhysicalGpu)gpuw->nextObject, funcName);
Peter Lohrmannd67314b2015-03-24 16:14:01 -07001934 }
1935}
1936