diff options
Diffstat (limited to 'layers/mem_tracker.cpp')
| -rw-r--r-- | layers/mem_tracker.cpp | 693 |
1 files changed, 494 insertions, 199 deletions
diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index 0da8996c..dc3dda4c 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -51,15 +51,15 @@ static loader_platform_thread_mutex globalLock; #define MAX_BINDING 0xFFFFFFFF -map<VkCmdBuffer, MT_CB_INFO*> cbMap; -map<VkDeviceMemory, MT_MEM_OBJ_INFO*> memObjMap; -map<VkObject, MT_OBJ_INFO*> objectMap; -map<uint64_t, MT_FENCE_INFO*> fenceMap; // Map fenceId to fence info -map<VkQueue, MT_QUEUE_INFO*> queueMap; -map<VkSwapChainWSI, MT_SWAP_CHAIN_INFO*> swapChainMap; +map<VkCmdBuffer, MT_CB_INFO*> cbMap; +map<VkDeviceMemory, MT_MEM_OBJ_INFO*> memObjMap; +map<VkObject, MT_OBJ_INFO*> objectMap; +map<uint64_t, MT_FENCE_INFO*> fenceMap; // Map fenceId to fence info +map<VkQueue, MT_QUEUE_INFO*> queueMap; +map<VkSwapChainWSI, MT_SWAP_CHAIN_INFO*> swapChainMap; // TODO : Add per-device fence completion -static uint64_t g_currentFenceId = 1; +static uint64_t g_currentFenceId = 1; static VkDevice globalDevice = NULL; // Add new queue for this device to map container @@ -71,7 +71,8 @@ static void addQueueInfo(const VkQueue queue) queueMap[queue] = pInfo; } -static void deleteQueueInfoList(void) +static void deleteQueueInfoList( + void) { // Process queue list, cleaning up each entry before deleting for (map<VkQueue, MT_QUEUE_INFO*>::iterator ii=queueMap.begin(); ii!=queueMap.end(); ++ii) { @@ -80,14 +81,16 @@ static void deleteQueueInfoList(void) queueMap.clear(); } -static void addSwapChainInfo(const VkSwapChainWSI swapChain) +static void addSwapChainInfo( + const VkSwapChainWSI swapChain) { MT_SWAP_CHAIN_INFO* pInfo = new MT_SWAP_CHAIN_INFO; swapChainMap[swapChain] = pInfo; } // Add new CBInfo for this cb to map container -static void addCBInfo(const VkCmdBuffer cb) +static void addCBInfo( + const VkCmdBuffer cb) { MT_CB_INFO* pInfo = new MT_CB_INFO; memset(pInfo, 0, (sizeof(MT_CB_INFO) - sizeof(list<VkDeviceMemory>))); @@ -96,7 +99,8 @@ static void addCBInfo(const VkCmdBuffer cb) } // Return ptr to Info in CB map, or NULL if not found -static MT_CB_INFO* getCBInfo(const VkCmdBuffer cb) +static MT_CB_INFO* getCBInfo( + const VkCmdBuffer cb) { MT_CB_INFO* pCBInfo = NULL; if (cbMap.find(cb) != cbMap.end()) { @@ -106,7 +110,8 @@ static MT_CB_INFO* getCBInfo(const VkCmdBuffer cb) } // Return object info for 'object' or return NULL if no info exists -static MT_OBJ_INFO* getObjectInfo(const VkObject object) +static MT_OBJ_INFO* getObjectInfo( + const VkObject object) { MT_OBJ_INFO* pObjInfo = NULL; @@ -116,7 +121,12 @@ static MT_OBJ_INFO* getObjectInfo(const VkObject object) return pObjInfo; } -static MT_OBJ_INFO* addObjectInfo(VkObject object, VkStructureType sType, const void *pCreateInfo, const int struct_size, const char *name_prefix) +static MT_OBJ_INFO* addObjectInfo( + VkObject object, + VkStructureType sType, + const void *pCreateInfo, + const int struct_size, + const char *name_prefix) { MT_OBJ_INFO* pInfo = new MT_OBJ_INFO; memset(pInfo, 0, sizeof(MT_OBJ_INFO)); @@ -132,7 +142,9 @@ static MT_OBJ_INFO* addObjectInfo(VkObject object, VkStructureType sType, const } // Add a fence, creating one if necessary to our list of fences/fenceIds -static uint64_t addFenceInfo(VkFence fence, VkQueue queue) +static uint64_t addFenceInfo( + VkFence fence, + VkQueue queue) { // Create fence object MT_FENCE_INFO* pFenceInfo = new MT_FENCE_INFO; @@ -169,7 +181,8 @@ static uint64_t addFenceInfo(VkFence fence, VkQueue queue) } // Remove a fenceInfo from our list of fences/fenceIds -static void deleteFenceInfo(uint64_t fenceId) +static void deleteFenceInfo( + uint64_t fenceId) { if (fenceId != 0) { if (fenceMap.find(fenceId) != fenceMap.end()) { @@ -188,12 +201,13 @@ static void deleteFenceInfo(uint64_t fenceId) } // Search through list for this fence, deleting all items before it (with lower IDs) and updating lastRetiredId -static void updateFenceTracking(VkFence fence) +static void updateFenceTracking( + VkFence fence) { MT_FENCE_INFO *pCurFenceInfo = NULL; uint64_t fenceId = 0; - VkQueue queue = NULL; - bool found = false; + VkQueue queue = NULL; + bool found = false; for (map<uint64_t, MT_FENCE_INFO*>::iterator ii=fenceMap.begin(); !found && ii!=fenceMap.end(); ++ii) { if ((*ii).second != NULL) { @@ -209,14 +223,16 @@ static void updateFenceTracking(VkFence fence) MT_OBJ_INFO* pObjectInfo = getObjectInfo(fence); if (pObjectInfo != NULL) { pObjectInfo->create_info.fence_create_info.flags = - static_cast<VkFenceCreateFlags>(pObjectInfo->create_info.fence_create_info.flags | VK_FENCE_CREATE_SIGNALED_BIT); + static_cast<VkFenceCreateFlags>( + pObjectInfo->create_info.fence_create_info.flags | VK_FENCE_CREATE_SIGNALED_BIT); } } } } // Utility function that determines if a fenceId has been retired yet -static bool32_t fenceRetired(uint64_t fenceId) +static bool32_t fenceRetired( + uint64_t fenceId) { bool32_t result = VK_FALSE; if (fenceMap.find(fenceId) != fenceMap.end()) { @@ -233,7 +249,8 @@ static bool32_t fenceRetired(uint64_t fenceId) } // Return the fence associated with a fenceId -static VkFence getFenceFromId(uint64_t fenceId) +static VkFence getFenceFromId( + uint64_t fenceId) { VkFence fence = NULL; if (fenceId != 0) { @@ -252,7 +269,8 @@ static VkFence getFenceFromId(uint64_t fenceId) } // Helper routine that updates the fence list for a specific queue to all-retired -static void retireQueueFences(VkQueue queue) +static void retireQueueFences( + VkQueue queue) { MT_QUEUE_INFO *pQueueInfo = queueMap[queue]; pQueueInfo->lastRetiredId = pQueueInfo->lastSubmittedId; @@ -272,7 +290,8 @@ static void retireQueueFences(VkQueue queue) } // Helper routine that updates fence list for all queues to all-retired -static void retireDeviceFences(VkDevice device) +static void retireDeviceFences( + VkDevice device) { // Process each queue for device // TODO: Add multiple device support @@ -284,7 +303,7 @@ static void retireDeviceFences(VkDevice device) // Returns True if a memory reference is present in a Queue's memory reference list // Queue is validated by caller static bool32_t checkMemRef( - VkQueue queue, + VkQueue queue, VkDeviceMemory mem) { bool32_t result = VK_FALSE; @@ -300,8 +319,8 @@ static bool32_t checkMemRef( } static bool32_t validateQueueMemRefs( - VkQueue queue, - uint32_t cmdBufferCount, + VkQueue queue, + uint32_t cmdBufferCount, const VkCmdBuffer *pCmdBuffers) { bool32_t result = VK_TRUE; @@ -319,7 +338,9 @@ static bool32_t validateQueueMemRefs( MT_CB_INFO* pCBInfo = getCBInfo(pCmdBuffers[i]); if (!pCBInfo) { char str[1024]; - sprintf(str, "Unable to find info for CB %p in order to check memory references in vkQueueSubmit for queue %p", (void*)pCmdBuffers[i], queue); + sprintf(str, "Unable to find info for CB %p in order to check memory references in " + "vkQueueSubmit for queue %p", + (void*)pCmdBuffers[i], queue); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_INVALID_CB, "MEM", str); result = VK_FALSE; } else { @@ -333,7 +354,8 @@ static bool32_t validateQueueMemRefs( } else { char str[1024]; - sprintf(str, "Queue %p Memory reference list for Command Buffer %p is missing ref to mem obj %p", queue, pCmdBuffers[i], (*it)); + sprintf(str, "Queue %p Memory reference list for Command Buffer %p is missing ref to mem obj %p", + queue, pCmdBuffers[i], (*it)); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_INVALID_MEM_REF, "MEM", str); result = VK_FALSE; } @@ -354,7 +376,8 @@ static bool32_t validateQueueMemRefs( // Return ptr to info in map container containing mem, or NULL if not found // Calls to this function should be wrapped in mutex -static MT_MEM_OBJ_INFO* getMemObjInfo(const VkDeviceMemory mem) +static MT_MEM_OBJ_INFO* getMemObjInfo( + const VkDeviceMemory mem) { MT_MEM_OBJ_INFO* pMemObjInfo = NULL; @@ -364,10 +387,12 @@ static MT_MEM_OBJ_INFO* getMemObjInfo(const VkDeviceMemory mem) return pMemObjInfo; } -static void addMemObjInfo(const VkDeviceMemory mem, const VkMemoryAllocInfo* pAllocInfo) +static void addMemObjInfo( + const VkDeviceMemory mem, + const VkMemoryAllocInfo *pAllocInfo) { MT_MEM_OBJ_INFO* pInfo = new MT_MEM_OBJ_INFO; - pInfo->refCount = 0; + pInfo->refCount = 0; memset(&pInfo->allocInfo, 0, sizeof(VkMemoryAllocInfo)); if (pAllocInfo) { // MEM alloc created by vkCreateSwapChainWSI() doesn't have alloc info struct @@ -381,14 +406,17 @@ static void addMemObjInfo(const VkDeviceMemory mem, const VkMemoryAllocInfo* pAl // Find CB Info and add mem binding to list container // Find Mem Obj Info and add CB binding to list container -static bool32_t updateCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) +static bool32_t updateCBBinding( + const VkCmdBuffer cb, + const VkDeviceMemory mem) { bool32_t result = VK_TRUE; // First update CB binding in MemObj mini CB list MT_MEM_OBJ_INFO* pMemInfo = getMemObjInfo(mem); if (!pMemInfo) { char str[1024]; - sprintf(str, "Trying to bind mem obj %p to CB %p but no info for that mem obj.\n Was it correctly allocated? Did it already get freed?", mem, cb); + sprintf(str, "Trying to bind mem obj %p to CB %p but no info for that mem obj.\n " + "Was it correctly allocated? Did it already get freed?", mem, cb); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = VK_FALSE; } else { @@ -433,7 +461,9 @@ static bool32_t updateCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) // Clear the CB Binding for mem // Calls to this function should be wrapped in mutex -static void clearCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) +static void clearCBBinding( + const VkCmdBuffer cb, + const VkDeviceMemory mem) { MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); // TODO : Having this check is not ideal, really if memInfo was deleted, @@ -446,7 +476,8 @@ static void clearCBBinding(const VkCmdBuffer cb, const VkDeviceMemory mem) } // Free bindings related to CB -static bool32_t freeCBBindings(const VkCmdBuffer cb) +static bool32_t freeCBBindings( + const VkCmdBuffer cb) { bool32_t result = VK_TRUE; MT_CB_INFO* pCBInfo = getCBInfo(cb); @@ -471,7 +502,8 @@ static bool32_t freeCBBindings(const VkCmdBuffer cb) // Delete CBInfo from list along with all of it's mini MemObjInfo // and also clear mem references to CB // TODO : When should this be called? There's no Destroy of CBs that I see -static bool32_t deleteCBInfo(const VkCmdBuffer cb) +static bool32_t deleteCBInfo( + const VkCmdBuffer cb) { bool32_t result = VK_TRUE; result = freeCBBindings(cb); @@ -487,7 +519,8 @@ static bool32_t deleteCBInfo(const VkCmdBuffer cb) } // Delete the entire CB list -static bool32_t deleteCBInfoList() +static bool32_t deleteCBInfoList( + void) { bool32_t result = VK_TRUE; for (map<VkCmdBuffer, MT_CB_INFO*>::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { @@ -498,14 +531,16 @@ static bool32_t deleteCBInfoList() } // For given MemObjInfo, report Obj & CB bindings -static void reportMemReferencesAndCleanUp(MT_MEM_OBJ_INFO* pMemObjInfo) +static void reportMemReferencesAndCleanUp( + MT_MEM_OBJ_INFO* pMemObjInfo) { size_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size(); size_t objRefCount = pMemObjInfo->pObjBindings.size(); if ((pMemObjInfo->pCmdBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) { char str[1024]; - sprintf(str, "Attempting to free memory object %p which still contains %lu references", pMemObjInfo->mem, (cmdBufRefCount + objRefCount)); + sprintf(str, "Attempting to free memory object %p which still contains %lu references", + pMemObjInfo->mem, (cmdBufRefCount + objRefCount)); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pMemObjInfo->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); } @@ -530,7 +565,8 @@ static void reportMemReferencesAndCleanUp(MT_MEM_OBJ_INFO* pMemObjInfo) } } -static void deleteMemObjInfo(VkDeviceMemory mem) +static void deleteMemObjInfo( + VkDeviceMemory mem) { if (memObjMap.find(mem) != memObjMap.end()) { MT_MEM_OBJ_INFO* pDelInfo = memObjMap[mem]; @@ -545,7 +581,8 @@ static void deleteMemObjInfo(VkDeviceMemory mem) } // Check if fence for given CB is completed -static bool32_t checkCBCompleted(const VkCmdBuffer cb) +static bool32_t checkCBCompleted( + const VkCmdBuffer cb) { bool32_t result = VK_TRUE; MT_CB_INFO* pCBInfo = getCBInfo(cb); @@ -557,7 +594,8 @@ static bool32_t checkCBCompleted(const VkCmdBuffer cb) } else { if (!fenceRetired(pCBInfo->fenceId)) { char str[1024]; - sprintf(str, "FenceId %" PRIx64", fence %p for CB %p has not been checked for completion", pCBInfo->fenceId, getFenceFromId(pCBInfo->fenceId), cb); + sprintf(str, "FenceId %" PRIx64", fence %p for CB %p has not been checked for completion", + pCBInfo->fenceId, getFenceFromId(pCBInfo->fenceId), cb); layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_NONE, "MEM", str); result = VK_FALSE; } @@ -565,20 +603,24 @@ static bool32_t checkCBCompleted(const VkCmdBuffer cb) return result; } -static bool32_t freeMemObjInfo(VkDeviceMemory mem, bool internal) +static bool32_t freeMemObjInfo( + VkDeviceMemory mem, + bool internal) { bool32_t result = VK_TRUE; // Parse global list to find info w/ mem MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); if (!pInfo) { char str[1024]; - sprintf(str, "Couldn't find mem info object for %p\n Was %p never allocated or previously freed?", (void*)mem, (void*)mem); + sprintf(str, "Couldn't find mem info object for %p\n Was %p never allocated or previously freed?", + (void*)mem, (void*)mem); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = VK_FALSE; } else { if (pInfo->allocInfo.allocationSize == 0 && !internal) { char str[1024]; - sprintf(str, "Attempting to free memory associated with a Persistent Image, %p, this should not be explicitly freed\n", (void*)mem); + sprintf(str, "Attempting to free memory associated with a Persistent Image, %p, " + "this should not be explicitly freed\n", (void*)mem); layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = VK_FALSE; } else { @@ -618,13 +660,16 @@ static bool32_t freeMemObjInfo(VkDeviceMemory mem, bool internal) // 1. Remove ObjectInfo from MemObjInfo list container of obj bindings & free it // 2. Decrement refCount for MemObjInfo // 3. Clear MemObjInfo ptr from ObjectInfo -static bool32_t clearObjectBinding(VkObject object) +static bool32_t clearObjectBinding( + VkObject object) { bool32_t result = VK_FALSE; MT_OBJ_INFO* pObjInfo = getObjectInfo(object); if (!pObjInfo) { char str[1024]; - sprintf(str, "Attempting to clear mem binding for object %p: devices, queues, command buffers, shaders and memory objects do not have external memory requirements and it is unneccessary to call bind/unbindObjectMemory on them.", object); + sprintf(str, "Attempting to clear mem binding for object %p: devices, queues, command buffers, " + "shaders and memory objects do not have external memory requirements and it is " + "unneccessary to call bind/unbindObjectMemory on them.", object); layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INVALID_OBJECT, "MEM", str); } else { if (!pObjInfo->pMemObjInfo) { @@ -660,7 +705,9 @@ static bool32_t clearObjectBinding(VkObject object) // Add reference from objectInfo to memoryInfo // Add reference off of objInfo // Return VK_TRUE if addition is successful, VK_FALSE otherwise -static bool32_t updateObjectBinding(VkObject object, VkDeviceMemory mem) +static bool32_t updateObjectBinding( + VkObject object, + VkDeviceMemory mem) { bool32_t result = VK_FALSE; // Handle NULL case separately, just clear previous binding & decrement reference @@ -703,7 +750,8 @@ static bool32_t updateObjectBinding(VkObject object, VkDeviceMemory mem) // For image objects, make sure default memory state is correctly set // TODO : What's the best/correct way to handle this? if (VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pObjInfo->sType) { - if (pObjInfo->create_info.image_create_info.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { + if (pObjInfo->create_info.image_create_info.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | + VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { // TODO:: More memory state transition stuff. } } @@ -714,7 +762,8 @@ static bool32_t updateObjectBinding(VkObject object, VkDeviceMemory mem) } // Print details of global Obj tracking list -static void printObjList() +static void printObjList( + void) { MT_OBJ_INFO* pInfo = NULL; char str[1024]; @@ -728,7 +777,8 @@ static void printObjList() } // For given Object, get 'mem' obj that it's bound to or NULL if no binding -static VkDeviceMemory getMemBindingFromObject(const VkObject object) +static VkDeviceMemory getMemBindingFromObject( + const VkObject object) { VkDeviceMemory mem = NULL; MT_OBJ_INFO* pObjInfo = getObjectInfo(object); @@ -753,7 +803,8 @@ static VkDeviceMemory getMemBindingFromObject(const VkObject object) } // Print details of MemObjInfo list -static void printMemList() +static void printMemList( + void) { MT_MEM_OBJ_INFO* pInfo = NULL; // Just printing each msg individually for now, may want to package these into single large print @@ -795,7 +846,8 @@ static void printMemList() } } -static void printCBList() +static void printCBList( + void) { char str[1024] = {0}; MT_CB_INFO* pCBInfo = NULL; @@ -817,7 +869,8 @@ static void printCBList() } } -static void initMemTracker(void) +static void initMemTracker( + void) { const char *strOpt; // initialize MemTracker options @@ -827,12 +880,12 @@ static void initMemTracker(void) if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG) { strOpt = getLayerOption("MemTrackerLogFilename"); - if (strOpt) - { + if (strOpt) { g_logFile = fopen(strOpt, "w"); } - if (g_logFile == NULL) + if (g_logFile == NULL) { g_logFile = stdout; + } } // initialize Layer dispatch table @@ -855,7 +908,10 @@ static void initMemTracker(void) } } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( + VkPhysicalDevice gpu, + const VkDeviceCreateInfo *pCreateInfo, + VkDevice *pDevice) { pCurObj = (VkBaseLayerObject *) gpu; loader_platform_thread_once(&g_initOnce, initMemTracker); @@ -865,7 +921,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDevi return result; } -VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) +VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice( + VkDevice device) { char str[1024]; sprintf(str, "Printing List details prior to vkDestroyDevice()"); @@ -884,8 +941,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) pInfo = (*ii).second; if (pInfo->allocInfo.allocationSize != 0) { - sprintf(str, "Mem Object %p has not been freed. You should clean up this memory by calling vkFreeMemory(%p) prior to vkDestroyDevice().", - pInfo->mem, pInfo->mem); + sprintf(str, "Mem Object %p has not been freed. You should clean up this memory by calling " + "vkFreeMemory(%p) prior to vkDestroyDevice().", pInfo->mem, pInfo->mem); layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pInfo->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", str); } } @@ -910,32 +967,36 @@ static const struct extProps mtExts[MEM_TRACKER_LAYER_EXT_ARRAY_SIZE] = { }; VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionInfoType infoType, + uint32_t extensionIndex, + size_t *pDataSize, + void *pData) { - /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ + // This entrypoint is NOT going to init its own dispatch table since loader calls here early VkExtensionProperties *ext_props; uint32_t *count; - if (pDataSize == NULL) + if (pDataSize == NULL) { return VK_ERROR_INVALID_POINTER; + } switch (infoType) { case VK_EXTENSION_INFO_TYPE_COUNT: *pDataSize = sizeof(uint32_t); - if (pData == NULL) + if (pData == NULL) { return VK_SUCCESS; + } count = (uint32_t *) pData; *count = MEM_TRACKER_LAYER_EXT_ARRAY_SIZE; break; case VK_EXTENSION_INFO_TYPE_PROPERTIES: *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) + if (pData == NULL) { return VK_SUCCESS; - if (extensionIndex >= MEM_TRACKER_LAYER_EXT_ARRAY_SIZE) + } + if (extensionIndex >= MEM_TRACKER_LAYER_EXT_ARRAY_SIZE) { return VK_ERROR_INVALID_VALUE; + } ext_props = (VkExtensionProperties *) pData; ext_props->version = mtExts[extensionIndex].version; strncpy(ext_props->extName, mtExts[extensionIndex].name, @@ -949,10 +1010,14 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( return VK_SUCCESS; } -VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, - size_t maxStringSize, size_t* pLayerCount, char* const* pOutLayers, void* pReserved) +VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers( + VkPhysicalDevice gpu, + size_t maxStringSize, + size_t *pLayerCount, + char* const *pOutLayers, + void *pReserved) { - if (gpu != NULL) + if (gpu != NULL) { pCurObj = (VkBaseLayerObject *) gpu; loader_platform_thread_once(&g_initOnce, initMemTracker); @@ -961,8 +1026,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, return result; } else { - if (pLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) + if (pLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) { return VK_ERROR_INVALID_POINTER; + } // This layer compatible with all GPUs *pLayerCount = 1; strncpy((char *) pOutLayers[0], "MemTracker", maxStringSize); @@ -970,7 +1036,11 @@ VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, } } -VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue) +VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue( + VkDevice device, + uint32_t queueNodeIndex, + uint32_t queueIndex, + VkQueue *pQueue) { VkResult result = nextTable.GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); if (result == VK_SUCCESS) { @@ -981,7 +1051,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueN return result; } -VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences(VkQueue queue, uint32_t count, const VkDeviceMemory* pMems) +VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences( + VkQueue queue, + uint32_t count, + const VkDeviceMemory *pMems) { VkResult result = nextTable.QueueAddMemReferences(queue, count, pMems); if (result == VK_SUCCESS) { @@ -997,7 +1070,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences(VkQueue queue, uint32_t c if (checkMemRef(queue, pMems[i]) == VK_TRUE) { // Alread in list, just warn char str[1024]; - sprintf(str, "Request to add a memory reference (%p) to Queue %p -- ref is already present in the queue's reference list", pMems[i], queue); + sprintf(str, "Request to add a memory reference (%p) to Queue %p -- ref is already " + "present in the queue's reference list", pMems[i], queue); layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, pMems[i], 0, MEMTRACK_INVALID_MEM_REF, "MEM", str); } else { // Add to queue's memory reference list @@ -1010,7 +1084,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences(VkQueue queue, uint32_t c return result; } -VK_LAYER_EXPORT VkResult VKAPI vkQueueRemoveMemReferences(VkQueue queue, uint32_t count, const VkDeviceMemory* pMems) +VK_LAYER_EXPORT VkResult VKAPI vkQueueRemoveMemReferences( + VkQueue queue, + uint32_t count, + const VkDeviceMemory *pMems) { // TODO : Decrement ref count for this memory reference on this queue. Remove if ref count is zero. VkResult result = nextTable.QueueRemoveMemReferences(queue, count, pMems); @@ -1038,8 +1115,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueRemoveMemReferences(VkQueue queue, uint32_ VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( VkQueue queue, - uint32_t cmdBufferCount, - const VkCmdBuffer *pCmdBuffers, + uint32_t cmdBufferCount, + const VkCmdBuffer *pCmdBuffers, VkFence fence) { loader_platform_thread_lock_mutex(&globalLock); @@ -1061,7 +1138,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit( return result; } -VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem) +VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory( + VkDevice device, + const VkMemoryAllocInfo *pAllocInfo, + VkDeviceMemory *pMem) { VkResult result = nextTable.AllocMemory(device, pAllocInfo, pMem); // TODO : Track allocations and overall size here @@ -1072,7 +1152,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllo return result; } -VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkDeviceMemory mem) +VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory( + VkDevice device, + VkDeviceMemory mem) { /* From spec : A memory object is freed by calling vkFreeMemory() when it is no longer needed. Before * freeing a memory object, an application must ensure the memory object is unbound from @@ -1092,7 +1174,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkDeviceMemory mem) return result; } -VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkDeviceMemory mem, VkMemoryPriority priority) +VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority( + VkDevice device, + VkDeviceMemory mem, + VkMemoryPriority priority) { // TODO : Update tracking for this alloc // Make sure memory is not pinned, which can't have priority set @@ -1100,7 +1185,13 @@ VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkDeviceMemo return result; } -VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData) +VK_LAYER_EXPORT VkResult VKAPI vkMapMemory( + VkDevice device, + VkDeviceMemory mem, + VkDeviceSize offset, + VkDeviceSize size, + VkFlags flags, + void **ppData) { // TODO : Track when memory is mapped loader_platform_thread_lock_mutex(&globalLock); @@ -1115,7 +1206,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkDeviceMemory mem, return result; } -VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem) +VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory( + VkDevice device, + VkDeviceMemory mem) { // TODO : Track as memory gets unmapped, do we want to check what changed following map? // Make sure that memory was ever mapped to begin with @@ -1123,7 +1216,11 @@ VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem return result; } -VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSysMem, size_t memSize, VkDeviceMemory* pMem) +VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory( + VkDevice device, + const void *pSysMem, + size_t memSize, + VkDeviceMemory *pMem) { // TODO : Track this // Verify that memory is actually pinnable @@ -1131,28 +1228,41 @@ VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pS return result; } -VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem) +VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory( + VkDevice device, + const VkMemoryOpenInfo *pOpenInfo, + VkDeviceMemory *pMem) { // TODO : Track this VkResult result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory(VkDevice device, const VkPeerMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem) +VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory( + VkDevice device, + const VkPeerMemoryOpenInfo *pOpenInfo, + VkDeviceMemory *pMem) { // TODO : Track this VkResult result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage(VkDevice device, const VkPeerImageOpenInfo* pOpenInfo, VkImage* pImage, VkDeviceMemory* pMem) +VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage( + VkDevice device, + const VkPeerImageOpenInfo *pOpenInfo, + VkImage *pImage, + VkDeviceMemory *pMem) { // TODO : Track this VkResult result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object) +VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject( + VkDevice device, + VkObjectType objType, + VkObject object) { loader_platform_thread_lock_mutex(&globalLock); @@ -1172,9 +1282,12 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType obj } else { char str[1024]; - sprintf(str, "Destroying obj %p that is still bound to memory object %p\nYou should first clear binding by calling vkQueueBindObjectMemory(queue, %p, 0, VK_NULL_HANDLE, 0)", object, (void*)pDelInfo->pMemObjInfo->mem, object); + sprintf(str, "Destroying obj %p that is still bound to memory object %p\nYou should first clear binding " + "by calling vkQueueBindObjectMemory(queue, %p, 0, VK_NULL_HANDLE, 0)", + object, (void*)pDelInfo->pMemObjInfo->mem, object); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, object, 0, MEMTRACK_DESTROY_OBJECT_ERROR, "MEM", str); - // From the spec : If an object has previous memory binding, it is required to unbind memory from an API object before it is destroyed. + // From the spec : If an object has previous memory binding, it is required to unbind memory + // from an API object before it is destroyed. clearObjectBinding(object); } } @@ -1187,16 +1300,29 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType obj return result; } -VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo( + VkDevice device, + VkObjectType objType, + VkObject object, + VkObjectInfoType infoType, + size_t *pDataSize, + void *pData) { // TODO : What to track here? // Could potentially save returned mem requirements and validate values passed into QueueBindObjectMemory for this object - // From spec : The only objects that are guaranteed to have no external memory requirements are devices, queues, command buffers, shaders and memory objects. + // From spec : The only objects that are guaranteed to have no external memory requirements are devices, queues, + // command buffers, shaders and memory objects. VkResult result = nextTable.GetObjectInfo(device, objType, object, infoType, pDataSize, pData); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemory(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceMemory mem, VkDeviceSize offset) +VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemory( + VkQueue queue, + VkObjectType objType, + VkObject object, + uint32_t allocationIdx, + VkDeviceMemory mem, + VkDeviceSize offset) { VkResult result = nextTable.QueueBindObjectMemory(queue, objType, object, allocationIdx, mem, offset); loader_platform_thread_lock_mutex(&globalLock); @@ -1212,7 +1338,15 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemory(VkQueue queue, VkObjectTy return result; } -VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemoryRange(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset) +VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemoryRange( + VkQueue queue, + VkObjectType objType, + VkObject object, + uint32_t allocationIdx, + VkDeviceSize rangeOffset, + VkDeviceSize rangeSize, + VkDeviceMemory mem, + VkDeviceSize memOffset) { VkResult result = nextTable.QueueBindObjectMemoryRange(queue, objType, object, allocationIdx, rangeOffset, rangeSize, mem, memOffset); loader_platform_thread_lock_mutex(&globalLock); @@ -1228,7 +1362,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueBindObjectMemoryRange(VkQueue queue, VkObj return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence) +VK_LAYER_EXPORT VkResult VKAPI vkCreateFence( + VkDevice device, + const VkFenceCreateInfo *pCreateInfo, + VkFence *pFence) { VkResult result = nextTable.CreateFence(device, pCreateInfo, pFence); if (VK_SUCCESS == result) { @@ -1239,7 +1376,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreat return result; } -VK_LAYER_EXPORT VkResult VKAPI vkResetFences(VkDevice device, uint32_t fenceCount, VkFence* pFences) +VK_LAYER_EXPORT VkResult VKAPI vkResetFences( + VkDevice device, + uint32_t fenceCount, + VkFence *pFences) { VkResult result = nextTable.ResetFences(device, fenceCount, pFences); if (VK_SUCCESS == result) { @@ -1266,7 +1406,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkResetFences(VkDevice device, uint32_t fenceCoun return result; } -VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence) +VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus( + VkDevice device, + VkFence fence) { VkResult result = nextTable.GetFenceStatus(device, fence); if (VK_SUCCESS == result) { @@ -1277,7 +1419,12 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence) return result; } -VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, bool32_t waitAll, uint64_t timeout) +VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences( + VkDevice device, + uint32_t fenceCount, + const VkFence *pFences, + bool32_t waitAll, + uint64_t timeout) { // Verify fence status of submitted fences for(uint32_t i = 0; i < fenceCount; i++) { @@ -1305,7 +1452,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences(VkDevice device, uint32_t fenceCo return result; } -VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue) +VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle( + VkQueue queue) { VkResult result = nextTable.QueueWaitIdle(queue); if (VK_SUCCESS == result) { @@ -1316,7 +1464,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue) return result; } -VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device) +VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle( + VkDevice device) { VkResult result = nextTable.DeviceWaitIdle(device); if (VK_SUCCESS == result) { @@ -1327,7 +1476,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device) return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent) +VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent( + VkDevice device, + const VkEventCreateInfo *pCreateInfo, + VkEvent *pEvent) { VkResult result = nextTable.CreateEvent(device, pCreateInfo, pEvent); if (VK_SUCCESS == result) { @@ -1338,7 +1490,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreat return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool) +VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool( + VkDevice device, + const VkQueryPoolCreateInfo *pCreateInfo, + VkQueryPool *pQueryPool) { VkResult result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool); if (VK_SUCCESS == result) { @@ -1349,7 +1504,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryP return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer) +VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer( + VkDevice device, + const VkBufferCreateInfo *pCreateInfo, + VkBuffer *pBuffer) { VkResult result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer); if (VK_SUCCESS == result) { @@ -1360,7 +1518,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCre return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView) +VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView( + VkDevice device, + const VkBufferViewCreateInfo *pCreateInfo, + VkBufferView *pView) { VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView); if (result == VK_SUCCESS) { @@ -1371,7 +1532,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBuffe return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage) +VK_LAYER_EXPORT VkResult VKAPI vkCreateImage( + VkDevice device, + const VkImageCreateInfo *pCreateInfo, + VkImage *pImage) { VkResult result = nextTable.CreateImage(device, pCreateInfo, pImage); if (VK_SUCCESS == result) { @@ -1382,7 +1546,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreat return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView) +VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView( + VkDevice device, + const VkImageViewCreateInfo *pCreateInfo, + VkImageView *pView) { VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView); if (result == VK_SUCCESS) { @@ -1393,8 +1560,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageV return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, - VkColorAttachmentView* pView) +VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView( + VkDevice device, + const VkColorAttachmentViewCreateInfo *pCreateInfo, + VkColorAttachmentView *pView) { VkResult result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView); if (result == VK_SUCCESS) { @@ -1405,7 +1574,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, cons return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView( + VkDevice device, + const VkDepthStencilViewCreateInfo *pCreateInfo, + VkDepthStencilView *pView) { VkResult result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView); if (result == VK_SUCCESS) { @@ -1416,13 +1588,19 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const V return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader) +VK_LAYER_EXPORT VkResult VKAPI vkCreateShader( + VkDevice device, + const VkShaderCreateInfo *pCreateInfo, + VkShader *pShader) { VkResult result = nextTable.CreateShader(device, pCreateInfo, pShader); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) +VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline( + VkDevice device, + const VkGraphicsPipelineCreateInfo *pCreateInfo, + VkPipeline *pPipeline) { VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); if (result == VK_SUCCESS) { @@ -1434,10 +1612,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const V } VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( - VkDevice device, - const VkGraphicsPipelineCreateInfo* pCreateInfo, - VkPipeline basePipeline, - VkPipeline* pPipeline) + VkDevice device, + const VkGraphicsPipelineCreateInfo *pCreateInfo, + VkPipeline basePipeline, + VkPipeline *pPipeline) { VkResult result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline); if (result == VK_SUCCESS) { @@ -1448,7 +1626,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) +VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline( + VkDevice device, + const VkComputePipelineCreateInfo *pCreateInfo, + VkPipeline *pPipeline) { VkResult result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline); if (result == VK_SUCCESS) { @@ -1459,7 +1640,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const Vk return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler) +VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler( + VkDevice device, + const VkSamplerCreateInfo *pCreateInfo, + VkSampler *pSampler) { VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler); if (result == VK_SUCCESS) { @@ -1470,8 +1654,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerC return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, - VkDynamicVpState* pState) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState( + VkDevice device, + const VkDynamicVpStateCreateInfo *pCreateInfo, + VkDynamicVpState *pState) { VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); if (result == VK_SUCCESS) { @@ -1482,8 +1668,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, con return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, - VkDynamicRsState* pState) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState( + VkDevice device, + const VkDynamicRsStateCreateInfo *pCreateInfo, + VkDynamicRsState *pState) { VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); if (result == VK_SUCCESS) { @@ -1494,8 +1682,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, - VkDynamicCbState* pState) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState( + VkDevice device, + const VkDynamicCbStateCreateInfo *pCreateInfo, + VkDynamicCbState *pState) { VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); if (result == VK_SUCCESS) { @@ -1506,8 +1696,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, c return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, - VkDynamicDsState* pState) +VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState( + VkDevice device, + const VkDynamicDsStateCreateInfo *pCreateInfo, + VkDynamicDsState *pState) { VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); if (result == VK_SUCCESS) { @@ -1518,7 +1710,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer) +VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer( + VkDevice device, + const VkCmdBufferCreateInfo *pCreateInfo, + VkCmdBuffer *pCmdBuffer) { VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); // At time of cmd buffer creation, create global cmd buffer info for the returned cmd buffer @@ -1530,7 +1725,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCm return result; } -VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) +VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer( + VkCmdBuffer cmdBuffer, + const VkCmdBufferBeginInfo *pBeginInfo) { // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); @@ -1538,7 +1735,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const bool32_t cbDone = checkCBCompleted(cmdBuffer); if (VK_FALSE == cbDone) { char str[1024]; - sprintf(str, "Calling vkBeginCommandBuffer() on active CB %p before it has completed. You must check CB flag before this call.", cmdBuffer); + sprintf(str, "Calling vkBeginCommandBuffer() on active CB %p before it has completed. " + "You must check CB flag before this call.", cmdBuffer); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", str); } } @@ -1549,14 +1747,16 @@ VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const return result; } -VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer) +VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer( + VkCmdBuffer cmdBuffer) { // TODO : Anything to do here? VkResult result = nextTable.EndCommandBuffer(cmdBuffer); return result; } -VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) +VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer( + VkCmdBuffer cmdBuffer) { // Verify that CB is complete (not in-flight) MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); @@ -1564,7 +1764,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) bool32_t cbDone = checkCBCompleted(cmdBuffer); if (VK_FALSE == cbDone) { char str[1024]; - sprintf(str, "Resetting CB %p before it has completed. You must check CB flag before calling vkResetCommandBuffer().", cmdBuffer); + sprintf(str, "Resetting CB %p before it has completed. You must check CB flag before " + "calling vkResetCommandBuffer().", cmdBuffer); layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", str); } } @@ -1577,7 +1778,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) } // TODO : For any vkCmdBind* calls that include an object which has mem bound to it, // need to account for that mem now having binding to given cmdBuffer -VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) +VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline( + VkCmdBuffer cmdBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline) { #if 0 // TODO : If memory bound to pipeline, then need to tie that mem to cmdBuffer @@ -1600,7 +1804,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBi nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); } -VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state) +VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject( + VkCmdBuffer cmdBuffer, + VkStateBindPoint stateBindPoint, + VkDynamicStateObject state) { MT_OBJ_INFO *pObjInfo; loader_platform_thread_lock_mutex(&globalLock); @@ -1622,34 +1829,43 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, Vk } VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets( - VkCmdBuffer cmdBuffer, - VkPipelineBindPoint pipelineBindPoint, - uint32_t firstSet, - uint32_t setCount, - const VkDescriptorSet* pDescriptorSets, - uint32_t dynamicOffsetCount, - const uint32_t* pDynamicOffsets) + VkCmdBuffer cmdBuffer, + VkPipelineBindPoint pipelineBindPoint, + uint32_t firstSet, + uint32_t setCount, + const VkDescriptorSet *pDescriptorSets, + uint32_t dynamicOffsetCount, + const uint32_t *pDynamicOffsets) { // TODO : Somewhere need to verify that all textures referenced by shaders in DS are in some type of *SHADER_READ* state nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); } VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( - VkCmdBuffer cmdBuffer, - uint32_t startBinding, - uint32_t bindingCount, - const VkBuffer* pBuffers, - const VkDeviceSize* pOffsets) + VkCmdBuffer cmdBuffer, + uint32_t startBinding, + uint32_t bindingCount, + const VkBuffer *pBuffers, + const VkDeviceSize *pOffsets) { nextTable.CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); } -VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) +VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer( + VkCmdBuffer cmdBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkIndexType indexType) { nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); } -VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) +VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect( + VkCmdBuffer cmdBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t count, + uint32_t stride) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(buffer); @@ -1662,7 +1878,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buf nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); } -VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) +VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect( + VkCmdBuffer cmdBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t count, + uint32_t stride) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(buffer); @@ -1675,7 +1896,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuf nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); } -VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) +VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect( + VkCmdBuffer cmdBuffer, + VkBuffer buffer, + VkDeviceSize offset) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(buffer); @@ -1688,8 +1912,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); } -VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, - uint32_t regionCount, const VkBufferCopy* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer( + VkCmdBuffer cmdBuffer, + VkBuffer srcBuffer, + VkBuffer destBuffer, + uint32_t regionCount, + const VkBufferCopy *pRegions) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(srcBuffer); @@ -1708,28 +1936,39 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBu nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, - VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, VkImageLayout destImageLayout, - uint32_t regionCount, const VkImageCopy* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdCopyImage( + VkCmdBuffer cmdBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage destImage, + VkImageLayout destImageLayout, + uint32_t regionCount, + const VkImageCopy *pRegions) { // TODO : Each image will have mem mapping so track them nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer, - VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, VkImageLayout destImageLayout, - uint32_t regionCount, const VkImageBlit* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdBlitImage( + VkCmdBuffer cmdBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage destImage, + VkImageLayout destImageLayout, + uint32_t regionCount, + const VkImageBlit *pRegions) { // TODO : Each image will have mem mapping so track them nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, - VkBuffer srcBuffer, - VkImage destImage, VkImageLayout destImageLayout, - uint32_t regionCount, const VkBufferImageCopy* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage( + VkCmdBuffer cmdBuffer, + VkBuffer srcBuffer, + VkImage destImage, + VkImageLayout destImageLayout, + uint32_t regionCount, + const VkBufferImageCopy *pRegions) { // TODO : Track this loader_platform_thread_lock_mutex(&globalLock); @@ -1750,10 +1989,13 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, - VkImage srcImage, VkImageLayout srcImageLayout, - VkBuffer destBuffer, - uint32_t regionCount, const VkBufferImageCopy* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer( + VkCmdBuffer cmdBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkBuffer destBuffer, + uint32_t regionCount, + const VkBufferImageCopy *pRegions) { // TODO : Track this loader_platform_thread_lock_mutex(&globalLock); @@ -1773,8 +2015,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, VkImageLayout destImageLayout) +VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData( + VkCmdBuffer cmdBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage destImage, + VkImageLayout destImageLayout) { // TODO : Each image will have mem mapping so track them loader_platform_thread_lock_mutex(&globalLock); @@ -1794,7 +2040,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage sr nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout); } -VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) +VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer( + VkCmdBuffer cmdBuffer, + VkBuffer destBuffer, + VkDeviceSize destOffset, + VkDeviceSize dataSize, + const uint32_t *pData) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(destBuffer); @@ -1807,7 +2058,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer des nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); } -VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) +VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer( + VkCmdBuffer cmdBuffer, + VkBuffer destBuffer, + VkDeviceSize destOffset, + VkDeviceSize fillSize, + uint32_t data) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(destBuffer); @@ -1820,10 +2076,13 @@ VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destB nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); } -VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, - VkImage image, VkImageLayout imageLayout, - VkClearColor color, - uint32_t rangeCount, const VkImageSubresourceRange* pRanges) +VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( + VkCmdBuffer cmdBuffer, + VkImage image, + VkImageLayout imageLayout, + VkClearColor color, + uint32_t rangeCount, + const VkImageSubresourceRange *pRanges) { // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state loader_platform_thread_lock_mutex(&globalLock); @@ -1837,10 +2096,14 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, color, rangeCount, pRanges); } -VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, - VkImage image, VkImageLayout imageLayout, - float depth, uint32_t stencil, - uint32_t rangeCount, const VkImageSubresourceRange* pRanges) +VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil( + VkCmdBuffer cmdBuffer, + VkImage image, + VkImageLayout imageLayout, + float depth, + uint32_t stencil, + uint32_t rangeCount, + const VkImageSubresourceRange *pRanges) { // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state loader_platform_thread_lock_mutex(&globalLock); @@ -1854,10 +2117,14 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); } -VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, - VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, VkImageLayout destImageLayout, - uint32_t regionCount, const VkImageResolve* pRegions) +VK_LAYER_EXPORT void VKAPI vkCmdResolveImage( + VkCmdBuffer cmdBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage destImage, + VkImageLayout destImageLayout, + uint32_t regionCount, + const VkImageResolve *pRegions) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(srcImage); @@ -1876,7 +2143,11 @@ VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); } -VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags) +VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery( + VkCmdBuffer cmdBuffer, + VkQueryPool queryPool, + uint32_t slot, + VkFlags flags) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(queryPool); @@ -1889,7 +2160,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool qu nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); } -VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) +VK_LAYER_EXPORT void VKAPI vkCmdEndQuery( + VkCmdBuffer cmdBuffer, + VkQueryPool queryPool, + uint32_t slot) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(queryPool); @@ -1902,7 +2176,11 @@ VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool quer nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); } -VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) +VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool( + VkCmdBuffer cmdBuffer, + VkQueryPool queryPool, + uint32_t startQuery, + uint32_t queryCount) { loader_platform_thread_lock_mutex(&globalLock); VkDeviceMemory mem = getMemBindingFromObject(queryPool); @@ -1915,7 +2193,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPoo nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); } -VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) +VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback( + VkInstance instance, + VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, + void *pUserData) { // This layer intercepts callbacks VK_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (VK_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(VK_LAYER_DBG_FUNCTION_NODE)); @@ -1933,23 +2214,25 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_ return result; } -VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) +VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback( + VkInstance instance, + VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) { VK_LAYER_DBG_FUNCTION_NODE *pInfo = g_pDbgFunctionHead; VK_LAYER_DBG_FUNCTION_NODE *pPrev = pInfo; while (pInfo) { if (pInfo->pfnMsgCallback == pfnMsgCallback) { pPrev->pNext = pInfo->pNext; - if (g_pDbgFunctionHead == pInfo) + if (g_pDbgFunctionHead == pInfo) { g_pDbgFunctionHead = pInfo->pNext; + } free(pInfo); break; } pPrev = pInfo; pInfo = pInfo->pNext; } - if (g_pDbgFunctionHead == NULL) - { + if (g_pDbgFunctionHead == NULL) { if (g_actionIsDefault) { g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; } else { @@ -1960,7 +2243,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, V return result; } -VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain) +VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI( + VkDevice device, + const VkSwapChainCreateInfoWSI *pCreateInfo, + VkSwapChainWSI *pSwapChain) { VkResult result = nextTable.CreateSwapChainWSI(device, pCreateInfo, pSwapChain); @@ -1973,7 +2259,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI(VkDevice device, const VkSwa return result; } -VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI(VkSwapChainWSI swapChain) +VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI( + VkSwapChainWSI swapChain) { loader_platform_thread_lock_mutex(&globalLock); @@ -1999,7 +2286,11 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI(VkSwapChainWSI swapChain) return nextTable.DestroySwapChainWSI(swapChain); } -VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI( + VkSwapChainWSI swapChain, + VkSwapChainInfoTypeWSI infoType, + size_t *pDataSize, + void *pData) { VkResult result = nextTable.GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData); @@ -2037,12 +2328,15 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI(VkSwapChainWSI swapChain, V return result; } -VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalDevice gpu, const char* funcName) +VK_LAYER_EXPORT void* VKAPI vkGetProcAddr( + VkPhysicalDevice gpu, + const char *funcName) { VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu; - if (gpu == NULL) + if (gpu == NULL) { return NULL; + } pCurObj = gpuw; loader_platform_thread_once(&g_initOnce, initMemTracker); @@ -2195,8 +2489,9 @@ VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalDevice gpu, const char* func if (!strcmp(funcName, "vkGetSwapChainInfoWSI")) return (void*) vkGetSwapChainInfoWSI; else { - if (gpuw->pGPA == NULL) + if (gpuw->pGPA == NULL) { return NULL; + } return gpuw->pGPA((VkPhysicalDevice)gpuw->nextObject, funcName); } } |
