diff options
| author | Lenny Komow <lenny@lunarg.com> | 2017-05-22 16:17:05 -0600 |
|---|---|---|
| committer | Lenny Komow <lenny@lunarg.com> | 2017-05-23 17:07:47 -0600 |
| commit | f6f0dcffcb5f965c0c693e27492f3ef56a62efea (patch) | |
| tree | 82c47280a4503bdd96c48567a56c7706b99ecd49 /scripts/loader_extension_generator.py | |
| parent | 903d80f2b6627ff7f808934f7973b06f878d9e79 (diff) | |
| download | usermoji-f6f0dcffcb5f965c0c693e27492f3ef56a62efea.tar.xz | |
loader: Fix extension surface params
Change-Id: I310d6d356b5c9377ff8285ee123def989e95b142
Diffstat (limited to 'scripts/loader_extension_generator.py')
| -rw-r--r-- | scripts/loader_extension_generator.py | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py index 015e774c..8aa52da3 100644 --- a/scripts/loader_extension_generator.py +++ b/scripts/loader_extension_generator.py @@ -865,19 +865,42 @@ class LoaderExtensionOutputGenerator(OutputGenerator): return_prefix = ' ' base_name = ext_cmd.name[2:] has_surface = 0 + update_structure_surface = 0 + update_structure_string = '' requires_terminator = 0 surface_var_name = '' phys_dev_var_name = '' has_return_type = False + always_use_param_name = True + surface_type_to_replace = '' + surface_name_replacement = '' + physdev_type_to_replace = '' + physdev_name_replacement = '' for param in ext_cmd.params: if param.type == 'VkSurfaceKHR': has_surface = 1 surface_var_name = param.name requires_terminator = 1 + always_use_param_name = False + surface_type_to_replace = 'VkSurfaceKHR' + surface_name_replacement = 'icd_surface->real_icd_surfaces[icd_index]' + if param.type == 'VkPhysicalDeviceSurfaceInfo2KHR': + has_surface = 1 + surface_var_name = param.name + '->surface' + requires_terminator = 1 + update_structure_surface = 1 + update_structure_string = ' VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo;\n' + update_structure_string += ' info_copy.surface = icd_surface->real_icd_surfaces[icd_index];\n' + always_use_param_name = False + surface_type_to_replace = 'VkPhysicalDeviceSurfaceInfo2KHR' + surface_name_replacement = '&info_copy' if param.type == 'VkPhysicalDevice': requires_terminator = 1 phys_dev_var_name = param.name + always_use_param_name = False + physdev_type_to_replace = 'VkPhysicalDevice' + physdev_name_replacement = 'phys_dev_term->phys_dev' if (ext_cmd.return_type != None): return_prefix += 'return ' @@ -942,9 +965,14 @@ class LoaderExtensionOutputGenerator(OutputGenerator): funcs += ' }\n' if has_surface == 1: - funcs += ' VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);\n' + funcs += ' VkIcdSurface *icd_surface = (VkIcdSurface *)(%s);\n' % (surface_var_name) funcs += ' uint8_t icd_index = phys_dev_term->icd_index;\n' funcs += ' if (NULL != icd_surface->real_icd_surfaces && NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {\n' + + # If there's a structure with a surface, we need to update its internals with the correct surface for the ICD + if update_structure_surface == 1: + funcs += update_structure_string + funcs += ' ' + return_prefix + 'icd_term->dispatch.' funcs += base_name funcs += '(' @@ -953,10 +981,13 @@ class LoaderExtensionOutputGenerator(OutputGenerator): if count != 0: funcs += ', ' - if param.type == 'VkPhysicalDevice': - funcs += 'phys_dev_term->phys_dev' - elif param.type == 'VkSurfaceKHR': - funcs += 'icd_surface->real_icd_surfaces[icd_index]' + if not always_use_param_name: + if surface_type_to_replace and surface_type_to_replace == param.type: + funcs += surface_name_replacement + elif physdev_type_to_replace and physdev_type_to_replace == param.type: + funcs += physdev_name_replacement + else: + funcs += param.name else: funcs += param.name |
