1 " ""VK API description""" 2 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. 7 # 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 11 # 12 # http://www.apache.org/licenses/LICENSE-2.0 13 # 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. 19 # 20 # Author: Chia-I Wu <olv (at] lunarg.com> 21 # Author: Jon Ashburn <jon (at] lunarg.com> 22 # Author: Courtney Goeltzenleuchter <courtney (at] LunarG.com> 23 # Author: Tobin Ehlis <tobin (at] lunarg.com> 24 # Author: Tony Barbour <tony (at] LunarG.com> 25 # Author: Gwan-gyeong Mun <kk.moon (at] samsung.com> 26 27 class Param(object): 28 """A function parameter.""" 29 30 def __init__(self, ty, name): 31 self.ty = ty 32 self.name = name 33 34 def c(self): 35 """Return the parameter in C.""" 36 idx = self.ty.find("[") 37 38 # arrays have a different syntax 39 if idx >= 0: 40 return "%s %s%s" % (self.ty[:idx], self.name, self.ty[idx:]) 41 else: 42 return "%s %s" % (self.ty, self.name) 43 44 def indirection_level(self): 45 """Return the level of indirection.""" 46 return self.ty.count("*") + self.ty.count("[") 47 48 def dereferenced_type(self, level=0): 49 """Return the type after dereferencing.""" 50 if not level: 51 level = self.indirection_level() 52 53 deref = self.ty if level else "" 54 while level > 0: 55 idx = deref.rfind("[") 56 if idx < 0: 57 idx = deref.rfind("*") 58 if idx < 0: 59 deref = "" 60 break 61 deref = deref[:idx] 62 level -= 1; 63 64 return deref.rstrip() 65 66 def __repr__(self): 67 return "Param(\"%s\", \"%s\")" % (self.ty, self.name) 68 69 class Proto(object): 70 """A function prototype.""" 71 72 def __init__(self, ret, name, params=[]): 73 # the proto has only a param 74 if not isinstance(params, list): 75 params = [params] 76 77 self.ret = ret 78 self.name = name 79 self.params = params 80 81 def c_params(self, need_type=True, need_name=True): 82 """Return the parameter list in C.""" 83 if self.params and (need_type or need_name): 84 if need_type and need_name: 85 return ", ".join([param.c() for param in self.params]) 86 elif need_type: 87 return ", ".join([param.ty for param in self.params]) 88 else: 89 return ", ".join([param.name for param in self.params]) 90 else: 91 return "void" if need_type else "" 92 93 def c_decl(self, name, attr="", typed=False, need_param_names=True): 94 """Return a named declaration in C.""" 95 if typed: 96 return "%s (%s*%s)(%s)" % ( 97 self.ret, 98 attr + "_PTR " if attr else "", 99 name, 100 self.c_params(need_name=need_param_names)) 101 else: 102 return "%s%s %s%s(%s)" % ( 103 attr + "_ATTR " if attr else "", 104 self.ret, 105 attr + "_CALL " if attr else "", 106 name, 107 self.c_params(need_name=need_param_names)) 108 109 def c_pretty_decl(self, name, attr=""): 110 """Return a named declaration in C, with vulkan.h formatting.""" 111 plist = [] 112 for param in self.params: 113 idx = param.ty.find("[") 114 if idx < 0: 115 idx = len(param.ty) 116 117 pad = 44 - idx 118 if pad <= 0: 119 pad = 1 120 121 plist.append(" %s%s%s%s" % (param.ty[:idx], 122 " " * pad, param.name, param.ty[idx:])) 123 124 return "%s%s %s%s(\n%s)" % ( 125 attr + "_ATTR " if attr else "", 126 self.ret, 127 attr + "_CALL " if attr else "", 128 name, 129 ",\n".join(plist)) 130 131 def c_typedef(self, suffix="", attr=""): 132 """Return the typedef for the prototype in C.""" 133 return self.c_decl(self.name + suffix, attr=attr, typed=True) 134 135 def c_func(self, prefix="", attr=""): 136 """Return the prototype in C.""" 137 return self.c_decl(prefix + self.name, attr=attr, typed=False) 138 139 def c_call(self): 140 """Return a call to the prototype in C.""" 141 return "%s(%s)" % (self.name, self.c_params(need_type=False)) 142 143 def object_in_params(self): 144 """Return the params that are simple VK objects and are inputs.""" 145 return [param for param in self.params if param.ty in objects] 146 147 def object_out_params(self): 148 """Return the params that are simple VK objects and are outputs.""" 149 return [param for param in self.params 150 if param.dereferenced_type() in objects] 151 152 def __repr__(self): 153 param_strs = [] 154 for param in self.params: 155 param_strs.append(str(param)) 156 param_str = " [%s]" % (",\n ".join(param_strs)) 157 158 return "Proto(\"%s\", \"%s\",\n%s)" % \ 159 (self.ret, self.name, param_str) 160 161 class Extension(object): 162 def __init__(self, name, headers, objects, protos): 163 self.name = name 164 self.headers = headers 165 self.objects = objects 166 self.protos = protos 167 168 def __repr__(self): 169 lines = [] 170 lines.append("Extension(") 171 lines.append(" name=\"%s\"," % self.name) 172 lines.append(" headers=[\"%s\"]," % 173 "\", \"".join(self.headers)) 174 175 lines.append(" objects=[") 176 for obj in self.objects: 177 lines.append(" \"%s\"," % obj) 178 lines.append(" ],") 179 180 lines.append(" protos=[") 181 for proto in self.protos: 182 param_lines = str(proto).splitlines() 183 param_lines[-1] += ",\n" if proto != self.protos[-1] else "," 184 for p in param_lines: 185 lines.append(" " + p) 186 lines.append(" ],") 187 lines.append(")") 188 189 return "\n".join(lines) 190 191 # VK core API 192 core = Extension( 193 name="VK_CORE", 194 headers=["vulkan/vulkan.h"], 195 objects=[ 196 "VkInstance", 197 "VkPhysicalDevice", 198 "VkDevice", 199 "VkQueue", 200 "VkSemaphore", 201 "VkCommandBuffer", 202 "VkFence", 203 "VkDeviceMemory", 204 "VkBuffer", 205 "VkImage", 206 "VkEvent", 207 "VkQueryPool", 208 "VkBufferView", 209 "VkImageView", 210 "VkShaderModule", 211 "VkPipelineCache", 212 "VkPipelineLayout", 213 "VkRenderPass", 214 "VkPipeline", 215 "VkDescriptorSetLayout", 216 "VkSampler", 217 "VkDescriptorPool", 218 "VkDescriptorSet", 219 "VkFramebuffer", 220 "VkCommandPool", 221 ], 222 protos=[ 223 Proto("VkResult", "CreateInstance", 224 [Param("const VkInstanceCreateInfo*", "pCreateInfo"), 225 Param("const VkAllocationCallbacks*", "pAllocator"), 226 Param("VkInstance*", "pInstance")]), 227 228 Proto("void", "DestroyInstance", 229 [Param("VkInstance", "instance"), 230 Param("const VkAllocationCallbacks*", "pAllocator")]), 231 232 Proto("VkResult", "EnumeratePhysicalDevices", 233 [Param("VkInstance", "instance"), 234 Param("uint32_t*", "pPhysicalDeviceCount"), 235 Param("VkPhysicalDevice*", "pPhysicalDevices")]), 236 237 Proto("void", "GetPhysicalDeviceFeatures", 238 [Param("VkPhysicalDevice", "physicalDevice"), 239 Param("VkPhysicalDeviceFeatures*", "pFeatures")]), 240 241 Proto("void", "GetPhysicalDeviceFormatProperties", 242 [Param("VkPhysicalDevice", "physicalDevice"), 243 Param("VkFormat", "format"), 244 Param("VkFormatProperties*", "pFormatProperties")]), 245 246 Proto("VkResult", "GetPhysicalDeviceImageFormatProperties", 247 [Param("VkPhysicalDevice", "physicalDevice"), 248 Param("VkFormat", "format"), 249 Param("VkImageType", "type"), 250 Param("VkImageTiling", "tiling"), 251 Param("VkImageUsageFlags", "usage"), 252 Param("VkImageCreateFlags", "flags"), 253 Param("VkImageFormatProperties*", "pImageFormatProperties")]), 254 255 Proto("void", "GetPhysicalDeviceProperties", 256 [Param("VkPhysicalDevice", "physicalDevice"), 257 Param("VkPhysicalDeviceProperties*", "pProperties")]), 258 259 Proto("void", "GetPhysicalDeviceQueueFamilyProperties", 260 [Param("VkPhysicalDevice", "physicalDevice"), 261 Param("uint32_t*", "pQueueFamilyPropertyCount"), 262 Param("VkQueueFamilyProperties*", "pQueueFamilyProperties")]), 263 264 Proto("void", "GetPhysicalDeviceMemoryProperties", 265 [Param("VkPhysicalDevice", "physicalDevice"), 266 Param("VkPhysicalDeviceMemoryProperties*", "pMemoryProperties")]), 267 268 Proto("PFN_vkVoidFunction", "GetInstanceProcAddr", 269 [Param("VkInstance", "instance"), 270 Param("const char*", "pName")]), 271 272 Proto("PFN_vkVoidFunction", "GetDeviceProcAddr", 273 [Param("VkDevice", "device"), 274 Param("const char*", "pName")]), 275 276 Proto("VkResult", "CreateDevice", 277 [Param("VkPhysicalDevice", "physicalDevice"), 278 Param("const VkDeviceCreateInfo*", "pCreateInfo"), 279 Param("const VkAllocationCallbacks*", "pAllocator"), 280 Param("VkDevice*", "pDevice")]), 281 282 Proto("void", "DestroyDevice", 283 [Param("VkDevice", "device"), 284 Param("const VkAllocationCallbacks*", "pAllocator")]), 285 286 Proto("VkResult", "EnumerateInstanceExtensionProperties", 287 [Param("const char*", "pLayerName"), 288 Param("uint32_t*", "pPropertyCount"), 289 Param("VkExtensionProperties*", "pProperties")]), 290 291 Proto("VkResult", "EnumerateDeviceExtensionProperties", 292 [Param("VkPhysicalDevice", "physicalDevice"), 293 Param("const char*", "pLayerName"), 294 Param("uint32_t*", "pPropertyCount"), 295 Param("VkExtensionProperties*", "pProperties")]), 296 297 Proto("VkResult", "EnumerateInstanceLayerProperties", 298 [Param("uint32_t*", "pPropertyCount"), 299 Param("VkLayerProperties*", "pProperties")]), 300 301 Proto("VkResult", "EnumerateDeviceLayerProperties", 302 [Param("VkPhysicalDevice", "physicalDevice"), 303 Param("uint32_t*", "pPropertyCount"), 304 Param("VkLayerProperties*", "pProperties")]), 305 306 Proto("void", "GetDeviceQueue", 307 [Param("VkDevice", "device"), 308 Param("uint32_t", "queueFamilyIndex"), 309 Param("uint32_t", "queueIndex"), 310 Param("VkQueue*", "pQueue")]), 311 312 Proto("VkResult", "QueueSubmit", 313 [Param("VkQueue", "queue"), 314 Param("uint32_t", "submitCount"), 315 Param("const VkSubmitInfo*", "pSubmits"), 316 Param("VkFence", "fence")]), 317 318 Proto("VkResult", "QueueWaitIdle", 319 [Param("VkQueue", "queue")]), 320 321 Proto("VkResult", "DeviceWaitIdle", 322 [Param("VkDevice", "device")]), 323 324 Proto("VkResult", "AllocateMemory", 325 [Param("VkDevice", "device"), 326 Param("const VkMemoryAllocateInfo*", "pAllocateInfo"), 327 Param("const VkAllocationCallbacks*", "pAllocator"), 328 Param("VkDeviceMemory*", "pMemory")]), 329 330 Proto("void", "FreeMemory", 331 [Param("VkDevice", "device"), 332 Param("VkDeviceMemory", "memory"), 333 Param("const VkAllocationCallbacks*", "pAllocator")]), 334 335 Proto("VkResult", "MapMemory", 336 [Param("VkDevice", "device"), 337 Param("VkDeviceMemory", "memory"), 338 Param("VkDeviceSize", "offset"), 339 Param("VkDeviceSize", "size"), 340 Param("VkMemoryMapFlags", "flags"), 341 Param("void**", "ppData")]), 342 343 Proto("void", "UnmapMemory", 344 [Param("VkDevice", "device"), 345 Param("VkDeviceMemory", "memory")]), 346 347 Proto("VkResult", "FlushMappedMemoryRanges", 348 [Param("VkDevice", "device"), 349 Param("uint32_t", "memoryRangeCount"), 350 Param("const VkMappedMemoryRange*", "pMemoryRanges")]), 351 352 Proto("VkResult", "InvalidateMappedMemoryRanges", 353 [Param("VkDevice", "device"), 354 Param("uint32_t", "memoryRangeCount"), 355 Param("const VkMappedMemoryRange*", "pMemoryRanges")]), 356 357 Proto("void", "GetDeviceMemoryCommitment", 358 [Param("VkDevice", "device"), 359 Param("VkDeviceMemory", "memory"), 360 Param("VkDeviceSize*", "pCommittedMemoryInBytes")]), 361 362 Proto("VkResult", "BindBufferMemory", 363 [Param("VkDevice", "device"), 364 Param("VkBuffer", "buffer"), 365 Param("VkDeviceMemory", "memory"), 366 Param("VkDeviceSize", "memoryOffset")]), 367 368 Proto("VkResult", "BindImageMemory", 369 [Param("VkDevice", "device"), 370 Param("VkImage", "image"), 371 Param("VkDeviceMemory", "memory"), 372 Param("VkDeviceSize", "memoryOffset")]), 373 374 Proto("void", "GetBufferMemoryRequirements", 375 [Param("VkDevice", "device"), 376 Param("VkBuffer", "buffer"), 377 Param("VkMemoryRequirements*", "pMemoryRequirements")]), 378 379 Proto("void", "GetImageMemoryRequirements", 380 [Param("VkDevice", "device"), 381 Param("VkImage", "image"), 382 Param("VkMemoryRequirements*", "pMemoryRequirements")]), 383 384 Proto("void", "GetImageSparseMemoryRequirements", 385 [Param("VkDevice", "device"), 386 Param("VkImage", "image"), 387 Param("uint32_t*", "pSparseMemoryRequirementCount"), 388 Param("VkSparseImageMemoryRequirements*", "pSparseMemoryRequirements")]), 389 390 Proto("void", "GetPhysicalDeviceSparseImageFormatProperties", 391 [Param("VkPhysicalDevice", "physicalDevice"), 392 Param("VkFormat", "format"), 393 Param("VkImageType", "type"), 394 Param("VkSampleCountFlagBits", "samples"), 395 Param("VkImageUsageFlags", "usage"), 396 Param("VkImageTiling", "tiling"), 397 Param("uint32_t*", "pPropertyCount"), 398 Param("VkSparseImageFormatProperties*", "pProperties")]), 399 400 Proto("VkResult", "QueueBindSparse", 401 [Param("VkQueue", "queue"), 402 Param("uint32_t", "bindInfoCount"), 403 Param("const VkBindSparseInfo*", "pBindInfo"), 404 Param("VkFence", "fence")]), 405 406 Proto("VkResult", "CreateFence", 407 [Param("VkDevice", "device"), 408 Param("const VkFenceCreateInfo*", "pCreateInfo"), 409 Param("const VkAllocationCallbacks*", "pAllocator"), 410 Param("VkFence*", "pFence")]), 411 412 Proto("void", "DestroyFence", 413 [Param("VkDevice", "device"), 414 Param("VkFence", "fence"), 415 Param("const VkAllocationCallbacks*", "pAllocator")]), 416 417 Proto("VkResult", "ResetFences", 418 [Param("VkDevice", "device"), 419 Param("uint32_t", "fenceCount"), 420 Param("const VkFence*", "pFences")]), 421 422 Proto("VkResult", "GetFenceStatus", 423 [Param("VkDevice", "device"), 424 Param("VkFence", "fence")]), 425 426 Proto("VkResult", "WaitForFences", 427 [Param("VkDevice", "device"), 428 Param("uint32_t", "fenceCount"), 429 Param("const VkFence*", "pFences"), 430 Param("VkBool32", "waitAll"), 431 Param("uint64_t", "timeout")]), 432 433 Proto("VkResult", "CreateSemaphore", 434 [Param("VkDevice", "device"), 435 Param("const VkSemaphoreCreateInfo*", "pCreateInfo"), 436 Param("const VkAllocationCallbacks*", "pAllocator"), 437 Param("VkSemaphore*", "pSemaphore")]), 438 439 Proto("void", "DestroySemaphore", 440 [Param("VkDevice", "device"), 441 Param("VkSemaphore", "semaphore"), 442 Param("const VkAllocationCallbacks*", "pAllocator")]), 443 444 Proto("VkResult", "CreateEvent", 445 [Param("VkDevice", "device"), 446 Param("const VkEventCreateInfo*", "pCreateInfo"), 447 Param("const VkAllocationCallbacks*", "pAllocator"), 448 Param("VkEvent*", "pEvent")]), 449 450 Proto("void", "DestroyEvent", 451 [Param("VkDevice", "device"), 452 Param("VkEvent", "event"), 453 Param("const VkAllocationCallbacks*", "pAllocator")]), 454 455 Proto("VkResult", "GetEventStatus", 456 [Param("VkDevice", "device"), 457 Param("VkEvent", "event")]), 458 459 Proto("VkResult", "SetEvent", 460 [Param("VkDevice", "device"), 461 Param("VkEvent", "event")]), 462 463 Proto("VkResult", "ResetEvent", 464 [Param("VkDevice", "device"), 465 Param("VkEvent", "event")]), 466 467 Proto("VkResult", "CreateQueryPool", 468 [Param("VkDevice", "device"), 469 Param("const VkQueryPoolCreateInfo*", "pCreateInfo"), 470 Param("const VkAllocationCallbacks*", "pAllocator"), 471 Param("VkQueryPool*", "pQueryPool")]), 472 473 Proto("void", "DestroyQueryPool", 474 [Param("VkDevice", "device"), 475 Param("VkQueryPool", "queryPool"), 476 Param("const VkAllocationCallbacks*", "pAllocator")]), 477 478 Proto("VkResult", "GetQueryPoolResults", 479 [Param("VkDevice", "device"), 480 Param("VkQueryPool", "queryPool"), 481 Param("uint32_t", "firstQuery"), 482 Param("uint32_t", "queryCount"), 483 Param("size_t", "dataSize"), 484 Param("void*", "pData"), 485 Param("VkDeviceSize", "stride"), 486 Param("VkQueryResultFlags", "flags")]), 487 488 Proto("VkResult", "CreateBuffer", 489 [Param("VkDevice", "device"), 490 Param("const VkBufferCreateInfo*", "pCreateInfo"), 491 Param("const VkAllocationCallbacks*", "pAllocator"), 492 Param("VkBuffer*", "pBuffer")]), 493 494 Proto("void", "DestroyBuffer", 495 [Param("VkDevice", "device"), 496 Param("VkBuffer", "buffer"), 497 Param("const VkAllocationCallbacks*", "pAllocator")]), 498 499 Proto("VkResult", "CreateBufferView", 500 [Param("VkDevice", "device"), 501 Param("const VkBufferViewCreateInfo*", "pCreateInfo"), 502 Param("const VkAllocationCallbacks*", "pAllocator"), 503 Param("VkBufferView*", "pView")]), 504 505 Proto("void", "DestroyBufferView", 506 [Param("VkDevice", "device"), 507 Param("VkBufferView", "bufferView"), 508 Param("const VkAllocationCallbacks*", "pAllocator")]), 509 510 Proto("VkResult", "CreateImage", 511 [Param("VkDevice", "device"), 512 Param("const VkImageCreateInfo*", "pCreateInfo"), 513 Param("const VkAllocationCallbacks*", "pAllocator"), 514 Param("VkImage*", "pImage")]), 515 516 Proto("void", "DestroyImage", 517 [Param("VkDevice", "device"), 518 Param("VkImage", "image"), 519 Param("const VkAllocationCallbacks*", "pAllocator")]), 520 521 Proto("void", "GetImageSubresourceLayout", 522 [Param("VkDevice", "device"), 523 Param("VkImage", "image"), 524 Param("const VkImageSubresource*", "pSubresource"), 525 Param("VkSubresourceLayout*", "pLayout")]), 526 527 Proto("VkResult", "CreateImageView", 528 [Param("VkDevice", "device"), 529 Param("const VkImageViewCreateInfo*", "pCreateInfo"), 530 Param("const VkAllocationCallbacks*", "pAllocator"), 531 Param("VkImageView*", "pView")]), 532 533 Proto("void", "DestroyImageView", 534 [Param("VkDevice", "device"), 535 Param("VkImageView", "imageView"), 536 Param("const VkAllocationCallbacks*", "pAllocator")]), 537 538 Proto("VkResult", "CreateShaderModule", 539 [Param("VkDevice", "device"), 540 Param("const VkShaderModuleCreateInfo*", "pCreateInfo"), 541 Param("const VkAllocationCallbacks*", "pAllocator"), 542 Param("VkShaderModule*", "pShaderModule")]), 543 544 Proto("void", "DestroyShaderModule", 545 [Param("VkDevice", "device"), 546 Param("VkShaderModule", "shaderModule"), 547 Param("const VkAllocationCallbacks*", "pAllocator")]), 548 549 Proto("VkResult", "CreatePipelineCache", 550 [Param("VkDevice", "device"), 551 Param("const VkPipelineCacheCreateInfo*", "pCreateInfo"), 552 Param("const VkAllocationCallbacks*", "pAllocator"), 553 Param("VkPipelineCache*", "pPipelineCache")]), 554 555 Proto("void", "DestroyPipelineCache", 556 [Param("VkDevice", "device"), 557 Param("VkPipelineCache", "pipelineCache"), 558 Param("const VkAllocationCallbacks*", "pAllocator")]), 559 560 Proto("VkResult", "GetPipelineCacheData", 561 [Param("VkDevice", "device"), 562 Param("VkPipelineCache", "pipelineCache"), 563 Param("size_t*", "pDataSize"), 564 Param("void*", "pData")]), 565 566 Proto("VkResult", "MergePipelineCaches", 567 [Param("VkDevice", "device"), 568 Param("VkPipelineCache", "dstCache"), 569 Param("uint32_t", "srcCacheCount"), 570 Param("const VkPipelineCache*", "pSrcCaches")]), 571 572 Proto("VkResult", "CreateGraphicsPipelines", 573 [Param("VkDevice", "device"), 574 Param("VkPipelineCache", "pipelineCache"), 575 Param("uint32_t", "createInfoCount"), 576 Param("const VkGraphicsPipelineCreateInfo*", "pCreateInfos"), 577 Param("const VkAllocationCallbacks*", "pAllocator"), 578 Param("VkPipeline*", "pPipelines")]), 579 580 Proto("VkResult", "CreateComputePipelines", 581 [Param("VkDevice", "device"), 582 Param("VkPipelineCache", "pipelineCache"), 583 Param("uint32_t", "createInfoCount"), 584 Param("const VkComputePipelineCreateInfo*", "pCreateInfos"), 585 Param("const VkAllocationCallbacks*", "pAllocator"), 586 Param("VkPipeline*", "pPipelines")]), 587 588 Proto("void", "DestroyPipeline", 589 [Param("VkDevice", "device"), 590 Param("VkPipeline", "pipeline"), 591 Param("const VkAllocationCallbacks*", "pAllocator")]), 592 593 Proto("VkResult", "CreatePipelineLayout", 594 [Param("VkDevice", "device"), 595 Param("const VkPipelineLayoutCreateInfo*", "pCreateInfo"), 596 Param("const VkAllocationCallbacks*", "pAllocator"), 597 Param("VkPipelineLayout*", "pPipelineLayout")]), 598 599 Proto("void", "DestroyPipelineLayout", 600 [Param("VkDevice", "device"), 601 Param("VkPipelineLayout", "pipelineLayout"), 602 Param("const VkAllocationCallbacks*", "pAllocator")]), 603 604 Proto("VkResult", "CreateSampler", 605 [Param("VkDevice", "device"), 606 Param("const VkSamplerCreateInfo*", "pCreateInfo"), 607 Param("const VkAllocationCallbacks*", "pAllocator"), 608 Param("VkSampler*", "pSampler")]), 609 610 Proto("void", "DestroySampler", 611 [Param("VkDevice", "device"), 612 Param("VkSampler", "sampler"), 613 Param("const VkAllocationCallbacks*", "pAllocator")]), 614 615 Proto("VkResult", "CreateDescriptorSetLayout", 616 [Param("VkDevice", "device"), 617 Param("const VkDescriptorSetLayoutCreateInfo*", "pCreateInfo"), 618 Param("const VkAllocationCallbacks*", "pAllocator"), 619 Param("VkDescriptorSetLayout*", "pSetLayout")]), 620 621 Proto("void", "DestroyDescriptorSetLayout", 622 [Param("VkDevice", "device"), 623 Param("VkDescriptorSetLayout", "descriptorSetLayout"), 624 Param("const VkAllocationCallbacks*", "pAllocator")]), 625 626 Proto("VkResult", "CreateDescriptorPool", 627 [Param("VkDevice", "device"), 628 Param("const VkDescriptorPoolCreateInfo*", "pCreateInfo"), 629 Param("const VkAllocationCallbacks*", "pAllocator"), 630 Param("VkDescriptorPool*", "pDescriptorPool")]), 631 632 Proto("void", "DestroyDescriptorPool", 633 [Param("VkDevice", "device"), 634 Param("VkDescriptorPool", "descriptorPool"), 635 Param("const VkAllocationCallbacks*", "pAllocator")]), 636 637 Proto("VkResult", "ResetDescriptorPool", 638 [Param("VkDevice", "device"), 639 Param("VkDescriptorPool", "descriptorPool"), 640 Param("VkDescriptorPoolResetFlags", "flags")]), 641 642 Proto("VkResult", "AllocateDescriptorSets", 643 [Param("VkDevice", "device"), 644 Param("const VkDescriptorSetAllocateInfo*", "pAllocateInfo"), 645 Param("VkDescriptorSet*", "pDescriptorSets")]), 646 647 Proto("VkResult", "FreeDescriptorSets", 648 [Param("VkDevice", "device"), 649 Param("VkDescriptorPool", "descriptorPool"), 650 Param("uint32_t", "descriptorSetCount"), 651 Param("const VkDescriptorSet*", "pDescriptorSets")]), 652 653 Proto("void", "UpdateDescriptorSets", 654 [Param("VkDevice", "device"), 655 Param("uint32_t", "descriptorWriteCount"), 656 Param("const VkWriteDescriptorSet*", "pDescriptorWrites"), 657 Param("uint32_t", "descriptorCopyCount"), 658 Param("const VkCopyDescriptorSet*", "pDescriptorCopies")]), 659 660 Proto("VkResult", "CreateFramebuffer", 661 [Param("VkDevice", "device"), 662 Param("const VkFramebufferCreateInfo*", "pCreateInfo"), 663 Param("const VkAllocationCallbacks*", "pAllocator"), 664 Param("VkFramebuffer*", "pFramebuffer")]), 665 666 Proto("void", "DestroyFramebuffer", 667 [Param("VkDevice", "device"), 668 Param("VkFramebuffer", "framebuffer"), 669 Param("const VkAllocationCallbacks*", "pAllocator")]), 670 671 Proto("VkResult", "CreateRenderPass", 672 [Param("VkDevice", "device"), 673 Param("const VkRenderPassCreateInfo*", "pCreateInfo"), 674 Param("const VkAllocationCallbacks*", "pAllocator"), 675 Param("VkRenderPass*", "pRenderPass")]), 676 677 Proto("void", "DestroyRenderPass", 678 [Param("VkDevice", "device"), 679 Param("VkRenderPass", "renderPass"), 680 Param("const VkAllocationCallbacks*", "pAllocator")]), 681 682 Proto("void", "GetRenderAreaGranularity", 683 [Param("VkDevice", "device"), 684 Param("VkRenderPass", "renderPass"), 685 Param("VkExtent2D*", "pGranularity")]), 686 687 Proto("VkResult", "CreateCommandPool", 688 [Param("VkDevice", "device"), 689 Param("const VkCommandPoolCreateInfo*", "pCreateInfo"), 690 Param("const VkAllocationCallbacks*", "pAllocator"), 691 Param("VkCommandPool*", "pCommandPool")]), 692 693 Proto("void", "DestroyCommandPool", 694 [Param("VkDevice", "device"), 695 Param("VkCommandPool", "commandPool"), 696 Param("const VkAllocationCallbacks*", "pAllocator")]), 697 698 Proto("VkResult", "ResetCommandPool", 699 [Param("VkDevice", "device"), 700 Param("VkCommandPool", "commandPool"), 701 Param("VkCommandPoolResetFlags", "flags")]), 702 703 Proto("VkResult", "AllocateCommandBuffers", 704 [Param("VkDevice", "device"), 705 Param("const VkCommandBufferAllocateInfo*", "pAllocateInfo"), 706 Param("VkCommandBuffer*", "pCommandBuffers")]), 707 708 Proto("void", "FreeCommandBuffers", 709 [Param("VkDevice", "device"), 710 Param("VkCommandPool", "commandPool"), 711 Param("uint32_t", "commandBufferCount"), 712 Param("const VkCommandBuffer*", "pCommandBuffers")]), 713 714 Proto("VkResult", "BeginCommandBuffer", 715 [Param("VkCommandBuffer", "commandBuffer"), 716 Param("const VkCommandBufferBeginInfo*", "pBeginInfo")]), 717 718 Proto("VkResult", "EndCommandBuffer", 719 [Param("VkCommandBuffer", "commandBuffer")]), 720 721 Proto("VkResult", "ResetCommandBuffer", 722 [Param("VkCommandBuffer", "commandBuffer"), 723 Param("VkCommandBufferResetFlags", "flags")]), 724 725 Proto("void", "CmdBindPipeline", 726 [Param("VkCommandBuffer", "commandBuffer"), 727 Param("VkPipelineBindPoint", "pipelineBindPoint"), 728 Param("VkPipeline", "pipeline")]), 729 730 Proto("void", "CmdSetViewport", 731 [Param("VkCommandBuffer", "commandBuffer"), 732 Param("uint32_t", "firstViewport"), 733 Param("uint32_t", "viewportCount"), 734 Param("const VkViewport*", "pViewports")]), 735 736 Proto("void", "CmdSetScissor", 737 [Param("VkCommandBuffer", "commandBuffer"), 738 Param("uint32_t", "firstScissor"), 739 Param("uint32_t", "scissorCount"), 740 Param("const VkRect2D*", "pScissors")]), 741 742 Proto("void", "CmdSetLineWidth", 743 [Param("VkCommandBuffer", "commandBuffer"), 744 Param("float", "lineWidth")]), 745 746 Proto("void", "CmdSetDepthBias", 747 [Param("VkCommandBuffer", "commandBuffer"), 748 Param("float", "depthBiasConstantFactor"), 749 Param("float", "depthBiasClamp"), 750 Param("float", "depthBiasSlopeFactor")]), 751 752 Proto("void", "CmdSetBlendConstants", 753 [Param("VkCommandBuffer", "commandBuffer"), 754 Param("const float[4]", "blendConstants")]), 755 756 Proto("void", "CmdSetDepthBounds", 757 [Param("VkCommandBuffer", "commandBuffer"), 758 Param("float", "minDepthBounds"), 759 Param("float", "maxDepthBounds")]), 760 761 Proto("void", "CmdSetStencilCompareMask", 762 [Param("VkCommandBuffer", "commandBuffer"), 763 Param("VkStencilFaceFlags", "faceMask"), 764 Param("uint32_t", "compareMask")]), 765 766 Proto("void", "CmdSetStencilWriteMask", 767 [Param("VkCommandBuffer", "commandBuffer"), 768 Param("VkStencilFaceFlags", "faceMask"), 769 Param("uint32_t", "writeMask")]), 770 771 Proto("void", "CmdSetStencilReference", 772 [Param("VkCommandBuffer", "commandBuffer"), 773 Param("VkStencilFaceFlags", "faceMask"), 774 Param("uint32_t", "reference")]), 775 776 Proto("void", "CmdBindDescriptorSets", 777 [Param("VkCommandBuffer", "commandBuffer"), 778 Param("VkPipelineBindPoint", "pipelineBindPoint"), 779 Param("VkPipelineLayout", "layout"), 780 Param("uint32_t", "firstSet"), 781 Param("uint32_t", "descriptorSetCount"), 782 Param("const VkDescriptorSet*", "pDescriptorSets"), 783 Param("uint32_t", "dynamicOffsetCount"), 784 Param("const uint32_t*", "pDynamicOffsets")]), 785 786 Proto("void", "CmdBindIndexBuffer", 787 [Param("VkCommandBuffer", "commandBuffer"), 788 Param("VkBuffer", "buffer"), 789 Param("VkDeviceSize", "offset"), 790 Param("VkIndexType", "indexType")]), 791 792 Proto("void", "CmdBindVertexBuffers", 793 [Param("VkCommandBuffer", "commandBuffer"), 794 Param("uint32_t", "firstBinding"), 795 Param("uint32_t", "bindingCount"), 796 Param("const VkBuffer*", "pBuffers"), 797 Param("const VkDeviceSize*", "pOffsets")]), 798 799 Proto("void", "CmdDraw", 800 [Param("VkCommandBuffer", "commandBuffer"), 801 Param("uint32_t", "vertexCount"), 802 Param("uint32_t", "instanceCount"), 803 Param("uint32_t", "firstVertex"), 804 Param("uint32_t", "firstInstance")]), 805 806 Proto("void", "CmdDrawIndexed", 807 [Param("VkCommandBuffer", "commandBuffer"), 808 Param("uint32_t", "indexCount"), 809 Param("uint32_t", "instanceCount"), 810 Param("uint32_t", "firstIndex"), 811 Param("int32_t", "vertexOffset"), 812 Param("uint32_t", "firstInstance")]), 813 814 Proto("void", "CmdDrawIndirect", 815 [Param("VkCommandBuffer", "commandBuffer"), 816 Param("VkBuffer", "buffer"), 817 Param("VkDeviceSize", "offset"), 818 Param("uint32_t", "drawCount"), 819 Param("uint32_t", "stride")]), 820 821 Proto("void", "CmdDrawIndexedIndirect", 822 [Param("VkCommandBuffer", "commandBuffer"), 823 Param("VkBuffer", "buffer"), 824 Param("VkDeviceSize", "offset"), 825 Param("uint32_t", "drawCount"), 826 Param("uint32_t", "stride")]), 827 828 Proto("void", "CmdDispatch", 829 [Param("VkCommandBuffer", "commandBuffer"), 830 Param("uint32_t", "x"), 831 Param("uint32_t", "y"), 832 Param("uint32_t", "z")]), 833 834 Proto("void", "CmdDispatchIndirect", 835 [Param("VkCommandBuffer", "commandBuffer"), 836 Param("VkBuffer", "buffer"), 837 Param("VkDeviceSize", "offset")]), 838 839 Proto("void", "CmdCopyBuffer", 840 [Param("VkCommandBuffer", "commandBuffer"), 841 Param("VkBuffer", "srcBuffer"), 842 Param("VkBuffer", "dstBuffer"), 843 Param("uint32_t", "regionCount"), 844 Param("const VkBufferCopy*", "pRegions")]), 845 846 Proto("void", "CmdCopyImage", 847 [Param("VkCommandBuffer", "commandBuffer"), 848 Param("VkImage", "srcImage"), 849 Param("VkImageLayout", "srcImageLayout"), 850 Param("VkImage", "dstImage"), 851 Param("VkImageLayout", "dstImageLayout"), 852 Param("uint32_t", "regionCount"), 853 Param("const VkImageCopy*", "pRegions")]), 854 855 Proto("void", "CmdBlitImage", 856 [Param("VkCommandBuffer", "commandBuffer"), 857 Param("VkImage", "srcImage"), 858 Param("VkImageLayout", "srcImageLayout"), 859 Param("VkImage", "dstImage"), 860 Param("VkImageLayout", "dstImageLayout"), 861 Param("uint32_t", "regionCount"), 862 Param("const VkImageBlit*", "pRegions"), 863 Param("VkFilter", "filter")]), 864 865 Proto("void", "CmdCopyBufferToImage", 866 [Param("VkCommandBuffer", "commandBuffer"), 867 Param("VkBuffer", "srcBuffer"), 868 Param("VkImage", "dstImage"), 869 Param("VkImageLayout", "dstImageLayout"), 870 Param("uint32_t", "regionCount"), 871 Param("const VkBufferImageCopy*", "pRegions")]), 872 873 Proto("void", "CmdCopyImageToBuffer", 874 [Param("VkCommandBuffer", "commandBuffer"), 875 Param("VkImage", "srcImage"), 876 Param("VkImageLayout", "srcImageLayout"), 877 Param("VkBuffer", "dstBuffer"), 878 Param("uint32_t", "regionCount"), 879 Param("const VkBufferImageCopy*", "pRegions")]), 880 881 Proto("void", "CmdUpdateBuffer", 882 [Param("VkCommandBuffer", "commandBuffer"), 883 Param("VkBuffer", "dstBuffer"), 884 Param("VkDeviceSize", "dstOffset"), 885 Param("VkDeviceSize", "dataSize"), 886 Param("const uint32_t*", "pData")]), 887 888 Proto("void", "CmdFillBuffer", 889 [Param("VkCommandBuffer", "commandBuffer"), 890 Param("VkBuffer", "dstBuffer"), 891 Param("VkDeviceSize", "dstOffset"), 892 Param("VkDeviceSize", "size"), 893 Param("uint32_t", "data")]), 894 895 Proto("void", "CmdClearColorImage", 896 [Param("VkCommandBuffer", "commandBuffer"), 897 Param("VkImage", "image"), 898 Param("VkImageLayout", "imageLayout"), 899 Param("const VkClearColorValue*", "pColor"), 900 Param("uint32_t", "rangeCount"), 901 Param("const VkImageSubresourceRange*", "pRanges")]), 902 903 Proto("void", "CmdClearDepthStencilImage", 904 [Param("VkCommandBuffer", "commandBuffer"), 905 Param("VkImage", "image"), 906 Param("VkImageLayout", "imageLayout"), 907 Param("const VkClearDepthStencilValue*", "pDepthStencil"), 908 Param("uint32_t", "rangeCount"), 909 Param("const VkImageSubresourceRange*", "pRanges")]), 910 911 Proto("void", "CmdClearAttachments", 912 [Param("VkCommandBuffer", "commandBuffer"), 913 Param("uint32_t", "attachmentCount"), 914 Param("const VkClearAttachment*", "pAttachments"), 915 Param("uint32_t", "rectCount"), 916 Param("const VkClearRect*", "pRects")]), 917 918 Proto("void", "CmdResolveImage", 919 [Param("VkCommandBuffer", "commandBuffer"), 920 Param("VkImage", "srcImage"), 921 Param("VkImageLayout", "srcImageLayout"), 922 Param("VkImage", "dstImage"), 923 Param("VkImageLayout", "dstImageLayout"), 924 Param("uint32_t", "regionCount"), 925 Param("const VkImageResolve*", "pRegions")]), 926 927 Proto("void", "CmdSetEvent", 928 [Param("VkCommandBuffer", "commandBuffer"), 929 Param("VkEvent", "event"), 930 Param("VkPipelineStageFlags", "stageMask")]), 931 932 Proto("void", "CmdResetEvent", 933 [Param("VkCommandBuffer", "commandBuffer"), 934 Param("VkEvent", "event"), 935 Param("VkPipelineStageFlags", "stageMask")]), 936 937 Proto("void", "CmdWaitEvents", 938 [Param("VkCommandBuffer", "commandBuffer"), 939 Param("uint32_t", "eventCount"), 940 Param("const VkEvent*", "pEvents"), 941 Param("VkPipelineStageFlags", "srcStageMask"), 942 Param("VkPipelineStageFlags", "dstStageMask"), 943 Param("uint32_t", "memoryBarrierCount"), 944 Param("const VkMemoryBarrier*", "pMemoryBarriers"), 945 Param("uint32_t", "bufferMemoryBarrierCount"), 946 Param("const VkBufferMemoryBarrier*", "pBufferMemoryBarriers"), 947 Param("uint32_t", "imageMemoryBarrierCount"), 948 Param("const VkImageMemoryBarrier*", "pImageMemoryBarriers")]), 949 950 Proto("void", "CmdPipelineBarrier", 951 [Param("VkCommandBuffer", "commandBuffer"), 952 Param("VkPipelineStageFlags", "srcStageMask"), 953 Param("VkPipelineStageFlags", "dstStageMask"), 954 Param("VkDependencyFlags", "dependencyFlags"), 955 Param("uint32_t", "memoryBarrierCount"), 956 Param("const VkMemoryBarrier*", "pMemoryBarriers"), 957 Param("uint32_t", "bufferMemoryBarrierCount"), 958 Param("const VkBufferMemoryBarrier*", "pBufferMemoryBarriers"), 959 Param("uint32_t", "imageMemoryBarrierCount"), 960 Param("const VkImageMemoryBarrier*", "pImageMemoryBarriers")]), 961 962 Proto("void", "CmdBeginQuery", 963 [Param("VkCommandBuffer", "commandBuffer"), 964 Param("VkQueryPool", "queryPool"), 965 Param("uint32_t", "query"), 966 Param("VkQueryControlFlags", "flags")]), 967 968 Proto("void", "CmdEndQuery", 969 [Param("VkCommandBuffer", "commandBuffer"), 970 Param("VkQueryPool", "queryPool"), 971 Param("uint32_t", "query")]), 972 973 Proto("void", "CmdResetQueryPool", 974 [Param("VkCommandBuffer", "commandBuffer"), 975 Param("VkQueryPool", "queryPool"), 976 Param("uint32_t", "firstQuery"), 977 Param("uint32_t", "queryCount")]), 978 979 Proto("void", "CmdWriteTimestamp", 980 [Param("VkCommandBuffer", "commandBuffer"), 981 Param("VkPipelineStageFlagBits", "pipelineStage"), 982 Param("VkQueryPool", "queryPool"), 983 Param("uint32_t", "query")]), 984 985 Proto("void", "CmdCopyQueryPoolResults", 986 [Param("VkCommandBuffer", "commandBuffer"), 987 Param("VkQueryPool", "queryPool"), 988 Param("uint32_t", "firstQuery"), 989 Param("uint32_t", "queryCount"), 990 Param("VkBuffer", "dstBuffer"), 991 Param("VkDeviceSize", "dstOffset"), 992 Param("VkDeviceSize", "stride"), 993 Param("VkQueryResultFlags", "flags")]), 994 995 Proto("void", "CmdPushConstants", 996 [Param("VkCommandBuffer", "commandBuffer"), 997 Param("VkPipelineLayout", "layout"), 998 Param("VkShaderStageFlags", "stageFlags"), 999 Param("uint32_t", "offset"), 1000 Param("uint32_t", "size"), 1001 Param("const void*", "pValues")]), 1002 1003 Proto("void", "CmdBeginRenderPass", 1004 [Param("VkCommandBuffer", "commandBuffer"), 1005 Param("const VkRenderPassBeginInfo*", "pRenderPassBegin"), 1006 Param("VkSubpassContents", "contents")]), 1007 1008 Proto("void", "CmdNextSubpass", 1009 [Param("VkCommandBuffer", "commandBuffer"), 1010 Param("VkSubpassContents", "contents")]), 1011 1012 Proto("void", "CmdEndRenderPass", 1013 [Param("VkCommandBuffer", "commandBuffer")]), 1014 1015 Proto("void", "CmdExecuteCommands", 1016 [Param("VkCommandBuffer", "commandBuffer"), 1017 Param("uint32_t", "commandBufferCount"), 1018 Param("const VkCommandBuffer*", "pCommandBuffers")]), 1019 ], 1020 ) 1021 1022 ext_khr_surface = Extension( 1023 name="VK_KHR_surface", 1024 headers=["vulkan/vulkan.h"], 1025 objects=["vkSurfaceKHR"], 1026 protos=[ 1027 Proto("void", "DestroySurfaceKHR", 1028 [Param("VkInstance", "instance"), 1029 Param("VkSurfaceKHR", "surface"), 1030 Param("const VkAllocationCallbacks*", "pAllocator")]), 1031 1032 Proto("VkResult", "GetPhysicalDeviceSurfaceSupportKHR", 1033 [Param("VkPhysicalDevice", "physicalDevice"), 1034 Param("uint32_t", "queueFamilyIndex"), 1035 Param("VkSurfaceKHR", "surface"), 1036 Param("VkBool32*", "pSupported")]), 1037 1038 Proto("VkResult", "GetPhysicalDeviceSurfaceCapabilitiesKHR", 1039 [Param("VkPhysicalDevice", "physicalDevice"), 1040 Param("VkSurfaceKHR", "surface"), 1041 Param("VkSurfaceCapabilitiesKHR*", "pSurfaceCapabilities")]), 1042 1043 Proto("VkResult", "GetPhysicalDeviceSurfaceFormatsKHR", 1044 [Param("VkPhysicalDevice", "physicalDevice"), 1045 Param("VkSurfaceKHR", "surface"), 1046 Param("uint32_t*", "pSurfaceFormatCount"), 1047 Param("VkSurfaceFormatKHR*", "pSurfaceFormats")]), 1048 1049 Proto("VkResult", "GetPhysicalDeviceSurfacePresentModesKHR", 1050 [Param("VkPhysicalDevice", "physicalDevice"), 1051 Param("VkSurfaceKHR", "surface"), 1052 Param("uint32_t*", "pPresentModeCount"), 1053 Param("VkPresentModeKHR*", "pPresentModes")]), 1054 ], 1055 ) 1056 1057 ext_khr_device_swapchain = Extension( 1058 name="VK_KHR_swapchain", 1059 headers=["vulkan/vulkan.h"], 1060 objects=["VkSwapchainKHR"], 1061 protos=[ 1062 Proto("VkResult", "CreateSwapchainKHR", 1063 [Param("VkDevice", "device"), 1064 Param("const VkSwapchainCreateInfoKHR*", "pCreateInfo"), 1065 Param("const VkAllocationCallbacks*", "pAllocator"), 1066 Param("VkSwapchainKHR*", "pSwapchain")]), 1067 1068 Proto("void", "DestroySwapchainKHR", 1069 [Param("VkDevice", "device"), 1070 Param("VkSwapchainKHR", "swapchain"), 1071 Param("const VkAllocationCallbacks*", "pAllocator")]), 1072 1073 Proto("VkResult", "GetSwapchainImagesKHR", 1074 [Param("VkDevice", "device"), 1075 Param("VkSwapchainKHR", "swapchain"), 1076 Param("uint32_t*", "pSwapchainImageCount"), 1077 Param("VkImage*", "pSwapchainImages")]), 1078 1079 Proto("VkResult", "AcquireNextImageKHR", 1080 [Param("VkDevice", "device"), 1081 Param("VkSwapchainKHR", "swapchain"), 1082 Param("uint64_t", "timeout"), 1083 Param("VkSemaphore", "semaphore"), 1084 Param("VkFence", "fence"), 1085 Param("uint32_t*", "pImageIndex")]), 1086 1087 Proto("VkResult", "QueuePresentKHR", 1088 [Param("VkQueue", "queue"), 1089 Param("const VkPresentInfoKHR*", "pPresentInfo")]), 1090 ], 1091 ) 1092 1093 ext_khr_xcb_surface = Extension( 1094 name="VK_KHR_xcb_surface", 1095 headers=["vulkan/vulkan.h"], 1096 objects=[], 1097 protos=[ 1098 Proto("VkResult", "CreateXcbSurfaceKHR", 1099 [Param("VkInstance", "instance"), 1100 Param("const VkXcbSurfaceCreateInfoKHR*", "pCreateInfo"), 1101 Param("const VkAllocationCallbacks*", "pAllocator"), 1102 Param("VkSurfaceKHR*", "pSurface")]), 1103 1104 Proto("VkBool32", "GetPhysicalDeviceXcbPresentationSupportKHR", 1105 [Param("VkPhysicalDevice", "physicalDevice"), 1106 Param("uint32_t", "queueFamilyIndex"), 1107 Param("xcb_connection_t*", "connection"), 1108 Param("xcb_visualid_t", "visual_id")]), 1109 ], 1110 ) 1111 ext_khr_xlib_surface = Extension( 1112 name="VK_KHR_xlib_surface", 1113 headers=["vulkan/vulkan.h"], 1114 objects=[], 1115 protos=[ 1116 Proto("VkResult", "CreateXlibSurfaceKHR", 1117 [Param("VkInstance", "instance"), 1118 Param("const VkXlibSurfaceCreateInfoKHR*", "pCreateInfo"), 1119 Param("const VkAllocationCallbacks*", "pAllocator"), 1120 Param("VkSurfaceKHR*", "pSurface")]), 1121 1122 Proto("VkBool32", "GetPhysicalDeviceXlibPresentationSupportKHR", 1123 [Param("VkPhysicalDevice", "physicalDevice"), 1124 Param("uint32_t", "queueFamilyIndex"), 1125 Param("Display*", "dpy"), 1126 Param("VisualID", "visualID")]), 1127 ], 1128 ) 1129 ext_khr_wayland_surface = Extension( 1130 name="VK_KHR_wayland_surface", 1131 headers=["vulkan/vulkan.h"], 1132 objects=[], 1133 protos=[ 1134 Proto("VkResult", "CreateWaylandSurfaceKHR", 1135 [Param("VkInstance", "instance"), 1136 Param("const VkWaylandSurfaceCreateInfoKHR*", "pCreateInfo"), 1137 Param("const VkAllocationCallbacks*", "pAllocator"), 1138 Param("VkSurfaceKHR*", "pSurface")]), 1139 1140 Proto("VkBool32", "GetPhysicalDeviceWaylandPresentationSupportKHR", 1141 [Param("VkPhysicalDevice", "physicalDevice"), 1142 Param("uint32_t", "queueFamilyIndex"), 1143 Param("struct wl_display*", "display")]), 1144 ], 1145 ) 1146 ext_khr_mir_surface = Extension( 1147 name="VK_KHR_mir_surface", 1148 headers=["vulkan/vulkan.h"], 1149 objects=[], 1150 protos=[ 1151 Proto("VkResult", "CreateMirSurfaceKHR", 1152 [Param("VkInstance", "instance"), 1153 Param("const VkMirSurfaceCreateInfoKHR*", "pCreateInfo"), 1154 Param("const VkAllocationCallbacks*", "pAllocator"), 1155 Param("VkSurfaceKHR*", "pSurface")]), 1156 1157 Proto("VkBool32", "GetPhysicalDeviceMirPresentationSupportKHR", 1158 [Param("VkPhysicalDevice", "physicalDevice"), 1159 Param("uint32_t", "queueFamilyIndex"), 1160 Param("MirConnection*", "connection")]), 1161 ], 1162 ) 1163 ext_khr_android_surface = Extension( 1164 name="VK_KHR_android_surface", 1165 headers=["vulkan/vulkan.h"], 1166 objects=[], 1167 protos=[ 1168 Proto("VkResult", "CreateAndroidSurfaceKHR", 1169 [Param("VkInstance", "instance"), 1170 Param("const VkAndroidSurfaceCreateInfoKHR*", "pCreateInfo"), 1171 Param("const VkAllocationCallbacks*", "pAllocator"), 1172 Param("VkSurfaceKHR*", "pSurface")]), 1173 ], 1174 ) 1175 ext_khr_win32_surface = Extension( 1176 name="VK_KHR_win32_surface", 1177 headers=["vulkan/vulkan.h"], 1178 objects=[], 1179 protos=[ 1180 Proto("VkResult", "CreateWin32SurfaceKHR", 1181 [Param("VkInstance", "instance"), 1182 Param("const VkWin32SurfaceCreateInfoKHR*", "pCreateInfo"), 1183 Param("const VkAllocationCallbacks*", "pAllocator"), 1184 Param("VkSurfaceKHR*", "pSurface")]), 1185 1186 Proto("VkBool32", "GetPhysicalDeviceWin32PresentationSupportKHR", 1187 [Param("VkPhysicalDevice", "physicalDevice"), 1188 Param("uint32_t", "queueFamilyIndex")]), 1189 ], 1190 ) 1191 lunarg_debug_report = Extension( 1192 name="VK_EXT_debug_report", 1193 headers=["vulkan/vulkan.h"], 1194 objects=[ 1195 "VkDebugReportCallbackEXT", 1196 ], 1197 protos=[ 1198 Proto("VkResult", "CreateDebugReportCallbackEXT", 1199 [Param("VkInstance", "instance"), 1200 Param("const VkDebugReportCallbackCreateInfoEXT*", "pCreateInfo"), 1201 Param("const VkAllocationCallbacks*", "pAllocator"), 1202 Param("VkDebugReportCallbackEXT*", "pCallback")]), 1203 1204 Proto("void", "DestroyDebugReportCallbackEXT", 1205 [Param("VkInstance", "instance"), 1206 Param("VkDebugReportCallbackEXT", "callback"), 1207 Param("const VkAllocationCallbacks*", "pAllocator")]), 1208 1209 Proto("void", "DebugReportMessageEXT", 1210 [Param("VkInstance", "instance"), 1211 Param("VkDebugReportFlagsEXT", "flags"), 1212 Param("VkDebugReportObjectTypeEXT", "objType"), 1213 Param("uint64_t", "object"), 1214 Param("size_t", "location"), 1215 Param("int32_t", "msgCode"), 1216 Param("const char *", "pLayerPrefix"), 1217 Param("const char *", "pMsg")]), 1218 ], 1219 ) 1220 1221 import sys 1222 1223 if len(sys.argv) > 3: 1224 # TODO : Need to clean this up to more seemlessly handle building different targets than the platform you're on 1225 if sys.platform.startswith('win32') and sys.argv[1] != 'Android': 1226 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface] 1227 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface, lunarg_debug_report] 1228 elif sys.platform.startswith('linux') and sys.argv[1] != 'Android': 1229 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface] 1230 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, lunarg_debug_report] 1231 else: # android 1232 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface] 1233 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface, lunarg_debug_report] 1234 else : 1235 if sys.argv[1] == 'Win32': 1236 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface] 1237 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface, lunarg_debug_report] 1238 elif sys.argv[1] == 'Android': 1239 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface] 1240 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface, lunarg_debug_report] 1241 elif sys.argv[1] == 'Xcb' or sys.argv[1] == 'Xlib' or sys.argv[1] == 'Wayland' or sys.argv[1] == 'Mir': 1242 extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface] 1243 extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, lunarg_debug_report] 1244 else: 1245 print('Error: Undefined DisplayServer') 1246 extensions = [] 1247 extensions_all = [] 1248 1249 object_dispatch_list = [ 1250 "VkInstance", 1251 "VkPhysicalDevice", 1252 "VkDevice", 1253 "VkQueue", 1254 "VkCommandBuffer", 1255 ] 1256 1257 object_non_dispatch_list = [ 1258 "VkCommandPool", 1259 "VkFence", 1260 "VkDeviceMemory", 1261 "VkBuffer", 1262 "VkImage", 1263 "VkSemaphore", 1264 "VkEvent", 1265 "VkQueryPool", 1266 "VkBufferView", 1267 "VkImageView", 1268 "VkShaderModule", 1269 "VkPipelineCache", 1270 "VkPipelineLayout", 1271 "VkPipeline", 1272 "VkDescriptorSetLayout", 1273 "VkSampler", 1274 "VkDescriptorPool", 1275 "VkDescriptorSet", 1276 "VkRenderPass", 1277 "VkFramebuffer", 1278 "VkSwapchainKHR", 1279 "VkSurfaceKHR", 1280 "VkDebugReportCallbackEXT", 1281 ] 1282 1283 object_type_list = object_dispatch_list + object_non_dispatch_list 1284 1285 headers = [] 1286 objects = [] 1287 protos = [] 1288 for ext in extensions: 1289 headers.extend(ext.headers) 1290 objects.extend(ext.objects) 1291 protos.extend(ext.protos) 1292 1293 proto_names = [proto.name for proto in protos] 1294 1295 def parse_vk_h(filename): 1296 # read object and protoype typedefs 1297 object_lines = [] 1298 proto_lines = [] 1299 with open(filename, "r") as fp: 1300 for line in fp: 1301 line = line.strip() 1302 if line.startswith("VK_DEFINE"): 1303 begin = line.find("(") + 1 1304 end = line.find(",") 1305 # extract the object type 1306 object_lines.append(line[begin:end]) 1307 if line.startswith("typedef") and line.endswith(");"): 1308 if "*PFN_vkVoidFunction" in line: 1309 continue 1310 1311 # drop leading "typedef " and trailing ");" 1312 proto_lines.append(line[8:-2]) 1313 1314 # parse proto_lines to protos 1315 protos = [] 1316 for line in proto_lines: 1317 first, rest = line.split(" (VKAPI_PTR *PFN_vk") 1318 second, third = rest.split(")(") 1319 1320 # get the return type, no space before "*" 1321 proto_ret = "*".join([t.rstrip() for t in first.split("*")]) 1322 1323 # get the name 1324 proto_name = second.strip() 1325 1326 # get the list of params 1327 param_strs = third.split(", ") 1328 params = [] 1329 for s in param_strs: 1330 ty, name = s.rsplit(" ", 1) 1331 1332 # no space before "*" 1333 ty = "*".join([t.rstrip() for t in ty.split("*")]) 1334 # attach [] to ty 1335 idx = name.rfind("[") 1336 if idx >= 0: 1337 ty += name[idx:] 1338 name = name[:idx] 1339 1340 params.append(Param(ty, name)) 1341 1342 protos.append(Proto(proto_ret, proto_name, params)) 1343 1344 # make them an extension and print 1345 ext = Extension("VK_CORE", 1346 headers=["vulkan/vulkan.h"], 1347 objects=object_lines, 1348 protos=protos) 1349 print("core =", str(ext)) 1350 1351 print("") 1352 print("typedef struct VkLayerDispatchTable_") 1353 print("{") 1354 for proto in ext.protos: 1355 print(" PFN_vk%s %s;" % (proto.name, proto.name)) 1356 print("} VkLayerDispatchTable;") 1357 1358 if __name__ == "__main__": 1359 parse_vk_h("include/vulkan/vulkan.h") 1360