header: Move vk.xml to version 1.0.29
[platform/upstream/Vulkan-LoaderAndValidationLayers.git] / vulkan.py
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@lunarg.com>
21 # Author: Jon Ashburn <jon@lunarg.com>
22 # Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
23 # Author: Tobin Ehlis <tobin@lunarg.com>
24 # Author: Tony Barbour <tony@LunarG.com>
25 # Author: Gwan-gyeong Mun <kk.moon@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, ifdef = None):
163         self.name = name
164         self.headers = headers
165         self.objects = objects
166         self.protos = protos
167         self.ifdef = ifdef
168
169     def __repr__(self):
170         lines = []
171         lines.append("Extension(")
172         lines.append("    name=\"%s\"," % self.name)
173         lines.append("    headers=[\"%s\"]," %
174                 "\", \"".join(self.headers))
175
176         lines.append("    objects=[")
177         for obj in self.objects:
178             lines.append("        \"%s\"," % obj)
179         lines.append("    ],")
180
181         lines.append("    protos=[")
182         for proto in self.protos:
183             param_lines = str(proto).splitlines()
184             param_lines[-1] += ",\n" if proto != self.protos[-1] else ","
185             for p in param_lines:
186                 lines.append("        " + p)
187         lines.append("    ],")
188         lines.append(")")
189
190         return "\n".join(lines)
191
192 # VK core API
193 core = Extension(
194     name="VK_CORE",
195     headers=["vulkan/vulkan.h"],
196     objects=[
197         "VkInstance",
198         "VkPhysicalDevice",
199         "VkDevice",
200         "VkQueue",
201         "VkSemaphore",
202         "VkCommandBuffer",
203         "VkFence",
204         "VkDeviceMemory",
205         "VkBuffer",
206         "VkImage",
207         "VkEvent",
208         "VkQueryPool",
209         "VkBufferView",
210         "VkImageView",
211         "VkShaderModule",
212         "VkPipelineCache",
213         "VkPipelineLayout",
214         "VkRenderPass",
215         "VkPipeline",
216         "VkDescriptorSetLayout",
217         "VkSampler",
218         "VkDescriptorPool",
219         "VkDescriptorSet",
220         "VkFramebuffer",
221         "VkCommandPool",
222     ],
223     protos=[
224         Proto("VkResult", "CreateInstance",
225             [Param("const VkInstanceCreateInfo*", "pCreateInfo"),
226              Param("const VkAllocationCallbacks*", "pAllocator"),
227              Param("VkInstance*", "pInstance")]),
228
229         Proto("void", "DestroyInstance",
230             [Param("VkInstance", "instance"),
231              Param("const VkAllocationCallbacks*", "pAllocator")]),
232
233         Proto("VkResult", "EnumeratePhysicalDevices",
234             [Param("VkInstance", "instance"),
235              Param("uint32_t*", "pPhysicalDeviceCount"),
236              Param("VkPhysicalDevice*", "pPhysicalDevices")]),
237
238         Proto("void", "GetPhysicalDeviceFeatures",
239             [Param("VkPhysicalDevice", "physicalDevice"),
240              Param("VkPhysicalDeviceFeatures*", "pFeatures")]),
241
242         Proto("void", "GetPhysicalDeviceFormatProperties",
243             [Param("VkPhysicalDevice", "physicalDevice"),
244              Param("VkFormat", "format"),
245              Param("VkFormatProperties*", "pFormatProperties")]),
246
247         Proto("VkResult", "GetPhysicalDeviceImageFormatProperties",
248             [Param("VkPhysicalDevice", "physicalDevice"),
249              Param("VkFormat", "format"),
250              Param("VkImageType", "type"),
251              Param("VkImageTiling", "tiling"),
252              Param("VkImageUsageFlags", "usage"),
253              Param("VkImageCreateFlags", "flags"),
254              Param("VkImageFormatProperties*", "pImageFormatProperties")]),
255
256         Proto("void", "GetPhysicalDeviceProperties",
257             [Param("VkPhysicalDevice", "physicalDevice"),
258              Param("VkPhysicalDeviceProperties*", "pProperties")]),
259
260         Proto("void", "GetPhysicalDeviceQueueFamilyProperties",
261             [Param("VkPhysicalDevice", "physicalDevice"),
262              Param("uint32_t*", "pQueueFamilyPropertyCount"),
263              Param("VkQueueFamilyProperties*", "pQueueFamilyProperties")]),
264
265         Proto("void", "GetPhysicalDeviceMemoryProperties",
266             [Param("VkPhysicalDevice", "physicalDevice"),
267              Param("VkPhysicalDeviceMemoryProperties*", "pMemoryProperties")]),
268
269         Proto("PFN_vkVoidFunction", "GetInstanceProcAddr",
270             [Param("VkInstance", "instance"),
271              Param("const char*", "pName")]),
272
273         Proto("PFN_vkVoidFunction", "GetDeviceProcAddr",
274             [Param("VkDevice", "device"),
275              Param("const char*", "pName")]),
276
277         Proto("VkResult", "CreateDevice",
278             [Param("VkPhysicalDevice", "physicalDevice"),
279              Param("const VkDeviceCreateInfo*", "pCreateInfo"),
280              Param("const VkAllocationCallbacks*", "pAllocator"),
281              Param("VkDevice*", "pDevice")]),
282
283         Proto("void", "DestroyDevice",
284             [Param("VkDevice", "device"),
285              Param("const VkAllocationCallbacks*", "pAllocator")]),
286
287         Proto("VkResult", "EnumerateInstanceExtensionProperties",
288             [Param("const char*", "pLayerName"),
289              Param("uint32_t*", "pPropertyCount"),
290              Param("VkExtensionProperties*", "pProperties")]),
291
292         Proto("VkResult", "EnumerateDeviceExtensionProperties",
293             [Param("VkPhysicalDevice", "physicalDevice"),
294              Param("const char*", "pLayerName"),
295              Param("uint32_t*", "pPropertyCount"),
296              Param("VkExtensionProperties*", "pProperties")]),
297
298         Proto("VkResult", "EnumerateInstanceLayerProperties",
299             [Param("uint32_t*", "pPropertyCount"),
300              Param("VkLayerProperties*", "pProperties")]),
301
302         Proto("VkResult", "EnumerateDeviceLayerProperties",
303             [Param("VkPhysicalDevice", "physicalDevice"),
304              Param("uint32_t*", "pPropertyCount"),
305              Param("VkLayerProperties*", "pProperties")]),
306
307         Proto("void", "GetDeviceQueue",
308             [Param("VkDevice", "device"),
309              Param("uint32_t", "queueFamilyIndex"),
310              Param("uint32_t", "queueIndex"),
311              Param("VkQueue*", "pQueue")]),
312
313         Proto("VkResult", "QueueSubmit",
314             [Param("VkQueue", "queue"),
315              Param("uint32_t", "submitCount"),
316              Param("const VkSubmitInfo*", "pSubmits"),
317              Param("VkFence", "fence")]),
318
319         Proto("VkResult", "QueueWaitIdle",
320             [Param("VkQueue", "queue")]),
321
322         Proto("VkResult", "DeviceWaitIdle",
323             [Param("VkDevice", "device")]),
324
325         Proto("VkResult", "AllocateMemory",
326             [Param("VkDevice", "device"),
327              Param("const VkMemoryAllocateInfo*", "pAllocateInfo"),
328              Param("const VkAllocationCallbacks*", "pAllocator"),
329              Param("VkDeviceMemory*", "pMemory")]),
330
331         Proto("void", "FreeMemory",
332             [Param("VkDevice", "device"),
333              Param("VkDeviceMemory", "memory"),
334              Param("const VkAllocationCallbacks*", "pAllocator")]),
335
336         Proto("VkResult", "MapMemory",
337             [Param("VkDevice", "device"),
338              Param("VkDeviceMemory", "memory"),
339              Param("VkDeviceSize", "offset"),
340              Param("VkDeviceSize", "size"),
341              Param("VkMemoryMapFlags", "flags"),
342              Param("void**", "ppData")]),
343
344         Proto("void", "UnmapMemory",
345             [Param("VkDevice", "device"),
346              Param("VkDeviceMemory", "memory")]),
347
348         Proto("VkResult", "FlushMappedMemoryRanges",
349             [Param("VkDevice", "device"),
350              Param("uint32_t", "memoryRangeCount"),
351              Param("const VkMappedMemoryRange*", "pMemoryRanges")]),
352
353         Proto("VkResult", "InvalidateMappedMemoryRanges",
354             [Param("VkDevice", "device"),
355              Param("uint32_t", "memoryRangeCount"),
356              Param("const VkMappedMemoryRange*", "pMemoryRanges")]),
357
358         Proto("void", "GetDeviceMemoryCommitment",
359             [Param("VkDevice", "device"),
360              Param("VkDeviceMemory", "memory"),
361              Param("VkDeviceSize*", "pCommittedMemoryInBytes")]),
362
363         Proto("VkResult", "BindBufferMemory",
364             [Param("VkDevice", "device"),
365              Param("VkBuffer", "buffer"),
366              Param("VkDeviceMemory", "memory"),
367              Param("VkDeviceSize", "memoryOffset")]),
368
369         Proto("VkResult", "BindImageMemory",
370             [Param("VkDevice", "device"),
371              Param("VkImage", "image"),
372              Param("VkDeviceMemory", "memory"),
373              Param("VkDeviceSize", "memoryOffset")]),
374
375         Proto("void", "GetBufferMemoryRequirements",
376             [Param("VkDevice", "device"),
377              Param("VkBuffer", "buffer"),
378              Param("VkMemoryRequirements*", "pMemoryRequirements")]),
379
380         Proto("void", "GetImageMemoryRequirements",
381             [Param("VkDevice", "device"),
382              Param("VkImage", "image"),
383              Param("VkMemoryRequirements*", "pMemoryRequirements")]),
384
385         Proto("void", "GetImageSparseMemoryRequirements",
386             [Param("VkDevice", "device"),
387              Param("VkImage", "image"),
388              Param("uint32_t*", "pSparseMemoryRequirementCount"),
389              Param("VkSparseImageMemoryRequirements*", "pSparseMemoryRequirements")]),
390
391         Proto("void", "GetPhysicalDeviceSparseImageFormatProperties",
392             [Param("VkPhysicalDevice", "physicalDevice"),
393              Param("VkFormat", "format"),
394              Param("VkImageType", "type"),
395              Param("VkSampleCountFlagBits", "samples"),
396              Param("VkImageUsageFlags", "usage"),
397              Param("VkImageTiling", "tiling"),
398              Param("uint32_t*", "pPropertyCount"),
399              Param("VkSparseImageFormatProperties*", "pProperties")]),
400
401         Proto("VkResult", "QueueBindSparse",
402             [Param("VkQueue", "queue"),
403              Param("uint32_t", "bindInfoCount"),
404              Param("const VkBindSparseInfo*", "pBindInfo"),
405              Param("VkFence", "fence")]),
406
407         Proto("VkResult", "CreateFence",
408             [Param("VkDevice", "device"),
409              Param("const VkFenceCreateInfo*", "pCreateInfo"),
410              Param("const VkAllocationCallbacks*", "pAllocator"),
411              Param("VkFence*", "pFence")]),
412
413         Proto("void", "DestroyFence",
414             [Param("VkDevice", "device"),
415              Param("VkFence", "fence"),
416              Param("const VkAllocationCallbacks*", "pAllocator")]),
417
418         Proto("VkResult", "ResetFences",
419             [Param("VkDevice", "device"),
420              Param("uint32_t", "fenceCount"),
421              Param("const VkFence*", "pFences")]),
422
423         Proto("VkResult", "GetFenceStatus",
424             [Param("VkDevice", "device"),
425              Param("VkFence", "fence")]),
426
427         Proto("VkResult", "WaitForFences",
428             [Param("VkDevice", "device"),
429              Param("uint32_t", "fenceCount"),
430              Param("const VkFence*", "pFences"),
431              Param("VkBool32", "waitAll"),
432              Param("uint64_t", "timeout")]),
433
434         Proto("VkResult", "CreateSemaphore",
435             [Param("VkDevice", "device"),
436              Param("const VkSemaphoreCreateInfo*", "pCreateInfo"),
437              Param("const VkAllocationCallbacks*", "pAllocator"),
438              Param("VkSemaphore*", "pSemaphore")]),
439
440         Proto("void", "DestroySemaphore",
441             [Param("VkDevice", "device"),
442              Param("VkSemaphore", "semaphore"),
443              Param("const VkAllocationCallbacks*", "pAllocator")]),
444
445         Proto("VkResult", "CreateEvent",
446             [Param("VkDevice", "device"),
447              Param("const VkEventCreateInfo*", "pCreateInfo"),
448              Param("const VkAllocationCallbacks*", "pAllocator"),
449              Param("VkEvent*", "pEvent")]),
450
451         Proto("void", "DestroyEvent",
452             [Param("VkDevice", "device"),
453              Param("VkEvent", "event"),
454              Param("const VkAllocationCallbacks*", "pAllocator")]),
455
456         Proto("VkResult", "GetEventStatus",
457             [Param("VkDevice", "device"),
458              Param("VkEvent", "event")]),
459
460         Proto("VkResult", "SetEvent",
461             [Param("VkDevice", "device"),
462              Param("VkEvent", "event")]),
463
464         Proto("VkResult", "ResetEvent",
465             [Param("VkDevice", "device"),
466              Param("VkEvent", "event")]),
467
468         Proto("VkResult", "CreateQueryPool",
469             [Param("VkDevice", "device"),
470              Param("const VkQueryPoolCreateInfo*", "pCreateInfo"),
471              Param("const VkAllocationCallbacks*", "pAllocator"),
472              Param("VkQueryPool*", "pQueryPool")]),
473
474         Proto("void", "DestroyQueryPool",
475             [Param("VkDevice", "device"),
476              Param("VkQueryPool", "queryPool"),
477              Param("const VkAllocationCallbacks*", "pAllocator")]),
478
479         Proto("VkResult", "GetQueryPoolResults",
480             [Param("VkDevice", "device"),
481              Param("VkQueryPool", "queryPool"),
482              Param("uint32_t", "firstQuery"),
483              Param("uint32_t", "queryCount"),
484              Param("size_t", "dataSize"),
485              Param("void*", "pData"),
486              Param("VkDeviceSize", "stride"),
487              Param("VkQueryResultFlags", "flags")]),
488
489         Proto("VkResult", "CreateBuffer",
490             [Param("VkDevice", "device"),
491              Param("const VkBufferCreateInfo*", "pCreateInfo"),
492              Param("const VkAllocationCallbacks*", "pAllocator"),
493              Param("VkBuffer*", "pBuffer")]),
494
495         Proto("void", "DestroyBuffer",
496             [Param("VkDevice", "device"),
497              Param("VkBuffer", "buffer"),
498              Param("const VkAllocationCallbacks*", "pAllocator")]),
499
500         Proto("VkResult", "CreateBufferView",
501             [Param("VkDevice", "device"),
502              Param("const VkBufferViewCreateInfo*", "pCreateInfo"),
503              Param("const VkAllocationCallbacks*", "pAllocator"),
504              Param("VkBufferView*", "pView")]),
505
506         Proto("void", "DestroyBufferView",
507             [Param("VkDevice", "device"),
508              Param("VkBufferView", "bufferView"),
509              Param("const VkAllocationCallbacks*", "pAllocator")]),
510
511         Proto("VkResult", "CreateImage",
512             [Param("VkDevice", "device"),
513              Param("const VkImageCreateInfo*", "pCreateInfo"),
514              Param("const VkAllocationCallbacks*", "pAllocator"),
515              Param("VkImage*", "pImage")]),
516
517         Proto("void", "DestroyImage",
518             [Param("VkDevice", "device"),
519              Param("VkImage", "image"),
520              Param("const VkAllocationCallbacks*", "pAllocator")]),
521
522         Proto("void", "GetImageSubresourceLayout",
523             [Param("VkDevice", "device"),
524              Param("VkImage", "image"),
525              Param("const VkImageSubresource*", "pSubresource"),
526              Param("VkSubresourceLayout*", "pLayout")]),
527
528         Proto("VkResult", "CreateImageView",
529             [Param("VkDevice", "device"),
530              Param("const VkImageViewCreateInfo*", "pCreateInfo"),
531              Param("const VkAllocationCallbacks*", "pAllocator"),
532              Param("VkImageView*", "pView")]),
533
534         Proto("void", "DestroyImageView",
535             [Param("VkDevice", "device"),
536              Param("VkImageView", "imageView"),
537              Param("const VkAllocationCallbacks*", "pAllocator")]),
538
539         Proto("VkResult", "CreateShaderModule",
540             [Param("VkDevice", "device"),
541              Param("const VkShaderModuleCreateInfo*", "pCreateInfo"),
542              Param("const VkAllocationCallbacks*", "pAllocator"),
543              Param("VkShaderModule*", "pShaderModule")]),
544
545         Proto("void", "DestroyShaderModule",
546             [Param("VkDevice", "device"),
547              Param("VkShaderModule", "shaderModule"),
548              Param("const VkAllocationCallbacks*", "pAllocator")]),
549
550         Proto("VkResult", "CreatePipelineCache",
551             [Param("VkDevice", "device"),
552              Param("const VkPipelineCacheCreateInfo*", "pCreateInfo"),
553              Param("const VkAllocationCallbacks*", "pAllocator"),
554              Param("VkPipelineCache*", "pPipelineCache")]),
555
556         Proto("void", "DestroyPipelineCache",
557             [Param("VkDevice", "device"),
558              Param("VkPipelineCache", "pipelineCache"),
559              Param("const VkAllocationCallbacks*", "pAllocator")]),
560
561         Proto("VkResult", "GetPipelineCacheData",
562             [Param("VkDevice", "device"),
563              Param("VkPipelineCache", "pipelineCache"),
564              Param("size_t*", "pDataSize"),
565              Param("void*", "pData")]),
566
567         Proto("VkResult", "MergePipelineCaches",
568             [Param("VkDevice", "device"),
569              Param("VkPipelineCache", "dstCache"),
570              Param("uint32_t", "srcCacheCount"),
571              Param("const VkPipelineCache*", "pSrcCaches")]),
572
573         Proto("VkResult", "CreateGraphicsPipelines",
574             [Param("VkDevice", "device"),
575              Param("VkPipelineCache", "pipelineCache"),
576              Param("uint32_t", "createInfoCount"),
577              Param("const VkGraphicsPipelineCreateInfo*", "pCreateInfos"),
578              Param("const VkAllocationCallbacks*", "pAllocator"),
579              Param("VkPipeline*", "pPipelines")]),
580
581         Proto("VkResult", "CreateComputePipelines",
582             [Param("VkDevice", "device"),
583              Param("VkPipelineCache", "pipelineCache"),
584              Param("uint32_t", "createInfoCount"),
585              Param("const VkComputePipelineCreateInfo*", "pCreateInfos"),
586              Param("const VkAllocationCallbacks*", "pAllocator"),
587              Param("VkPipeline*", "pPipelines")]),
588
589         Proto("void", "DestroyPipeline",
590             [Param("VkDevice", "device"),
591              Param("VkPipeline", "pipeline"),
592              Param("const VkAllocationCallbacks*", "pAllocator")]),
593
594         Proto("VkResult", "CreatePipelineLayout",
595             [Param("VkDevice", "device"),
596              Param("const VkPipelineLayoutCreateInfo*", "pCreateInfo"),
597              Param("const VkAllocationCallbacks*", "pAllocator"),
598              Param("VkPipelineLayout*", "pPipelineLayout")]),
599
600         Proto("void", "DestroyPipelineLayout",
601             [Param("VkDevice", "device"),
602              Param("VkPipelineLayout", "pipelineLayout"),
603              Param("const VkAllocationCallbacks*", "pAllocator")]),
604
605         Proto("VkResult", "CreateSampler",
606             [Param("VkDevice", "device"),
607              Param("const VkSamplerCreateInfo*", "pCreateInfo"),
608              Param("const VkAllocationCallbacks*", "pAllocator"),
609              Param("VkSampler*", "pSampler")]),
610
611         Proto("void", "DestroySampler",
612             [Param("VkDevice", "device"),
613              Param("VkSampler", "sampler"),
614              Param("const VkAllocationCallbacks*", "pAllocator")]),
615
616         Proto("VkResult", "CreateDescriptorSetLayout",
617             [Param("VkDevice", "device"),
618              Param("const VkDescriptorSetLayoutCreateInfo*", "pCreateInfo"),
619              Param("const VkAllocationCallbacks*", "pAllocator"),
620              Param("VkDescriptorSetLayout*", "pSetLayout")]),
621
622         Proto("void", "DestroyDescriptorSetLayout",
623             [Param("VkDevice", "device"),
624              Param("VkDescriptorSetLayout", "descriptorSetLayout"),
625              Param("const VkAllocationCallbacks*", "pAllocator")]),
626
627         Proto("VkResult", "CreateDescriptorPool",
628             [Param("VkDevice", "device"),
629              Param("const VkDescriptorPoolCreateInfo*", "pCreateInfo"),
630              Param("const VkAllocationCallbacks*", "pAllocator"),
631              Param("VkDescriptorPool*", "pDescriptorPool")]),
632
633         Proto("void", "DestroyDescriptorPool",
634             [Param("VkDevice", "device"),
635              Param("VkDescriptorPool", "descriptorPool"),
636              Param("const VkAllocationCallbacks*", "pAllocator")]),
637
638         Proto("VkResult", "ResetDescriptorPool",
639             [Param("VkDevice", "device"),
640              Param("VkDescriptorPool", "descriptorPool"),
641              Param("VkDescriptorPoolResetFlags", "flags")]),
642
643         Proto("VkResult", "AllocateDescriptorSets",
644             [Param("VkDevice", "device"),
645              Param("const VkDescriptorSetAllocateInfo*", "pAllocateInfo"),
646              Param("VkDescriptorSet*", "pDescriptorSets")]),
647
648         Proto("VkResult", "FreeDescriptorSets",
649             [Param("VkDevice", "device"),
650              Param("VkDescriptorPool", "descriptorPool"),
651              Param("uint32_t", "descriptorSetCount"),
652              Param("const VkDescriptorSet*", "pDescriptorSets")]),
653
654         Proto("void", "UpdateDescriptorSets",
655             [Param("VkDevice", "device"),
656              Param("uint32_t", "descriptorWriteCount"),
657              Param("const VkWriteDescriptorSet*", "pDescriptorWrites"),
658              Param("uint32_t", "descriptorCopyCount"),
659              Param("const VkCopyDescriptorSet*", "pDescriptorCopies")]),
660
661         Proto("VkResult", "CreateFramebuffer",
662             [Param("VkDevice", "device"),
663              Param("const VkFramebufferCreateInfo*", "pCreateInfo"),
664              Param("const VkAllocationCallbacks*", "pAllocator"),
665              Param("VkFramebuffer*", "pFramebuffer")]),
666
667         Proto("void", "DestroyFramebuffer",
668             [Param("VkDevice", "device"),
669              Param("VkFramebuffer", "framebuffer"),
670              Param("const VkAllocationCallbacks*", "pAllocator")]),
671
672         Proto("VkResult", "CreateRenderPass",
673             [Param("VkDevice", "device"),
674              Param("const VkRenderPassCreateInfo*", "pCreateInfo"),
675              Param("const VkAllocationCallbacks*", "pAllocator"),
676              Param("VkRenderPass*", "pRenderPass")]),
677
678         Proto("void", "DestroyRenderPass",
679             [Param("VkDevice", "device"),
680              Param("VkRenderPass", "renderPass"),
681              Param("const VkAllocationCallbacks*", "pAllocator")]),
682
683         Proto("void", "GetRenderAreaGranularity",
684             [Param("VkDevice", "device"),
685              Param("VkRenderPass", "renderPass"),
686              Param("VkExtent2D*", "pGranularity")]),
687
688         Proto("VkResult", "CreateCommandPool",
689             [Param("VkDevice", "device"),
690              Param("const VkCommandPoolCreateInfo*", "pCreateInfo"),
691              Param("const VkAllocationCallbacks*", "pAllocator"),
692              Param("VkCommandPool*", "pCommandPool")]),
693
694         Proto("void", "DestroyCommandPool",
695             [Param("VkDevice", "device"),
696              Param("VkCommandPool", "commandPool"),
697              Param("const VkAllocationCallbacks*", "pAllocator")]),
698
699         Proto("VkResult", "ResetCommandPool",
700             [Param("VkDevice", "device"),
701              Param("VkCommandPool", "commandPool"),
702              Param("VkCommandPoolResetFlags", "flags")]),
703
704         Proto("VkResult", "AllocateCommandBuffers",
705             [Param("VkDevice", "device"),
706              Param("const VkCommandBufferAllocateInfo*", "pAllocateInfo"),
707              Param("VkCommandBuffer*", "pCommandBuffers")]),
708
709         Proto("void", "FreeCommandBuffers",
710             [Param("VkDevice", "device"),
711              Param("VkCommandPool", "commandPool"),
712              Param("uint32_t", "commandBufferCount"),
713              Param("const VkCommandBuffer*", "pCommandBuffers")]),
714
715         Proto("VkResult", "BeginCommandBuffer",
716             [Param("VkCommandBuffer", "commandBuffer"),
717              Param("const VkCommandBufferBeginInfo*", "pBeginInfo")]),
718
719         Proto("VkResult", "EndCommandBuffer",
720             [Param("VkCommandBuffer", "commandBuffer")]),
721
722         Proto("VkResult", "ResetCommandBuffer",
723             [Param("VkCommandBuffer", "commandBuffer"),
724              Param("VkCommandBufferResetFlags", "flags")]),
725
726         Proto("void", "CmdBindPipeline",
727             [Param("VkCommandBuffer", "commandBuffer"),
728              Param("VkPipelineBindPoint", "pipelineBindPoint"),
729              Param("VkPipeline", "pipeline")]),
730
731         Proto("void", "CmdSetViewport",
732             [Param("VkCommandBuffer", "commandBuffer"),
733              Param("uint32_t", "firstViewport"),
734              Param("uint32_t", "viewportCount"),
735              Param("const VkViewport*", "pViewports")]),
736
737         Proto("void", "CmdSetScissor",
738             [Param("VkCommandBuffer", "commandBuffer"),
739              Param("uint32_t", "firstScissor"),
740              Param("uint32_t", "scissorCount"),
741              Param("const VkRect2D*", "pScissors")]),
742
743         Proto("void", "CmdSetLineWidth",
744             [Param("VkCommandBuffer", "commandBuffer"),
745              Param("float", "lineWidth")]),
746
747         Proto("void", "CmdSetDepthBias",
748             [Param("VkCommandBuffer", "commandBuffer"),
749              Param("float", "depthBiasConstantFactor"),
750              Param("float", "depthBiasClamp"),
751              Param("float", "depthBiasSlopeFactor")]),
752
753         Proto("void", "CmdSetBlendConstants",
754             [Param("VkCommandBuffer", "commandBuffer"),
755              Param("const float[4]", "blendConstants")]),
756
757         Proto("void", "CmdSetDepthBounds",
758             [Param("VkCommandBuffer", "commandBuffer"),
759              Param("float", "minDepthBounds"),
760              Param("float", "maxDepthBounds")]),
761
762         Proto("void", "CmdSetStencilCompareMask",
763             [Param("VkCommandBuffer", "commandBuffer"),
764              Param("VkStencilFaceFlags", "faceMask"),
765              Param("uint32_t", "compareMask")]),
766
767         Proto("void", "CmdSetStencilWriteMask",
768             [Param("VkCommandBuffer", "commandBuffer"),
769              Param("VkStencilFaceFlags", "faceMask"),
770              Param("uint32_t", "writeMask")]),
771
772         Proto("void", "CmdSetStencilReference",
773             [Param("VkCommandBuffer", "commandBuffer"),
774              Param("VkStencilFaceFlags", "faceMask"),
775              Param("uint32_t", "reference")]),
776
777         Proto("void", "CmdBindDescriptorSets",
778             [Param("VkCommandBuffer", "commandBuffer"),
779              Param("VkPipelineBindPoint", "pipelineBindPoint"),
780              Param("VkPipelineLayout", "layout"),
781              Param("uint32_t", "firstSet"),
782              Param("uint32_t", "descriptorSetCount"),
783              Param("const VkDescriptorSet*", "pDescriptorSets"),
784              Param("uint32_t", "dynamicOffsetCount"),
785              Param("const uint32_t*", "pDynamicOffsets")]),
786
787         Proto("void", "CmdBindIndexBuffer",
788             [Param("VkCommandBuffer", "commandBuffer"),
789              Param("VkBuffer", "buffer"),
790              Param("VkDeviceSize", "offset"),
791              Param("VkIndexType", "indexType")]),
792
793         Proto("void", "CmdBindVertexBuffers",
794             [Param("VkCommandBuffer", "commandBuffer"),
795              Param("uint32_t", "firstBinding"),
796              Param("uint32_t", "bindingCount"),
797              Param("const VkBuffer*", "pBuffers"),
798              Param("const VkDeviceSize*", "pOffsets")]),
799
800         Proto("void", "CmdDraw",
801             [Param("VkCommandBuffer", "commandBuffer"),
802              Param("uint32_t", "vertexCount"),
803              Param("uint32_t", "instanceCount"),
804              Param("uint32_t", "firstVertex"),
805              Param("uint32_t", "firstInstance")]),
806
807         Proto("void", "CmdDrawIndexed",
808             [Param("VkCommandBuffer", "commandBuffer"),
809              Param("uint32_t", "indexCount"),
810              Param("uint32_t", "instanceCount"),
811              Param("uint32_t", "firstIndex"),
812              Param("int32_t", "vertexOffset"),
813              Param("uint32_t", "firstInstance")]),
814
815         Proto("void", "CmdDrawIndirect",
816             [Param("VkCommandBuffer", "commandBuffer"),
817              Param("VkBuffer", "buffer"),
818              Param("VkDeviceSize", "offset"),
819              Param("uint32_t", "drawCount"),
820              Param("uint32_t", "stride")]),
821
822         Proto("void", "CmdDrawIndexedIndirect",
823             [Param("VkCommandBuffer", "commandBuffer"),
824              Param("VkBuffer", "buffer"),
825              Param("VkDeviceSize", "offset"),
826              Param("uint32_t", "drawCount"),
827              Param("uint32_t", "stride")]),
828
829         Proto("void", "CmdDispatch",
830             [Param("VkCommandBuffer", "commandBuffer"),
831              Param("uint32_t", "x"),
832              Param("uint32_t", "y"),
833              Param("uint32_t", "z")]),
834
835         Proto("void", "CmdDispatchIndirect",
836             [Param("VkCommandBuffer", "commandBuffer"),
837              Param("VkBuffer", "buffer"),
838              Param("VkDeviceSize", "offset")]),
839
840         Proto("void", "CmdCopyBuffer",
841             [Param("VkCommandBuffer", "commandBuffer"),
842              Param("VkBuffer", "srcBuffer"),
843              Param("VkBuffer", "dstBuffer"),
844              Param("uint32_t", "regionCount"),
845              Param("const VkBufferCopy*", "pRegions")]),
846
847         Proto("void", "CmdCopyImage",
848             [Param("VkCommandBuffer", "commandBuffer"),
849              Param("VkImage", "srcImage"),
850              Param("VkImageLayout", "srcImageLayout"),
851              Param("VkImage", "dstImage"),
852              Param("VkImageLayout", "dstImageLayout"),
853              Param("uint32_t", "regionCount"),
854              Param("const VkImageCopy*", "pRegions")]),
855
856         Proto("void", "CmdBlitImage",
857             [Param("VkCommandBuffer", "commandBuffer"),
858              Param("VkImage", "srcImage"),
859              Param("VkImageLayout", "srcImageLayout"),
860              Param("VkImage", "dstImage"),
861              Param("VkImageLayout", "dstImageLayout"),
862              Param("uint32_t", "regionCount"),
863              Param("const VkImageBlit*", "pRegions"),
864              Param("VkFilter", "filter")]),
865
866         Proto("void", "CmdCopyBufferToImage",
867             [Param("VkCommandBuffer", "commandBuffer"),
868              Param("VkBuffer", "srcBuffer"),
869              Param("VkImage", "dstImage"),
870              Param("VkImageLayout", "dstImageLayout"),
871              Param("uint32_t", "regionCount"),
872              Param("const VkBufferImageCopy*", "pRegions")]),
873
874         Proto("void", "CmdCopyImageToBuffer",
875             [Param("VkCommandBuffer", "commandBuffer"),
876              Param("VkImage", "srcImage"),
877              Param("VkImageLayout", "srcImageLayout"),
878              Param("VkBuffer", "dstBuffer"),
879              Param("uint32_t", "regionCount"),
880              Param("const VkBufferImageCopy*", "pRegions")]),
881
882         Proto("void", "CmdUpdateBuffer",
883             [Param("VkCommandBuffer", "commandBuffer"),
884              Param("VkBuffer", "dstBuffer"),
885              Param("VkDeviceSize", "dstOffset"),
886              Param("VkDeviceSize", "dataSize"),
887              Param("const void*", "pData")]),
888
889         Proto("void", "CmdFillBuffer",
890             [Param("VkCommandBuffer", "commandBuffer"),
891              Param("VkBuffer", "dstBuffer"),
892              Param("VkDeviceSize", "dstOffset"),
893              Param("VkDeviceSize", "size"),
894              Param("uint32_t", "data")]),
895
896         Proto("void", "CmdClearColorImage",
897             [Param("VkCommandBuffer", "commandBuffer"),
898              Param("VkImage", "image"),
899              Param("VkImageLayout", "imageLayout"),
900              Param("const VkClearColorValue*", "pColor"),
901              Param("uint32_t", "rangeCount"),
902              Param("const VkImageSubresourceRange*", "pRanges")]),
903
904         Proto("void", "CmdClearDepthStencilImage",
905             [Param("VkCommandBuffer", "commandBuffer"),
906              Param("VkImage", "image"),
907              Param("VkImageLayout", "imageLayout"),
908              Param("const VkClearDepthStencilValue*", "pDepthStencil"),
909              Param("uint32_t", "rangeCount"),
910              Param("const VkImageSubresourceRange*", "pRanges")]),
911
912         Proto("void", "CmdClearAttachments",
913             [Param("VkCommandBuffer", "commandBuffer"),
914              Param("uint32_t", "attachmentCount"),
915              Param("const VkClearAttachment*", "pAttachments"),
916              Param("uint32_t", "rectCount"),
917              Param("const VkClearRect*", "pRects")]),
918
919         Proto("void", "CmdResolveImage",
920             [Param("VkCommandBuffer", "commandBuffer"),
921              Param("VkImage", "srcImage"),
922              Param("VkImageLayout", "srcImageLayout"),
923              Param("VkImage", "dstImage"),
924              Param("VkImageLayout", "dstImageLayout"),
925              Param("uint32_t", "regionCount"),
926              Param("const VkImageResolve*", "pRegions")]),
927
928         Proto("void", "CmdSetEvent",
929             [Param("VkCommandBuffer", "commandBuffer"),
930              Param("VkEvent", "event"),
931              Param("VkPipelineStageFlags", "stageMask")]),
932
933         Proto("void", "CmdResetEvent",
934             [Param("VkCommandBuffer", "commandBuffer"),
935              Param("VkEvent", "event"),
936              Param("VkPipelineStageFlags", "stageMask")]),
937
938         Proto("void", "CmdWaitEvents",
939             [Param("VkCommandBuffer", "commandBuffer"),
940              Param("uint32_t", "eventCount"),
941              Param("const VkEvent*", "pEvents"),
942              Param("VkPipelineStageFlags", "srcStageMask"),
943              Param("VkPipelineStageFlags", "dstStageMask"),
944              Param("uint32_t", "memoryBarrierCount"),
945              Param("const VkMemoryBarrier*", "pMemoryBarriers"),
946              Param("uint32_t", "bufferMemoryBarrierCount"),
947              Param("const VkBufferMemoryBarrier*", "pBufferMemoryBarriers"),
948              Param("uint32_t", "imageMemoryBarrierCount"),
949              Param("const VkImageMemoryBarrier*", "pImageMemoryBarriers")]),
950
951         Proto("void", "CmdPipelineBarrier",
952             [Param("VkCommandBuffer", "commandBuffer"),
953              Param("VkPipelineStageFlags", "srcStageMask"),
954              Param("VkPipelineStageFlags", "dstStageMask"),
955              Param("VkDependencyFlags", "dependencyFlags"),
956              Param("uint32_t", "memoryBarrierCount"),
957              Param("const VkMemoryBarrier*", "pMemoryBarriers"),
958              Param("uint32_t", "bufferMemoryBarrierCount"),
959              Param("const VkBufferMemoryBarrier*", "pBufferMemoryBarriers"),
960              Param("uint32_t", "imageMemoryBarrierCount"),
961              Param("const VkImageMemoryBarrier*", "pImageMemoryBarriers")]),
962
963         Proto("void", "CmdBeginQuery",
964             [Param("VkCommandBuffer", "commandBuffer"),
965              Param("VkQueryPool", "queryPool"),
966              Param("uint32_t", "query"),
967              Param("VkQueryControlFlags", "flags")]),
968
969         Proto("void", "CmdEndQuery",
970             [Param("VkCommandBuffer", "commandBuffer"),
971              Param("VkQueryPool", "queryPool"),
972              Param("uint32_t", "query")]),
973
974         Proto("void", "CmdResetQueryPool",
975             [Param("VkCommandBuffer", "commandBuffer"),
976              Param("VkQueryPool", "queryPool"),
977              Param("uint32_t", "firstQuery"),
978              Param("uint32_t", "queryCount")]),
979
980         Proto("void", "CmdWriteTimestamp",
981             [Param("VkCommandBuffer", "commandBuffer"),
982              Param("VkPipelineStageFlagBits", "pipelineStage"),
983              Param("VkQueryPool", "queryPool"),
984              Param("uint32_t", "query")]),
985
986         Proto("void", "CmdCopyQueryPoolResults",
987             [Param("VkCommandBuffer", "commandBuffer"),
988              Param("VkQueryPool", "queryPool"),
989              Param("uint32_t", "firstQuery"),
990              Param("uint32_t", "queryCount"),
991              Param("VkBuffer", "dstBuffer"),
992              Param("VkDeviceSize", "dstOffset"),
993              Param("VkDeviceSize", "stride"),
994              Param("VkQueryResultFlags", "flags")]),
995
996         Proto("void", "CmdPushConstants",
997             [Param("VkCommandBuffer", "commandBuffer"),
998              Param("VkPipelineLayout", "layout"),
999              Param("VkShaderStageFlags", "stageFlags"),
1000              Param("uint32_t", "offset"),
1001              Param("uint32_t", "size"),
1002              Param("const void*", "pValues")]),
1003
1004         Proto("void", "CmdBeginRenderPass",
1005             [Param("VkCommandBuffer", "commandBuffer"),
1006              Param("const VkRenderPassBeginInfo*", "pRenderPassBegin"),
1007              Param("VkSubpassContents", "contents")]),
1008
1009         Proto("void", "CmdNextSubpass",
1010             [Param("VkCommandBuffer", "commandBuffer"),
1011              Param("VkSubpassContents", "contents")]),
1012
1013         Proto("void", "CmdEndRenderPass",
1014             [Param("VkCommandBuffer", "commandBuffer")]),
1015
1016         Proto("void", "CmdExecuteCommands",
1017             [Param("VkCommandBuffer", "commandBuffer"),
1018              Param("uint32_t", "commandBufferCount"),
1019              Param("const VkCommandBuffer*", "pCommandBuffers")]),
1020     ],
1021 )
1022
1023 ext_amd_draw_indirect_count = Extension(
1024     name="VK_AMD_draw_indirect_count",
1025     headers=["vulkan/vulkan.h"],
1026     objects=[],
1027     protos=[
1028         Proto("void", "CmdDrawIndirectCountAMD",
1029             [Param("VkCommandBuffer", "commandBuffer"),
1030              Param("VkBuffer", "buffer"),
1031              Param("VkDeviceSize", "offset"),
1032              Param("VkBuffer", "countBuffer"),
1033              Param("VkDeviceSize", "countBufferOffset"),
1034              Param("uint32_t", "maxDrawCount"),
1035              Param("uint32_t", "stride")]),
1036
1037         Proto("void", "CmdDrawIndexedIndirectCountAMD",
1038             [Param("VkCommandBuffer", "commandBuffer"),
1039              Param("VkBuffer", "buffer"),
1040              Param("VkDeviceSize", "offset"),
1041              Param("VkBuffer", "countBuffer"),
1042              Param("VkDeviceSize", "countBufferOffset"),
1043              Param("uint32_t", "maxDrawCount"),
1044              Param("uint32_t", "stride")]),
1045     ],
1046 )
1047
1048 ext_nv_external_memory_capabilities = Extension(
1049     name="VK_NV_external_memory_capabilities",
1050     headers=["vulkan/vulkan.h"],
1051     objects=[],
1052     protos=[
1053         Proto("VkResult", "GetPhysicalDeviceExternalImageFormatPropertiesNV",
1054             [Param("VkPhysicalDevice", "physicalDevice"),
1055              Param("VkFormat", "format"),
1056              Param("VkImageType", "type"),
1057              Param("VkImageTiling", "tiling"),
1058              Param("VkImageUsageFlags", "usage"),
1059              Param("VkImageCreateFlags", "flags"),
1060              Param("VkExternalMemoryHandleTypeFlagsNV", "externalHandleType"),
1061              Param("VkExternalImageFormatPropertiesNV*", "pExternalImageFormatProperties")]),
1062     ],
1063 )
1064
1065 ext_nv_external_memory_win32 = Extension(
1066     name="VK_NV_external_memory_win32",
1067     headers=["vulkan/vulkan.h"],
1068     objects=[],
1069     ifdef="VK_USE_PLATFORM_WIN32_KHR",
1070     protos=[
1071         Proto("VkResult", "GetMemoryWin32HandleNV",
1072             [Param("VkDevice", "device"),
1073              Param("VkDeviceMemory", "memory"),
1074              Param("VkExternalMemoryHandleTypeFlagsNV", "handleType"),
1075              Param("HANDLE*", "pHandle")]),
1076     ],
1077 )
1078
1079 ext_khr_surface = Extension(
1080     name="VK_KHR_surface",
1081     headers=["vulkan/vulkan.h"],
1082     objects=["vkSurfaceKHR"],
1083     protos=[
1084         Proto("void", "DestroySurfaceKHR",
1085             [Param("VkInstance", "instance"),
1086              Param("VkSurfaceKHR", "surface"),
1087              Param("const VkAllocationCallbacks*", "pAllocator")]),
1088
1089         Proto("VkResult", "GetPhysicalDeviceSurfaceSupportKHR",
1090             [Param("VkPhysicalDevice", "physicalDevice"),
1091              Param("uint32_t", "queueFamilyIndex"),
1092              Param("VkSurfaceKHR", "surface"),
1093              Param("VkBool32*", "pSupported")]),
1094
1095         Proto("VkResult", "GetPhysicalDeviceSurfaceCapabilitiesKHR",
1096             [Param("VkPhysicalDevice", "physicalDevice"),
1097              Param("VkSurfaceKHR", "surface"),
1098              Param("VkSurfaceCapabilitiesKHR*", "pSurfaceCapabilities")]),
1099
1100         Proto("VkResult", "GetPhysicalDeviceSurfaceFormatsKHR",
1101             [Param("VkPhysicalDevice", "physicalDevice"),
1102              Param("VkSurfaceKHR", "surface"),
1103              Param("uint32_t*", "pSurfaceFormatCount"),
1104              Param("VkSurfaceFormatKHR*", "pSurfaceFormats")]),
1105
1106         Proto("VkResult", "GetPhysicalDeviceSurfacePresentModesKHR",
1107             [Param("VkPhysicalDevice", "physicalDevice"),
1108              Param("VkSurfaceKHR", "surface"),
1109              Param("uint32_t*", "pPresentModeCount"),
1110              Param("VkPresentModeKHR*", "pPresentModes")]),
1111     ],
1112 )
1113
1114 ext_khr_display = Extension(
1115     name="VK_KHR_display",
1116     headers=["vulkan/vulkan.h"],
1117     objects=['VkSurfaceKHR', 'VkDisplayModeKHR'],
1118     protos=[
1119         Proto("VkResult", "GetPhysicalDeviceDisplayPropertiesKHR",
1120             [Param("VkPhysicalDevice", "physicalDevice"),
1121              Param("uint32_t*", "pPropertyCount"),
1122              Param("VkDisplayPropertiesKHR*", "pProperties")]),
1123
1124         Proto("VkResult", "GetPhysicalDeviceDisplayPlanePropertiesKHR",
1125             [Param("VkPhysicalDevice", "physicalDevice"),
1126              Param("uint32_t*", "pPropertyCount"),
1127              Param("VkDisplayPlanePropertiesKHR*", "pProperties")]),
1128
1129         Proto("VkResult", "GetDisplayPlaneSupportedDisplaysKHR",
1130             [Param("VkPhysicalDevice", "physicalDevice"),
1131              Param("uint32_t", "planeIndex"),
1132              Param("uint32_t*", "pDisplayCount"),
1133              Param("VkDisplayKHR*", "pDisplays")]),
1134
1135         Proto("VkResult", "GetDisplayModePropertiesKHR",
1136             [Param("VkPhysicalDevice", "physicalDevice"),
1137              Param("VkDisplayKHR", "display"),
1138              Param("uint32_t*", "pPropertyCount"),
1139              Param("VkDisplayModePropertiesKHR*", "pProperties")]),
1140
1141         Proto("VkResult", "CreateDisplayModeKHR",
1142             [Param("VkPhysicalDevice", "physicalDevice"),
1143              Param("VkDisplayKHR", "display"),
1144              Param("const VkDisplayModeCreateInfoKHR*", "pCreateInfo"),
1145              Param("const VkAllocationCallbacks*", "pAllocator"),
1146              Param("VkDisplayModeKHR*", "pMode")]),
1147
1148         Proto("VkResult", "GetDisplayPlaneCapabilitiesKHR",
1149             [Param("VkPhysicalDevice", "physicalDevice"),
1150              Param("VkDisplayModeKHR", "mode"),
1151              Param("uint32_t", "planeIndex"),
1152              Param("VkDisplayPlaneCapabilitiesKHR*", "pCapabilities")]),
1153
1154         Proto("VkResult", "CreateDisplayPlaneSurfaceKHR",
1155             [Param("VkInstance", "instance"),
1156              Param("const VkDisplaySurfaceCreateInfoKHR*", "pCreateInfo"),
1157              Param("const VkAllocationCallbacks*", "pAllocator"),
1158              Param("VkSurfaceKHR*", "pSurface")]),
1159     ],
1160 )
1161
1162 ext_khr_device_swapchain = Extension(
1163     name="VK_KHR_swapchain",
1164     headers=["vulkan/vulkan.h"],
1165     objects=["VkSwapchainKHR"],
1166     protos=[
1167         Proto("VkResult", "CreateSwapchainKHR",
1168             [Param("VkDevice", "device"),
1169              Param("const VkSwapchainCreateInfoKHR*", "pCreateInfo"),
1170              Param("const VkAllocationCallbacks*", "pAllocator"),
1171              Param("VkSwapchainKHR*", "pSwapchain")]),
1172
1173         Proto("void", "DestroySwapchainKHR",
1174             [Param("VkDevice", "device"),
1175              Param("VkSwapchainKHR", "swapchain"),
1176              Param("const VkAllocationCallbacks*", "pAllocator")]),
1177
1178         Proto("VkResult", "GetSwapchainImagesKHR",
1179             [Param("VkDevice", "device"),
1180          Param("VkSwapchainKHR", "swapchain"),
1181          Param("uint32_t*", "pSwapchainImageCount"),
1182              Param("VkImage*", "pSwapchainImages")]),
1183
1184         Proto("VkResult", "AcquireNextImageKHR",
1185             [Param("VkDevice", "device"),
1186              Param("VkSwapchainKHR", "swapchain"),
1187              Param("uint64_t", "timeout"),
1188              Param("VkSemaphore", "semaphore"),
1189              Param("VkFence", "fence"),
1190              Param("uint32_t*", "pImageIndex")]),
1191
1192         Proto("VkResult", "QueuePresentKHR",
1193             [Param("VkQueue", "queue"),
1194              Param("const VkPresentInfoKHR*", "pPresentInfo")]),
1195     ],
1196 )
1197
1198 ext_khr_display_swapchain = Extension(
1199     name="VK_KHR_display_swapchain",
1200     headers=["vulkan/vulkan.h"],
1201     objects=["VkDisplayPresentInfoKHR"],
1202     protos=[
1203         Proto("VkResult", "CreateSharedSwapchainsKHR",
1204             [Param("VkDevice", "device"),
1205              Param("uint32_t", "swapchainCount"),
1206              Param("const VkSwapchainCreateInfoKHR*", "pCreateInfos"),
1207              Param("const VkAllocationCallbacks*", "pAllocator"),
1208              Param("VkSwapchainKHR*", "pSwapchains")]),
1209     ],
1210 )
1211
1212 ext_khr_xcb_surface = Extension(
1213     name="VK_KHR_xcb_surface",
1214     headers=["vulkan/vulkan.h"],
1215     objects=[],
1216     protos=[
1217         Proto("VkResult", "CreateXcbSurfaceKHR",
1218             [Param("VkInstance", "instance"),
1219              Param("const VkXcbSurfaceCreateInfoKHR*", "pCreateInfo"),
1220              Param("const VkAllocationCallbacks*", "pAllocator"),
1221              Param("VkSurfaceKHR*", "pSurface")]),
1222
1223         Proto("VkBool32", "GetPhysicalDeviceXcbPresentationSupportKHR",
1224             [Param("VkPhysicalDevice", "physicalDevice"),
1225              Param("uint32_t", "queueFamilyIndex"),
1226              Param("xcb_connection_t*", "connection"),
1227              Param("xcb_visualid_t", "visual_id")]),
1228     ],
1229 )
1230 ext_khr_xlib_surface = Extension(
1231     name="VK_KHR_xlib_surface",
1232     headers=["vulkan/vulkan.h"],
1233     objects=[],
1234     ifdef="VK_USE_PLATFORM_XLIB_KHR",
1235     protos=[
1236         Proto("VkResult", "CreateXlibSurfaceKHR",
1237             [Param("VkInstance", "instance"),
1238              Param("const VkXlibSurfaceCreateInfoKHR*", "pCreateInfo"),
1239              Param("const VkAllocationCallbacks*", "pAllocator"),
1240              Param("VkSurfaceKHR*", "pSurface")]),
1241
1242         Proto("VkBool32", "GetPhysicalDeviceXlibPresentationSupportKHR",
1243             [Param("VkPhysicalDevice", "physicalDevice"),
1244              Param("uint32_t", "queueFamilyIndex"),
1245              Param("Display*", "dpy"),
1246              Param("VisualID", "visualID")]),
1247     ],
1248 )
1249 ext_khr_wayland_surface = Extension(
1250     name="VK_KHR_wayland_surface",
1251     headers=["vulkan/vulkan.h"],
1252     objects=[],
1253     protos=[
1254         Proto("VkResult", "CreateWaylandSurfaceKHR",
1255             [Param("VkInstance", "instance"),
1256              Param("const VkWaylandSurfaceCreateInfoKHR*", "pCreateInfo"),
1257              Param("const VkAllocationCallbacks*", "pAllocator"),
1258              Param("VkSurfaceKHR*", "pSurface")]),
1259
1260         Proto("VkBool32", "GetPhysicalDeviceWaylandPresentationSupportKHR",
1261             [Param("VkPhysicalDevice", "physicalDevice"),
1262              Param("uint32_t", "queueFamilyIndex"),
1263              Param("struct wl_display*", "display")]),
1264     ],
1265 )
1266 ext_khr_mir_surface = Extension(
1267     name="VK_KHR_mir_surface",
1268     headers=["vulkan/vulkan.h"],
1269     objects=[],
1270     protos=[
1271         Proto("VkResult", "CreateMirSurfaceKHR",
1272             [Param("VkInstance", "instance"),
1273              Param("const VkMirSurfaceCreateInfoKHR*", "pCreateInfo"),
1274              Param("const VkAllocationCallbacks*", "pAllocator"),
1275              Param("VkSurfaceKHR*", "pSurface")]),
1276
1277         Proto("VkBool32", "GetPhysicalDeviceMirPresentationSupportKHR",
1278             [Param("VkPhysicalDevice", "physicalDevice"),
1279              Param("uint32_t", "queueFamilyIndex"),
1280              Param("MirConnection*", "connection")]),
1281     ],
1282 )
1283 ext_khr_android_surface = Extension(
1284     name="VK_KHR_android_surface",
1285     headers=["vulkan/vulkan.h"],
1286     objects=[],
1287     protos=[
1288         Proto("VkResult", "CreateAndroidSurfaceKHR",
1289             [Param("VkInstance", "instance"),
1290              Param("const VkAndroidSurfaceCreateInfoKHR*", "pCreateInfo"),
1291              Param("const VkAllocationCallbacks*", "pAllocator"),
1292              Param("VkSurfaceKHR*", "pSurface")]),
1293     ],
1294 )
1295 ext_khr_win32_surface = Extension(
1296     name="VK_KHR_win32_surface",
1297     headers=["vulkan/vulkan.h"],
1298     objects=[],
1299     protos=[
1300         Proto("VkResult", "CreateWin32SurfaceKHR",
1301             [Param("VkInstance", "instance"),
1302              Param("const VkWin32SurfaceCreateInfoKHR*", "pCreateInfo"),
1303              Param("const VkAllocationCallbacks*", "pAllocator"),
1304              Param("VkSurfaceKHR*", "pSurface")]),
1305
1306         Proto("VkBool32", "GetPhysicalDeviceWin32PresentationSupportKHR",
1307             [Param("VkPhysicalDevice", "physicalDevice"),
1308              Param("uint32_t", "queueFamilyIndex")]),
1309     ],
1310 )
1311 ext_debug_report = Extension(
1312     name="VK_EXT_debug_report",
1313     headers=["vulkan/vulkan.h"],
1314     objects=[
1315         "VkDebugReportCallbackEXT",
1316     ],
1317     protos=[
1318         Proto("VkResult", "CreateDebugReportCallbackEXT",
1319             [Param("VkInstance", "instance"),
1320              Param("const VkDebugReportCallbackCreateInfoEXT*", "pCreateInfo"),
1321              Param("const VkAllocationCallbacks*", "pAllocator"),
1322              Param("VkDebugReportCallbackEXT*", "pCallback")]),
1323
1324         Proto("void", "DestroyDebugReportCallbackEXT",
1325             [Param("VkInstance", "instance"),
1326              Param("VkDebugReportCallbackEXT", "callback"),
1327              Param("const VkAllocationCallbacks*", "pAllocator")]),
1328
1329         Proto("void", "DebugReportMessageEXT",
1330             [Param("VkInstance", "instance"),
1331              Param("VkDebugReportFlagsEXT", "flags"),
1332              Param("VkDebugReportObjectTypeEXT", "objType"),
1333              Param("uint64_t", "object"),
1334              Param("size_t", "location"),
1335              Param("int32_t", "msgCode"),
1336              Param("const char *", "pLayerPrefix"),
1337              Param("const char *", "pMsg")]),
1338     ],
1339 )
1340 ext_debug_marker = Extension(
1341     name="VK_EXT_debug_marker",
1342     headers=["vulkan/vulkan.h"],
1343     objects=[
1344         "VkDebugMarkerObjectNameInfoEXT",
1345         "VkDebugMarkerObjectTagInfoEXT",
1346         "VkDebugMarkerMarkerInfoEXT"
1347     ],
1348     protos=[
1349         Proto("VkResult", "DebugMarkerSetObjectTagEXT",
1350             [Param("VkDevice", "device"),
1351              Param("VkDebugMarkerObjectTagInfoEXT*", "pTagInfo")]),
1352
1353         Proto("VkResult", "DebugMarkerSetObjectNameEXT",
1354             [Param("VkDevice", "device"),
1355              Param("VkDebugMarkerObjectNameInfoEXT*", "pNameInfo")]),
1356
1357         Proto("void", "CmdDebugMarkerBeginEXT",
1358             [Param("VkCommandBuffer", "commandBuffer"),
1359              Param("VkDebugMarkerMarkerInfoEXT*", "pMarkerInfo")]),
1360
1361         Proto("void", "CmdDebugMarkerEndEXT",
1362             [Param("VkCommandBuffer", "commandBuffer")]),
1363
1364         Proto("void", "CmdDebugMarkerInsertEXT",
1365             [Param("VkCommandBuffer", "commandBuffer"),
1366              Param("VkDebugMarkerMarkerInfoEXT*", "pMarkerInfo")]),
1367     ],
1368 )
1369
1370 import sys
1371
1372 if sys.argv[1] == 'AllPlatforms':
1373     extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface, ext_khr_xcb_surface,
1374                          ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, ext_khr_display,
1375                          ext_khr_android_surface, ext_khr_display_swapchain]
1376     extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
1377                              ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
1378                              ext_khr_display, ext_khr_android_surface, ext_amd_draw_indirect_count,
1379                              ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
1380                              ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
1381 else :
1382     if len(sys.argv) > 3:
1383         if (sys.platform.startswith('win32') or sys.platform.startswith('msys')) and sys.argv[1] != 'Android':
1384             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
1385                                  ext_khr_display, ext_khr_display_swapchain]
1386             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
1387                                       ext_khr_display, ext_amd_draw_indirect_count,
1388                                       ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
1389                                       ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
1390         elif sys.platform.startswith('linux') and sys.argv[1] != 'Android':
1391             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
1392                                  ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, ext_khr_display,
1393                                  ext_khr_display_swapchain]
1394             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
1395                                       ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
1396                                       ext_khr_display, ext_amd_draw_indirect_count,
1397                                       ext_nv_external_memory_capabilities, ext_khr_display_swapchain,
1398                                       ext_debug_report, ext_debug_marker]
1399         else: # android
1400             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
1401                                  ext_khr_display_swapchain]
1402             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
1403                                       ext_amd_draw_indirect_count, ext_nv_external_memory_capabilities,
1404                                       ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
1405     else :
1406         if sys.argv[1] == 'Win32' or sys.argv[1] == 'msys':
1407             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
1408                                  ext_khr_display, ext_khr_display_swapchain]
1409             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
1410                                       ext_khr_display, ext_amd_draw_indirect_count,
1411                                       ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
1412                                       ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
1413         elif sys.argv[1] == 'Android':
1414             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
1415                                  ext_khr_display_swapchain]
1416             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
1417                                       ext_amd_draw_indirect_count, ext_nv_external_memory_capabilities,
1418                                       ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
1419         elif sys.argv[1] == 'Xcb' or sys.argv[1] == 'Xlib' or sys.argv[1] == 'Wayland' or sys.argv[1] == 'Mir' or sys.argv[1] == 'Display':
1420             extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
1421                                  ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
1422                                  ext_khr_display, ext_khr_display_swapchain]
1423             extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
1424                                       ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
1425                                       ext_khr_display, ext_amd_draw_indirect_count,
1426                                       ext_nv_external_memory_capabilities, ext_khr_display_swapchain,
1427                                       ext_debug_report, ext_debug_marker]
1428         else:
1429             print('Error: Undefined DisplayServer')
1430             extensions = []
1431             extensions_all = []
1432
1433 object_dispatch_list = [
1434     "VkInstance",
1435     "VkPhysicalDevice",
1436     "VkDevice",
1437     "VkQueue",
1438     "VkCommandBuffer",
1439 ]
1440
1441 object_non_dispatch_list = [
1442     "VkCommandPool",
1443     "VkFence",
1444     "VkDeviceMemory",
1445     "VkBuffer",
1446     "VkImage",
1447     "VkSemaphore",
1448     "VkEvent",
1449     "VkQueryPool",
1450     "VkBufferView",
1451     "VkImageView",
1452     "VkShaderModule",
1453     "VkPipelineCache",
1454     "VkPipelineLayout",
1455     "VkPipeline",
1456     "VkDescriptorSetLayout",
1457     "VkSampler",
1458     "VkDescriptorPool",
1459     "VkDescriptorSet",
1460     "VkRenderPass",
1461     "VkFramebuffer",
1462     "VkSwapchainKHR",
1463     "VkSurfaceKHR",
1464     "VkDebugReportCallbackEXT",
1465     "VkDisplayKHR",
1466     "VkDisplayModeKHR",
1467 ]
1468
1469 object_type_list = object_dispatch_list + object_non_dispatch_list
1470
1471 headers = []
1472 objects = []
1473 protos = []
1474 for ext in extensions:
1475     headers.extend(ext.headers)
1476     objects.extend(ext.objects)
1477     protos.extend(ext.protos)
1478
1479 proto_names = [proto.name for proto in protos]
1480
1481 headers_all = []
1482 objects_all = []
1483 protos_all = []
1484 for ext in extensions_all:
1485     headers_all.extend(ext.headers)
1486     objects_all.extend(ext.objects)
1487     protos_all.extend(ext.protos)
1488
1489 proto_all_names = [proto.name for proto in protos_all]
1490
1491 def parse_vk_h(filename):
1492     # read object and protoype typedefs
1493     object_lines = []
1494     proto_lines = []
1495     with open(filename, "r") as fp:
1496         for line in fp:
1497             line = line.strip()
1498             if line.startswith("VK_DEFINE"):
1499                 begin = line.find("(") + 1
1500                 end = line.find(",")
1501                 # extract the object type
1502                 object_lines.append(line[begin:end])
1503             if line.startswith("typedef") and line.endswith(");"):
1504                 if "*PFN_vkVoidFunction" in line:
1505                     continue
1506
1507                 # drop leading "typedef " and trailing ");"
1508                 proto_lines.append(line[8:-2])
1509
1510     # parse proto_lines to protos
1511     protos = []
1512     for line in proto_lines:
1513         first, rest = line.split(" (VKAPI_PTR *PFN_vk")
1514         second, third = rest.split(")(")
1515
1516         # get the return type, no space before "*"
1517         proto_ret = "*".join([t.rstrip() for t in first.split("*")])
1518
1519         # get the name
1520         proto_name = second.strip()
1521
1522         # get the list of params
1523         param_strs = third.split(", ")
1524         params = []
1525         for s in param_strs:
1526             ty, name = s.rsplit(" ", 1)
1527
1528             # no space before "*"
1529             ty = "*".join([t.rstrip() for t in ty.split("*")])
1530             # attach [] to ty
1531             idx = name.rfind("[")
1532             if idx >= 0:
1533                 ty += name[idx:]
1534                 name = name[:idx]
1535
1536             params.append(Param(ty, name))
1537
1538         protos.append(Proto(proto_ret, proto_name, params))
1539
1540     # make them an extension and print
1541     ext = Extension("VK_CORE",
1542             headers=["vulkan/vulkan.h"],
1543             objects=object_lines,
1544             protos=protos)
1545     print("core =", str(ext))
1546
1547     print("")
1548     print("typedef struct VkLayerDispatchTable_")
1549     print("{")
1550     for proto in ext.protos:
1551         print("    PFN_vk%s %s;" % (proto.name, proto.name))
1552     print("} VkLayerDispatchTable;")
1553
1554 if __name__ == "__main__":
1555     parse_vk_h("include/vulkan/vulkan.h")