header_txt.append(' }')
header_txt.append('}')
header_txt.append('')
- header_txt.append('// Returns pointer to this queue\'s mem ref data')
- header_txt.append('static OT_QUEUE_INFO* getQueueInfo(VkQueue queue)')
- header_txt.append('{')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo;')
- header_txt.append(' OT_QUEUE_INFO *pFound = NULL;')
- header_txt.append(' while (pQueueInfo != NULL) {')
- header_txt.append(' if (pQueueInfo->queue != queue) {')
- header_txt.append(' pQueueInfo = pQueueInfo->pNextQI;')
- header_txt.append(' }')
- header_txt.append(' else {')
- header_txt.append(' pFound = pQueueInfo;')
- header_txt.append(' break;')
- header_txt.append(' }')
- header_txt.append(' }')
- header_txt.append(' return pFound;')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('// Returns pointer to a specific memory reference in a queue\'s mem ref list')
- header_txt.append('static OT_MEM_INFO* findMemRefInQueueList(VkQueue queue, VkGpuMemory mem)')
- header_txt.append('{')
- header_txt.append(' // Get pointer to queue\'s list')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = getQueueInfo(queue);')
- header_txt.append(' OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList;')
- header_txt.append(' OT_MEM_INFO *pFound = NULL;')
- header_txt.append('')
- header_txt.append(' while (pMemInfo != NULL) {')
- header_txt.append(' if (pMemInfo->mem != mem) {')
- header_txt.append(' pMemInfo = pMemInfo->pNextMI;')
- header_txt.append(' }')
- header_txt.append(' else {')
- header_txt.append(' pFound = pMemInfo;')
- header_txt.append(' break;')
- header_txt.append(' }')
- header_txt.append(' }')
- header_txt.append(' return pFound;')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('// Add memory reference to queue\'s mem ref list')
- header_txt.append('static void addMemRef(VkQueue queue, VkGpuMemory mem)')
- header_txt.append('{')
- header_txt.append(' // if ref not already in queue\'s list, add to front.')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = getQueueInfo(queue);')
- header_txt.append(' OT_MEM_INFO *pMemInfo = findMemRefInQueueList(queue, mem);')
- header_txt.append(' if (pMemInfo == NULL) {')
- header_txt.append(' // Not in list, add to front')
- header_txt.append(' pMemInfo = malloc(sizeof(OT_MEM_INFO));')
- header_txt.append(' memset(pMemInfo, 0, sizeof(OT_MEM_INFO));')
- header_txt.append('')
- header_txt.append(' if (pMemInfo != NULL) {')
- header_txt.append(' pMemInfo->mem = mem;')
- header_txt.append(' pMemInfo->pNextMI = pQueueInfo->pMemRefList;')
- header_txt.append(' pMemInfo->pPrevMI = NULL;')
- header_txt.append(' if (pQueueInfo->pMemRefList != NULL) {')
- header_txt.append(' pQueueInfo->pMemRefList->pPrevMI = pMemInfo;')
- header_txt.append(' }')
- header_txt.append(' pQueueInfo->pMemRefList = pMemInfo;')
- header_txt.append(' pQueueInfo->refCount++;')
- header_txt.append(' }')
- header_txt.append(' else {')
- header_txt.append(' char str[1024];')
- header_txt.append(' sprintf(str, "ERROR: VK_ERROR_OUT_OF_MEMORY -- could not allocate memory for memory reference Information");')
- header_txt.append(' layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, OBJTRACK_INTERNAL_ERROR, "OBJTRACK", str);')
- header_txt.append(' }')
- header_txt.append(' }')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('static void deleteMemRef(VkQueue queue, VkGpuMemory mem)')
- header_txt.append('{')
- header_txt.append(' // Search queue\'s list for mem, remove from list')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = getQueueInfo(queue);')
- header_txt.append(' OT_MEM_INFO *pMemInfo = findMemRefInQueueList(queue, mem);')
- header_txt.append('')
- header_txt.append(' if (pMemInfo != NULL) {')
- header_txt.append(' // Remove pMemInfo from doubly-linked list')
- header_txt.append(' if (pQueueInfo->pMemRefList == pMemInfo) {')
- header_txt.append(' // update head of list, which is being removed')
- header_txt.append(' pQueueInfo->pMemRefList = pMemInfo->pNextMI;')
- header_txt.append(' }')
- header_txt.append(' if (pMemInfo->pNextMI != NULL) {')
- header_txt.append(' pMemInfo->pNextMI->pPrevMI = pMemInfo->pPrevMI;')
- header_txt.append(' }')
- header_txt.append(' if (pMemInfo->pPrevMI != NULL) {')
- header_txt.append(' pMemInfo->pPrevMI->pNextMI = pMemInfo->pNextMI;')
- header_txt.append(' }')
- header_txt.append(' free(pMemInfo);')
- header_txt.append(' pQueueInfo->refCount--;')
- header_txt.append(' }')
- header_txt.append(' else {')
- header_txt.append(' char str[1024];')
- header_txt.append(' sprintf(str, "vkQueueRemoveReference called to remove a memory reference %p from queue %p that was not added", mem, queue);')
- header_txt.append(' layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, OBJTRACK_MISSING_OBJECT, "OBJTRACK", str);')
- header_txt.append(' }')
- header_txt.append('}')
- header_txt.append('')
header_txt.append('// Destroy memRef lists and free all memory')
header_txt.append('static void destroyQueueMemRefLists()')
header_txt.append('{')
header_txt.append(' validate_status((void*)pObj, VkObjectTypeCmdBuffer, OBJSTATUS_DEPTH_STENCIL_BOUND, OBJSTATUS_DEPTH_STENCIL_BOUND, VK_DBG_MSG_UNKNOWN, OBJTRACK_DEPTH_STENCIL_NOT_BOUND, "Depth-stencil object not bound to this command buffer");')
header_txt.append('}')
header_txt.append('')
- header_txt.append('static void validate_memory_mapping_status(VkQueue queue)')
- header_txt.append('{')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = getQueueInfo(queue);')
- header_txt.append(' OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList;')
- header_txt.append('')
- header_txt.append(' while (pMemInfo != NULL) {')
- header_txt.append(' // If mem reference is in a presentable image memory list, skip the check of the GPU_MEMORY list')
- header_txt.append(' if (!validate_status((void *)pMemInfo->mem, VkObjectTypePresentableImageMemory, OBJSTATUS_NONE,')
- header_txt.append(' OBJSTATUS_NONE, VK_DBG_MSG_UNKNOWN, OBJTRACK_NONE, NULL) == VK_TRUE) {')
- header_txt.append(' validate_status((void *)pMemInfo->mem, VkObjectTypeGpuMemory, OBJSTATUS_GPU_MEM_MAPPED, OBJSTATUS_NONE,')
- header_txt.append(' VK_DBG_MSG_ERROR, OBJTRACK_GPU_MEM_MAPPED, "A Mapped Memory Object was referenced in a command buffer");')
- header_txt.append(' }')
- header_txt.append(' pMemInfo = pMemInfo->pNextMI;')
- header_txt.append(' }')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('static void validate_mem_ref_count(VkQueue queue) {')
- header_txt.append(' if (maxMemReferences == 0) {')
- header_txt.append(' char str[1024];')
- header_txt.append(' sprintf(str, "vkQueueSubmit called before calling vkGetGpuInfo");')
- header_txt.append(' layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, NULL, 0, OBJTRACK_GETGPUINFO_NOT_CALLED, "OBJTRACK", str);')
- header_txt.append(' } else {')
- header_txt.append(' OT_QUEUE_INFO *pQueueInfo = getQueueInfo(queue);')
- header_txt.append(' if (pQueueInfo->refCount > maxMemReferences) {')
- header_txt.append(' char str[1024];')
- header_txt.append(' sprintf(str, "vkQueueSubmit Memory reference count (%d) exceeds allowable GPU limit (%d)", pQueueInfo->refCount, maxMemReferences);')
- header_txt.append(' layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, OBJTRACK_MEMREFCOUNT_MAX_EXCEEDED, "OBJTRACK", str);')
- header_txt.append(' }')
- header_txt.append(' }')
- header_txt.append('}')
- header_txt.append('')
header_txt.append('static void setGpuQueueInfoState(void *pData) {')
header_txt.append(' maxMemReferences = ((VkPhysicalGpuQueueProperties *)pData)->maxMemReferences;')
header_txt.append('}')