From: Mark Lobodzinski Date: Tue, 31 Mar 2015 21:05:35 +0000 (-0500) Subject: layers: Added GetDeviceQueue API, fixed up variable names X-Git-Tag: submit/tizen/20181227.054638~5906^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5f31a61616fe1e812fd46e96879b35738f48a14;p=platform%2Fupstream%2FVulkan-Tools.git layers: Added GetDeviceQueue API, fixed up variable names Updated LinkedList-related variable names --- diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index eb682c58..1be90a85 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -50,10 +50,10 @@ static loader_platform_thread_mutex globalLock; #define MAX_BINDING 0xFFFFFFFF -map cbMap; -map memObjMap; -map objectMap; -map fenceMap; // Map fenceId to fence node +map cbMap; +map memObjMap; +map objectMap; +map fenceMap; // Map fenceId to fence node // TODO : Add support for per-queue and per-device fence completion static uint64_t g_currentFenceId = 1; @@ -61,57 +61,57 @@ static uint64_t g_lastRetiredId = 0; static XGL_DEVICE globalDevice = NULL; // Add new CB node for this cb to map container -static void insertGlobalCB(const XGL_CMD_BUFFER cb) +static void insertCBInfo(const XGL_CMD_BUFFER cb) { - GLOBAL_CB_NODE* pTrav = new GLOBAL_CB_NODE; - memset(pTrav, 0, (sizeof(GLOBAL_CB_NODE) - sizeof(list))); - pTrav->cmdBuffer = cb; - cbMap[cb] = pTrav; + MT_CB_INFO* pInfo = new MT_CB_INFO; + memset(pInfo, 0, (sizeof(MT_CB_INFO) - sizeof(list))); + pInfo->cmdBuffer = cb; + cbMap[cb] = pInfo; } // Return ptr to node in CB map, or NULL if not found -static GLOBAL_CB_NODE* getGlobalCBNode(const XGL_CMD_BUFFER cb) +static MT_CB_INFO* getCBInfo(const XGL_CMD_BUFFER cb) { - GLOBAL_CB_NODE* pCBNode = NULL; + MT_CB_INFO* pCBInfo = NULL; if (cbMap.find(cb) != cbMap.end()) { - pCBNode = cbMap[cb]; + pCBInfo = cbMap[cb]; } - return pCBNode; + return pCBInfo; } // Add a fence, creating one if necessary to our list of fences/fenceIds -static uint64_t addFenceNode(XGL_FENCE fence) +static uint64_t addFenceInfo(XGL_FENCE fence) { // Create fence node - GLOBAL_FENCE_NODE* pFenceNode = new GLOBAL_FENCE_NODE; - memset(pFenceNode, 0, sizeof(GLOBAL_FENCE_NODE)); + MT_FENCE_INFO* pFenceInfo = new MT_FENCE_INFO; + memset(pFenceInfo, 0, sizeof(MT_FENCE_INFO)); // If no fence, create an internal fence to track the submissions if (fence == NULL) { XGL_FENCE_CREATE_INFO fci; fci.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO; fci.pNext = NULL; fci.flags = 0; - nextTable.CreateFence(globalDevice, &fci, &pFenceNode->fence); - pFenceNode->localFence = XGL_TRUE; + nextTable.CreateFence(globalDevice, &fci, &pFenceInfo->fence); + pFenceInfo->localFence = XGL_TRUE; } else { - pFenceNode->localFence = XGL_FALSE; - pFenceNode->fence = fence; + pFenceInfo->localFence = XGL_FALSE; + pFenceInfo->fence = fence; } uint64_t fenceId = g_currentFenceId++; - fenceMap[fenceId] = pFenceNode; + fenceMap[fenceId] = pFenceInfo; return fenceId; } // Remove a node from our list of fences/fenceIds -static void deleteFenceNode(uint64_t fenceId) +static void deleteFenceInfo(uint64_t fenceId) { if (fenceId != 0) { if (fenceMap.find(fenceId) != fenceMap.end()) { - GLOBAL_FENCE_NODE* pDelNode = fenceMap[fenceId]; - if (pDelNode->localFence == XGL_TRUE) { - nextTable.DestroyObject(pDelNode->fence); + MT_FENCE_INFO* pDelInfo = fenceMap[fenceId]; + if (pDelInfo->localFence == XGL_TRUE) { + nextTable.DestroyObject(pDelInfo->fence); } - delete pDelNode; + delete pDelInfo; fenceMap.erase(fenceId); } } @@ -120,14 +120,14 @@ static void deleteFenceNode(uint64_t fenceId) // Search through list for this fence, deleting all nodes before it (with lower IDs) and updating lastRetiredId static void updateFenceTracking(XGL_FENCE fence) { - GLOBAL_FENCE_NODE *pCurFenceNode = NULL; - uint64_t fenceId = 0; + MT_FENCE_INFO *pCurFenceInfo = NULL; + uint64_t fenceId = 0; - for (map::iterator ii=fenceMap.begin(); ii!=fenceMap.end(); ++ii) { + for (map::iterator ii=fenceMap.begin(); ii!=fenceMap.end(); ++ii) { if (fence == ((*ii).second)->fence) { g_lastRetiredId = (*ii).first; } else { - deleteFenceNode((*ii).first); + deleteFenceInfo((*ii).first); } } } @@ -161,18 +161,18 @@ static XGL_FENCE getFenceFromId(uint64_t fenceId) static void retireAllFences(void) { // In this case, we go throught the whole list, retiring each node and update the global retired ID until the list is empty - GLOBAL_FENCE_NODE* pDelNode = NULL; - for (map::iterator ii=fenceMap.begin(); ii!=fenceMap.end(); ++ii) { + MT_FENCE_INFO* pDelInfo = NULL; + for (map::iterator ii=fenceMap.begin(); ii!=fenceMap.end(); ++ii) { g_lastRetiredId = (*ii).first; - deleteFenceNode((*ii).first); + deleteFenceInfo((*ii).first); } } static bool32_t validateCBMemRef(const XGL_CMD_BUFFER cb, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs) { bool32_t result = XGL_TRUE; - GLOBAL_CB_NODE* pTrav = getGlobalCBNode(cb); - if (!pTrav) { + MT_CB_INFO* pInfo = getCBInfo(cb); + if (!pInfo) { char str[1024]; sprintf(str, "Unable to find node for CB %p in order to check memory references", (void*)cb); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_CB, "MEM", str); @@ -183,7 +183,7 @@ static bool32_t validateCBMemRef(const XGL_CMD_BUFFER cb, uint32_t memRefCount, uint8_t found = 0; uint64_t foundCount = 0; - for (list::iterator it = pTrav->pMemObjList.begin(); it != pTrav->pMemObjList.end(); ++it) { + for (list::iterator it = pInfo->pMemObjList.begin(); it != pInfo->pMemObjList.end(); ++it) { for (i = 0; i < memRefCount; i++) { if ((*it) == pMemRefs[i].mem) { char str[1024]; @@ -219,47 +219,47 @@ static bool32_t validateCBMemRef(const XGL_CMD_BUFFER cb, uint32_t memRefCount, } // Return ptr to node in map container containing mem, or NULL if not found // Calls to this function should be wrapped in mutex -static GLOBAL_MEM_OBJ_NODE* getGlobalMemNode(const XGL_GPU_MEMORY mem) +static MT_MEM_OBJ_INFO* getMemObjInfo(const XGL_GPU_MEMORY mem) { - GLOBAL_MEM_OBJ_NODE* pMemNode = NULL; + MT_MEM_OBJ_INFO* pMemObjInfo = NULL; if (memObjMap.find(mem) != memObjMap.end()) { - pMemNode = memObjMap[mem]; + pMemObjInfo = memObjMap[mem]; } - return pMemNode; + return pMemObjInfo; } -static void insertGlobalMemObj(const XGL_GPU_MEMORY mem, const XGL_MEMORY_ALLOC_INFO* pAllocInfo) +static void insertMemObjInfo(const XGL_GPU_MEMORY mem, const XGL_MEMORY_ALLOC_INFO* pAllocInfo) { - GLOBAL_MEM_OBJ_NODE* pTrav = new GLOBAL_MEM_OBJ_NODE; - pTrav->refCount = 0; - memset(&pTrav->allocInfo, 0, sizeof(XGL_MEMORY_ALLOC_INFO)); + MT_MEM_OBJ_INFO* pInfo = new MT_MEM_OBJ_INFO; + pInfo->refCount = 0; + memset(&pInfo->allocInfo, 0, sizeof(XGL_MEMORY_ALLOC_INFO)); if (pAllocInfo) { // MEM alloc created by xglWsiX11CreatePresentableImage() doesn't have alloc info struct - memcpy(&pTrav->allocInfo, pAllocInfo, sizeof(XGL_MEMORY_ALLOC_INFO)); + memcpy(&pInfo->allocInfo, pAllocInfo, sizeof(XGL_MEMORY_ALLOC_INFO)); // TODO: Update for real hardware, actually process allocation info structures - pTrav->allocInfo.pNext = NULL; + pInfo->allocInfo.pNext = NULL; } - pTrav->mem = mem; - memObjMap[mem] = pTrav; + pInfo->mem = mem; + memObjMap[mem] = pInfo; } -// Find Global CB Node and add mem binding to list container -// Find Global Mem Obj Node and add CB binding to list container +// 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 XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY mem) { bool32_t result = XGL_TRUE; // First update CB binding in MemObj mini CB list - GLOBAL_MEM_OBJ_NODE* pMemTrav = getGlobalMemNode(mem); - if (!pMemTrav) { + 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 Node 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(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = XGL_FALSE; } else { // Search for cmd buffer object in memory object's binding list bool32_t found = XGL_FALSE; - for (list::iterator it = pMemTrav->pCmdBufferBindings.begin(); it != pMemTrav->pCmdBufferBindings.end(); ++it) { + for (list::iterator it = pMemInfo->pCmdBufferBindings.begin(); it != pMemInfo->pCmdBufferBindings.end(); ++it) { if ((*it) == cb) { found = XGL_TRUE; break; @@ -267,21 +267,21 @@ static bool32_t updateCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY me } // If not present, add to list if (found == XGL_FALSE) { - pMemTrav->pCmdBufferBindings.push_front(cb); - pMemTrav->refCount++; + pMemInfo->pCmdBufferBindings.push_front(cb); + pMemInfo->refCount++; } - // Now update Global CB's Mem binding list - GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cb); - if (!pCBTrav) { + // Now update CBInfo's Mem binding list + MT_CB_INFO* pCBInfo = getCBInfo(cb); + if (!pCBInfo) { char str[1024]; - sprintf(str, "Trying to bind mem obj %p to CB %p but no Node for that CB. Was it CB incorrectly destroyed?", mem, cb); + sprintf(str, "Trying to bind mem obj %p to CB %p but no info for that CB. Was it CB incorrectly destroyed?", mem, cb); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = XGL_FALSE; } else { // Search for memory object in cmd buffer's binding list bool32_t found = XGL_FALSE; - for (list::iterator it = pCBTrav->pMemObjList.begin(); it != pCBTrav->pMemObjList.end(); ++it) { + for (list::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { if ((*it) == mem) { found = XGL_TRUE; break; @@ -289,7 +289,7 @@ static bool32_t updateCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY me } // If not present, add to list if (found == XGL_FALSE) { - pCBTrav->pMemObjList.push_front(mem); + pCBInfo->pMemObjList.push_front(mem); } } } @@ -300,13 +300,13 @@ static bool32_t updateCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY me // Calls to this function should be wrapped in mutex static void clearCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY mem) { - GLOBAL_MEM_OBJ_NODE* pTrav = getGlobalMemNode(mem); + MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); // TODO : Having this check is not ideal, really if mem node was deleted, // its CB bindings should be cleared and then freeCBBindings wouldn't call // us here with stale mem objs - if (pTrav) { - pTrav->pCmdBufferBindings.remove(cb); - pTrav->refCount--; + if (pInfo) { + pInfo->pCmdBufferBindings.remove(cb); + pInfo->refCount--; } } @@ -314,37 +314,37 @@ static void clearCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY mem) static bool32_t freeCBBindings(const XGL_CMD_BUFFER cb) { bool32_t result = XGL_TRUE; - GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cb); - if (!pCBTrav) { + MT_CB_INFO* pCBInfo = getCBInfo(cb); + if (!pCBInfo) { char str[1024]; sprintf(str, "Unable to find global CB node %p for deletion", cb); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_CB, "MEM", str); result = XGL_FALSE; } else { - if (!fenceRetired(pCBTrav->fenceId)) { - deleteFenceNode(pCBTrav->fenceId); + if (!fenceRetired(pCBInfo->fenceId)) { + deleteFenceInfo(pCBInfo->fenceId); } - for (list::iterator it=pCBTrav->pMemObjList.begin(); it!=pCBTrav->pMemObjList.end(); ++it) { + for (list::iterator it=pCBInfo->pMemObjList.begin(); it!=pCBInfo->pMemObjList.end(); ++it) { clearCBBinding(cb, (*it)); } - pCBTrav->pMemObjList.clear(); + pCBInfo->pMemObjList.clear(); } return result; } -// Delete Global CB Node from list along with all of it's mini mem obj node -// and also clear Global mem references to 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 deleteGlobalCBNode(const XGL_CMD_BUFFER cb) +static bool32_t deleteCBInfo(const XGL_CMD_BUFFER cb) { bool32_t result = XGL_TRUE; result = freeCBBindings(cb); - // Delete the Global CB node + // Delete the CBInfo node if (result == XGL_TRUE) { if (cbMap.find(cb) != cbMap.end()) { - GLOBAL_CB_NODE* pDelNode = cbMap[cb]; - delete pDelNode; + MT_CB_INFO* pDelInfo = cbMap[cb]; + delete pDelInfo; cbMap.erase(cb); } } @@ -352,10 +352,10 @@ static bool32_t deleteGlobalCBNode(const XGL_CMD_BUFFER cb) } // Delete the entire CB list -static bool32_t deleteGlobalCBList() +static bool32_t deleteCBInfoList() { bool32_t result = XGL_TRUE; - for (map::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { + for (map::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { freeCBBindings((*ii).first); delete (*ii).second; } @@ -363,34 +363,34 @@ static bool32_t deleteGlobalCBList() } // For given MemObj node, report Obj & CB bindings -static void reportMemReferences(const GLOBAL_MEM_OBJ_NODE* pMemObjTrav) +static void reportMemReferences(const MT_MEM_OBJ_INFO* pMemObjInfo) { uint32_t refCount = 0; // Count found references - for (list::const_iterator it = pMemObjTrav->pCmdBufferBindings.begin(); it != pMemObjTrav->pCmdBufferBindings.end(); ++it) { + for (list::const_iterator it = pMemObjInfo->pCmdBufferBindings.begin(); it != pMemObjInfo->pCmdBufferBindings.end(); ++it) { refCount++; char str[1024]; - sprintf(str, "Command Buffer %p has reference to mem obj %p", (*it), pMemObjTrav->mem); + sprintf(str, "Command Buffer %p has reference to mem obj %p", (*it), pMemObjInfo->mem); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, (*it), 0, MEMTRACK_NONE, "MEM", str); } - for (list::const_iterator it = pMemObjTrav->pObjBindings.begin(); it != pMemObjTrav->pObjBindings.end(); ++it) { + for (list::const_iterator it = pMemObjInfo->pObjBindings.begin(); it != pMemObjInfo->pObjBindings.end(); ++it) { char str[1024]; - sprintf(str, "XGL Object %p has reference to mem obj %p", (*it), pMemObjTrav->mem); + sprintf(str, "XGL Object %p has reference to mem obj %p", (*it), pMemObjInfo->mem); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, (*it), 0, MEMTRACK_NONE, "MEM", str); } - if (refCount != pMemObjTrav->refCount) { + if (refCount != pMemObjInfo->refCount) { char str[1024]; - sprintf(str, "Refcount of %u for Mem Obj %p does't match reported refs of %u", pMemObjTrav->refCount, pMemObjTrav->mem, refCount); - layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pMemObjTrav->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); + sprintf(str, "Refcount of %u for Mem Obj %p does't match reported refs of %u", pMemObjInfo->refCount, pMemObjInfo->mem, refCount); + layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pMemObjInfo->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); } } -static void deleteGlobalMemNode(XGL_GPU_MEMORY mem) +static void deleteMemObjInfo(XGL_GPU_MEMORY mem) { - GLOBAL_MEM_OBJ_NODE* pDelNode = memObjMap[mem]; + MT_MEM_OBJ_INFO* pDelInfo = memObjMap[mem]; if (memObjMap.find(mem) != memObjMap.end()) { - GLOBAL_MEM_OBJ_NODE* pDelNode = memObjMap[mem]; - delete pDelNode; + MT_MEM_OBJ_INFO* pDelInfo = memObjMap[mem]; + delete pDelInfo; memObjMap.erase(mem); } } @@ -399,18 +399,18 @@ static void deleteGlobalMemNode(XGL_GPU_MEMORY mem) static bool32_t checkCBCompleted(const XGL_CMD_BUFFER cb) { bool32_t result = XGL_TRUE; - GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cb); - if (!pCBTrav) { + MT_CB_INFO* pCBInfo = getCBInfo(cb); + if (!pCBInfo) { char str[1024]; sprintf(str, "Unable to find global CB node %p to check for completion", cb); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_INVALID_CB, "MEM", str); result = XGL_FALSE; } else { - if (!fenceRetired(pCBTrav->fenceId)) { + if (!fenceRetired(pCBInfo->fenceId)) { // Explicitly call the internal xglGetFenceStatus routine - if (XGL_SUCCESS != xglGetFenceStatus(getFenceFromId(pCBTrav->fenceId))) { + if (XGL_SUCCESS != xglGetFenceStatus(getFenceFromId(pCBInfo->fenceId))) { char str[1024]; - sprintf(str, "FenceId %" PRIx64", fence %p for CB %p has not completed", pCBTrav->fenceId, getFenceFromId(pCBTrav->fenceId), cb); + sprintf(str, "FenceId %" PRIx64", fence %p for CB %p has not completed", pCBInfo->fenceId, getFenceFromId(pCBInfo->fenceId), cb); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cb, 0, MEMTRACK_NONE, "MEM", str); result = XGL_FALSE; } @@ -419,18 +419,18 @@ static bool32_t checkCBCompleted(const XGL_CMD_BUFFER cb) return result; } -static bool32_t freeMemNode(XGL_GPU_MEMORY mem) +static bool32_t freeMemObjInfo(XGL_GPU_MEMORY mem) { bool32_t result = XGL_TRUE; // Parse global list to find node w/ mem - GLOBAL_MEM_OBJ_NODE* pTrav = getGlobalMemNode(mem); - if (!pTrav) { + MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); + if (!pInfo) { char str[1024]; sprintf(str, "Couldn't find mem node object for %p\n Was %p never allocated or previously freed?", (void*)mem, (void*)mem); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); result = XGL_FALSE; } else { - if (pTrav->allocInfo.allocationSize == 0) { + if (pInfo->allocInfo.allocationSize == 0) { char str[1024]; sprintf(str, "Attempting to free memory associated with a Presentable Image, %p, this should not be explicitly freed\n", (void*)mem); layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); @@ -439,9 +439,9 @@ static bool32_t freeMemNode(XGL_GPU_MEMORY mem) // Clear any CB bindings for completed CBs // TODO : Is there a better place to do this? - list::iterator it = pTrav->pCmdBufferBindings.begin(); + list::iterator it = pInfo->pCmdBufferBindings.begin(); list::iterator temp; - while (it != pTrav->pCmdBufferBindings.end()) { + while (it != pInfo->pCmdBufferBindings.end()) { if (XGL_TRUE == checkCBCompleted(*it)) { temp = it; ++temp; @@ -453,76 +453,76 @@ static bool32_t freeMemNode(XGL_GPU_MEMORY mem) } // Now verify that no references to this mem obj remain - if (0 != pTrav->refCount) { + if (0 != pInfo->refCount) { // If references remain, report the error and can search CB list to find references char str[1024]; sprintf(str, "Freeing mem obj %p while it still has references", (void*)mem); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_FREED_MEM_REF, "MEM", str); - reportMemReferences(pTrav); + reportMemReferences(pInfo); result = XGL_FALSE; } // Delete global node - deleteGlobalMemNode(mem); + deleteMemObjInfo(mem); } } return result; } // Return object node for 'object' or return NULL if no node exists -static GLOBAL_OBJECT_NODE* getGlobalObjectNode(const XGL_OBJECT object) +static MT_OBJ_INFO* getObjectInfo(const XGL_OBJECT object) { - GLOBAL_OBJECT_NODE* pObjNode = NULL; + MT_OBJ_INFO* pObjInfo = NULL; if (objectMap.find(object) != objectMap.end()) { - pObjNode = objectMap[object]; + pObjInfo = objectMap[object]; } - return pObjNode; + return pObjInfo; } -static GLOBAL_OBJECT_NODE* insertGlobalObjectNode(XGL_OBJECT object, XGL_STRUCTURE_TYPE sType, const void *pCreateInfo, const int struct_size, const char *name_prefix) +static MT_OBJ_INFO* insertObjectInfo(XGL_OBJECT object, XGL_STRUCTURE_TYPE sType, const void *pCreateInfo, const int struct_size, const char *name_prefix) { - GLOBAL_OBJECT_NODE* pTrav = new GLOBAL_OBJECT_NODE; - memset(pTrav, 0, sizeof(GLOBAL_OBJECT_NODE)); - memcpy(&pTrav->create_info, pCreateInfo, struct_size); - sprintf(pTrav->object_name, "%s_%p", name_prefix, object); + MT_OBJ_INFO* pInfo = new MT_OBJ_INFO; + memset(pInfo, 0, sizeof(MT_OBJ_INFO)); + memcpy(&pInfo->create_info, pCreateInfo, struct_size); + sprintf(pInfo->object_name, "%s_%p", name_prefix, object); - pTrav->object = object; - pTrav->ref_count = 1; - pTrav->sType = sType; - objectMap[object] = pTrav; + pInfo->object = object; + pInfo->ref_count = 1; + pInfo->sType = sType; + objectMap[object] = pInfo; - return pTrav; + return pInfo; } // Remove object binding performs 3 tasks: -// 1. Remove object node from Global Mem Obj list container of obj bindings & free it -// 2. Decrement refCount for Global Mem Obj -// 3. Clear Global Mem Obj ptr from Global Object Node +// 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(XGL_OBJECT object) { bool32_t result = XGL_FALSE; - GLOBAL_OBJECT_NODE* pGlobalObjTrav = getGlobalObjectNode(object); - if (!pGlobalObjTrav) { + 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); layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INVALID_OBJECT, "MEM", str); } else { - if (!pGlobalObjTrav->pMemNode) { + if (!pObjInfo->pMemObjInfo) { char str[1024]; sprintf(str, "Attempting to clear mem binding on obj %p but it has no binding.", (void*)object); layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, object, 0, MEMTRACK_MEM_OBJ_CLEAR_EMPTY_BINDINGS, "MEM", str); } else { - for (list::iterator it = pGlobalObjTrav->pMemNode->pObjBindings.begin(); it != pGlobalObjTrav->pMemNode->pObjBindings.end(); ++it) { - pGlobalObjTrav->pMemNode->refCount--; - pGlobalObjTrav->pMemNode = NULL; - it = pGlobalObjTrav->pMemNode->pObjBindings.erase(it); + for (list::iterator it = pObjInfo->pMemObjInfo->pObjBindings.begin(); it != pObjInfo->pMemObjInfo->pObjBindings.end(); ++it) { + pObjInfo->pMemObjInfo->refCount--; + pObjInfo->pMemObjInfo = NULL; + it = pObjInfo->pMemObjInfo->pObjBindings.erase(it); result = XGL_TRUE; break; } if (result == XGL_FALSE) { char str[1024]; sprintf(str, "While trying to clear mem binding for object %p, unable to find that object referenced by mem obj %p", - object, pGlobalObjTrav->pMemNode->mem); + object, pObjInfo->pMemObjInfo->mem); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); } } @@ -545,21 +545,21 @@ static bool32_t updateObjectBinding(XGL_OBJECT object, XGL_GPU_MEMORY mem) result = XGL_TRUE; } else { char str[1024]; - GLOBAL_OBJECT_NODE* pGlobalObjTrav = getGlobalObjectNode(object); - if (!pGlobalObjTrav) { + MT_OBJ_INFO* pObjInfo = getObjectInfo(object); + if (!pObjInfo) { sprintf(str, "Attempting to update Binding of Obj(%p) that's not in global list()", (void*)object); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, object, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); return XGL_FALSE; } // non-null case so should have real mem obj - GLOBAL_MEM_OBJ_NODE* pTrav = getGlobalMemNode(mem); - if (!pTrav) { + MT_MEM_OBJ_INFO* pInfo = getMemObjInfo(mem); + if (!pInfo) { sprintf(str, "While trying to bind mem for obj %p, couldn't find node for mem obj %p", (void*)object, (void*)mem); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_MEM_OBJ, "MEM", str); } else { // Search for object in memory object's binding list bool32_t found = XGL_FALSE; - for (list::iterator it = pTrav->pObjBindings.begin(); it != pTrav->pObjBindings.end(); ++it) { + for (list::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { if ((*it) == object) { found = XGL_TRUE; break; @@ -567,23 +567,23 @@ static bool32_t updateObjectBinding(XGL_OBJECT object, XGL_GPU_MEMORY mem) } // If not present, add to list if (found == XGL_FALSE) { - pTrav->pObjBindings.push_front(object); - pTrav->refCount++; + pInfo->pObjBindings.push_front(object); + pInfo->refCount++; } - if (pGlobalObjTrav->pMemNode) { + if (pObjInfo->pMemObjInfo) { clearObjectBinding(object); // Need to clear the previous object binding before setting new binding - sprintf(str, "Updating memory binding for object %p from mem obj %p to %p", object, pGlobalObjTrav->pMemNode->mem, mem); + sprintf(str, "Updating memory binding for object %p from mem obj %p to %p", object, pObjInfo->pMemObjInfo->mem, mem); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, object, 0, MEMTRACK_NONE, "MEM", str); } // For image objects, make sure default memory state is correctly set // TODO : What's the best/correct way to handle this? - if (XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pGlobalObjTrav->sType) { - if (pGlobalObjTrav->create_info.image_create_info.usage & (XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { + if (XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO == pObjInfo->sType) { + if (pObjInfo->create_info.image_create_info.usage & (XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT)) { // TODO:: More memory state transition stuff. } } - pGlobalObjTrav->pMemNode = pTrav; + pObjInfo->pMemObjInfo = pInfo; } } return XGL_TRUE; @@ -592,14 +592,14 @@ static bool32_t updateObjectBinding(XGL_OBJECT object, XGL_GPU_MEMORY mem) // Print details of global Obj tracking list static void printObjList() { - GLOBAL_OBJECT_NODE* pTrav = NULL; + MT_OBJ_INFO* pInfo = NULL; char str[1024]; - sprintf(str, "Details of Global Object list of size %lu elements", objectMap.size()); + sprintf(str, "Details of Object list of size %lu elements", objectMap.size()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (map::iterator ii=objectMap.begin(); ii!=objectMap.end(); ++ii) { - pTrav = (*ii).second; - sprintf(str, " GlobObjNode %p has object %p, pMemNode %p", pTrav, pTrav->object, pTrav->pMemNode); - layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pTrav->object, 0, MEMTRACK_NONE, "MEM", str); + for (map::iterator ii=objectMap.begin(); ii!=objectMap.end(); ++ii) { + pInfo = (*ii).second; + sprintf(str, " ObjInfo %p has object %p, pMemObjInfo %p", pInfo, pInfo->object, pInfo->pMemObjInfo); + layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pInfo->object, 0, MEMTRACK_NONE, "MEM", str); } } @@ -607,10 +607,10 @@ static void printObjList() static XGL_GPU_MEMORY getMemBindingFromObject(const XGL_OBJECT object) { XGL_GPU_MEMORY mem = NULL; - GLOBAL_OBJECT_NODE* pObjNode = getGlobalObjectNode(object); - if (pObjNode) { - if (pObjNode->pMemNode) { - mem = pObjNode->pMemNode->mem; + MT_OBJ_INFO* pObjInfo = getObjectInfo(object); + if (pObjInfo) { + if (pObjInfo->pMemObjInfo) { + mem = pObjInfo->pMemObjInfo->mem; } else { char str[1024]; @@ -628,26 +628,26 @@ static XGL_GPU_MEMORY getMemBindingFromObject(const XGL_OBJECT object) return mem; } -// Print details of global Mem Obj list +// Print details of MemObjInfo list static void printMemList() { - GLOBAL_MEM_OBJ_NODE* pTrav = NULL; + MT_MEM_OBJ_INFO* pInfo = NULL; // Just printing each msg individually for now, may want to package these into single large print char str[1024]; - sprintf(str, "MEM INFO : Details of Global Memory Object list of size %lu elements", memObjMap.size()); + sprintf(str, "MEM INFO : Details of Memory Object list of size %lu elements", memObjMap.size()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (map::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { - pTrav = (*ii).second; + for (map::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { + pInfo = (*ii).second; - sprintf(str, " ===MemObj Node at %p===", (void*)pTrav); + sprintf(str, " ===MemObjInfo at %p===", (void*)pInfo); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - sprintf(str, " Mem object: %p", (void*)pTrav->mem); + sprintf(str, " Mem object: %p", (void*)pInfo->mem); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - sprintf(str, " Ref Count: %u", pTrav->refCount); + sprintf(str, " Ref Count: %u", pInfo->refCount); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - if (0 != pTrav->allocInfo.allocationSize) { - string pAllocInfoMsg = xgl_print_xgl_memory_alloc_info(&pTrav->allocInfo, "{MEM}INFO : "); + if (0 != pInfo->allocInfo.allocationSize) { + string pAllocInfoMsg = xgl_print_xgl_memory_alloc_info(&pInfo->allocInfo, "{MEM}INFO : "); sprintf(str, " Mem Alloc info:\n%s", pAllocInfoMsg.c_str()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); } else { @@ -655,38 +655,38 @@ static void printMemList() layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); } - sprintf(str, " XGL OBJECT Binding list of size %lu elements:", pTrav->pObjBindings.size()); + sprintf(str, " XGL OBJECT Binding list of size %lu elements:", pInfo->pObjBindings.size()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (list::iterator it = pTrav->pObjBindings.begin(); it != pTrav->pObjBindings.end(); ++it) { + for (list::iterator it = pInfo->pObjBindings.begin(); it != pInfo->pObjBindings.end(); ++it) { sprintf(str, " XGL OBJECT %p", (*it)); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); } - sprintf(str, " XGL Command Buffer (CB) binding list of size %lu elements", pTrav->pCmdBufferBindings.size()); + sprintf(str, " XGL Command Buffer (CB) binding list of size %lu elements", pInfo->pCmdBufferBindings.size()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (list::iterator it = pTrav->pCmdBufferBindings.begin(); it != pTrav->pCmdBufferBindings.end(); ++it) { + for (list::iterator it = pInfo->pCmdBufferBindings.begin(); it != pInfo->pCmdBufferBindings.end(); ++it) { sprintf(str, " XGL CB %p", (*it)); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); } } } -static void printGlobalCB() +static void printCBList() { char str[1024] = {0}; - GLOBAL_CB_NODE* pNode = NULL; - sprintf(str, "Details of Global CB list of size %lu elements", cbMap.size()); + MT_CB_INFO* pCBInfo = NULL; + sprintf(str, "Details of CB list of size %lu elements", cbMap.size()); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (map::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { - pNode = (*ii).second; + for (map::iterator ii=cbMap.begin(); ii!=cbMap.end(); ++ii) { + pCBInfo = (*ii).second; - sprintf(str, " Global CB Node (%p) has CB %p, fenceId %" PRIx64", and fence %p", - (void*)pNode, (void*)pNode->cmdBuffer, pNode->fenceId, - (void*)getFenceFromId(pNode->fenceId)); + sprintf(str, " CB Info (%p) has CB %p, fenceId %" PRIx64", and fence %p", + (void*)pCBInfo, (void*)pCBInfo->cmdBuffer, pCBInfo->fenceId, + (void*)getFenceFromId(pCBInfo->fenceId)); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); - for (list::iterator it = pNode->pMemObjList.begin(); it != pNode->pMemObjList.end(); ++it) { + for (list::iterator it = pCBInfo->pMemObjList.begin(); it != pCBInfo->pMemObjList.end(); ++it) { sprintf(str, " Mem obj %p", (*it)); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, MEMTRACK_NONE, "MEM", str); } @@ -752,21 +752,21 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) loader_platform_thread_lock_mutex(&globalLock); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, device, 0, MEMTRACK_NONE, "MEM", str); printMemList(); - printGlobalCB(); + printCBList(); printObjList(); - if (XGL_FALSE == deleteGlobalCBList()) { + if (XGL_FALSE == deleteCBInfoList()) { sprintf(str, "Issue deleting global CB list in xglDestroyDevice()"); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, device, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str); } // Report any memory leaks - GLOBAL_MEM_OBJ_NODE* pTrav = NULL; - for (map::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { - pTrav = (*ii).second; + MT_MEM_OBJ_INFO* pInfo = NULL; + for (map::iterator ii=memObjMap.begin(); ii!=memObjMap.end(); ++ii) { + pInfo = (*ii).second; - if (pTrav->allocInfo.allocationSize != 0) { + if (pInfo->allocInfo.allocationSize != 0) { sprintf(str, "Mem Object %p has not been freed. You should clean up this memory by calling xglFreeMemory(%p) prior to xglDestroyDevice().", - pTrav->mem, pTrav->mem); - layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, pTrav->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", str); + pInfo->mem, pInfo->mem); + layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, pInfo->mem, 0, MEMTRACK_MEMORY_LEAK, "MEM", str); } } loader_platform_thread_unlock_mutex(&globalLock); @@ -796,21 +796,27 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size } } +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue) +{ + XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue); + return result; +} + XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, uint32_t cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence) { loader_platform_thread_lock_mutex(&globalLock); // TODO : Need to track fence and clear mem references when fence clears - GLOBAL_CB_NODE* pCBNode = NULL; - uint64_t fenceId = addFenceNode(fence); - char str[1024]; + MT_CB_INFO* pCBInfo = NULL; + uint64_t fenceId = addFenceInfo(fence); + char str[1024]; sprintf(str, "In xglQueueSubmit(), checking %u cmdBuffers with %u memRefs", cmdBufferCount, memRefCount); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_NONE, "MEM", str); printMemList(); - printGlobalCB(); + printCBList(); for (uint32_t i = 0; i < cmdBufferCount; i++) { - pCBNode = getGlobalCBNode(pCmdBuffers[i]); - pCBNode->fenceId = fenceId; + pCBInfo = getCBInfo(pCmdBuffers[i]); + pCBInfo->fenceId = fenceId; sprintf(str, "Verifying mem refs for CB %p", pCmdBuffers[i]); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_NONE, "MEM", str); if (XGL_FALSE == validateCBMemRef(pCmdBuffers[i], memRefCount, pMemRefs)) { @@ -818,7 +824,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, uint32_t cmdB layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pCmdBuffers[i], 0, MEMTRACK_CB_MISSING_MEM_REF, "MEM", str); } } - printGlobalCB(); + printCBList(); loader_platform_thread_unlock_mutex(&globalLock); XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, getFenceFromId(fenceId)); return result; @@ -836,7 +842,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_M XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem); // TODO : Track allocations and overall size here loader_platform_thread_lock_mutex(&globalLock); - insertGlobalMemObj(*pMem, pAllocInfo); + insertMemObjInfo(*pMem, pAllocInfo); printMemList(); loader_platform_thread_unlock_mutex(&globalLock); return result; @@ -849,14 +855,14 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem) * all API objects referencing it and that it is not referenced by any queued command buffers */ loader_platform_thread_lock_mutex(&globalLock); - if (XGL_FALSE == freeMemNode(mem)) { + if (XGL_FALSE == freeMemObjInfo(mem)) { char str[1024]; sprintf(str, "Issue while freeing mem obj %p", (void*)mem); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_FREE_MEM_ERROR, "MEM", str); } printMemList(); printObjList(); - printGlobalCB(); + printCBList(); loader_platform_thread_unlock_mutex(&globalLock); XGL_RESULT result = nextTable.FreeMemory(mem); return result; @@ -874,7 +880,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglMapMemory(XGL_GPU_MEMORY mem, XGL_FLAGS fl { // TODO : Track when memory is mapped loader_platform_thread_lock_mutex(&globalLock); - GLOBAL_MEM_OBJ_NODE *pMemObj = getGlobalMemNode(mem); + MT_MEM_OBJ_INFO *pMemObj = getMemObjInfo(mem); if ((pMemObj->allocInfo.memProps & XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT) == 0) { char str[1024]; sprintf(str, "Mapping Memory (%p) without XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT set", (void*)mem); @@ -927,27 +933,27 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) loader_platform_thread_lock_mutex(&globalLock); // First check if this is a CmdBuffer - if (NULL != getGlobalCBNode((XGL_CMD_BUFFER)object)) { - deleteGlobalCBNode((XGL_CMD_BUFFER)object); + if (NULL != getCBInfo((XGL_CMD_BUFFER)object)) { + deleteCBInfo((XGL_CMD_BUFFER)object); } if (objectMap.find(object) != objectMap.end()) { - GLOBAL_OBJECT_NODE* pDelNode = objectMap[object]; - if (pDelNode->pMemNode) { + MT_OBJ_INFO* pDelInfo = objectMap[object]; + if (pDelInfo->pMemObjInfo) { // Wsi allocated Memory is tied to image object so clear the binding and free that memory automatically - if (0 == pDelNode->pMemNode->allocInfo.allocationSize) { // Wsi allocated memory has NULL allocInfo w/ 0 size - XGL_GPU_MEMORY memToFree = pDelNode->pMemNode->mem; + if (0 == pDelInfo->pMemObjInfo->allocInfo.allocationSize) { // Wsi allocated memory has NULL allocInfo w/ 0 size + XGL_GPU_MEMORY memToFree = pDelInfo->pMemObjInfo->mem; clearObjectBinding(object); - freeMemNode(memToFree); + freeMemObjInfo(memToFree); } else { char str[1024]; - sprintf(str, "Destroying obj %p that is still bound to memory object %p\nYou should first clear binding by calling xglBindObjectMemory(%p, 0, XGL_NULL_HANDLE, 0)", object, (void*)pDelNode->pMemNode->mem, object); + sprintf(str, "Destroying obj %p that is still bound to memory object %p\nYou should first clear binding by calling xglBindObjectMemory(%p, 0, XGL_NULL_HANDLE, 0)", object, (void*)pDelInfo->pMemObjInfo->mem, object); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_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. clearObjectBinding(object); } } - delete pDelNode; + delete pDelInfo; objectMap.erase(object); } @@ -986,7 +992,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFence(XGL_DEVICE device, const XGL_F XGL_RESULT result = nextTable.CreateFence(device, pCreateInfo, pFence); if (XGL_SUCCESS == result) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pFence, pCreateInfo->sType, pCreateInfo, sizeof(XGL_FENCE_CREATE_INFO), "fence"); + insertObjectInfo(*pFence, pCreateInfo->sType, pCreateInfo, sizeof(XGL_FENCE_CREATE_INFO), "fence"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1052,7 +1058,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateEvent(XGL_DEVICE device, const XGL_E XGL_RESULT result = nextTable.CreateEvent(device, pCreateInfo, pEvent); if (XGL_SUCCESS == result) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pEvent, pCreateInfo->sType, pCreateInfo, sizeof(XGL_EVENT_CREATE_INFO), "event"); + insertObjectInfo(*pEvent, pCreateInfo->sType, pCreateInfo, sizeof(XGL_EVENT_CREATE_INFO), "event"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1063,7 +1069,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueryPool(XGL_DEVICE device, const X XGL_RESULT result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool); if (XGL_SUCCESS == result) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pQueryPool, pCreateInfo->sType, pCreateInfo, sizeof(XGL_QUERY_POOL_CREATE_INFO), "query_pool"); + insertObjectInfo(*pQueryPool, pCreateInfo->sType, pCreateInfo, sizeof(XGL_QUERY_POOL_CREATE_INFO), "query_pool"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1074,7 +1080,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBuffer(XGL_DEVICE device, const XGL_ XGL_RESULT result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer); if (XGL_SUCCESS == result) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pBuffer, pCreateInfo->sType, pCreateInfo, sizeof(XGL_BUFFER_CREATE_INFO), "buffer"); + insertObjectInfo(*pBuffer, pCreateInfo->sType, pCreateInfo, sizeof(XGL_BUFFER_CREATE_INFO), "buffer"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1085,7 +1091,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBufferView(XGL_DEVICE device, const XGL_RESULT result = nextTable.CreateBufferView(device, pCreateInfo, pView); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_BUFFER_VIEW_CREATE_INFO), "buffer_view"); + insertObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_BUFFER_VIEW_CREATE_INFO), "buffer_view"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1096,7 +1102,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImage(XGL_DEVICE device, const XGL_I XGL_RESULT result = nextTable.CreateImage(device, pCreateInfo, pImage); if (XGL_SUCCESS == result) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pImage, pCreateInfo->sType, pCreateInfo, sizeof(XGL_IMAGE_CREATE_INFO), "image"); + insertObjectInfo(*pImage, pCreateInfo->sType, pCreateInfo, sizeof(XGL_IMAGE_CREATE_INFO), "image"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1107,7 +1113,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const X XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_IMAGE_VIEW_CREATE_INFO), "image_view"); + insertObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_IMAGE_VIEW_CREATE_INFO), "image_view"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1119,7 +1125,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorAttachmentView(XGL_DEVICE devic XGL_RESULT result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO), "color_attachment_view"); + insertObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO), "color_attachment_view"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1130,7 +1136,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilView(XGL_DEVICE device, XGL_RESULT result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DEPTH_STENCIL_VIEW_CREATE_INFO), "ds_view"); + insertObjectInfo(*pView, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DEPTH_STENCIL_VIEW_CREATE_INFO), "ds_view"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1147,7 +1153,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO), "graphics_pipeline"); + insertObjectInfo(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO), "graphics_pipeline"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1158,7 +1164,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateComputePipeline(XGL_DEVICE device, c XGL_RESULT result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(XGL_COMPUTE_PIPELINE_CREATE_INFO), "compute_pipeline"); + insertObjectInfo(*pPipeline, pCreateInfo->sType, pCreateInfo, sizeof(XGL_COMPUTE_PIPELINE_CREATE_INFO), "compute_pipeline"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1169,7 +1175,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pSampler, pCreateInfo->sType, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO), "sampler"); + insertObjectInfo(*pSampler, pCreateInfo->sType, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO), "sampler"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1181,7 +1187,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicViewportState(XGL_DEVICE devi XGL_RESULT result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO), "viewport_state"); + insertObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO), "viewport_state"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1193,7 +1199,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicRasterState(XGL_DEVICE device XGL_RESULT result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO), "raster_state"); + insertObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO), "raster_state"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1205,7 +1211,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(XGL_DEVICE de XGL_RESULT result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO), "cb_state"); + insertObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO), "cb_state"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1217,7 +1223,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(XGL_DEVICE XGL_RESULT result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); if (result == XGL_SUCCESS) { loader_platform_thread_lock_mutex(&globalLock); - insertGlobalObjectNode(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO), "ds_state"); + insertObjectInfo(*pState, pCreateInfo->sType, pCreateInfo, sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO), "ds_state"); loader_platform_thread_unlock_mutex(&globalLock); } return result; @@ -1229,8 +1235,8 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, con // At time of cmd buffer creation, create global cmd buffer node for the returned cmd buffer loader_platform_thread_lock_mutex(&globalLock); if (*pCmdBuffer) - insertGlobalCB(*pCmdBuffer); - printGlobalCB(); + insertCBInfo(*pCmdBuffer); + printCBList(); loader_platform_thread_unlock_mutex(&globalLock); return result; } @@ -1238,8 +1244,8 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, con XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo) { // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references - GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cmdBuffer); - if (pCBTrav && (!fenceRetired(pCBTrav->fenceId))) { + MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); + if (pCBInfo && (!fenceRetired(pCBInfo->fenceId))) { bool32_t cbDone = checkCBCompleted(cmdBuffer); if (XGL_FALSE == cbDone) { char str[1024]; @@ -1264,8 +1270,8 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer) XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer) { // Verify that CB is complete (not in-flight) - GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cmdBuffer); - if (pCBTrav && (!fenceRetired(pCBTrav->fenceId))) { + MT_CB_INFO* pCBInfo = getCBInfo(cmdBuffer); + if (pCBInfo && (!fenceRetired(pCBInfo->fenceId))) { bool32_t cbDone = checkCBCompleted(cmdBuffer); if (XGL_FALSE == cbDone) { char str[1024]; @@ -1287,9 +1293,9 @@ XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PI #if 0 // TODO : If memory bound to pipeline, then need to tie that mem to cmdBuffer if (getPipeline(pipeline)) { - GLOBAL_CB_NODE *pCBTrav = getGlobalCBNode(cmdBuffer); - if (pCBTrav) { - pCBTrav->pipelines[pipelineBindPoint] = pipeline; + MT_CB_INFO *pCBInfo = getCBInfo(cmdBuffer); + if (pCBInfo) { + pCBInfo->pipelines[pipelineBindPoint] = pipeline; } else { char str[1024]; sprintf(str, "Attempt to bind Pipeline %p to non-existant command buffer %p!", (void*)pipeline, cmdBuffer); @@ -1307,21 +1313,21 @@ XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PI XGL_LAYER_EXPORT void XGLAPI xglCmdBindDynamicStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state) { - GLOBAL_OBJECT_NODE *pNode; + MT_OBJ_INFO *pObjInfo; loader_platform_thread_lock_mutex(&globalLock); - GLOBAL_CB_NODE *pCmdBuf = getGlobalCBNode(cmdBuffer); + MT_CB_INFO *pCmdBuf = getCBInfo(cmdBuffer); if (!pCmdBuf) { char str[1024]; sprintf(str, "Unable to find command buffer object %p, was it ever created?", (void*)cmdBuffer); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, MEMTRACK_INVALID_CB, "DD", str); } - pNode = getGlobalObjectNode(state); - if (!pNode) { + pObjInfo = getObjectInfo(state); + if (!pObjInfo) { char str[1024]; sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state); layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, MEMTRACK_INVALID_OBJECT, "DD", str); } - pCmdBuf->pDynamicState[stateBindPoint] = pNode; + pCmdBuf->pDynamicState[stateBindPoint] = pObjInfo; loader_platform_thread_unlock_mutex(&globalLock); nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); } @@ -1623,18 +1629,18 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBAC XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) { - XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; - XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; - while (pTrav) { - if (pTrav->pfnMsgCallback == pfnMsgCallback) { - pPrev->pNext = pTrav->pNext; - if (g_pDbgFunctionHead == pTrav) - g_pDbgFunctionHead = pTrav->pNext; - free(pTrav); + XGL_LAYER_DBG_FUNCTION_NODE *pInfo = g_pDbgFunctionHead; + XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pInfo; + while (pInfo) { + if (pInfo->pfnMsgCallback == pfnMsgCallback) { + pPrev->pNext = pInfo->pNext; + if (g_pDbgFunctionHead == pInfo) + g_pDbgFunctionHead = pInfo->pNext; + free(pInfo); break; } - pPrev = pTrav; - pTrav = pTrav->pNext; + pPrev = pInfo; + pInfo = pInfo->pNext; } if (g_pDbgFunctionHead == NULL) { @@ -1656,8 +1662,8 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage(XGL_DEVICE de loader_platform_thread_lock_mutex(&globalLock); if (XGL_SUCCESS == result) { // Add image object, then insert the new Mem Object and then bind it to created image - insertGlobalObjectNode(*pImage, _XGL_STRUCTURE_TYPE_MAX_ENUM, pCreateInfo, sizeof(XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO), "wsi_x11_image"); - insertGlobalMemObj(*pMem, NULL); + insertObjectInfo(*pImage, _XGL_STRUCTURE_TYPE_MAX_ENUM, pCreateInfo, sizeof(XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO), "wsi_x11_image"); + insertMemObjInfo(*pMem, NULL); if (XGL_FALSE == updateObjectBinding(*pImage, *pMem)) { char str[1024]; sprintf(str, "In xglWsiX11CreatePresentableImage(), unable to set image %p binding to mem obj %p", (void*)*pImage, (void*)*pMem); @@ -1673,7 +1679,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage(XGL_DEVICE de XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence) { loader_platform_thread_lock_mutex(&globalLock); - addFenceNode(fence); + addFenceInfo(fence); char str[1024]; sprintf(str, "In xglWsiX11QueuePresent(), checking queue %p for fence %p", queue, fence); layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_NONE, "MEM", str); @@ -1826,6 +1832,8 @@ XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* f return (void*) xglDbgRegisterMsgCallback; if (!strcmp(funcName, "xglDbgUnregisterMsgCallback")) return (void*) xglDbgUnregisterMsgCallback; + if (!strcmp(funcName, "xglGetDeviceQueue")) + return (void*) xglGetDeviceQueue; #if !defined(WIN32) if (!strcmp(funcName, "xglWsiX11CreatePresentableImage")) return (void*) xglWsiX11CreatePresentableImage; diff --git a/layers/mem_tracker.h b/layers/mem_tracker.h index 743a995e..1159c850 100644 --- a/layers/mem_tracker.h +++ b/layers/mem_tracker.h @@ -53,14 +53,14 @@ typedef enum _MEM_TRACK_ERROR /* * Data Structure overview * There are 4 global STL maps - * cbMap -- map of command Buffer (CB) objects to GLOBAL_CB_NODE structures - * Each GLOBAL_CB_NODE struct has an stl list container with + * cbMap -- map of command Buffer (CB) objects to MT_CB_INFO structures + * Each MT_CB_INFO struct has an stl list container with * memory objects that are referenced by this CB - * memObjMap -- map of Memory Objects to GLOBAL_MEM_OBJ_NODE structures - * Each GLOBAL_MEM_OBJ_NODE has two stl list containers with: + * memObjMap -- map of Memory Objects to MT_MEM_OBJ_INFO structures + * Each MT_MEM_OBJ_INFO has two stl list containers with: * -- all CBs referencing this mem obj * -- all XGL Objects that are bound to this memory - * objectMap -- map of objects to GLOBAL_OBJECT_NODE structures + * objectMap -- map of objects to MT_OBJ_INFO structures * * Algorithm overview * These are the primary events that should happen related to different objects @@ -75,15 +75,13 @@ typedef enum _MEM_TRACK_ERROR * DESTROY - Flag as errors any remaining refs and remove from map * 3. Generic Objects * MEM BIND - DESTROY any previous binding, Add obj node w/ ref to map, add obj ref to list container for that mem node - * DESTROY - If mem bound, remove reference list container for that mem Node, remove object ref from map + * DESTROY - If mem bound, remove reference list container for that memInfo, remove object ref from map */ // TODO : Is there a way to track when Cmd Buffer finishes & remove mem references at that point? // TODO : Could potentially store a list of freed mem allocs to flag when they're incorrectly used -struct GLOBAL_MEM_OBJ_NODE; - // Data struct for tracking memory object -struct GLOBAL_MEM_OBJ_NODE { +struct MT_MEM_OBJ_INFO { uint32_t refCount; // Count of references (obj bindings or CB use) XGL_GPU_MEMORY mem; XGL_MEMORY_ALLOC_INFO allocInfo; @@ -91,8 +89,8 @@ struct GLOBAL_MEM_OBJ_NODE { list pCmdBufferBindings; // list container of cmd buffers that reference this mem object }; -struct GLOBAL_OBJECT_NODE { - GLOBAL_MEM_OBJ_NODE* pMemNode; +struct MT_OBJ_INFO { + MT_MEM_OBJ_INFO* pMemObjInfo; XGL_OBJECT object; XGL_STRUCTURE_TYPE sType; uint32_t ref_count; @@ -116,9 +114,9 @@ struct GLOBAL_OBJECT_NODE { }; // Track all command buffers -struct GLOBAL_CB_NODE { +struct MT_CB_INFO { XGL_CMD_BUFFER_CREATE_INFO createInfo; - GLOBAL_OBJECT_NODE* pDynamicState[XGL_NUM_STATE_BIND_POINT]; + MT_OBJ_INFO* pDynamicState[XGL_NUM_STATE_BIND_POINT]; XGL_PIPELINE pipelines[XGL_NUM_PIPELINE_BIND_POINT]; uint32_t colorAttachmentCount; XGL_DEPTH_STENCIL_BIND_INFO dsBindInfo; @@ -129,7 +127,7 @@ struct GLOBAL_CB_NODE { }; // Associate fenceId with a fence object -struct GLOBAL_FENCE_NODE { +struct MT_FENCE_INFO { XGL_FENCE fence; bool32_t localFence; };