Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 2 | # |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 3 | # Copyright (c) 2015-2016 The Khronos Group Inc. |
| 4 | # Copyright (c) 2015-2016 Valve Corporation |
| 5 | # Copyright (c) 2015-2016 LunarG, Inc. |
| 6 | # Copyright (c) 2015-2016 Google Inc. |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 7 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 11 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 13 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 19 | # |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 20 | # Author: Chia-I Wu <olv@lunarg.com> |
| 21 | # Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 22 | # Author: Jon Ashburn <jon@lunarg.com> |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 23 | # Author: Gwan-gyeong Mun <kk.moon@samsung.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 24 | |
| 25 | import sys |
| 26 | |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 27 | import vulkan |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 28 | |
Chia-I Wu | 6cdaedb | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 29 | def generate_get_proc_addr_check(name): |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 30 | return " if (!%s || %s[0] != 'v' || %s[1] != 'k')\n" \ |
| 31 | " return NULL;" % ((name,) * 3) |
Chia-I Wu | 6cdaedb | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 32 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 33 | class Subcommand(object): |
| 34 | def __init__(self, argv): |
| 35 | self.argv = argv |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 36 | self.headers = vulkan.headers |
| 37 | self.protos = vulkan.protos |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 38 | self.outfile = None |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 39 | |
| 40 | def run(self): |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 41 | if self.outfile: |
| 42 | with open(self.outfile, "w") as outfile: |
| 43 | outfile.write(self.generate()) |
| 44 | else: |
| 45 | print(self.generate()) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 46 | |
| 47 | def generate(self): |
| 48 | copyright = self.generate_copyright() |
| 49 | header = self.generate_header() |
| 50 | body = self.generate_body() |
| 51 | footer = self.generate_footer() |
| 52 | |
| 53 | contents = [] |
| 54 | if copyright: |
| 55 | contents.append(copyright) |
| 56 | if header: |
| 57 | contents.append(header) |
| 58 | if body: |
| 59 | contents.append(body) |
| 60 | if footer: |
| 61 | contents.append(footer) |
| 62 | |
| 63 | return "\n\n".join(contents) |
| 64 | |
| 65 | def generate_copyright(self): |
| 66 | return """/* THIS FILE IS GENERATED. DO NOT EDIT. */ |
| 67 | |
| 68 | /* |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 69 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 70 | * Copyright (c) 2015-2016 Valve Corporation |
| 71 | * Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 72 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 73 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 74 | * you may not use this file except in compliance with the License. |
| 75 | * You may obtain a copy of the License at |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 76 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 77 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 78 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 79 | * Unless required by applicable law or agreed to in writing, software |
| 80 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 81 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 82 | * See the License for the specific language governing permissions and |
| 83 | * limitations under the License. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 84 | * |
| 85 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 86 | */""" |
| 87 | |
| 88 | def generate_header(self): |
Chia-I Wu | 6bdf019 | 2014-09-13 13:36:06 +0800 | [diff] [blame] | 89 | return "\n".join(["#include <" + h + ">" for h in self.headers]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 90 | |
| 91 | def generate_body(self): |
| 92 | pass |
| 93 | |
| 94 | def generate_footer(self): |
| 95 | pass |
| 96 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 97 | class DispatchTableOpsSubcommand(Subcommand): |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 98 | def __init__(self, argv): |
| 99 | self.argv = argv |
| 100 | self.headers = vulkan.headers_all |
| 101 | self.protos = vulkan.protos_all |
| 102 | self.outfile = None |
| 103 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 104 | def run(self): |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 105 | if len(self.argv) < 1: |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 106 | print("DispatchTableOpsSubcommand: <prefix> unspecified") |
| 107 | return |
| 108 | |
| 109 | self.prefix = self.argv[0] |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 110 | |
| 111 | if len(self.argv) > 2: |
| 112 | print("DispatchTableOpsSubcommand: <prefix> [outfile]") |
| 113 | return |
| 114 | |
| 115 | if len(self.argv) == 2: |
| 116 | self.outfile = self.argv[1] |
| 117 | |
Michael Lentine | 695f2c2 | 2015-09-09 12:39:13 -0700 | [diff] [blame] | 118 | super(DispatchTableOpsSubcommand, self).run() |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 119 | |
| 120 | def generate_header(self): |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 121 | return "\n".join(["#include <vulkan/vulkan.h>", |
| 122 | "#include <vulkan/vk_layer.h>", |
Jon Ashburn | 1dd0a5c | 2015-05-04 09:16:41 -0600 | [diff] [blame] | 123 | "#include <string.h>"]) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 124 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 125 | def _generate_init_dispatch(self, type): |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 126 | stmts = [] |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 127 | func = [] |
| 128 | if type == "device": |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 129 | # GPA has to be first one and uses wrapped object |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 130 | stmts.append(" memset(table, 0, sizeof(*table));") |
| 131 | stmts.append(" // Core device function pointers") |
| 132 | stmts.append(" table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) gpa(device, \"vkGetDeviceProcAddr\");") |
| 133 | |
| 134 | KHR_printed = False |
| 135 | EXT_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 136 | Win32_printed = False |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 137 | XLIB_printed = False |
| 138 | XCB_printed = False |
| 139 | MIR_printed = False |
| 140 | WAY_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 141 | Android_printed = False |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 142 | for proto in self.protos: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 143 | if proto.name == "CreateInstance" or proto.name == "EnumerateInstanceExtensionProperties" or \ |
| 144 | proto.name == "EnumerateInstanceLayerProperties" or proto.params[0].ty == "VkInstance" or \ |
| 145 | proto.params[0].ty == "VkPhysicalDevice" or proto.name == "GetDeviceProcAddr": |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 146 | continue |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 147 | if Win32_printed and 'Win32' not in proto.name: |
| 148 | stmts.append("#endif // VK_USE_PLATFORM_WIN32_KHR") |
| 149 | Win32_printed = False |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 150 | if XLIB_printed and 'Xlib' not in proto.name: |
| 151 | stmts.append("#endif // VK_USE_PLATFORM_XLIB_KHR") |
| 152 | XLIB_printed = False |
| 153 | if XCB_printed and 'Xcb' not in proto.name: |
| 154 | stmts.append("#endif // VK_USE_PLATFORM_XCB_KHR") |
| 155 | XCB_printed = False |
| 156 | if MIR_printed and 'Mir' not in proto.name: |
| 157 | stmts.append("#endif // VK_USE_PLATFORM_MIR_KHR") |
| 158 | MIR_printed = False |
| 159 | if WAY_printed and 'Wayland' not in proto.name: |
| 160 | stmts.append("#endif // VK_USE_PLATFORM_WAYLAND_KHR") |
| 161 | WAY_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 162 | if Android_printed and 'Android' not in proto.name: |
| 163 | stmts.append("#endif // VK_USE_PLATFORM_ANDROID_KHR") |
| 164 | Android_printed = False |
| 165 | if 'KHR' in proto.name and 'Win32' in proto.name: |
| 166 | if not Win32_printed: |
| 167 | stmts.append("#ifdef VK_USE_PLATFORM_WIN32_KHR") |
| 168 | Win32_printed = True |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 169 | if 'KHR' in proto.name and 'Xlib' in proto.name: |
| 170 | if not XLIB_printed: |
| 171 | stmts.append("#ifdef VK_USE_PLATFORM_XLIB_KHR") |
| 172 | XLIB_printed = True |
| 173 | if 'KHR' in proto.name and 'Xcb' in proto.name: |
| 174 | if not XCB_printed: |
| 175 | stmts.append("#ifdef VK_USE_PLATFORM_XCB_KHR") |
| 176 | XCB_printed = True |
| 177 | if 'KHR' in proto.name and 'Mir' in proto.name: |
| 178 | if not MIR_printed: |
| 179 | stmts.append("#ifdef VK_USE_PLATFORM_MIR_KHR") |
| 180 | MIR_printed = True |
| 181 | if 'KHR' in proto.name and 'Wayland' in proto.name: |
| 182 | if not WAY_printed: |
| 183 | stmts.append("#ifdef VK_USE_PLATFORM_WAYLAND_KHR") |
| 184 | WAY_printed = True |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 185 | if 'KHR' in proto.name and 'Android' in proto.name: |
| 186 | if not Android_printed: |
| 187 | stmts.append("#ifdef VK_USE_PLATFORM_ANDROID_KHR") |
| 188 | Android_printed = True |
| 189 | if 'KHR' in proto.name and not KHR_printed: |
| 190 | stmts.append(" // KHR device extension function pointers") |
| 191 | KHR_printed = True |
| 192 | if 'EXT' in proto.name and not EXT_printed: |
| 193 | stmts.append(" // EXT device extension function pointers") |
| 194 | EXT_printed = True |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 195 | stmts.append(" table->%s = (PFN_vk%s) gpa(device, \"vk%s\");" % |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 196 | (proto.name, proto.name, proto.name)) |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 197 | func.append("static inline void %s_init_device_dispatch_table(VkDevice device," |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 198 | % self.prefix) |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 199 | func.append("%s VkLayerDispatchTable *table," |
| 200 | % (" " * len(self.prefix))) |
| 201 | func.append("%s PFN_vkGetDeviceProcAddr gpa)" |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 202 | % (" " * len(self.prefix))) |
| 203 | else: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 204 | stmts.append(" memset(table, 0, sizeof(*table));") |
| 205 | stmts.append(" // Core instance function pointers") |
| 206 | stmts.append(" table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(instance, \"vkGetInstanceProcAddr\");") |
| 207 | |
| 208 | KHR_printed = False |
| 209 | EXT_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 210 | Win32_printed = False |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 211 | XLIB_printed = False |
| 212 | XCB_printed = False |
| 213 | MIR_printed = False |
| 214 | WAY_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 215 | Android_printed = False |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 216 | for proto in self.protos: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 217 | if proto.params[0].ty != "VkInstance" and proto.params[0].ty != "VkPhysicalDevice" or \ |
| 218 | proto.name == "CreateDevice" or proto.name == "GetInstanceProcAddr": |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 219 | continue |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 220 | if Win32_printed and 'Win32' not in proto.name: |
| 221 | stmts.append("#endif // VK_USE_PLATFORM_WIN32_KHR") |
| 222 | Win32_printed = False |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 223 | if XLIB_printed and 'Xlib' not in proto.name: |
| 224 | stmts.append("#endif // VK_USE_PLATFORM_XLIB_KHR") |
| 225 | XLIB_printed = False |
| 226 | if XCB_printed and 'Xcb' not in proto.name: |
| 227 | stmts.append("#endif // VK_USE_PLATFORM_XCB_KHR") |
| 228 | XCB_printed = False |
| 229 | if MIR_printed and 'Mir' not in proto.name: |
| 230 | stmts.append("#endif // VK_USE_PLATFORM_MIR_KHR") |
| 231 | MIR_printed = False |
| 232 | if WAY_printed and 'Wayland' not in proto.name: |
| 233 | stmts.append("#endif // VK_USE_PLATFORM_WAYLAND_KHR") |
| 234 | WAY_printed = False |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 235 | if Android_printed and 'Android' not in proto.name: |
| 236 | stmts.append("#endif // VK_USE_PLATFORM_ANDROID_KHR") |
| 237 | Android_printed = False |
| 238 | if 'KHR' in proto.name and 'Win32' in proto.name: |
| 239 | if not Win32_printed: |
| 240 | stmts.append("#ifdef VK_USE_PLATFORM_WIN32_KHR") |
| 241 | Win32_printed = True |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 242 | if 'KHR' in proto.name and 'Xlib' in proto.name: |
| 243 | if not XLIB_printed: |
| 244 | stmts.append("#ifdef VK_USE_PLATFORM_XLIB_KHR") |
| 245 | XLIB_printed = True |
| 246 | if 'KHR' in proto.name and 'Xcb' in proto.name: |
| 247 | if not XCB_printed: |
| 248 | stmts.append("#ifdef VK_USE_PLATFORM_XCB_KHR") |
| 249 | XCB_printed = True |
| 250 | if 'KHR' in proto.name and 'Mir' in proto.name: |
| 251 | if not MIR_printed: |
| 252 | stmts.append("#ifdef VK_USE_PLATFORM_MIR_KHR") |
| 253 | MIR_printed = True |
| 254 | if 'KHR' in proto.name and 'Wayland' in proto.name: |
| 255 | if not WAY_printed: |
| 256 | stmts.append("#ifdef VK_USE_PLATFORM_WAYLAND_KHR") |
| 257 | WAY_printed = True |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 258 | if 'KHR' in proto.name and 'Android' in proto.name: |
| 259 | if not Android_printed: |
| 260 | stmts.append("#ifdef VK_USE_PLATFORM_ANDROID_KHR") |
| 261 | Android_printed = True |
| 262 | if 'KHR' in proto.name and not KHR_printed: |
| 263 | stmts.append(" // KHR instance extension function pointers") |
| 264 | KHR_printed = True |
| 265 | if 'EXT' in proto.name and not EXT_printed: |
| 266 | stmts.append(" // EXT instance extension function pointers") |
| 267 | EXT_printed = True |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 268 | stmts.append(" table->%s = (PFN_vk%s) gpa(instance, \"vk%s\");" % |
| 269 | (proto.name, proto.name, proto.name)) |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 270 | func.append("static inline void %s_init_instance_dispatch_table(" % self.prefix) |
| 271 | func.append("%s VkInstance instance," % (" " * len(self.prefix))) |
| 272 | func.append("%s VkLayerInstanceDispatchTable *table," % (" " * len(self.prefix))) |
| 273 | func.append("%s PFN_vkGetInstanceProcAddr gpa)" % (" " * len(self.prefix))) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 274 | func.append("{") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 275 | func.append("%s" % "\n".join(stmts)) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 276 | func.append("}") |
| 277 | |
| 278 | return "\n".join(func) |
| 279 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 280 | def generate_body(self): |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 281 | body = [self._generate_init_dispatch("device"), |
| 282 | self._generate_init_dispatch("instance")] |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 283 | |
| 284 | return "\n\n".join(body) |
| 285 | |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 286 | class WinDefFileSubcommand(Subcommand): |
| 287 | def run(self): |
| 288 | library_exports = { |
| 289 | "all": [], |
| 290 | "icd": [ |
Jon Ashburn | f5e9754 | 2016-01-07 09:46:26 -0700 | [diff] [blame] | 291 | "vk_icdGetInstanceProcAddr", |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 292 | ], |
| 293 | "layer": [ |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 294 | "vkGetInstanceProcAddr", |
| 295 | "vkGetDeviceProcAddr", |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 296 | "vkEnumerateInstanceLayerProperties", |
| 297 | "vkEnumerateInstanceExtensionProperties" |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 298 | ], |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 299 | "layer_multi": [ |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 300 | "multi2GetInstanceProcAddr", |
| 301 | "multi1GetDeviceProcAddr" |
| 302 | ] |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 303 | } |
| 304 | |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 305 | if len(self.argv) < 2 or len(self.argv) > 3 or self.argv[1] not in library_exports: |
| 306 | print("WinDefFileSubcommand: <library-name> {%s} [outfile]" % |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 307 | "|".join(library_exports.keys())) |
| 308 | return |
| 309 | |
| 310 | self.library = self.argv[0] |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 311 | if self.library == "VkLayer_multi": |
| 312 | self.exports = library_exports["layer_multi"] |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 313 | else: |
| 314 | self.exports = library_exports[self.argv[1]] |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 315 | |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 316 | if len(self.argv) == 3: |
| 317 | self.outfile = self.argv[2] |
| 318 | |
Jamie Madill | c001885 | 2016-04-04 11:20:24 -0400 | [diff] [blame] | 319 | super(WinDefFileSubcommand, self).run() |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 320 | |
| 321 | def generate_copyright(self): |
| 322 | return """; THIS FILE IS GENERATED. DO NOT EDIT. |
| 323 | |
| 324 | ;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 325 | ; Vulkan |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 326 | ; |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 327 | ; Copyright (c) 2015-2016 The Khronos Group Inc. |
| 328 | ; Copyright (c) 2015-2016 Valve Corporation |
| 329 | ; Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 330 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 331 | ; Licensed under the Apache License, Version 2.0 (the "License"); |
| 332 | ; you may not use this file except in compliance with the License. |
| 333 | ; You may obtain a copy of the License at |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 334 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 335 | ; http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 336 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 337 | ; Unless required by applicable law or agreed to in writing, software |
| 338 | ; distributed under the License is distributed on an "AS IS" BASIS, |
| 339 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 340 | ; See the License for the specific language governing permissions and |
| 341 | ; limitations under the License. |
Courtney Goeltzenleuchter | bdde0b2 | 2015-12-16 14:57:27 -0700 | [diff] [blame] | 342 | ; |
| 343 | ; Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 344 | ;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;""" |
| 345 | |
| 346 | def generate_header(self): |
| 347 | return "; The following is required on Windows, for exporting symbols from the DLL" |
| 348 | |
| 349 | def generate_body(self): |
| 350 | body = [] |
| 351 | |
| 352 | body.append("LIBRARY " + self.library) |
| 353 | body.append("EXPORTS") |
| 354 | |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 355 | for proto in self.exports: |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 356 | if self.library != "VkLayerSwapchain" or proto != "vkEnumerateInstanceExtensionProperties" and proto != "vkEnumerateInstanceLayerProperties": |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 357 | body.append( proto) |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 358 | |
| 359 | return "\n".join(body) |
| 360 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 361 | def main(): |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 362 | wsi = { |
| 363 | "Win32", |
| 364 | "Android", |
| 365 | "Xcb", |
| 366 | "Xlib", |
| 367 | "Wayland", |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 368 | "Mir", |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 369 | "Display", |
| 370 | "AllPlatforms" |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 371 | } |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 372 | subcommands = { |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 373 | "dispatch-table-ops": DispatchTableOpsSubcommand, |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 374 | "win-def-file": WinDefFileSubcommand, |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 375 | } |
| 376 | |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 377 | if len(sys.argv) < 3 or sys.argv[1] not in wsi or sys.argv[2] not in subcommands: |
| 378 | print("Usage: %s <wsi> <subcommand> [options]" % sys.argv[0]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 379 | print |
| 380 | print("Available sucommands are: %s" % " ".join(subcommands)) |
| 381 | exit(1) |
| 382 | |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 383 | subcmd = subcommands[sys.argv[2]](sys.argv[3:]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 384 | subcmd.run() |
| 385 | |
| 386 | if __name__ == "__main__": |
| 387 | main() |