Skip to content

Commit

Permalink
loader: Check JSON API version in create instance
Browse files Browse the repository at this point in the history
Some old drivers crash when calling vkGetInstanceProcAddr to get the
vkEnumerateInstanceVersion entry point. This checks that the JSON
API version is 1.1 before doing that to avoid the crash

Change-Id: I85eac4e1ee38222c936c63484fb9f4353ba55ab0
  • Loading branch information
lenny-lunarg committed Aug 28, 2019
1 parent 23c3bca commit 160e66b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -6140,16 +6140,18 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI

// Get the driver version from vkEnumerateInstanceVersion
uint32_t icd_version = VK_API_VERSION_1_0;
PFN_vkEnumerateInstanceVersion icd_enumerate_instance_version = (PFN_vkEnumerateInstanceVersion)
icd_term->scanned_icd->GetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
VkResult icd_result = VK_SUCCESS;
if (icd_enumerate_instance_version != NULL) {
icd_result = icd_enumerate_instance_version(&icd_version);
if (icd_result != VK_SUCCESS) {
icd_version = VK_API_VERSION_1_0;
loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "terminator_CreateInstance: ICD \"%s\" "
"vkEnumerateInstanceVersion returned error. The ICD will be treated as a 1.0 ICD",
icd_term->scanned_icd->lib_name);
if (icd_term->scanned_icd->api_version >= VK_API_VERSION_1_1) {
PFN_vkEnumerateInstanceVersion icd_enumerate_instance_version = (PFN_vkEnumerateInstanceVersion)
icd_term->scanned_icd->GetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
if (icd_enumerate_instance_version != NULL) {
icd_result = icd_enumerate_instance_version(&icd_version);
if (icd_result != VK_SUCCESS) {
icd_version = VK_API_VERSION_1_0;
loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "terminator_CreateInstance: ICD \"%s\" "
"vkEnumerateInstanceVersion returned error. The ICD will be treated as a 1.0 ICD",
icd_term->scanned_icd->lib_name);
}
}
}

Expand Down

0 comments on commit 160e66b

Please sign in to comment.