diff options
| author | Mark Young <marky@lunarg.com> | 2017-03-10 17:31:18 -0700 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2017-03-16 10:38:05 -0600 |
| commit | 2becce6c2922a9bd9866ec62aa74dfd0de2c655d (patch) | |
| tree | 739828aa75006f2284978c44757da708e89b34dc /scripts/loader_extension_generator.py | |
| parent | 33ececd03ff44cbb37ead0359ce5a5964d3c3b1c (diff) | |
| download | usermoji-2becce6c2922a9bd9866ec62aa74dfd0de2c655d.tar.xz | |
loader: Fix vkEnumeratePhysicalDeviceGroupsKHX
vkEnumeratePhysicalDeviceGroupsKHX was not properly generating the
physical device information or groups. Several changes resolve
most of the issue, however, I'm still seeing issues when certain
layers enabled.
Change-Id: Id8d4553da25491a3d0a97e8d44e21340b41bc09c
Diffstat (limited to 'scripts/loader_extension_generator.py')
| -rw-r--r-- | scripts/loader_extension_generator.py | 186 |
1 files changed, 8 insertions, 178 deletions
diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py index 1aafd843..f44a2dce 100644 --- a/scripts/loader_extension_generator.py +++ b/scripts/loader_extension_generator.py @@ -158,6 +158,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): preamble += '#include <vulkan/vk_icd.h>\n' preamble += '#include "wsi.h"\n' preamble += '#include "debug_report.h"\n' + preamble += '#include "extension_manual.h"\n' elif self.genOpts.filename == 'vk_layer_dispatch_table.h': preamble += '#pragma once\n' @@ -812,179 +813,6 @@ class LoaderExtensionOutputGenerator(OutputGenerator): return tables # - # Several functions need a manual trampoline/terminator - def AddManualTrampTermFuncs(self): - funcs = '' - - # vkEnumeratePhysicalDeviceGroupsKHX - funcs += '\n// ---- Manually added trampoline/terminator functison\n\n' - funcs += 'VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHX(\n' - funcs += ' VkInstance instance, uint32_t *pPhysicalDeviceGroupCount,\n' - funcs += ' VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties) {\n' - funcs += ' VkResult res = VK_SUCCESS;\n' - funcs += ' struct loader_instance *inst = NULL;\n' - funcs += '\n' - funcs += ' loader_platform_thread_lock_mutex(&loader_lock);\n' - funcs += '\n' - funcs += ' inst = loader_get_instance(instance);\n' - funcs += ' if (NULL == inst) {\n' - funcs += ' res = VK_ERROR_INITIALIZATION_FAILED;\n' - funcs += ' goto out;\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' if (pPhysicalDeviceGroupProperties == NULL || 0 == inst->total_gpu_count) {\n' - funcs += ' VkResult setup_res = setupLoaderTrampPhysDevs(instance);\n' - funcs += ' if (VK_SUCCESS != setup_res) {\n' - funcs += ' res = setup_res;\n' - funcs += ' goto out;\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' res = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHX(\n' - funcs += ' instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);\n' - funcs += ' if ((VK_SUCCESS != res && VK_INCOMPLETE != res) ||\n' - funcs += ' NULL == pPhysicalDeviceGroupProperties) {\n' - funcs += ' goto out;\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' for (uint32_t group = 0; group < *pPhysicalDeviceGroupCount; group++) {\n' - funcs += ' for (uint32_t dev = 0;' - funcs += ' dev < pPhysicalDeviceGroupProperties[group].physicalDeviceCount; dev++) {\n' - funcs += ' for (uint32_t tramp = 0; tramp < inst->total_gpu_count; tramp++) {\n' - funcs += ' if (inst->phys_devs_tramp[tramp]->phys_dev ==\n' - funcs += ' pPhysicalDeviceGroupProperties[group].physicalDevices[dev]) {\n' - funcs += ' pPhysicalDeviceGroupProperties[group].physicalDevices[dev] =\n' - funcs += ' (VkPhysicalDevice)inst->phys_devs_tramp[tramp];\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += '\n' - funcs += 'out:\n' - funcs += '\n' - funcs += ' loader_platform_thread_unlock_mutex(&loader_lock);\n' - funcs += ' return res;\n' - funcs += '}\n\n' - funcs += 'VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroupsKHX(\n' - funcs += ' VkInstance instance, uint32_t *pPhysicalDeviceGroupCount,\n' - funcs += ' VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties) {\n' - funcs += ' struct loader_instance *inst = loader_get_instance(instance);\n' - funcs += ' VkResult res = VK_SUCCESS;\n' - funcs += ' uint32_t total_group_count = 0;\n' - funcs += ' uint32_t max_group_count = *pPhysicalDeviceGroupCount;\n' - funcs += ' uint32_t i = 0;\n' - funcs += '\n' - funcs += ' // We have to loop through all ICDs which may be capable of handling this\n' - funcs += ' // call and sum all the possible physical device groups together.\n' - funcs += ' struct loader_icd_term *icd_term = inst->icd_terms;\n' - funcs += ' while (NULL != icd_term) {\n' - funcs += ' if (NULL != icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX) {\n' - funcs += ' uint32_t cur_group_count = 0;\n' - funcs += ' res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX(\n' - funcs += ' icd_term->instance, &cur_group_count, NULL);\n' - funcs += ' if (res != VK_SUCCESS) {\n' - funcs += ' break;\n' - funcs += ' } else if (NULL != pPhysicalDeviceGroupProperties && max_group_count > total_group_count) {\n' - funcs += '\n' - funcs += ' uint32_t remain_count = max_group_count - total_group_count;\n' - funcs += ' res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX(\n' - funcs += ' icd_term->instance, &remain_count,\n' - funcs += ' &pPhysicalDeviceGroupProperties[total_group_count]);\n' - funcs += ' if (res != VK_SUCCESS) {\n' - funcs += ' break;\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' total_group_count += cur_group_count;\n' - funcs += ' } else {\n' - funcs += ' // For ICDs which don\'t directly support this, create a group for each physical device\n' - funcs += ' for (uint32_t j = 0; j < inst->total_gpu_count; j++) {\n' - funcs += ' if (inst->phys_devs_term[j]->icd_index == i) {\n' - funcs += ' if (NULL != pPhysicalDeviceGroupProperties && max_group_count > total_group_count) {\n' - funcs += ' pPhysicalDeviceGroupProperties[total_group_count].physicalDeviceCount = 1;\n' - funcs += ' pPhysicalDeviceGroupProperties[total_group_count].physicalDevices[0] =\n' - funcs += ' inst->phys_devs_term[j]->phys_dev;\n' - funcs += ' }\n' - funcs += ' total_group_count++;\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' icd_term = icd_term->next;\n' - funcs += ' i++;\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' *pPhysicalDeviceGroupCount = total_group_count;\n' - funcs += '\n' - funcs += ' // Replace the physical devices with the value from the loader terminator\n' - funcs += ' // so we can de-reference them if needed.\n' - funcs += ' if (NULL != pPhysicalDeviceGroupProperties) {\n' - funcs += ' for (uint32_t group = 0; group < max_group_count; group++) {\n' - funcs += ' VkPhysicalDeviceGroupPropertiesKHX *cur_props = &pPhysicalDeviceGroupProperties[group];\n' - funcs += ' for (i = 0; i < cur_props->physicalDeviceCount; i++) {\n' - funcs += ' for (uint32_t term = 0; term < inst->total_gpu_count; term++) {\n' - funcs += ' if (inst->phys_devs_term[term]->phys_dev == cur_props->physicalDevices[i]) {\n' - funcs += ' cur_props->physicalDevices[i] = (VkPhysicalDevice)inst->phys_devs_term[term];\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' if (VK_SUCCESS == res && max_group_count < total_group_count) {\n' - funcs += ' res = VK_INCOMPLETE;\n' - funcs += ' }\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' return res;\n' - funcs += '}\n\n' - funcs += 'VKAPI_ATTR VkResult VKAPI_CALL\n' - funcs += 'vkGetPhysicalDeviceExternalImageFormatPropertiesNV(\n' - funcs += ' VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,\n' - funcs += ' VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,\n' - funcs += ' VkExternalMemoryHandleTypeFlagsNV externalHandleType,\n' - funcs += ' VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {\n' - funcs += ' const VkLayerInstanceDispatchTable *disp;\n' - funcs += ' VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);\n' - funcs += ' disp = loader_get_instance_layer_dispatch(physicalDevice);\n' - funcs += '\n' - funcs += ' return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(\n' - funcs += ' unwrapped_phys_dev, format, type, tiling, usage, flags,\n' - funcs += ' externalHandleType, pExternalImageFormatProperties);\n' - funcs += '}\n' - funcs += '\n' - funcs += 'VKAPI_ATTR VkResult VKAPI_CALL\n' - funcs += 'terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(\n' - funcs += ' VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,\n' - funcs += ' VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,\n' - funcs += ' VkExternalMemoryHandleTypeFlagsNV externalHandleType,\n' - funcs += ' VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {\n' - funcs += ' struct loader_physical_device_term *phys_dev_term =\n' - funcs += ' (struct loader_physical_device_term *)physicalDevice;\n' - funcs += ' struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;\n' - funcs += '\n' - funcs += ' if (!icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV) {\n' - funcs += ' if (externalHandleType) {\n' - funcs += ' return VK_ERROR_FORMAT_NOT_SUPPORTED;\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' if (!icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) {\n' - funcs += ' return VK_ERROR_INITIALIZATION_FAILED;\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' pExternalImageFormatProperties->externalMemoryFeatures = 0;\n' - funcs += ' pExternalImageFormatProperties->exportFromImportedHandleTypes = 0;\n' - funcs += ' pExternalImageFormatProperties->compatibleHandleTypes = 0;\n' - funcs += '\n' - funcs += ' return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(\n' - funcs += ' phys_dev_term->phys_dev, format, type, tiling, usage, flags,\n' - funcs += ' &pExternalImageFormatProperties->imageFormatProperties);\n' - funcs += ' }\n' - funcs += '\n' - funcs += ' return icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV(\n' - funcs += ' phys_dev_term->phys_dev, format, type, tiling, usage, flags,\n' - funcs += ' externalHandleType, pExternalImageFormatProperties);\n' - funcs += '}\n\n' - return funcs - - # # Create the appropriate trampoline (and possibly terminator) functinos def CreateTrampTermFuncs(self): entries = [] @@ -1012,7 +840,8 @@ class LoaderExtensionOutputGenerator(OutputGenerator): if ext_cmd.protect is not None: funcs += '#ifdef %s\n' % ext_cmd.protect - tramp_header = ext_cmd.cdecl.replace(";", " {\n") + func_header = ext_cmd.cdecl.replace(";", " {\n") + tramp_header = func_header.replace("VKAPI_CALL vk", "VKAPI_CALL ") return_prefix = ' ' base_name = ext_cmd.name[2:] has_surface = 0 @@ -1039,7 +868,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): requires_terminator = 1 if requires_terminator == 1: - term_header = tramp_header.replace("VKAPI_CALL vk", "VKAPI_CALL terminator_") + term_header = tramp_header.replace("VKAPI_CALL ", "VKAPI_CALL terminator_") funcs += tramp_header @@ -1240,7 +1069,6 @@ class LoaderExtensionOutputGenerator(OutputGenerator): if ext_cmd.protect is not None: funcs += '#endif // %s\n' % ext_cmd.protect - funcs += self.AddManualTrampTermFuncs() return funcs @@ -1268,18 +1096,20 @@ class LoaderExtensionOutputGenerator(OutputGenerator): if cur_cmd.protect is not None: gpa_func += '#ifdef %s\n' % cur_cmd.protect + base_name = cur_cmd.name[2:] + if (cur_cmd.ext_type == 'instance'): gpa_func += ' if (!strcmp("%s", name)) {\n' % (cur_cmd.name) gpa_func += ' *addr = (ptr_instance->enabled_known_extensions.' gpa_func += cur_cmd.ext_name[3:].lower() gpa_func += ' == 1)\n' - gpa_func += ' ? (void *)%s\n' % (cur_cmd.name) + gpa_func += ' ? (void *)%s\n' % (base_name) gpa_func += ' : NULL;\n' gpa_func += ' return true;\n' gpa_func += ' }\n' else: gpa_func += ' if (!strcmp("%s", name)) {\n' % (cur_cmd.name) - gpa_func += ' *addr = (void *)%s;\n' % (cur_cmd.name) + gpa_func += ' *addr = (void *)%s;\n' % (base_name) gpa_func += ' return true;\n' gpa_func += ' }\n' |
