diff options
| author | Jon Ashburn <jon@lunarg.com> | 2015-05-15 15:09:35 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-17 19:47:02 -0600 |
| commit | eddcf1d2462c477f2b1004333adb459d0c2554ce (patch) | |
| tree | 9ab140682db7e8f54271de28d401915c28bbe2e6 /loader | |
| parent | d8107d14e2619740c5ca276ce8fe06cf584b2d9b (diff) | |
| download | usermoji-eddcf1d2462c477f2b1004333adb459d0c2554ce.tar.xz | |
misc: Loader and Layers move device chain activation to CreateDevice
Diffstat (limited to 'loader')
| -rw-r--r-- | loader/loader.c | 166 | ||||
| -rw-r--r-- | loader/loader.h | 66 | ||||
| -rw-r--r-- | loader/table_ops.h | 44 | ||||
| -rw-r--r-- | loader/trampoline.c | 53 |
4 files changed, 207 insertions, 122 deletions
diff --git a/loader/loader.c b/loader/loader.c index f80ce610..9cbee3f9 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -60,31 +60,6 @@ struct extension_property { bool hosted; // does the extension reside in one driver/layer }; -struct loader_icd { - const struct loader_scanned_icds *scanned_icds; - - VkLayerDispatchTable *loader_dispatch; - uint32_t layer_count[MAX_GPUS_FOR_LAYER]; - struct loader_layers layer_libs[MAX_GPUS_FOR_LAYER][MAX_LAYER_LIBRARIES]; - VkBaseLayerObject *wrappedGpus[MAX_GPUS_FOR_LAYER]; - uint32_t gpu_count; - VkBaseLayerObject *gpus; - VkInstance instance; // instance object from the icd - PFN_vkGetProcAddr GetProcAddr; - PFN_vkDestroyInstance DestroyInstance; - PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetPhysicalDeviceInfo GetPhysicalDeviceInfo; - PFN_vkCreateDevice CreateDevice; - PFN_vkGetPhysicalDeviceExtensionInfo GetPhysicalDeviceExtensionInfo; - PFN_vkEnumerateLayers EnumerateLayers; - PFN_vkGetMultiDeviceCompatibility GetMultiDeviceCompatibility; - PFN_vkDbgRegisterMsgCallback DbgRegisterMsgCallback; - PFN_vkDbgUnregisterMsgCallback DbgUnregisterMsgCallback; - PFN_vkDbgSetGlobalOption DbgSetGlobalOption; - struct loader_icd *next; -}; - - struct loader_scanned_icds { loader_platform_dl_handle handle; @@ -103,15 +78,16 @@ VkLayerInstanceDispatchTable instance_disp = { .CreateInstance = loader_CreateInstance, .DestroyInstance = loader_DestroyInstance, .EnumeratePhysicalDevices = loader_EnumeratePhysicalDevices, - .GetPhysicalDeviceInfo = vkGetPhysicalDeviceInfo, - .CreateDevice = vkCreateDevice, + .GetPhysicalDeviceInfo = loader_GetPhysicalDeviceInfo, + .CreateDevice = loader_CreateDevice, .GetGlobalExtensionInfo = loader_GetGlobalExtensionInfo, - .GetPhysicalDeviceExtensionInfo = vkGetPhysicalDeviceExtensionInfo, - .EnumerateLayers = vkEnumerateLayers, - .GetMultiDeviceCompatibility = vkGetMultiDeviceCompatibility, + .GetPhysicalDeviceExtensionInfo = loader_GetPhysicalDeviceExtensionInfo, + .EnumerateLayers = loader_EnumerateLayers, + .GetMultiDeviceCompatibility = loader_GetMultiDeviceCompatibility, .DbgRegisterMsgCallback = loader_DbgRegisterMsgCallback, .DbgUnregisterMsgCallback = loader_DbgUnregisterMsgCallback, .DbgSetGlobalOption = loader_DbgSetGlobalOption, + .GetDisplayInfoWSI = loader_GetDisplayInfoWSI }; LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_icd); @@ -498,6 +474,7 @@ static void loader_icd_init_entrys(struct loader_icd *icd, LOOKUP(DbgRegisterMsgCallback); LOOKUP(DbgUnregisterMsgCallback); LOOKUP(DbgSetGlobalOption); + LOOKUP(GetDisplayInfoWSI); #undef LOOKUP return; @@ -747,11 +724,11 @@ void layer_lib_scan(void) static void* VKAPI loader_gpa_device_internal(VkPhysicalDevice physDev, const char * pName) { + //physDev is not wrapped if (physDev == VK_NULL_HANDLE) { return NULL; } - VkBaseLayerObject* physDevWrap = (VkBaseLayerObject *) physDev; - VkLayerDispatchTable* disp_table = * (VkLayerDispatchTable **) physDevWrap->baseObject; + VkLayerDispatchTable* disp_table = * (VkLayerDispatchTable **) physDev; void *addr; if (disp_table == NULL) @@ -763,9 +740,7 @@ static void* VKAPI loader_gpa_device_internal(VkPhysicalDevice physDev, const ch else { if (disp_table->GetProcAddr == NULL) return NULL; - if (physDevWrap->baseObject == physDevWrap->nextObject) - return physDevWrap->pGPA(physDevWrap->baseObject, pName); - return disp_table->GetProcAddr(physDevWrap->nextObject, pName); + return disp_table->GetProcAddr(physDev, pName); } } @@ -1147,21 +1122,19 @@ uint32_t loader_activate_instance_layers(struct loader_instance *inst) return inst->layer_count; } -extern uint32_t loader_activate_device_layers(struct loader_icd *icd, uint32_t gpu_index, uint32_t ext_count, const char *const* ext_names) +uint32_t loader_activate_device_layers(VkDevice device, struct loader_icd *icd, uint32_t gpu_index, uint32_t ext_count, const char *const* ext_names) { uint32_t count; - VkBaseLayerObject *gpu; struct layer_name_pair *pLayerNames; if (!icd) return 0; assert(gpu_index < MAX_GPUS_FOR_LAYER); - gpu = icd->gpus + gpu_index; /* activate any layer libraries */ if (!loader_layers_activated(icd, gpu_index)) { - // Note gpu object is wrapped once already - VkBaseLayerObject *gpuObj = gpu; - VkBaseLayerObject *nextGpuObj, *baseObj = (VkBaseLayerObject *) gpuObj->baseObject; + VkObject nextObj = (VkObject) device; + VkObject baseObj = nextObj; + VkBaseLayerObject *nextGpuObj; PFN_vkGetProcAddr nextGPA = loader_gpa_device_internal; count = loader_get_layer_libs(ext_count, ext_names, &pLayerNames); @@ -1177,9 +1150,9 @@ extern uint32_t loader_activate_device_layers(struct loader_icd *icd, uint32_t g for (int32_t i = icd->layer_count[gpu_index] - 1; i >= 0; i--) { nextGpuObj = (icd->wrappedGpus[gpu_index] + i); nextGpuObj->pGPA = nextGPA; - nextGpuObj->baseObject = (VkObject) baseObj; - nextGpuObj->nextObject = (VkObject) gpuObj; - gpuObj = nextGpuObj; + nextGpuObj->baseObject = baseObj; + nextGpuObj->nextObject = nextObj; + nextObj = (VkObject) nextGpuObj; char funcStr[256]; snprintf(funcStr, 256, "%sGetProcAddr",icd->layer_libs[gpu_index][i].name); @@ -1191,13 +1164,11 @@ extern uint32_t loader_activate_device_layers(struct loader_icd *icd, uint32_t g } if (i == 0) { - loader_init_device_dispatch_table(icd->loader_dispatch + gpu_index, nextGPA, (VkPhysicalDevice) gpuObj); + loader_init_device_dispatch_table(icd->loader_dispatch + gpu_index, nextGPA, (VkPhysicalDevice) nextObj); //Insert the new wrapped objects into the list with loader object at head - gpu->nextObject = (VkObject) gpuObj; - gpu->pGPA = nextGPA; - gpuObj = icd->wrappedGpus[gpu_index] + icd->layer_count[gpu_index] - 1; - gpuObj->nextObject = (VkObject) baseObj; - gpuObj->pGPA = icd->GetProcAddr; + nextGpuObj = icd->wrappedGpus[gpu_index] + icd->layer_count[gpu_index] - 1; + nextGpuObj->nextObject = baseObj; + nextGpuObj->pGPA = icd->GetProcAddr; } } @@ -1362,18 +1333,7 @@ VkResult loader_EnumeratePhysicalDevices( loader_init_device_dispatch_table(icd->loader_dispatch + i, get_proc_addr, gpus[i]); - /* Verify ICD compatibility */ - if (!valid_loader_magic_value(gpus[i])) { - loader_log(VK_DBG_MSG_WARNING, 0, - "Loader: Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.\n"); - assert(0); - } - - const VkLayerDispatchTable **disp; - disp = (const VkLayerDispatchTable **) gpus[i]; - *disp = icd->loader_dispatch + i; - loader_activate_device_layers(icd, i, ptr_instance->extension_count, - (const char *const*) ptr_instance->extension_names); + loader_init_dispatch(gpus[i], ptr_instance->disp); } count += n; @@ -1408,6 +1368,33 @@ VkResult loader_GetPhysicalDeviceInfo( return res; } +VkResult loader_CreateDevice( + VkPhysicalDevice gpu, + const VkDeviceCreateInfo* pCreateInfo, + VkDevice* pDevice) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + struct loader_instance *ptr_instance; + + ptr_instance = loader.instances; + if (icd->CreateDevice) { + res = icd->CreateDevice(gpu, pCreateInfo, pDevice); + if (res == VK_SUCCESS) { + VkLayerDispatchTable *dev_disp = icd->loader_dispatch + gpu_index; + loader_init_dispatch(*pDevice, dev_disp); + } + //TODO fix this extension parameters once support GetDeviceExtensionInfo() + // don't know which instance we are on with this call + + loader_activate_device_layers(*pDevice, icd, gpu_index, ptr_instance->extension_count, + (const char *const*) ptr_instance->extension_names); + } + + return res; +} + LOADER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const char * pName) { if (instance != VK_NULL_HANDLE) { @@ -1505,8 +1492,30 @@ VkResult loader_GetGlobalExtensionInfo( return VK_SUCCESS; } +VkResult loader_GetPhysicalDeviceExtensionInfo( + VkPhysicalDevice gpu, + VkExtensionInfoType infoType, + uint32_t extensionIndex, + size_t* pDataSize, + void* pData) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetPhysicalDeviceExtensionInfo) + res = icd->GetPhysicalDeviceExtensionInfo(gpu, infoType, extensionIndex, + pDataSize, pData); + + return res; +} -LOADER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, size_t maxStringSize, size_t* pLayerCount, char* const* pOutLayers, void* pReserved) +VkResult loader_EnumerateLayers( + VkPhysicalDevice gpu, + size_t maxStringSize, + size_t* pLayerCount, + char* const* pOutLayers, + void* pReserved) { size_t maxLayerCount; uint32_t gpu_index; @@ -1582,6 +1591,21 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, size_t maxS return VK_SUCCESS; } +VkResult loader_GetMultiDeviceCompatibility( + VkPhysicalDevice gpu0, + VkPhysicalDevice gpu1, + VkPhysicalDeviceCompatibilityInfo* pInfo) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu0, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetMultiDeviceCompatibility) + res = icd->GetMultiDeviceCompatibility(gpu0, gpu1, pInfo); + + return res; +} + VkResult loader_DbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) { const struct loader_icd *icd; @@ -1686,3 +1710,19 @@ VkResult loader_DbgSetGlobalOption(VkInstance instance, VK_DBG_GLOBAL_OPTION dbg return res; } + +VkResult loader_GetDisplayInfoWSI( + VkDisplayWSI display, + VkDisplayInfoTypeWSI infoType, + size_t* pDataSize, + void* pData) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) display, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetDisplayInfoWSI) + res = icd->GetDisplayInfoWSI(display, infoType, pDataSize, pData); + + return res; +}
\ No newline at end of file diff --git a/loader/loader.h b/loader/loader.h index 40046925..54a97584 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -57,8 +57,34 @@ struct loader_layers { char name[256]; }; +struct loader_icd { + const struct loader_scanned_icds *scanned_icds; + + VkLayerDispatchTable *loader_dispatch; + uint32_t layer_count[MAX_GPUS_FOR_LAYER]; + struct loader_layers layer_libs[MAX_GPUS_FOR_LAYER][MAX_LAYER_LIBRARIES]; + VkBaseLayerObject *wrappedGpus[MAX_GPUS_FOR_LAYER]; + uint32_t gpu_count; + VkBaseLayerObject *gpus; + VkInstance instance; // instance object from the icd + PFN_vkGetProcAddr GetProcAddr; + PFN_vkDestroyInstance DestroyInstance; + PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; + PFN_vkGetPhysicalDeviceInfo GetPhysicalDeviceInfo; + PFN_vkCreateDevice CreateDevice; + PFN_vkGetPhysicalDeviceExtensionInfo GetPhysicalDeviceExtensionInfo; + PFN_vkEnumerateLayers EnumerateLayers; + PFN_vkGetMultiDeviceCompatibility GetMultiDeviceCompatibility; + PFN_vkDbgRegisterMsgCallback DbgRegisterMsgCallback; + PFN_vkDbgUnregisterMsgCallback DbgUnregisterMsgCallback; + PFN_vkDbgSetGlobalOption DbgSetGlobalOption; + PFN_vkGetDisplayInfoWSI GetDisplayInfoWSI; + struct loader_icd *next; +}; + struct loader_instance { - VkLayerInstanceDispatchTable *disp; + VkLayerInstanceDispatchTable *disp; // must be first entry in structure + uint32_t layer_count; struct loader_layers layer_libs[MAX_LAYER_LIBRARIES]; VkBaseLayerObject *wrappedInstance; @@ -126,6 +152,16 @@ VkResult loader_EnumeratePhysicalDevices( VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +VkResult loader_GetPhysicalDeviceInfo( + VkPhysicalDevice gpu, + VkPhysicalDeviceInfoType infoType, + size_t* pDataSize, + void* pData); + +VkResult loader_CreateDevice( + VkPhysicalDevice gpu, + const VkDeviceCreateInfo* pCreateInfo, + VkDevice* pDevice); VkResult VKAPI loader_GetGlobalExtensionInfo( VkExtensionInfoType infoType, @@ -133,6 +169,25 @@ VkResult VKAPI loader_GetGlobalExtensionInfo( size_t* pDataSize, void* pData); +VkResult loader_GetPhysicalDeviceExtensionInfo( + VkPhysicalDevice gpu, + VkExtensionInfoType infoType, + uint32_t extensionIndex, + size_t* pDataSize, + void* pData); + +VkResult loader_EnumerateLayers( + VkPhysicalDevice gpu, + size_t maxStringSize, + size_t* pLayerCount, + char* const* pOutLayers, + void* pReserved); + +VkResult loader_GetMultiDeviceCompatibility( + VkPhysicalDevice gpu0, + VkPhysicalDevice gpu1, + VkPhysicalDeviceCompatibilityInfo* pInfo); + VkResult loader_DbgRegisterMsgCallback( VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, @@ -148,11 +203,18 @@ VkResult loader_DbgSetGlobalOption( size_t dataSize, const void* pData); +VkResult loader_GetDisplayInfoWSI( + VkDisplayWSI display, + VkDisplayInfoTypeWSI infoType, + size_t* pDataSize, + void* pData); + /* function definitions */ bool loader_is_extension_scanned(const char *name); void loader_icd_scan(void); void layer_lib_scan(void); void loader_coalesce_extensions(void); -struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, uint32_t *gpu_index); +struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, + uint32_t *gpu_index); uint32_t loader_activate_instance_layers(struct loader_instance *inst); #endif /* LOADER_H */ diff --git a/loader/table_ops.h b/loader/table_ops.h index fedfb79d..5316720b 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -32,17 +32,7 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table PFN_vkGetProcAddr gpa, VkPhysicalDevice gpu) { - table->CreateInstance = vkCreateInstance; /* non-dispatchable */ - table->DestroyInstance = (PFN_vkDestroyInstance) gpa(gpu, "vkDestroyInstance"); - table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) gpa(gpu, "vkEnumeratePhysicalDevices"); - table->GetPhysicalDeviceInfo = (PFN_vkGetPhysicalDeviceInfo) gpa(gpu, "vkGetPhysicalDeviceInfo"); - table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(gpu, "vkGetInstanceProcAddr"); - table->GetProcAddr = (PFN_vkGetProcAddr) gpa(gpu, "vkGetProcAddr"); - table->CreateDevice = (PFN_vkCreateDevice) gpa(gpu, "vkCreateDevice"); table->DestroyDevice = (PFN_vkDestroyDevice) gpa(gpu, "vkDestroyDevice"); - table->GetGlobalExtensionInfo = vkGetGlobalExtensionInfo; /* non-dispatchable */ - table->GetPhysicalDeviceExtensionInfo = (PFN_vkGetPhysicalDeviceExtensionInfo) gpa(gpu, "vkGetPhysicalDeviceExtensionInfo"); - table->EnumerateLayers = (PFN_vkEnumerateLayers) gpa(gpu, "vkEnumerateLayers"); table->GetDeviceQueue = (PFN_vkGetDeviceQueue) gpa(gpu, "vkGetDeviceQueue"); table->QueueSubmit = (PFN_vkQueueSubmit) gpa(gpu, "vkQueueSubmit"); table->QueueWaitIdle = (PFN_vkQueueWaitIdle) gpa(gpu, "vkQueueWaitIdle"); @@ -55,7 +45,6 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table table->FlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) gpa(gpu, "vkFlushMappedMemoryRanges"); table->InvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) gpa(gpu, "vkInvalidateMappedMemoryRanges"); table->PinSystemMemory = (PFN_vkPinSystemMemory) gpa(gpu, "vkPinSystemMemory"); - table->GetMultiDeviceCompatibility = (PFN_vkGetMultiDeviceCompatibility) gpa(gpu, "vkGetMultiDeviceCompatibility"); table->OpenSharedMemory = (PFN_vkOpenSharedMemory) gpa(gpu, "vkOpenSharedMemory"); table->OpenSharedSemaphore = (PFN_vkOpenSharedSemaphore) gpa(gpu, "vkOpenSharedSemaphore"); table->OpenPeerMemory = (PFN_vkOpenPeerMemory) gpa(gpu, "vkOpenPeerMemory"); @@ -147,15 +136,11 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table table->CmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) gpa(gpu, "vkCmdBeginRenderPass"); table->CmdEndRenderPass = (PFN_vkCmdEndRenderPass) gpa(gpu, "vkCmdEndRenderPass"); table->DbgSetValidationLevel = (PFN_vkDbgSetValidationLevel) gpa(gpu, "vkDbgSetValidationLevel"); - table->DbgRegisterMsgCallback = (PFN_vkDbgRegisterMsgCallback) gpa(gpu, "vkDbgRegisterMsgCallback"); - table->DbgUnregisterMsgCallback = (PFN_vkDbgUnregisterMsgCallback) gpa(gpu, "vkDbgUnregisterMsgCallback"); table->DbgSetMessageFilter = (PFN_vkDbgSetMessageFilter) gpa(gpu, "vkDbgSetMessageFilter"); table->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) gpa(gpu, "vkDbgSetObjectTag"); - table->DbgSetGlobalOption = (PFN_vkDbgSetGlobalOption) gpa(gpu, "vkDbgSetGlobalOption"); table->DbgSetDeviceOption = (PFN_vkDbgSetDeviceOption) gpa(gpu, "vkDbgSetDeviceOption"); table->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) gpa(gpu, "vkCmdDbgMarkerBegin"); table->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) gpa(gpu, "vkCmdDbgMarkerEnd"); - table->GetDisplayInfoWSI = (PFN_vkGetDisplayInfoWSI) gpa(gpu, "vkGetDisplayInfoWSI"); table->CreateSwapChainWSI = (PFN_vkCreateSwapChainWSI) gpa(gpu, "vkCreateSwapChainWSI"); table->DestroySwapChainWSI = (PFN_vkDestroySwapChainWSI) gpa(gpu, "vkDestroySwapChainWSI"); table->GetSwapChainInfoWSI = (PFN_vkGetSwapChainInfoWSI) gpa(gpu, "vkGetSwapChainInfoWSI"); @@ -170,24 +155,8 @@ static inline void *loader_lookup_device_dispatch_table( return NULL; name += 2; - if (!strcmp(name, "DestroyInstance")) - return (void *) table->DestroyInstance; - if (!strcmp(name, "EnumeratePhysicalDevices")) - return (void *) table->EnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceInfo")) - return (void *) table->GetPhysicalDeviceInfo; - if (!strcmp(name, "GetInstanceProcAddr")) - return (void *) table->GetInstanceProcAddr; - if (!strcmp(name, "GetProcAddr")) - return (void *) table->GetProcAddr; - if (!strcmp(name, "CreateDevice")) - return (void *) table->CreateDevice; if (!strcmp(name, "DestroyDevice")) return (void *) table->DestroyDevice; - if (!strcmp(name, "GetPhysicalDeviceExtensionInfo")) - return (void *) table->GetPhysicalDeviceExtensionInfo; - if (!strcmp(name, "EnumerateLayers")) - return (void *) table->EnumerateLayers; if (!strcmp(name, "GetDeviceQueue")) return (void *) table->GetDeviceQueue; if (!strcmp(name, "QueueSubmit")) @@ -212,8 +181,6 @@ static inline void *loader_lookup_device_dispatch_table( return (void *) table->InvalidateMappedMemoryRanges; if (!strcmp(name, "PinSystemMemory")) return (void *) table->PinSystemMemory; - if (!strcmp(name, "GetMultiDeviceCompatibility")) - return (void *) table->GetMultiDeviceCompatibility; if (!strcmp(name, "OpenSharedMemory")) return (void *) table->OpenSharedMemory; if (!strcmp(name, "OpenSharedSemaphore")) @@ -396,24 +363,16 @@ static inline void *loader_lookup_device_dispatch_table( return (void *) table->CmdEndRenderPass; if (!strcmp(name, "DbgSetValidationLevel")) return (void *) table->DbgSetValidationLevel; - if (!strcmp(name, "DbgRegisterMsgCallback")) - return (void *) table->DbgRegisterMsgCallback; - if (!strcmp(name, "DbgUnregisterMsgCallback")) - return (void *) table->DbgUnregisterMsgCallback; if (!strcmp(name, "DbgSetMessageFilter")) return (void *) table->DbgSetMessageFilter; if (!strcmp(name, "DbgSetObjectTag")) return (void *) table->DbgSetObjectTag; - if (!strcmp(name, "DbgSetGlobalOption")) - return (void *) table->DbgSetGlobalOption; if (!strcmp(name, "DbgSetDeviceOption")) return (void *) table->DbgSetDeviceOption; if (!strcmp(name, "CmdDbgMarkerBegin")) return (void *) table->CmdDbgMarkerBegin; if (!strcmp(name, "CmdDbgMarkerEnd")) return (void *) table->CmdDbgMarkerEnd; - if (!strcmp(name, "GetDisplayInfoWSI")) - return (void *) table->GetDisplayInfoWSI; if (!strcmp(name, "CreateSwapChainWSI")) return (void *) table->CreateSwapChainWSI; if (!strcmp(name, "DestroySwapChainWSI")) @@ -444,6 +403,7 @@ static inline void loader_init_instance_dispatch_table(VkLayerInstanceDispatchTa table->DbgRegisterMsgCallback = (PFN_vkDbgRegisterMsgCallback) gpa(inst, "vkDbgRegisterMsgCallback"); table->DbgUnregisterMsgCallback = (PFN_vkDbgUnregisterMsgCallback) gpa(inst, "vkDbgUnregisterMsgCallback"); table->DbgSetGlobalOption = (PFN_vkDbgSetGlobalOption) gpa(inst, "vkDbgSetGlobalOption"); + table->GetDisplayInfoWSI = (PFN_vkGetDisplayInfoWSI) gpa(inst, "vkGetDisplayInfoWSI"); } static inline void *loader_lookup_instance_dispatch_table( @@ -482,6 +442,8 @@ static inline void *loader_lookup_instance_dispatch_table( return (void *) table->DbgUnregisterMsgCallback; if (!strcmp(name, "DbgSetGlobalOption")) return (void *) table->DbgSetGlobalOption; + if (!strcmp(name, "GetDisplayInfoWSI")) + return (void *) table->GetDisplayInfoWSI; return NULL; }
\ No newline at end of file diff --git a/loader/trampoline.c b/loader/trampoline.c index b7b6c58d..15d2c5e5 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -89,6 +89,7 @@ LOADER_EXPORT VkResult VKAPI vkDestroyInstance( disp = loader_get_instance_dispatch(instance); return disp->DestroyInstance(instance); } + LOADER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices( VkInstance instance, uint32_t* pPhysicalDeviceCount, @@ -107,12 +108,13 @@ LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo( size_t* pDataSize, void* pData) { - const VkLayerDispatchTable *disp; + const VkLayerInstanceDispatchTable *disp; VkResult res; - disp = loader_get_dispatch(gpu); + disp = loader_get_instance_dispatch(gpu); res = disp->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData); + //TODO add check for extension enabled if (infoType == VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI && pData && res == VK_SUCCESS) { VkDisplayPropertiesWSI *info = pData; size_t count = *pDataSize / sizeof(*info), i; @@ -124,18 +126,18 @@ LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo( return res; } -LOADER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) +LOADER_EXPORT VkResult VKAPI vkCreateDevice( + VkPhysicalDevice gpu, + const VkDeviceCreateInfo* pCreateInfo, + VkDevice* pDevice) { - const VkLayerDispatchTable *disp; + const VkLayerInstanceDispatchTable *disp; VkResult res; - disp = loader_get_dispatch(gpu); + disp = loader_get_instance_dispatch(gpu); + // CreateDevice is dispatched on the instance chain res = disp->CreateDevice(gpu, pCreateInfo, pDevice); - if (res == VK_SUCCESS) { - loader_init_dispatch(*pDevice, disp); - } - return res; } @@ -161,15 +163,34 @@ LOADER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( return instance_disp.GetGlobalExtensionInfo(infoType, extensionIndex, pDataSize, pData); } -LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo(VkPhysicalDevice gpu, VkExtensionInfoType infoType, uint32_t extensionIndex, size_t* pDataSize, void* pData) +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( + VkPhysicalDevice gpu, + VkExtensionInfoType infoType, + uint32_t extensionIndex, + size_t* pDataSize, + void* pData) { - const VkLayerDispatchTable *disp; + const VkLayerInstanceDispatchTable *disp; - disp = loader_get_dispatch(gpu); + disp = loader_get_instance_dispatch(gpu); return disp->GetPhysicalDeviceExtensionInfo(gpu, infoType, extensionIndex, pDataSize, pData); } +LOADER_EXPORT VkResult VKAPI vkEnumerateLayers( + VkPhysicalDevice gpu, + size_t maxStringSize, + size_t* pLayerCount, + char* const* pOutLayers, + void* pReserved) +{ + const VkLayerInstanceDispatchTable *disp; + + disp = loader_get_instance_dispatch(gpu); + + return disp->EnumerateLayers(gpu, maxStringSize, pLayerCount,pOutLayers, pReserved); +} + LOADER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue) { const VkLayerDispatchTable *disp; @@ -286,9 +307,9 @@ LOADER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSys LOADER_EXPORT VkResult VKAPI vkGetMultiDeviceCompatibility(VkPhysicalDevice gpu0, VkPhysicalDevice gpu1, VkPhysicalDeviceCompatibilityInfo* pInfo) { - const VkLayerDispatchTable *disp; + const VkLayerInstanceDispatchTable *disp; - disp = loader_get_dispatch(gpu0); + disp = loader_get_instance_dispatch(gpu0); return disp->GetMultiDeviceCompatibility(gpu0, gpu1, pInfo); } @@ -1192,9 +1213,9 @@ LOADER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) LOADER_EXPORT VkResult VKAPI vkGetDisplayInfoWSI(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData) { - const VkLayerDispatchTable *disp; + const VkLayerInstanceDispatchTable *disp; - disp = loader_get_dispatch(display); + disp = loader_get_instance_dispatch(display); return disp->GetDisplayInfoWSI(display, infoType, pDataSize, pData); } |
