diff options
| author | Lenny Komow <lenny@lunarg.com> | 2018-03-29 13:25:38 -0600 |
|---|---|---|
| committer | Lenny Komow <lenny@lunarg.com> | 2018-03-29 16:50:20 -0600 |
| commit | 8df2c26952f6748d964d146d1ac592931ef61bda (patch) | |
| tree | 061d954ee45dc57574e33df80bcf39b9fa0b65c4 /scripts | |
| parent | 249440ac0c67ed804dd1372ff1ce1f5127c83702 (diff) | |
| download | usermoji-8df2c26952f6748d964d146d1ac592931ef61bda.tar.xz | |
loader: Fix GetDeviceProcAddr with terminators
Fix a bug where vkGetDeviceProcAddr would return a valid pointer for
any device command that used a custom terminator, even if it was part
of an extension which wasn't enabled
Change-Id: I3b088fe0c850fbaa5f7285ced81552273bc38e7e
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/loader_extension_generator.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py index 7f38de91..d9f5564c 100644 --- a/scripts/loader_extension_generator.py +++ b/scripts/loader_extension_generator.py @@ -383,6 +383,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): protos = '' protos += '// Structures defined externally, but used here\n' protos += 'struct loader_instance;\n' + protos += 'struct loader_device;\n' protos += 'struct loader_icd_term;\n' protos += 'struct loader_dev_dispatch_table;\n' protos += '\n' @@ -401,7 +402,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): protos += '// Extension interception for vkGetDeviceProcAddr function, so we can return\n' protos += '// an appropriate terminator if this is one of those few device commands requiring\n' protos += '// a terminator.\n' - protos += 'PFN_vkVoidFunction get_extension_device_proc_terminator(const char *pName);\n' + protos += 'PFN_vkVoidFunction get_extension_device_proc_terminator(struct loader_device *dev, const char *pName);\n' protos += '\n' protos += '// Dispatch table properly filled in with appropriate terminators for the\n' protos += '// supported extensions.\n' @@ -1365,28 +1366,38 @@ class LoaderExtensionOutputGenerator(OutputGenerator): term_func += '// Some device commands still need a terminator because the loader needs to unwrap something about them.\n' term_func += '// In many cases, the item needing unwrapping is a VkPhysicalDevice or VkSurfaceKHR object. But there may be other items\n' term_func += '// in the future.\n' - term_func += 'PFN_vkVoidFunction get_extension_device_proc_terminator(const char *pName) {\n' + term_func += 'PFN_vkVoidFunction get_extension_device_proc_terminator(struct loader_device *dev, const char *pName) {\n' term_func += ' PFN_vkVoidFunction addr = NULL;\n' count = 0 + is_extension = False for ext_cmd in self.ext_commands: if ext_cmd.name in DEVICE_CMDS_NEED_TERM: if ext_cmd.ext_name != cur_extension_name: + if count > 0: + count = 0; + term_func += ' }\n' + if is_extension: + term_func += ' }\n' + is_extension = False + if 'VK_VERSION_' in ext_cmd.ext_name: term_func += '\n // ---- Core %s commands\n' % ext_cmd.ext_name[11:] else: term_func += '\n // ---- %s extension commands\n' % ext_cmd.ext_name + term_func += ' if (dev->extensions.%s_enabled) {\n' % ext_cmd.ext_name[3:].lower() + is_extension = True cur_extension_name = ext_cmd.ext_name if ext_cmd.protect is not None: term_func += '#ifdef %s\n' % ext_cmd.protect if count == 0: - term_func += ' if' + term_func += ' if' else: - term_func += ' } else if' + term_func += ' } else if' term_func += '(!strcmp(pName, "%s")) {\n' % (ext_cmd.name) - term_func += ' addr = (PFN_vkVoidFunction)terminator_%s;\n' % (ext_cmd.name[2:]) + term_func += ' addr = (PFN_vkVoidFunction)terminator_%s;\n' % (ext_cmd.name[2:]) if ext_cmd.protect is not None: term_func += '#endif // %s\n' % ext_cmd.protect @@ -1394,6 +1405,8 @@ class LoaderExtensionOutputGenerator(OutputGenerator): count += 1 if count > 0: + term_func += ' }\n' + if is_extension: term_func += ' }\n' term_func += ' return addr;\n' |
