VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) { VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); assert(chain_info->u.pLayerInfo); PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance"); if (fpCreateInstance == NULL) { return VK_ERROR_INITIALIZATION_FAILED; } // Advance the link info for the next element on the chain chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); if (result != VK_SUCCESS) return result; layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); my_data->report_data = debug_report_create_instance( my_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); initThreading(my_data, pAllocator); return result; }
VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); assert(chain_info->u.pLayerInfo); PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); if (fpCreateInstance == NULL) { return VK_ERROR_INITIALIZATION_FAILED; } // Advance the link info for the next element on the chain chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); if (result != VK_SUCCESS) return result; layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); my_data->instance = *pInstance; my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); my_data->report_data = debug_report_create_instance(my_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); initThreading(my_data, pAllocator); // Look for one or more debug report create info structures, and copy the // callback(s) for each one found (for use by vkDestroyInstance) layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_data->num_tmp_callbacks, &my_data->tmp_dbg_create_infos, &my_data->tmp_callbacks); return result; }
SO_PUBLIC struct Thread * Thread_Launch (void (*p_fpFunction) (struct Thread *), void *p_pUserData, char *p_sName, struct RazorbackContext *p_pContext) { struct Thread *l_pThread; ASSERT (p_fpFunction != NULL); #ifdef _MSC_VER if (initialized == 0) initThreading(); #else //_MSC_VER pthread_once (&g_once_control, initThreading); #endif //_MSC_VER // Racy if (sg_threadList->length == Config_getThreadLimit ()) return NULL; // allocate memory for thread structure l_pThread = (struct Thread *)calloc (1, sizeof (struct Thread)); if (l_pThread == NULL) { rzb_log (LOG_ERR, "%s: Failed to launch thread in Thread_Launch due to out of memory for Thread", __func__); return NULL; } // initialize running indicator l_pThread->bRunning = false; l_pThread->pContext = NULL; l_pThread->pUserData = p_pUserData; l_pThread->sName = p_sName; l_pThread->bShutdown = false; // Init ref count, once for the list, once for the caller. l_pThread->refs =2; l_pThread->mainFunction = p_fpFunction; // initialize running mutex if ((l_pThread->mMutex = Mutex_Create(MUTEX_MODE_NORMAL)) == NULL) { free(l_pThread); return NULL; } #ifdef _MSC_VER l_pThread->hThread = CreateThread(NULL, 0, Thread_MainWrapper, l_pThread, 0, &l_pThread->iThread); #else //_MSC_VER // start thread, check for error if (pthread_create (&l_pThread->iThread, &g_attr, Thread_MainWrapper, l_pThread) != 0) { free (l_pThread); rzb_log (LOG_ERR, "%s: Failed to launch thread in Thread_Launch due to pthread_create error (%i)", __func__, errno); return NULL; } #endif //_MSC_VER List_Push(sg_threadList, l_pThread); // done return l_pThread; }