vulkan.api revision 33faaad096afbd0b103bd1284ce5b78cce74aa01
1// Copyright (c) 2015 The Khronos Group Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and/or associated documentation files (the
5// "Materials"), to deal in the Materials without restriction, including
6// without limitation the rights to use, copy, modify, merge, publish,
7// distribute, sublicense, and/or sell copies of the Materials, and to
8// permit persons to whom the Materials are furnished to do so, subject to
9// the following conditions:
10//
11// The above copyright notice and this permission notice shall be included
12// in all copies or substantial portions of the Materials.
13//
14// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21
22import platform "platform.api"
23
24///////////////
25// Constants //
26///////////////
27
28// API version (major.minor.patch)
29define VERSION_MAJOR 1
30define VERSION_MINOR 0
31define VERSION_PATCH 2
32
33// API limits
34define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256
35define VK_UUID_SIZE                     16
36define VK_MAX_EXTENSION_NAME_SIZE       256
37define VK_MAX_DESCRIPTION_SIZE          256
38define VK_MAX_MEMORY_TYPES              32
39define VK_MAX_MEMORY_HEAPS              16    /// The maximum number of unique memory heaps, each of which supporting 1 or more memory types.
40
41// API keywords
42define VK_TRUE        1
43define VK_FALSE       0
44
45// API keyword, but needs special handling by some templates
46define NULL_HANDLE 0
47
48@extension("VK_KHR_surface") define VK_KHR_SURFACE_SPEC_VERSION                 25
49@extension("VK_KHR_surface") define VK_KHR_SURFACE_EXTENSION_NAME               "VK_KHR_surface"
50
51@extension("VK_KHR_swapchain") define VK_KHR_SWAPCHAIN_SPEC_VERSION             67
52@extension("VK_KHR_swapchain") define VK_KHR_SWAPCHAIN_EXTENSION_NAME           "VK_KHR_swapchain"
53
54@extension("VK_KHR_display") define VK_KHR_DISPLAY_SPEC_VERSION                 21
55@extension("VK_KHR_display") define VK_KHR_DISPLAY_EXTENSION_NAME               "VK_KHR_display"
56
57@extension("VK_KHR_display_swapchain") define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION     9
58@extension("VK_KHR_display_swapchain") define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME   "VK_KHR_display_swapchain"
59
60@extension("VK_KHR_xlib_surface") define VK_KHR_XLIB_SURFACE_SPEC_VERSION       6
61@extension("VK_KHR_xlib_surface") define VK_KHR_XLIB_SURFACE_NAME               "VK_KHR_xlib_surface"
62
63@extension("VK_KHR_xcb_surface") define VK_KHR_XCB_SURFACE_SPEC_VERSION         6
64@extension("VK_KHR_xcb_surface") define VK_KHR_XCB_SURFACE_NAME                 "VK_KHR_xcb_surface"
65
66@extension("VK_KHR_wayland_surface") define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 5
67@extension("VK_KHR_wayland_surface") define VK_KHR_WAYLAND_SURFACE_NAME         "VK_KHR_wayland_surface"
68
69@extension("VK_KHR_mir_surface") define VK_KHR_MIR_SURFACE_SPEC_VERSION         4
70@extension("VK_KHR_mir_surface") define VK_KHR_MIR_SURFACE_NAME                 "VK_KHR_mir_surface"
71
72@extension("VK_KHR_android_surface") define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
73@extension("VK_KHR_android_surface") define VK_KHR_ANDROID_SURFACE_NAME         "VK_KHR_android_surface"
74
75@extension("VK_KHR_win32_surface") define VK_KHR_WIN32_SURFACE_SPEC_VERSION     5
76@extension("VK_KHR_win32_surface") define VK_KHR_WIN32_SURFACE_NAME             "VK_KHR_win32_surface"
77
78@extension("VK_EXT_debug_report") define VK_EXT_DEBUG_REPORT_SPEC_VERSION       2
79@extension("VK_EXT_debug_report") define VK_EXT_DEBUG_REPORT_NAME               "VK_EXT_debug_report"
80
81
82/////////////
83//  Types  //
84/////////////
85
86type u32 VkBool32
87type u32 VkFlags
88type u64 VkDeviceSize
89type u32 VkSampleMask
90
91/// Dispatchable handle types.
92@dispatchHandle type u64 VkInstance
93@dispatchHandle type u64 VkPhysicalDevice
94@dispatchHandle type u64 VkDevice
95@dispatchHandle type u64 VkQueue
96@dispatchHandle type u64 VkCommandBuffer
97
98/// Non dispatchable handle types.
99@nonDispatchHandle type u64 VkDeviceMemory
100@nonDispatchHandle type u64 VkCommandPool
101@nonDispatchHandle type u64 VkBuffer
102@nonDispatchHandle type u64 VkBufferView
103@nonDispatchHandle type u64 VkImage
104@nonDispatchHandle type u64 VkImageView
105@nonDispatchHandle type u64 VkShaderModule
106@nonDispatchHandle type u64 VkPipeline
107@nonDispatchHandle type u64 VkPipelineLayout
108@nonDispatchHandle type u64 VkSampler
109@nonDispatchHandle type u64 VkDescriptorSet
110@nonDispatchHandle type u64 VkDescriptorSetLayout
111@nonDispatchHandle type u64 VkDescriptorPool
112@nonDispatchHandle type u64 VkFence
113@nonDispatchHandle type u64 VkSemaphore
114@nonDispatchHandle type u64 VkEvent
115@nonDispatchHandle type u64 VkQueryPool
116@nonDispatchHandle type u64 VkFramebuffer
117@nonDispatchHandle type u64 VkRenderPass
118@nonDispatchHandle type u64 VkPipelineCache
119
120@extension("VK_KHR_surface")    @nonDispatchHandle type u64 VkSurfaceKHR
121
122@extension("VK_KHR_swapchain")  @nonDispatchHandle type u64 VkSwapchainKHR
123
124@extension("VK_KHR_display")    @nonDispatchHandle type u64 VkDisplayKHR
125@extension("VK_KHR_display")    @nonDispatchHandle type u64 VkDisplayModeKHR
126
127@extension("VK_EXT_debug_report") @nonDispatchHandle type u64 VkDebugReportCallbackEXT
128
129
130/////////////
131//  Enums  //
132/////////////
133
134enum VkImageLayout {
135    VK_IMAGE_LAYOUT_UNDEFINED                               = 0x00000000,   /// Implicit layout an image is when its contents are undefined due to various reasons (e.g. right after creation)
136    VK_IMAGE_LAYOUT_GENERAL                                 = 0x00000001,   /// General layout when image can be used for any kind of access
137    VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL                = 0x00000002,   /// Optimal layout when image is only used for color attachment read/write
138    VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL        = 0x00000003,   /// Optimal layout when image is only used for depth/stencil attachment read/write
139    VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL         = 0x00000004,   /// Optimal layout when image is used for read only depth/stencil attachment and shader access
140    VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL                = 0x00000005,   /// Optimal layout when image is used for read only shader access
141    VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL                    = 0x00000006,   /// Optimal layout when image is used only as source of transfer operations
142    VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL                    = 0x00000007,   /// Optimal layout when image is used only as destination of transfer operations
143    VK_IMAGE_LAYOUT_PREINITIALIZED                          = 0x00000008,   /// Initial layout used when the data is populated by the CPU
144
145    //@extension("VK_KHR_swapchain")
146    VK_IMAGE_LAYOUT_PRESENT_SRC_KHR                         = 1000001002,
147}
148
149enum VkAttachmentLoadOp {
150    VK_ATTACHMENT_LOAD_OP_LOAD                              = 0x00000000,
151    VK_ATTACHMENT_LOAD_OP_CLEAR                             = 0x00000001,
152    VK_ATTACHMENT_LOAD_OP_DONT_CARE                         = 0x00000002,
153}
154
155enum VkAttachmentStoreOp {
156    VK_ATTACHMENT_STORE_OP_STORE                            = 0x00000000,
157    VK_ATTACHMENT_STORE_OP_DONT_CARE                        = 0x00000001,
158}
159
160enum VkImageType {
161    VK_IMAGE_TYPE_1D                                        = 0x00000000,
162    VK_IMAGE_TYPE_2D                                        = 0x00000001,
163    VK_IMAGE_TYPE_3D                                        = 0x00000002,
164}
165
166enum VkImageTiling {
167    VK_IMAGE_TILING_OPTIMAL                                 = 0x00000000,
168    VK_IMAGE_TILING_LINEAR                                  = 0x00000001,
169}
170
171enum VkImageViewType {
172    VK_IMAGE_VIEW_TYPE_1D                                   = 0x00000000,
173    VK_IMAGE_VIEW_TYPE_2D                                   = 0x00000001,
174    VK_IMAGE_VIEW_TYPE_3D                                   = 0x00000002,
175    VK_IMAGE_VIEW_TYPE_CUBE                                 = 0x00000003,
176    VK_IMAGE_VIEW_TYPE_1D_ARRAY                             = 0x00000004,
177    VK_IMAGE_VIEW_TYPE_2D_ARRAY                             = 0x00000005,
178    VK_IMAGE_VIEW_TYPE_CUBE_ARRAY                           = 0x00000006,
179}
180
181enum VkCommandBufferLevel {
182    VK_COMMAND_BUFFER_LEVEL_PRIMARY                         = 0x00000000,
183    VK_COMMAND_BUFFER_LEVEL_SECONDARY                       = 0x00000001,
184}
185
186enum VkComponentSwizzle {
187    VK_COMPONENT_SWIZZLE_IDENTITY                           = 0x00000000,
188    VK_COMPONENT_SWIZZLE_ZERO                               = 0x00000001,
189    VK_COMPONENT_SWIZZLE_ONE                                = 0x00000002,
190    VK_COMPONENT_SWIZZLE_R                                  = 0x00000003,
191    VK_COMPONENT_SWIZZLE_G                                  = 0x00000004,
192    VK_COMPONENT_SWIZZLE_B                                  = 0x00000005,
193    VK_COMPONENT_SWIZZLE_A                                  = 0x00000006,
194}
195
196enum VkDescriptorType {
197    VK_DESCRIPTOR_TYPE_SAMPLER                              = 0x00000000,
198    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER               = 0x00000001,
199    VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE                        = 0x00000002,
200    VK_DESCRIPTOR_TYPE_STORAGE_IMAGE                        = 0x00000003,
201    VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER                 = 0x00000004,
202    VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER                 = 0x00000005,
203    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER                       = 0x00000006,
204    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER                       = 0x00000007,
205    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC               = 0x00000008,
206    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC               = 0x00000009,
207    VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT                     = 0x0000000a,
208}
209
210enum VkQueryType {
211    VK_QUERY_TYPE_OCCLUSION                                 = 0x00000000,
212    VK_QUERY_TYPE_PIPELINE_STATISTICS                       = 0x00000001, /// Optional
213    VK_QUERY_TYPE_TIMESTAMP                                 = 0x00000002,
214}
215
216enum VkBorderColor {
217    VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK                 = 0x00000000,
218    VK_BORDER_COLOR_INT_TRANSPARENT_BLACK                   = 0x00000001,
219    VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK                      = 0x00000002,
220    VK_BORDER_COLOR_INT_OPAQUE_BLACK                        = 0x00000003,
221    VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE                      = 0x00000004,
222    VK_BORDER_COLOR_INT_OPAQUE_WHITE                        = 0x00000005,
223}
224
225enum VkPipelineBindPoint {
226    VK_PIPELINE_BIND_POINT_GRAPHICS                         = 0x00000000,
227    VK_PIPELINE_BIND_POINT_COMPUTE                          = 0x00000001,
228}
229
230enum VkPrimitiveTopology {
231    VK_PRIMITIVE_TOPOLOGY_POINT_LIST                        = 0x00000000,
232    VK_PRIMITIVE_TOPOLOGY_LINE_LIST                         = 0x00000001,
233    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP                        = 0x00000002,
234    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST                     = 0x00000003,
235    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP                    = 0x00000004,
236    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN                      = 0x00000005,
237    VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY          = 0x00000006,
238    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY         = 0x00000007,
239    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY      = 0x00000008,
240    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY     = 0x00000009,
241    VK_PRIMITIVE_TOPOLOGY_PATCH_LIST                        = 0x0000000a,
242}
243
244enum VkSharingMode {
245    VK_SHARING_MODE_EXCLUSIVE                               = 0x00000000,
246    VK_SHARING_MODE_CONCURRENT                              = 0x00000001,
247}
248
249enum VkIndexType {
250    VK_INDEX_TYPE_UINT16                                    = 0x00000000,
251    VK_INDEX_TYPE_UINT32                                    = 0x00000001,
252}
253
254enum VkFilter {
255    VK_FILTER_NEAREST                                       = 0x00000000,
256    VK_FILTER_LINEAR                                        = 0x00000001,
257}
258
259enum VkSamplerMipmapMode {
260    VK_SAMPLER_MIPMAP_MODE_NEAREST                          = 0x00000001,   /// Choose nearest mip level
261    VK_SAMPLER_MIPMAP_MODE_LINEAR                           = 0x00000002,   /// Linear filter between mip levels
262}
263
264enum VkSamplerAddressMode {
265    VK_SAMPLER_ADDRESS_MODE_REPEAT                          = 0x00000000,
266    VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT                 = 0x00000001,
267    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE                   = 0x00000002,
268    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER                 = 0x00000003,
269    VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE            = 0x00000004,
270}
271
272enum VkCompareOp {
273    VK_COMPARE_OP_NEVER                                     = 0x00000000,
274    VK_COMPARE_OP_LESS                                      = 0x00000001,
275    VK_COMPARE_OP_EQUAL                                     = 0x00000002,
276    VK_COMPARE_OP_LESS_OR_EQUAL                             = 0x00000003,
277    VK_COMPARE_OP_GREATER                                   = 0x00000004,
278    VK_COMPARE_OP_NOT_EQUAL                                 = 0x00000005,
279    VK_COMPARE_OP_GREATER_OR_EQUAL                          = 0x00000006,
280    VK_COMPARE_OP_ALWAYS                                    = 0x00000007,
281}
282
283enum VkPolygonMode {
284    VK_POLYGON_MODE_FILL                                    = 0x00000000,
285    VK_POLYGON_MODE_LINE                                    = 0x00000001,
286    VK_POLYGON_MODE_POINT                                   = 0x00000002,
287}
288
289enum VkFrontFace {
290    VK_FRONT_FACE_COUNTER_CLOCKWISE                         = 0x00000000,
291    VK_FRONT_FACE_CLOCKWISE                                 = 0x00000001,
292}
293
294enum VkBlendFactor {
295    VK_BLEND_FACTOR_ZERO                                    = 0x00000000,
296    VK_BLEND_FACTOR_ONE                                     = 0x00000001,
297    VK_BLEND_FACTOR_SRC_COLOR                               = 0x00000002,
298    VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR                     = 0x00000003,
299    VK_BLEND_FACTOR_DST_COLOR                               = 0x00000004,
300    VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR                     = 0x00000005,
301    VK_BLEND_FACTOR_SRC_ALPHA                               = 0x00000006,
302    VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA                     = 0x00000007,
303    VK_BLEND_FACTOR_DST_ALPHA                               = 0x00000008,
304    VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA                     = 0x00000009,
305    VK_BLEND_FACTOR_CONSTANT_COLOR                          = 0x0000000a,
306    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR                = 0x0000000b,
307    VK_BLEND_FACTOR_CONSTANT_ALPHA                          = 0x0000000c,
308    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA                = 0x0000000d,
309    VK_BLEND_FACTOR_SRC_ALPHA_SATURATE                      = 0x0000000e,
310    VK_BLEND_FACTOR_SRC1_COLOR                              = 0x0000000f,
311    VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR                    = 0x00000010,
312    VK_BLEND_FACTOR_SRC1_ALPHA                              = 0x00000011,
313    VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA                    = 0x00000012,
314}
315
316enum VkBlendOp {
317    VK_BLEND_OP_ADD                                         = 0x00000000,
318    VK_BLEND_OP_SUBTRACT                                    = 0x00000001,
319    VK_BLEND_OP_REVERSE_SUBTRACT                            = 0x00000002,
320    VK_BLEND_OP_MIN                                         = 0x00000003,
321    VK_BLEND_OP_MAX                                         = 0x00000004,
322}
323
324enum VkStencilOp {
325    VK_STENCIL_OP_KEEP                                      = 0x00000000,
326    VK_STENCIL_OP_ZERO                                      = 0x00000001,
327    VK_STENCIL_OP_REPLACE                                   = 0x00000002,
328    VK_STENCIL_OP_INCREMENT_AND_CLAMP                       = 0x00000003,
329    VK_STENCIL_OP_DECREMENT_AND_CLAMP                       = 0x00000004,
330    VK_STENCIL_OP_INVERT                                    = 0x00000005,
331    VK_STENCIL_OP_INCREMENT_AND_WRAP                        = 0x00000006,
332    VK_STENCIL_OP_DECREMENT_AND_WRAP                        = 0x00000007,
333}
334
335enum VkLogicOp {
336    VK_LOGIC_OP_CLEAR                                       = 0x00000000,
337    VK_LOGIC_OP_AND                                         = 0x00000001,
338    VK_LOGIC_OP_AND_REVERSE                                 = 0x00000002,
339    VK_LOGIC_OP_COPY                                        = 0x00000003,
340    VK_LOGIC_OP_AND_INVERTED                                = 0x00000004,
341    VK_LOGIC_OP_NO_OP                                       = 0x00000005,
342    VK_LOGIC_OP_XOR                                         = 0x00000006,
343    VK_LOGIC_OP_OR                                          = 0x00000007,
344    VK_LOGIC_OP_NOR                                         = 0x00000008,
345    VK_LOGIC_OP_EQUIVALENT                                  = 0x00000009,
346    VK_LOGIC_OP_INVERT                                      = 0x0000000a,
347    VK_LOGIC_OP_OR_REVERSE                                  = 0x0000000b,
348    VK_LOGIC_OP_COPY_INVERTED                               = 0x0000000c,
349    VK_LOGIC_OP_OR_INVERTED                                 = 0x0000000d,
350    VK_LOGIC_OP_NAND                                        = 0x0000000e,
351    VK_LOGIC_OP_SET                                         = 0x0000000f,
352}
353
354enum VkSystemAllocationScope {
355    VK_SYSTEM_ALLOCATION_SCOPE_COMMAND                      = 0x00000000,
356    VK_SYSTEM_ALLOCATION_SCOPE_OBJECT                       = 0x00000001,
357    VK_SYSTEM_ALLOCATION_SCOPE_CACHE                        = 0x00000002,
358    VK_SYSTEM_ALLOCATION_SCOPE_DEVICE                       = 0x00000003,
359    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE                     = 0x00000004,
360}
361
362enum VkInternalAllocationType {
363    VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE                  = 0x00000000,
364}
365
366enum VkPhysicalDeviceType {
367    VK_PHYSICAL_DEVICE_TYPE_OTHER                           = 0x00000000,
368    VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU                  = 0x00000001,
369    VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU                    = 0x00000002,
370    VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU                     = 0x00000003,
371    VK_PHYSICAL_DEVICE_TYPE_CPU                             = 0x00000004,
372}
373
374enum VkVertexInputRate {
375    VK_VERTEX_INPUT_RATE_VERTEX                             = 0x00000000,
376    VK_VERTEX_INPUT_RATE_INSTANCE                           = 0x00000001,
377}
378
379/// Vulkan format definitions
380enum VkFormat {
381    VK_FORMAT_UNDEFINED                                     = 0,
382    VK_FORMAT_R4G4_UNORM_PACK8                              = 1,
383    VK_FORMAT_R4G4B4A4_UNORM_PACK16                         = 2,
384    VK_FORMAT_B4G4R4A4_UNORM_PACK16                         = 3,
385    VK_FORMAT_R5G6B5_UNORM_PACK16                           = 4,
386    VK_FORMAT_B5G6R5_UNORM_PACK16                           = 5,
387    VK_FORMAT_R5G5B5A1_UNORM_PACK16                         = 6,
388    VK_FORMAT_B5G5R5A1_UNORM_PACK16                         = 7,
389    VK_FORMAT_A1R5G5B5_UNORM_PACK16                         = 8,
390    VK_FORMAT_R8_UNORM                                      = 9,
391    VK_FORMAT_R8_SNORM                                      = 10,
392    VK_FORMAT_R8_USCALED                                    = 11,
393    VK_FORMAT_R8_SSCALED                                    = 12,
394    VK_FORMAT_R8_UINT                                       = 13,
395    VK_FORMAT_R8_SINT                                       = 14,
396    VK_FORMAT_R8_SRGB                                       = 15,
397    VK_FORMAT_R8G8_UNORM                                    = 16,
398    VK_FORMAT_R8G8_SNORM                                    = 17,
399    VK_FORMAT_R8G8_USCALED                                  = 18,
400    VK_FORMAT_R8G8_SSCALED                                  = 19,
401    VK_FORMAT_R8G8_UINT                                     = 20,
402    VK_FORMAT_R8G8_SINT                                     = 21,
403    VK_FORMAT_R8G8_SRGB                                     = 22,
404    VK_FORMAT_R8G8B8_UNORM                                  = 23,
405    VK_FORMAT_R8G8B8_SNORM                                  = 24,
406    VK_FORMAT_R8G8B8_USCALED                                = 25,
407    VK_FORMAT_R8G8B8_SSCALED                                = 26,
408    VK_FORMAT_R8G8B8_UINT                                   = 27,
409    VK_FORMAT_R8G8B8_SINT                                   = 28,
410    VK_FORMAT_R8G8B8_SRGB                                   = 29,
411    VK_FORMAT_B8G8R8_UNORM                                  = 30,
412    VK_FORMAT_B8G8R8_SNORM                                  = 31,
413    VK_FORMAT_B8G8R8_USCALED                                = 32,
414    VK_FORMAT_B8G8R8_SSCALED                                = 33,
415    VK_FORMAT_B8G8R8_UINT                                   = 34,
416    VK_FORMAT_B8G8R8_SINT                                   = 35,
417    VK_FORMAT_B8G8R8_SRGB                                   = 36,
418    VK_FORMAT_R8G8B8A8_UNORM                                = 37,
419    VK_FORMAT_R8G8B8A8_SNORM                                = 38,
420    VK_FORMAT_R8G8B8A8_USCALED                              = 39,
421    VK_FORMAT_R8G8B8A8_SSCALED                              = 40,
422    VK_FORMAT_R8G8B8A8_UINT                                 = 41,
423    VK_FORMAT_R8G8B8A8_SINT                                 = 42,
424    VK_FORMAT_R8G8B8A8_SRGB                                 = 43,
425    VK_FORMAT_B8G8R8A8_UNORM                                = 44,
426    VK_FORMAT_B8G8R8A8_SNORM                                = 45,
427    VK_FORMAT_B8G8R8A8_USCALED                              = 46,
428    VK_FORMAT_B8G8R8A8_SSCALED                              = 47,
429    VK_FORMAT_B8G8R8A8_UINT                                 = 48,
430    VK_FORMAT_B8G8R8A8_SINT                                 = 49,
431    VK_FORMAT_B8G8R8A8_SRGB                                 = 50,
432    VK_FORMAT_A8B8G8R8_UNORM_PACK32                         = 51,
433    VK_FORMAT_A8B8G8R8_SNORM_PACK32                         = 52,
434    VK_FORMAT_A8B8G8R8_USCALED_PACK32                       = 53,
435    VK_FORMAT_A8B8G8R8_SSCALED_PACK32                       = 54,
436    VK_FORMAT_A8B8G8R8_UINT_PACK32                          = 55,
437    VK_FORMAT_A8B8G8R8_SINT_PACK32                          = 56,
438    VK_FORMAT_A8B8G8R8_SRGB_PACK32                          = 57,
439    VK_FORMAT_A2R10G10B10_UNORM_PACK32                      = 58,
440    VK_FORMAT_A2R10G10B10_SNORM_PACK32                      = 59,
441    VK_FORMAT_A2R10G10B10_USCALED_PACK32                    = 60,
442    VK_FORMAT_A2R10G10B10_SSCALED_PACK32                    = 61,
443    VK_FORMAT_A2R10G10B10_UINT_PACK32                       = 62,
444    VK_FORMAT_A2R10G10B10_SINT_PACK32                       = 63,
445    VK_FORMAT_A2B10G10R10_UNORM_PACK32                      = 64,
446    VK_FORMAT_A2B10G10R10_SNORM_PACK32                      = 65,
447    VK_FORMAT_A2B10G10R10_USCALED_PACK32                    = 66,
448    VK_FORMAT_A2B10G10R10_SSCALED_PACK32                    = 67,
449    VK_FORMAT_A2B10G10R10_UINT_PACK32                       = 68,
450    VK_FORMAT_A2B10G10R10_SINT_PACK32                       = 69,
451    VK_FORMAT_R16_UNORM                                     = 70,
452    VK_FORMAT_R16_SNORM                                     = 71,
453    VK_FORMAT_R16_USCALED                                   = 72,
454    VK_FORMAT_R16_SSCALED                                   = 73,
455    VK_FORMAT_R16_UINT                                      = 74,
456    VK_FORMAT_R16_SINT                                      = 75,
457    VK_FORMAT_R16_SFLOAT                                    = 76,
458    VK_FORMAT_R16G16_UNORM                                  = 77,
459    VK_FORMAT_R16G16_SNORM                                  = 78,
460    VK_FORMAT_R16G16_USCALED                                = 79,
461    VK_FORMAT_R16G16_SSCALED                                = 80,
462    VK_FORMAT_R16G16_UINT                                   = 81,
463    VK_FORMAT_R16G16_SINT                                   = 82,
464    VK_FORMAT_R16G16_SFLOAT                                 = 83,
465    VK_FORMAT_R16G16B16_UNORM                               = 84,
466    VK_FORMAT_R16G16B16_SNORM                               = 85,
467    VK_FORMAT_R16G16B16_USCALED                             = 86,
468    VK_FORMAT_R16G16B16_SSCALED                             = 87,
469    VK_FORMAT_R16G16B16_UINT                                = 88,
470    VK_FORMAT_R16G16B16_SINT                                = 89,
471    VK_FORMAT_R16G16B16_SFLOAT                              = 90,
472    VK_FORMAT_R16G16B16A16_UNORM                            = 91,
473    VK_FORMAT_R16G16B16A16_SNORM                            = 92,
474    VK_FORMAT_R16G16B16A16_USCALED                          = 93,
475    VK_FORMAT_R16G16B16A16_SSCALED                          = 94,
476    VK_FORMAT_R16G16B16A16_UINT                             = 95,
477    VK_FORMAT_R16G16B16A16_SINT                             = 96,
478    VK_FORMAT_R16G16B16A16_SFLOAT                           = 97,
479    VK_FORMAT_R32_UINT                                      = 98,
480    VK_FORMAT_R32_SINT                                      = 99,
481    VK_FORMAT_R32_SFLOAT                                    = 100,
482    VK_FORMAT_R32G32_UINT                                   = 101,
483    VK_FORMAT_R32G32_SINT                                   = 102,
484    VK_FORMAT_R32G32_SFLOAT                                 = 103,
485    VK_FORMAT_R32G32B32_UINT                                = 104,
486    VK_FORMAT_R32G32B32_SINT                                = 105,
487    VK_FORMAT_R32G32B32_SFLOAT                              = 106,
488    VK_FORMAT_R32G32B32A32_UINT                             = 107,
489    VK_FORMAT_R32G32B32A32_SINT                             = 108,
490    VK_FORMAT_R32G32B32A32_SFLOAT                           = 109,
491    VK_FORMAT_R64_UINT                                      = 110,
492    VK_FORMAT_R64_SINT                                      = 111,
493    VK_FORMAT_R64_SFLOAT                                    = 112,
494    VK_FORMAT_R64G64_UINT                                   = 113,
495    VK_FORMAT_R64G64_SINT                                   = 114,
496    VK_FORMAT_R64G64_SFLOAT                                 = 115,
497    VK_FORMAT_R64G64B64_UINT                                = 116,
498    VK_FORMAT_R64G64B64_SINT                                = 117,
499    VK_FORMAT_R64G64B64_SFLOAT                              = 118,
500    VK_FORMAT_R64G64B64A64_UINT                             = 119,
501    VK_FORMAT_R64G64B64A64_SINT                             = 120,
502    VK_FORMAT_R64G64B64A64_SFLOAT                           = 121,
503    VK_FORMAT_B10G11R11_UFLOAT_PACK32                       = 122,
504    VK_FORMAT_E5B9G9R9_UFLOAT_PACK32                        = 123,
505    VK_FORMAT_D16_UNORM                                     = 124,
506    VK_FORMAT_X8_D24_UNORM_PACK32                           = 125,
507    VK_FORMAT_D32_SFLOAT                                    = 126,
508    VK_FORMAT_S8_UINT                                       = 127,
509    VK_FORMAT_D16_UNORM_S8_UINT                             = 128,
510    VK_FORMAT_D24_UNORM_S8_UINT                             = 129,
511    VK_FORMAT_D32_SFLOAT_S8_UINT                            = 130,
512    VK_FORMAT_BC1_RGB_UNORM_BLOCK                           = 131,
513    VK_FORMAT_BC1_RGB_SRGB_BLOCK                            = 132,
514    VK_FORMAT_BC1_RGBA_UNORM_BLOCK                          = 133,
515    VK_FORMAT_BC1_RGBA_SRGB_BLOCK                           = 134,
516    VK_FORMAT_BC2_UNORM_BLOCK                               = 135,
517    VK_FORMAT_BC2_SRGB_BLOCK                                = 136,
518    VK_FORMAT_BC3_UNORM_BLOCK                               = 137,
519    VK_FORMAT_BC3_SRGB_BLOCK                                = 138,
520    VK_FORMAT_BC4_UNORM_BLOCK                               = 139,
521    VK_FORMAT_BC4_SNORM_BLOCK                               = 140,
522    VK_FORMAT_BC5_UNORM_BLOCK                               = 141,
523    VK_FORMAT_BC5_SNORM_BLOCK                               = 142,
524    VK_FORMAT_BC6H_UFLOAT_BLOCK                             = 143,
525    VK_FORMAT_BC6H_SFLOAT_BLOCK                             = 144,
526    VK_FORMAT_BC7_UNORM_BLOCK                               = 145,
527    VK_FORMAT_BC7_SRGB_BLOCK                                = 146,
528    VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK                       = 147,
529    VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK                        = 148,
530    VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK                     = 149,
531    VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK                      = 150,
532    VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK                     = 151,
533    VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK                      = 152,
534    VK_FORMAT_EAC_R11_UNORM_BLOCK                           = 153,
535    VK_FORMAT_EAC_R11_SNORM_BLOCK                           = 154,
536    VK_FORMAT_EAC_R11G11_UNORM_BLOCK                        = 155,
537    VK_FORMAT_EAC_R11G11_SNORM_BLOCK                        = 156,
538    VK_FORMAT_ASTC_4x4_UNORM_BLOCK                          = 157,
539    VK_FORMAT_ASTC_4x4_SRGB_BLOCK                           = 158,
540    VK_FORMAT_ASTC_5x4_UNORM_BLOCK                          = 159,
541    VK_FORMAT_ASTC_5x4_SRGB_BLOCK                           = 160,
542    VK_FORMAT_ASTC_5x5_UNORM_BLOCK                          = 161,
543    VK_FORMAT_ASTC_5x5_SRGB_BLOCK                           = 162,
544    VK_FORMAT_ASTC_6x5_UNORM_BLOCK                          = 163,
545    VK_FORMAT_ASTC_6x5_SRGB_BLOCK                           = 164,
546    VK_FORMAT_ASTC_6x6_UNORM_BLOCK                          = 165,
547    VK_FORMAT_ASTC_6x6_SRGB_BLOCK                           = 166,
548    VK_FORMAT_ASTC_8x5_UNORM_BLOCK                          = 167,
549    VK_FORMAT_ASTC_8x5_SRGB_BLOCK                           = 168,
550    VK_FORMAT_ASTC_8x6_UNORM_BLOCK                          = 169,
551    VK_FORMAT_ASTC_8x6_SRGB_BLOCK                           = 170,
552    VK_FORMAT_ASTC_8x8_UNORM_BLOCK                          = 171,
553    VK_FORMAT_ASTC_8x8_SRGB_BLOCK                           = 172,
554    VK_FORMAT_ASTC_10x5_UNORM_BLOCK                         = 173,
555    VK_FORMAT_ASTC_10x5_SRGB_BLOCK                          = 174,
556    VK_FORMAT_ASTC_10x6_UNORM_BLOCK                         = 175,
557    VK_FORMAT_ASTC_10x6_SRGB_BLOCK                          = 176,
558    VK_FORMAT_ASTC_10x8_UNORM_BLOCK                         = 177,
559    VK_FORMAT_ASTC_10x8_SRGB_BLOCK                          = 178,
560    VK_FORMAT_ASTC_10x10_UNORM_BLOCK                        = 179,
561    VK_FORMAT_ASTC_10x10_SRGB_BLOCK                         = 180,
562    VK_FORMAT_ASTC_12x10_UNORM_BLOCK                        = 181,
563    VK_FORMAT_ASTC_12x10_SRGB_BLOCK                         = 182,
564    VK_FORMAT_ASTC_12x12_UNORM_BLOCK                        = 183,
565    VK_FORMAT_ASTC_12x12_SRGB_BLOCK                         = 184,
566}
567
568/// Structure type enumerant
569enum VkStructureType {
570    VK_STRUCTURE_TYPE_APPLICATION_INFO                          = 0,
571    VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO                      = 1,
572    VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO                  = 2,
573    VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO                        = 3,
574    VK_STRUCTURE_TYPE_SUBMIT_INFO                               = 4,
575    VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO                      = 5,
576    VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE                       = 6,
577    VK_STRUCTURE_TYPE_BIND_SPARSE_INFO                          = 7,
578    VK_STRUCTURE_TYPE_FENCE_CREATE_INFO                         = 8,
579    VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO                     = 9,
580    VK_STRUCTURE_TYPE_EVENT_CREATE_INFO                         = 10,
581    VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO                    = 11,
582    VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO                        = 12,
583    VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO                   = 13,
584    VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO                         = 14,
585    VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO                    = 15,
586    VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO                 = 16,
587    VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO                = 17,
588    VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO         = 18,
589    VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO   = 19,
590    VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
591    VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO   = 21,
592    VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO       = 22,
593    VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO  = 23,
594    VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO    = 24,
595    VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO  = 25,
596    VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO    = 26,
597    VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO        = 27,
598    VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO             = 28,
599    VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO              = 29,
600    VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO               = 30,
601    VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO                       = 31,
602    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO         = 32,
603    VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO               = 33,
604    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO              = 34,
605    VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET                      = 35,
606    VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET                       = 36,
607    VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO                   = 37,
608    VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO                   = 38,
609    VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO                  = 39,
610    VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO              = 40,
611    VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO           = 41,
612    VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO                 = 42,
613    VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO                    = 43,
614    VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER                     = 44,
615    VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER                      = 45,
616    VK_STRUCTURE_TYPE_MEMORY_BARRIER                            = 46,
617    VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO               = 47,
618    VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO                 = 48,
619
620    //@extension("VK_KHR_swapchain")
621    VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR                 = 1000001000,
622    VK_STRUCTURE_TYPE_PRESENT_INFO_KHR                          = 1000001001,
623
624    //@extension("VK_KHR_display")
625    VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR              = 1000002000,
626    VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR           = 1000002001,
627
628    //@extension("VK_KHR_display_swapchain")
629    VK_STRUCTURE_TYPE_DISPLAY_DISPLAY_PRESENT_INFO_KHR          = 1000003000,
630
631    //@extension("VK_KHR_xlib_surface")
632    VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR              = 1000004000,
633
634    //@extension("VK_KHR_xcb_surface")
635    VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR               = 1000005000,
636
637    //@extension("VK_KHR_wayland_surface")
638    VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR           = 1000006000,
639
640    //@extension("VK_KHR_mir_surface")
641    VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR               = 1000007000,
642
643    //@extension("VK_KHR_android_surface")
644    VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR           = 1000008000,
645
646    //@extension("VK_KHR_win32_surface")
647    VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR             = 1000009000,
648
649    //@extension("VK_EXT_debug_report")
650    VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT              = 1000011000,
651}
652
653enum VkSubpassContents {
654    VK_SUBPASS_CONTENTS_INLINE                              = 0x00000000,
655    VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS           = 0x00000001,
656}
657
658enum VkPipelineCacheHeaderVersion {
659    VK_PIPELINE_CACHE_HEADER_VERSION_ONE                    = 1,
660}
661
662@lastUnused(-11)
663/// Error and return codes
664enum VkResult {
665    // Return codes for successful operation execution (positive values)
666    VK_SUCCESS                                              = 0,
667    VK_NOT_READY                                            = 1,
668    VK_TIMEOUT                                              = 2,
669    VK_EVENT_SET                                            = 3,
670    VK_EVENT_RESET                                          = 4,
671    VK_INCOMPLETE                                           = 5,
672
673    //@extension("VK_KHR_swapchain")
674    VK_SUBOPTIMAL_KHR                                       = 1000001003,
675
676    // Error codes (negative values)
677    VK_ERROR_OUT_OF_HOST_MEMORY                             = 0xFFFFFFFF, // -1
678    VK_ERROR_OUT_OF_DEVICE_MEMORY                           = 0xFFFFFFFE, // -2
679    VK_ERROR_INITIALIZATION_FAILED                          = 0xFFFFFFFD, // -3
680    VK_ERROR_DEVICE_LOST                                    = 0xFFFFFFFC, // -4
681    VK_ERROR_MEMORY_MAP_FAILED                              = 0xFFFFFFFB, // -5
682    VK_ERROR_LAYER_NOT_PRESENT                              = 0xFFFFFFFA, // -6
683    VK_ERROR_EXTENSION_NOT_PRESENT                          = 0xFFFFFFF9, // -7
684    VK_ERROR_FEATURE_NOT_PRESENT                            = 0xFFFFFFF8, // -8
685    VK_ERROR_INCOMPATIBLE_DRIVER                            = 0xFFFFFFF7, // -9
686    VK_ERROR_TOO_MANY_OBJECTS                               = 0xFFFFFFF6, // -10
687    VK_ERROR_FORMAT_NOT_SUPPORTED                           = 0xFFFFFFF5, // -11
688
689    //@extension("VK_KHR_surface")
690    VK_ERROR_SURFACE_LOST_KHR                               = 0xC4653600, // -1000000000
691
692    //@extension("VK_KHR_surface")
693    VK_ERROR_NATIVE_WINDOW_IN_USE_KHR                       = 0xC46535FF, // -1000008001
694
695    //@extension("VK_KHR_swapchain")
696    VK_ERROR_OUT_OF_DATE_KHR                                = 0xC4653214, // -1000001004
697
698    //@extension("VK_KHR_display_swapchain")
699    VK_ERROR_INCOMPATIBLE_DISPLAY_KHR                       = 0xC4652A47, // -1000003001
700
701    //@extension("VK_EXT_debug_report")
702    VK_ERROR_VALIDATION_FAILED_EXT                          = 0xC4650B07, // -1000011001
703}
704
705enum VkDynamicState {
706    VK_DYNAMIC_STATE_VIEWPORT                               = 0x00000000,
707    VK_DYNAMIC_STATE_SCISSOR                                = 0x00000001,
708    VK_DYNAMIC_STATE_LINE_WIDTH                             = 0x00000002,
709    VK_DYNAMIC_STATE_DEPTH_BIAS                             = 0x00000003,
710    VK_DYNAMIC_STATE_BLEND_CONSTANTS                        = 0x00000004,
711    VK_DYNAMIC_STATE_DEPTH_BOUNDS                           = 0x00000005,
712    VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK                   = 0x00000006,
713    VK_DYNAMIC_STATE_STENCIL_WRITE_MASK                     = 0x00000007,
714    VK_DYNAMIC_STATE_STENCIL_REFERENCE                      = 0x00000008,
715}
716
717@extension("VK_KHR_surface")
718enum VkPresentModeKHR {
719    VK_PRESENT_MODE_IMMEDIATE_KHR                           = 0x00000000,
720    VK_PRESENT_MODE_MAILBOX_KHR                             = 0x00000001,
721    VK_PRESENT_MODE_FIFO_KHR                                = 0x00000002,
722    VK_PRESENT_MODE_FIFO_RELAXED_KHR                        = 0x00000003,
723}
724
725@extension("VK_KHR_surface")
726enum VkColorSpaceKHR {
727    VK_COLORSPACE_SRGB_NONLINEAR_KHR                        = 0x00000000,
728}
729
730@extension("VK_EXT_debug_report")
731enum VkDebugReportObjectTypeEXT {
732    VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT                 = 0,
733    VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT                = 1,
734    VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT         = 2,
735    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT                  = 3,
736    VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT                   = 4,
737    VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT               = 5,
738    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT          = 6,
739    VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT                   = 7,
740    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT           = 8,
741    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT                  = 9,
742    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT                   = 10,
743    VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT                   = 11,
744    VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT              = 12,
745    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT             = 13,
746    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT              = 14,
747    VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT           = 15,
748    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT          = 16,
749    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT         = 17,
750    VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT             = 18,
751    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT                = 19,
752    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT   = 20,
753    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT                 = 21,
754    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT         = 22,
755    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT          = 23,
756    VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT             = 24,
757    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT            = 25,
758    VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT             = 26,
759    VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT           = 27,
760    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT            = 28,
761}
762
763@extension("VK_EXT_debug_report")
764enum VkDebugReportErrorEXT {
765    VK_DEBUG_REPORT_ERROR_NONE_EXT                          = 0,
766    VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT                  = 1,
767}
768
769
770/////////////////
771//  Bitfields  //
772/////////////////
773
774/// Queue capabilities
775type VkFlags VkQueueFlags
776bitfield VkQueueFlagBits {
777    VK_QUEUE_GRAPHICS_BIT                                   = 0x00000001,    /// Queue supports graphics operations
778    VK_QUEUE_COMPUTE_BIT                                    = 0x00000002,    /// Queue supports compute operations
779    VK_QUEUE_TRANSFER_BIT                                   = 0x00000004,    /// Queue supports transfer operations
780    VK_QUEUE_SPARSE_BINDING_BIT                             = 0x00000008,    /// Queue supports sparse resource memory management operations
781}
782
783/// Memory properties passed into vkAllocMemory().
784type VkFlags VkMemoryPropertyFlags
785bitfield VkMemoryPropertyFlagBits {
786    VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT                     = 0x00000001,
787    VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT                     = 0x00000002,
788    VK_MEMORY_PROPERTY_HOST_COHERENT_BIT                    = 0x00000004,
789    VK_MEMORY_PROPERTY_HOST_CACHED_BIT                      = 0x00000008,
790    VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT                 = 0x00000010,
791}
792
793/// Memory heap flags
794type VkFlags VkMemoryHeapFlags
795bitfield VkMemoryHeapFlagBits {
796    VK_MEMORY_HEAP_DEVICE_LOCAL_BIT                         = 0x00000001,
797}
798
799/// Access flags
800type VkFlags VkAccessFlags
801bitfield VkAccessFlagBits {
802    VK_ACCESS_INDIRECT_COMMAND_READ_BIT                     = 0x00000001,
803    VK_ACCESS_INDEX_READ_BIT                                = 0x00000002,
804    VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT                     = 0x00000004,
805    VK_ACCESS_UNIFORM_READ_BIT                              = 0x00000008,
806    VK_ACCESS_INPUT_ATTACHMENT_READ_BIT                     = 0x00000010,
807    VK_ACCESS_SHADER_READ_BIT                               = 0x00000020,
808    VK_ACCESS_SHADER_WRITE_BIT                              = 0x00000040,
809    VK_ACCESS_COLOR_ATTACHMENT_READ_BIT                     = 0x00000080,
810    VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT                    = 0x00000100,
811    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT             = 0x00000200,
812    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT            = 0x00000400,
813    VK_ACCESS_TRANSFER_READ_BIT                             = 0x00000800,
814    VK_ACCESS_TRANSFER_WRITE_BIT                            = 0x00001000,
815    VK_ACCESS_HOST_READ_BIT                                 = 0x00002000,
816    VK_ACCESS_HOST_WRITE_BIT                                = 0x00004000,
817    VK_ACCESS_MEMORY_READ_BIT                               = 0x00008000,
818    VK_ACCESS_MEMORY_WRITE_BIT                              = 0x00010000,
819}
820
821/// Buffer usage flags
822type VkFlags VkBufferUsageFlags
823bitfield VkBufferUsageFlagBits {
824    VK_BUFFER_USAGE_TRANSFER_SRC_BIT                        = 0x00000001,    /// Can be used as a source of transfer operations
825    VK_BUFFER_USAGE_TRANSFER_DST_BIT                        = 0x00000002,    /// Can be used as a destination of transfer operations
826    VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT                = 0x00000004,    /// Can be used as TBO
827    VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT                = 0x00000008,    /// Can be used as IBO
828    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT                      = 0x00000010,    /// Can be used as UBO
829    VK_BUFFER_USAGE_STORAGE_BUFFER_BIT                      = 0x00000020,    /// Can be used as SSBO
830    VK_BUFFER_USAGE_INDEX_BUFFER_BIT                        = 0x00000040,    /// Can be used as source of fixed function index fetch (index buffer)
831    VK_BUFFER_USAGE_VERTEX_BUFFER_BIT                       = 0x00000080,    /// Can be used as source of fixed function vertex fetch (VBO)
832    VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT                     = 0x00000100,    /// Can be the source of indirect parameters (e.g. indirect buffer, parameter buffer)
833}
834
835/// Buffer creation flags
836type VkFlags VkBufferCreateFlags
837bitfield VkBufferCreateFlagBits {
838    VK_BUFFER_CREATE_SPARSE_BINDING_BIT                     = 0x00000001,    /// Buffer should support sparse backing
839    VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT                   = 0x00000002,    /// Buffer should support sparse backing with partial residency
840    VK_BUFFER_CREATE_SPARSE_ALIASED_BIT                     = 0x00000004,    /// Buffer should support constent data access to physical memory blocks mapped into multiple locations of sparse buffers
841}
842
843/// Shader stage flags
844type VkFlags VkShaderStageFlags
845bitfield VkShaderStageFlagBits {
846    VK_SHADER_STAGE_VERTEX_BIT                              = 0x00000001,
847    VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT                = 0x00000002,
848    VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT             = 0x00000004,
849    VK_SHADER_STAGE_GEOMETRY_BIT                            = 0x00000008,
850    VK_SHADER_STAGE_FRAGMENT_BIT                            = 0x00000010,
851    VK_SHADER_STAGE_COMPUTE_BIT                             = 0x00000020,
852    VK_SHADER_STAGE_ALL_GRAPHICS                            = 0x0000001F,
853
854    VK_SHADER_STAGE_ALL                                     = 0x7FFFFFFF,
855}
856
857/// Descriptor pool create flags
858type VkFlags VkDescriptorPoolCreateFlags
859bitfield VkDescriptorPoolCreateFlagBits {
860    VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT       = 0x00000001,
861}
862
863/// Descriptor pool reset flags
864type VkFlags VkDescriptorPoolResetFlags
865//bitfield VkDescriptorPoolResetFlagBits {
866//}
867
868/// Image usage flags
869type VkFlags VkImageUsageFlags
870bitfield VkImageUsageFlagBits {
871    VK_IMAGE_USAGE_TRANSFER_SRC_BIT                         = 0x00000001,    /// Can be used as a source of transfer operations
872    VK_IMAGE_USAGE_TRANSFER_DST_BIT                         = 0x00000002,    /// Can be used as a destination of transfer operations
873    VK_IMAGE_USAGE_SAMPLED_BIT                              = 0x00000004,    /// Can be sampled from (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types)
874    VK_IMAGE_USAGE_STORAGE_BIT                              = 0x00000008,    /// Can be used as storage image (STORAGE_IMAGE descriptor type)
875    VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT                     = 0x00000010,    /// Can be used as framebuffer color attachment
876    VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT             = 0x00000020,    /// Can be used as framebuffer depth/stencil attachment
877    VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT                 = 0x00000040,    /// Image data not needed outside of rendering
878    VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT                     = 0x00000080,    /// Can be used as framebuffer input attachment
879}
880
881/// Image creation flags
882type VkFlags VkImageCreateFlags
883bitfield VkImageCreateFlagBits {
884    VK_IMAGE_CREATE_SPARSE_BINDING_BIT                      = 0x00000001,    /// Image should support sparse backing
885    VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT                    = 0x00000002,    /// Image should support sparse backing with partial residency
886    VK_IMAGE_CREATE_SPARSE_ALIASED_BIT                      = 0x00000004,    /// Image should support constent data access to physical memory blocks mapped into multiple locations of sparse images
887    VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT                      = 0x00000008,    /// Allows image views to have different format than the base image
888    VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT                     = 0x00000010,    /// Allows creating image views with cube type from the created image
889}
890
891/// Image view creation flags
892type VkFlags VkImageViewCreateFlags
893//bitfield VkImageViewCreateFlagBits {
894//}
895
896/// Pipeline creation flags
897type VkFlags VkPipelineCreateFlags
898bitfield VkPipelineCreateFlagBits {
899    VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT             = 0x00000001,
900    VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT                = 0x00000002,
901    VK_PIPELINE_CREATE_DERIVATIVE_BIT                       = 0x00000004,
902}
903
904/// Color component flags
905type VkFlags VkColorComponentFlags
906bitfield VkColorComponentFlagBits {
907    VK_COLOR_COMPONENT_R_BIT                                = 0x00000001,
908    VK_COLOR_COMPONENT_G_BIT                                = 0x00000002,
909    VK_COLOR_COMPONENT_B_BIT                                = 0x00000004,
910    VK_COLOR_COMPONENT_A_BIT                                = 0x00000008,
911}
912
913/// Fence creation flags
914type VkFlags VkFenceCreateFlags
915bitfield VkFenceCreateFlagBits {
916    VK_FENCE_CREATE_SIGNALED_BIT                            = 0x00000001,
917}
918
919/// Semaphore creation flags
920type VkFlags VkSemaphoreCreateFlags
921//bitfield VkSemaphoreCreateFlagBits {
922//}
923
924/// Format capability flags
925type VkFlags VkFormatFeatureFlags
926bitfield VkFormatFeatureFlagBits {
927    VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT                     = 0x00000001,    /// Format can be used for sampled images (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types)
928    VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT                     = 0x00000002,    /// Format can be used for storage images (STORAGE_IMAGE descriptor type)
929    VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT              = 0x00000004,    /// Format supports atomic operations in case it's used for storage images
930    VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT              = 0x00000008,    /// Format can be used for uniform texel buffers (TBOs)
931    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT              = 0x00000010,    /// Format can be used for storage texel buffers (IBOs)
932    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT       = 0x00000020,    /// Format supports atomic operations in case it's used for storage texel buffers
933    VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT                     = 0x00000040,    /// Format can be used for vertex buffers (VBOs)
934    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT                  = 0x00000080,    /// Format can be used for color attachment images
935    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT            = 0x00000100,    /// Format supports blending in case it's used for color attachment images
936    VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT          = 0x00000200,    /// Format can be used for depth/stencil attachment images
937    VK_FORMAT_FEATURE_BLIT_SRC_BIT                          = 0x00000400,    /// Format can be used as the source image of blits with vkCommandBlitImage
938    VK_FORMAT_FEATURE_BLIT_DST_BIT                          = 0x00000800,    /// Format can be used as the destination image of blits with vkCommandBlitImage
939    VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT       = 0x00001000,
940}
941
942/// Query control flags
943type VkFlags VkQueryControlFlags
944bitfield VkQueryControlFlagBits {
945    VK_QUERY_CONTROL_PRECISE_BIT                            = 0x00000001,
946}
947
948/// Query result flags
949type VkFlags VkQueryResultFlags
950bitfield VkQueryResultFlagBits {
951    VK_QUERY_RESULT_64_BIT                                  = 0x00000001,   /// Results of the queries are written to the destination buffer as 64-bit values
952    VK_QUERY_RESULT_WAIT_BIT                                = 0x00000002,   /// Results of the queries are waited on before proceeding with the result copy
953    VK_QUERY_RESULT_WITH_AVAILABILITY_BIT                   = 0x00000004,   /// Besides the results of the query, the availability of the results is also written
954    VK_QUERY_RESULT_PARTIAL_BIT                             = 0x00000008,   /// Copy the partial results of the query even if the final results aren't available
955}
956
957/// Shader module creation flags
958type VkFlags VkShaderModuleCreateFlags
959//bitfield VkShaderModuleCreateFlagBits {
960//}
961
962/// Event creation flags
963type VkFlags VkEventCreateFlags
964//bitfield VkEventCreateFlagBits {
965//}
966
967/// Command buffer usage flags
968type VkFlags VkCommandBufferUsageFlags
969bitfield VkCommandBufferUsageFlagBits {
970    VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT             = 0x00000001,
971    VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT        = 0x00000002,
972    VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT            = 0x00000004,
973}
974
975/// Pipeline statistics flags
976type VkFlags VkQueryPipelineStatisticFlags
977bitfield VkQueryPipelineStatisticFlagBits {
978    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT                     = 0x00000001,  /// Optional
979    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT                   = 0x00000002,  /// Optional
980    VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT                   = 0x00000004,  /// Optional
981    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT                 = 0x00000008,  /// Optional
982    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT                  = 0x00000010,  /// Optional
983    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT                        = 0x00000020,  /// Optional
984    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT                         = 0x00000040,  /// Optional
985    VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT                 = 0x00000080,  /// Optional
986    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT         = 0x00000100,  /// Optional
987    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT  = 0x00000200,  /// Optional
988    VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT                  = 0x00000400,  /// Optional
989}
990
991/// Memory mapping flags
992type VkFlags VkMemoryMapFlags
993//bitfield VkMemoryMapFlagBits {
994//}
995
996/// Bitfield of image aspects
997type VkFlags VkImageAspectFlags
998bitfield VkImageAspectFlagBits {
999    VK_IMAGE_ASPECT_COLOR_BIT                               = 0x00000001,
1000    VK_IMAGE_ASPECT_DEPTH_BIT                               = 0x00000002,
1001    VK_IMAGE_ASPECT_STENCIL_BIT                             = 0x00000004,
1002    VK_IMAGE_ASPECT_METADATA_BIT                            = 0x00000008,
1003}
1004
1005/// Sparse memory bind flags
1006type VkFlags VkSparseMemoryBindFlags
1007bitfield VkSparseMemoryBindFlagBits {
1008    VK_SPARSE_MEMORY_BIND_METADATA_BIT                      = 0x00000001,
1009}
1010
1011/// Sparse image memory requirements flags
1012type VkFlags VkSparseImageFormatFlags
1013bitfield VkSparseImageFormatFlagBits {
1014    VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT                  = 0x00000001,  /// Image uses a single miptail region for all array slices
1015    VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT                = 0x00000002,  /// Image requires mip levels to be an exact multiple of the sparse iamge block size for non-mip-tail levels.
1016    VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT          = 0x00000004,  /// Image uses a non-standard sparse block size
1017}
1018
1019/// Pipeline stages
1020type VkFlags VkPipelineStageFlags
1021bitfield VkPipelineStageFlagBits {
1022    VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT                       = 0x00000001,  /// Before subsequent commands are processed
1023    VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT                     = 0x00000002,  /// Draw/DispatchIndirect command fetch
1024    VK_PIPELINE_STAGE_VERTEX_INPUT_BIT                      = 0x00000004,  /// Vertex/index fetch
1025    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT                     = 0x00000008,  /// Vertex shading
1026    VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT       = 0x00000010,  /// Tessellation control shading
1027    VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT    = 0x00000020,  /// Tessellation evaluation shading
1028    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT                   = 0x00000040,  /// Geometry shading
1029    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT                   = 0x00000080,  /// Fragment shading
1030    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT              = 0x00000100,  /// Early fragment (depth/stencil) tests
1031    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT               = 0x00000200,  /// Late fragment (depth/stencil) tests
1032    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT           = 0x00000400,  /// Color attachment writes
1033    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT                    = 0x00000800,  /// Compute shading
1034    VK_PIPELINE_STAGE_TRANSFER_BIT                          = 0x00001000,  /// Transfer/copy operations
1035    VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT                    = 0x00002000,
1036    VK_PIPELINE_STAGE_HOST_BIT                              = 0x00004000,  /// Indicates host (CPU) is a source/sink of the dependency
1037
1038    VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT                      = 0x00008000,  /// All stages of the graphics pipeline
1039    VK_PIPELINE_STAGE_ALL_COMMANDS_BIT                      = 0x00010000,  /// All graphics, compute, copy, and transition commands
1040}
1041
1042/// Render pass attachment description flags
1043type VkFlags VkAttachmentDescriptionFlags
1044bitfield VkAttachmentDescriptionFlagBits {
1045    VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT                 = 0x00000001,  /// The attachment may alias physical memory of another attachment in the same renderpass
1046}
1047
1048/// Subpass description flags
1049type VkFlags VkSubpassDescriptionFlags
1050bitfield VkSubpassDescriptionFlagBits {
1051}
1052
1053/// Command pool creation flags
1054type VkFlags VkCommandPoolCreateFlags
1055bitfield VkCommandPoolCreateFlagBits {
1056    VK_COMMAND_POOL_CREATE_TRANSIENT_BIT                    = 0x00000001,  /// Command buffers have a short lifetime
1057    VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT         = 0x00000002,  /// Command buffers may release their memory individually
1058}
1059
1060/// Command pool reset flags
1061type VkFlags VkCommandPoolResetFlags
1062bitfield VkCommandPoolResetFlagBits {
1063    VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT             = 0x00000001,  /// Release resources owned by the pool
1064}
1065
1066type VkFlags VkCommandBufferResetFlags
1067bitfield VkCommandBufferResetFlagBits {
1068    VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT           = 0x00000001,  /// Release resources owned by the buffer
1069}
1070
1071type VkFlags VkSampleCountFlags
1072bitfield VkSampleCountFlagBits {
1073    VK_SAMPLE_COUNT_1_BIT                                   = 0x00000001,
1074    VK_SAMPLE_COUNT_2_BIT                                   = 0x00000002,
1075    VK_SAMPLE_COUNT_4_BIT                                   = 0x00000004,
1076    VK_SAMPLE_COUNT_8_BIT                                   = 0x00000008,
1077    VK_SAMPLE_COUNT_16_BIT                                  = 0x00000010,
1078    VK_SAMPLE_COUNT_32_BIT                                  = 0x00000020,
1079    VK_SAMPLE_COUNT_64_BIT                                  = 0x00000040,
1080}
1081
1082type VkFlags VkStencilFaceFlags
1083bitfield VkStencilFaceFlagBits {
1084    VK_STENCIL_FACE_FRONT_BIT                               = 0x00000001,   /// Front face
1085    VK_STENCIL_FACE_BACK_BIT                                = 0x00000002,   /// Back face
1086    VK_STENCIL_FRONT_AND_BACK                               = 0x00000003,
1087}
1088
1089/// Instance creation flags
1090type VkFlags VkInstanceCreateFlags
1091//bitfield VkInstanceCreateFlagBits {
1092//}
1093
1094/// Device creation flags
1095type VkFlags VkDeviceCreateFlags
1096//bitfield VkDeviceCreateFlagBits {
1097//}
1098
1099/// Device queue creation flags
1100type VkFlags VkDeviceQueueCreateFlags
1101//bitfield VkDeviceQueueCreateFlagBits {
1102//}
1103
1104/// Query pool creation flags
1105type VkFlags VkQueryPoolCreateFlags
1106//bitfield VkQueryPoolCreateFlagBits {
1107//}
1108
1109/// Buffer view creation flags
1110type VkFlags VkBufferViewCreateFlags
1111//bitfield VkBufferViewCreateFlagBits {
1112//}
1113
1114/// Pipeline cache creation flags
1115type VkFlags VkPipelineCacheCreateFlags
1116//bitfield VkPipelineCacheCreateFlagBits {
1117//}
1118
1119/// Pipeline shader stage creation flags
1120type VkFlags VkPipelineShaderStageCreateFlags
1121//bitfield VkPipelineShaderStageCreateFlagBits {
1122//}
1123
1124/// Descriptor set layout creation flags
1125type VkFlags VkDescriptorSetLayoutCreateFlags
1126//bitfield VkDescriptorSetLayoutCreateFlagBits {
1127//}
1128
1129/// Pipeline vertex input state creation flags
1130type VkFlags VkPipelineVertexInputStateCreateFlags
1131//bitfield VkPipelineVertexInputStateCreateFlagBits {
1132//}
1133
1134/// Pipeline input assembly state creation flags
1135type VkFlags VkPipelineInputAssemblyStateCreateFlags
1136//bitfield VkPipelineInputAssemblyStateCreateFlagBits {
1137//}
1138
1139/// Tessellation state creation flags
1140type VkFlags VkPipelineTessellationStateCreateFlags
1141//bitfield VkPipelineTessellationStateCreateFlagBits {
1142//}
1143
1144/// Viewport state creation flags
1145type VkFlags VkPipelineViewportStateCreateFlags
1146//bitfield VkPipelineViewportStateCreateFlagBits {
1147//}
1148
1149/// Rasterization state creation flags
1150type VkFlags VkPipelineRasterizationStateCreateFlags
1151//bitfield VkPipelineRasterizationStateCreateFlagBits {
1152//}
1153
1154/// Multisample state creation flags
1155type VkFlags VkPipelineMultisampleStateCreateFlags
1156//bitfield VkPipelineMultisampleStateCreateFlagBits {
1157//}
1158
1159/// Color blend state creation flags
1160type VkFlags VkPipelineColorBlendStateCreateFlags
1161//bitfield VkPipelineColorBlendStateCreateFlagBits {
1162//}
1163
1164/// Depth/stencil state creation flags
1165type VkFlags VkPipelineDepthStencilStateCreateFlags
1166//bitfield VkPipelineDepthStencilStateCreateFlagBits {
1167//}
1168
1169/// Dynamic state creation flags
1170type VkFlags VkPipelineDynamicStateCreateFlags
1171//bitfield VkPipelineDynamicStateCreateFlagBits {
1172//}
1173
1174/// Pipeline layout creation flags
1175type VkFlags VkPipelineLayoutCreateFlags
1176//bitfield VkPipelineLayoutCreateFlagBits {
1177//}
1178
1179/// Sampler creation flags
1180type VkFlags VkSamplerCreateFlags
1181//bitfield VkSamplerCreateFlagBits {
1182//}
1183
1184/// Render pass creation flags
1185type VkFlags VkRenderPassCreateFlags
1186//bitfield VkRenderPassCreateFlagBits {
1187//}
1188
1189/// Framebuffer creation flags
1190type VkFlags VkFramebufferCreateFlags
1191//bitfield VkFramebufferCreateFlagBits {
1192//}
1193
1194/// Dependency flags
1195type VkFlags VkDependencyFlags
1196bitfield VkDependencyFlagBits {
1197    VK_DEPENDENCY_BY_REGION_BIT                             = 0x00000001,
1198}
1199
1200/// Cull mode flags
1201type VkFlags VkCullModeFlags
1202bitfield VkCullModeFlagBits {
1203    VK_CULL_MODE_NONE                                       = 0x00000000,
1204    VK_CULL_MODE_FRONT_BIT                                  = 0x00000001,
1205    VK_CULL_MODE_BACK_BIT                                   = 0x00000002,
1206    VK_CULL_MODE_FRONT_AND_BACK                             = 0x00000003,
1207}
1208
1209@extension("VK_KHR_surface")
1210type VkFlags VkSurfaceTransformFlagsKHR
1211@extension("VK_KHR_surface")
1212bitfield VkSurfaceTransformFlagBitsKHR {
1213    VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR                       = 0x00000001,
1214    VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR                      = 0x00000002,
1215    VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR                     = 0x00000004,
1216    VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR                     = 0x00000008,
1217    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR              = 0x00000010,
1218    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR    = 0x00000020,
1219    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR   = 0x00000040,
1220    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR   = 0x00000080,
1221    VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR                        = 0x00000100,
1222}
1223
1224@extension("VK_KHR_surface")
1225type VkFlags VkCompositeAlphaFlagsKHR
1226@extension("VK_KHR_surface")
1227bitfield VkCompositeAlphaFlagBitsKHR {
1228    VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR                       = 0x00000001,
1229    VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR               = 0x00000002,
1230    VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR              = 0x00000004,
1231    VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR                      = 0x00000008,
1232}
1233
1234@extension("VK_KHR_swapchain")
1235type VkFlags VkSwapchainCreateFlagsKHR
1236//@extension("VK_KHR_swapchain")
1237//bitfield VkSwapchainCreateFlagBitsKHR {
1238//}
1239
1240@extension("VK_KHR_display")
1241type VkFlags VkDisplayPlaneAlphaFlagsKHR
1242@extension("VK_KHR_display")
1243bitfield VkDisplayPlaneAlphaFlagBitsKHR {
1244    VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR                   = 0x00000001,
1245    VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR                   = 0x00000002,
1246    VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR                = 0x00000004,
1247    VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR  = 0x00000008,
1248}
1249
1250@extension("VK_KHR_display")
1251type VkFlags VkDisplaySurfaceCreateFlagsKHR
1252//@extension("VK_KHR_display")
1253//bitfield VkDisplaySurfaceCreateFlagBitsKHR {
1254//}
1255
1256@extension("VK_KHR_display")
1257type VkFlags VkDisplayModeCreateFlagsKHR
1258//@extension("VK_KHR_display")
1259//bitfield VkDisplayModeCreateFlagBitsKHR {
1260//}
1261
1262@extension("VK_KHR_xlib_surface")
1263type VkFlags VkXlibSurfaceCreateFlagsKHR
1264//@extension("VK_KHR_xlib_surface")
1265//bitfield VkXlibSurfaceCreateFlagBitsKHR {
1266//}
1267
1268@extension("VK_KHR_xcb_surface")
1269type VkFlags VkXcbSurfaceCreateFlagsKHR
1270//@extension("VK_KHR_xcb_surface")
1271//bitfield VkXcbSurfaceCreateFlagBitsKHR {
1272//}
1273
1274@extension("VK_KHR_wayland_surface")
1275type VkFlags VkWaylandSurfaceCreateFlagsKHR
1276//@extension("VK_KHR_wayland_surface")
1277//bitfield VkWaylandSurfaceCreateFlagBitsKHR {
1278//}
1279
1280@extension("VK_KHR_mir_surface")
1281type VkFlags VkMirSurfaceCreateFlagsKHR
1282//@extension("VK_KHR_mir_surface")
1283//bitfield VkMirSurfaceCreateFlagBitsKHR {
1284//}
1285
1286@extension("VK_KHR_android_surface")
1287type VkFlags VkAndroidSurfaceCreateFlagsKHR
1288//@extension("VK_KHR_android_surface")
1289//bitfield VkAndroidSurfaceCreateFlagBitsKHR {
1290//}
1291
1292@extension("VK_KHR_win32_surface")
1293type VkFlags VkWin32SurfaceCreateFlagsKHR
1294//@extension("VK_KHR_win32_surface")
1295//bitfield VkWin32SurfaceCreateFlagBitsKHR {
1296//}
1297
1298@extension("VK_EXT_debug_report")
1299type VkFlags VkDebugReportFlagsEXT
1300@extension("VK_EXT_debug_report")
1301bitfield VkDebugReportFlagBitsEXT {
1302    VK_DEBUG_REPORT_INFO_BIT_EXT                            = 0x00000001,
1303    VK_DEBUG_REPORT_WARN_BIT_EXT                            = 0x00000002,
1304    VK_DEBUG_REPORT_PERF_WARN_BIT_EXT                       = 0x00000004,
1305    VK_DEBUG_REPORT_ERROR_BIT_EXT                           = 0x00000008,
1306    VK_DEBUG_REPORT_DEBUG_BIT_EXT                           = 0x00000010,
1307}
1308
1309
1310//////////////////
1311//  Structures  //
1312//////////////////
1313
1314class VkOffset2D {
1315    s32                                         x
1316    s32                                         y
1317}
1318
1319class VkOffset3D {
1320    s32                                         x
1321    s32                                         y
1322    s32                                         z
1323}
1324
1325class VkExtent2D {
1326    u32                                         width
1327    u32                                         height
1328}
1329
1330class VkExtent3D {
1331    u32                                         width
1332    u32                                         height
1333    u32                                         depth
1334}
1335
1336class VkViewport {
1337    f32                                         x
1338    f32                                         y
1339    f32                                         width
1340    f32                                         height
1341    f32                                         minDepth
1342    f32                                         maxDepth
1343}
1344
1345class VkRect2D {
1346    VkOffset2D                                  offset
1347    VkExtent2D                                  extent
1348}
1349
1350class VkClearRect {
1351    VkRect2D                                    rect
1352    u32                                         baseArrayLayer
1353    u32                                         layerCount
1354}
1355
1356class VkComponentMapping {
1357    VkComponentSwizzle                          r
1358    VkComponentSwizzle                          g
1359    VkComponentSwizzle                          b
1360    VkComponentSwizzle                          a
1361}
1362
1363class VkPhysicalDeviceProperties {
1364    u32                                         apiVersion
1365    u32                                         driverVersion
1366    u32                                         vendorID
1367    u32                                         deviceID
1368    VkPhysicalDeviceType                        deviceType
1369    char[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]      deviceName
1370    u8[VK_UUID_SIZE]                            pipelineCacheUUID
1371    VkPhysicalDeviceLimits                      limits
1372    VkPhysicalDeviceSparseProperties            sparseProperties
1373}
1374
1375class VkExtensionProperties {
1376    char[VK_MAX_EXTENSION_NAME_SIZE]            extensionName      /// extension name
1377    u32                                         specVersion        /// version of the extension specification implemented
1378}
1379
1380class VkLayerProperties {
1381    char[VK_MAX_EXTENSION_NAME_SIZE]            layerName               /// layer name
1382    u32                                         specVersion             /// version of the layer specification implemented
1383    u32                                         implementationVersion   /// build or release version of the layer's library
1384    char[VK_MAX_DESCRIPTION_SIZE]               description             /// Free-form description of the layer
1385}
1386
1387class VkSubmitInfo {
1388    VkStructureType                             sType              /// Type of structure. Should be VK_STRUCTURE_TYPE_SUBMIT_INFO
1389    const void*                                 pNext              /// Next structure in chain
1390    u32                                         waitSemaphoreCount
1391    const VkSemaphore*                          pWaitSemaphores
1392    const VkPipelineStageFlags*                 pWaitDstStageMask
1393    u32                                         commandBufferCount
1394    const VkCommandBuffer*                      pCommandBuffers
1395    u32                                         signalSemaphoreCount
1396    const VkSemaphore*                          pSignalSemaphores
1397}
1398
1399class VkApplicationInfo {
1400    VkStructureType                             sType              /// Type of structure. Should be VK_STRUCTURE_TYPE_APPLICATION_INFO
1401    const void*                                 pNext              /// Next structure in chain
1402    const char*                                 pApplicationName
1403    u32                                         applicationVersion
1404    const char*                                 pEngineName
1405    u32                                         engineVersion
1406    u32                                         apiVersion
1407}
1408
1409class VkAllocationCallbacks {
1410    void*                                       pUserData
1411    PFN_vkAllocationFunction                    pfnAllocation
1412    PFN_vkReallocationFunction                  pfnReallocation
1413    PFN_vkFreeFunction                          pfnFree
1414    PFN_vkInternalAllocationNotification        pfnInternalAllocation
1415    PFN_vkInternalFreeNotification              pfnInternalFree
1416}
1417
1418class VkDeviceQueueCreateInfo {
1419    VkStructureType                             sStype                    /// Should be VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO
1420    const void*                                 pNext                     /// Pointer to next structure
1421    VkDeviceQueueCreateFlags                    flags
1422    u32                                         queueFamilyIndex
1423    u32                                         queueCount
1424    const f32*                                  pQueuePriorities
1425}
1426
1427class VkDeviceCreateInfo {
1428    VkStructureType                             sType                      /// Should be VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
1429    const void*                                 pNext                      /// Pointer to next structure
1430    VkDeviceCreateFlags                         flags
1431    u32                                         queueCreateInfoCount
1432    const VkDeviceQueueCreateInfo*              pQueueCreateInfos
1433    u32                                         enabledLayerCount
1434    const char* const*                          ppEnabledLayerNames        /// Ordered list of layer names to be enabled
1435    u32                                         enabledExtensionCount
1436    const char* const*                          ppEnabledExtensionNames
1437    const VkPhysicalDeviceFeatures*             pEnabledFeatures
1438}
1439
1440class VkInstanceCreateInfo {
1441    VkStructureType                             sType                      /// Should be VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
1442    const void*                                 pNext                      /// Pointer to next structure
1443    VkInstanceCreateFlags                       flags
1444    const VkApplicationInfo*                    pApplicationInfo
1445    u32                                         enabledLayerCount
1446    const char* const*                          ppEnabledLayerNames        /// Ordered list of layer names to be enabled
1447    u32                                         enabledExtensionCount
1448    const char* const*                          ppEnabledExtensionNames    /// Extension names to be enabled
1449}
1450
1451class VkQueueFamilyProperties {
1452    VkQueueFlags                                queueFlags                 /// Queue flags
1453    u32                                         queueCount
1454    u32                                         timestampValidBits
1455    VkExtent3D                                  minImageTransferGranularity
1456}
1457
1458class VkPhysicalDeviceMemoryProperties {
1459    u32                                         memoryTypeCount
1460    VkMemoryType[VK_MAX_MEMORY_TYPES]           memoryTypes
1461    u32                                         memoryHeapCount
1462    VkMemoryHeap[VK_MAX_MEMORY_HEAPS]           memoryHeaps
1463}
1464
1465class VkMemoryAllocateInfo {
1466    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
1467    const void*                                 pNext                      /// Pointer to next structure
1468    VkDeviceSize                                allocationSize             /// Size of memory allocation
1469    u32                                         memoryTypeIndex            /// Index of the of the memory type to allocate from
1470}
1471
1472class VkMemoryRequirements {
1473    VkDeviceSize                                size                       /// Specified in bytes
1474    VkDeviceSize                                alignment                  /// Specified in bytes
1475    u32                                         memoryTypeBits             /// Bitfield of the allowed memory type indices into memoryTypes[] for this object
1476}
1477
1478class VkSparseImageFormatProperties {
1479    VkImageAspectFlagBits                       aspectMask
1480    VkExtent3D                                  imageGranularity
1481    VkSparseImageFormatFlags                    flags
1482}
1483
1484class VkSparseImageMemoryRequirements {
1485    VkSparseImageFormatProperties               formatProperties
1486    u32                                         imageMipTailFirstLod
1487    VkDeviceSize                                imageMipTailSize           /// Specified in bytes, must be a multiple of image block size / alignment
1488    VkDeviceSize                                imageMipTailOffset         /// Specified in bytes, must be a multiple of image block size / alignment
1489    VkDeviceSize                                imageMipTailStride         /// Specified in bytes, must be a multiple of image block size / alignment
1490}
1491
1492class VkMemoryType {
1493    VkMemoryPropertyFlags                       propertyFlags              /// Memory properties of this memory type
1494    u32                                         heapIndex                  /// Index of the memory heap allocations of this memory type are taken from
1495}
1496
1497class VkMemoryHeap {
1498    VkDeviceSize                                size                       /// Available memory in the heap
1499    VkMemoryHeapFlags                           flags                      /// Flags for the heap
1500}
1501
1502class VkMappedMemoryRange {
1503    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE
1504    const void*                                 pNext                      /// Pointer to next structure
1505    VkDeviceMemory                              memory                     /// Mapped memory object
1506    VkDeviceSize                                offset                     /// Offset within the mapped memory the range starts from
1507    VkDeviceSize                                size                       /// Size of the range within the mapped memory
1508}
1509
1510class VkFormatProperties {
1511    VkFormatFeatureFlags                        linearTilingFeatures       /// Format features in case of linear tiling
1512    VkFormatFeatureFlags                        optimalTilingFeatures      /// Format features in case of optimal tiling
1513    VkFormatFeatureFlags                        bufferFeatures             /// Format features supported by buffers
1514}
1515
1516class VkImageFormatProperties {
1517    VkExtent3D                                  maxExtent                  /// max image dimensions for this resource type
1518    u32                                         maxMipLevels               /// max number of mipmap levels for this resource type
1519    u32                                         maxArrayLayers             /// max array layers for this resource type
1520    VkSampleCountFlags                          sampleCounts               /// supported sample counts for this resource type
1521    VkDeviceSize                                maxResourceSize            /// max size (in bytes) of this resource type
1522}
1523
1524class VkDescriptorImageInfo {
1525    VkSampler                                   sampler
1526    VkImageView                                 imageView
1527    VkImageLayout                               imageLayout
1528}
1529
1530class VkDescriptorBufferInfo {
1531    VkBuffer                                    buffer                     /// Buffer used for this descriptor when the descriptor is UNIFORM_BUFFER[_DYNAMIC]
1532    VkDeviceSize                                offset                     /// Base offset from buffer start in bytes to update in the descriptor set.
1533    VkDeviceSize                                range                      /// Size in bytes of the buffer resource for this descriptor update.
1534}
1535
1536class VkWriteDescriptorSet {
1537    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
1538    const void*                                 pNext                      /// Pointer to next structure
1539    VkDescriptorSet                             dstSet                     /// Destination descriptor set
1540    u32                                         dstBinding                 /// Binding within the destination descriptor set to write
1541    u32                                         dstArrayElement            /// Array element within the destination binding to write
1542    u32                                         descriptorCount            /// Number of descriptors to write (determines the size of the array pointed by <pDescriptors>)
1543    VkDescriptorType                            descriptorType             /// Descriptor type to write (determines which fields of the array pointed by <pDescriptors> are going to be used)
1544    const VkDescriptorImageInfo*                pImageInfo
1545    const VkDescriptorBufferInfo*               pBufferInfo
1546    const VkBufferView*                         pTexelBufferView
1547}
1548
1549class VkCopyDescriptorSet {
1550    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET
1551    const void*                                 pNext                      /// Pointer to next structure
1552    VkDescriptorSet                             srcSet                     /// Source descriptor set
1553    u32                                         srcBinding                 /// Binding within the source descriptor set to copy from
1554    u32                                         srcArrayElement            /// Array element within the source binding to copy from
1555    VkDescriptorSet                             dstSet                     /// Destination descriptor set
1556    u32                                         dstBinding                 /// Binding within the destination descriptor set to copy to
1557    u32                                         dstArrayElement            /// Array element within the destination binding to copy to
1558    u32                                         descriptorCount            /// Number of descriptors to copy
1559}
1560
1561class VkBufferCreateInfo {
1562    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
1563    const void*                                 pNext                      /// Pointer to next structure.
1564    VkBufferCreateFlags                         flags                      /// Buffer creation flags
1565    VkDeviceSize                                size                       /// Specified in bytes
1566    VkBufferUsageFlags                          usage                      /// Buffer usage flags
1567    VkSharingMode                               sharingMode
1568    u32                                         queueFamilyIndexCount
1569    const u32*                                  pQueueFamilyIndices
1570}
1571
1572class VkBufferViewCreateInfo {
1573    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO
1574    const void*                                 pNext                      /// Pointer to next structure.
1575    VkBufferViewCreateFlags                     flags
1576    VkBuffer                                    buffer
1577    VkFormat                                    format                     /// Optionally specifies format of elements
1578    VkDeviceSize                                offset                     /// Specified in bytes
1579    VkDeviceSize                                range                      /// View size specified in bytes
1580}
1581
1582class VkImageSubresource {
1583    VkImageAspectFlagBits                       aspectMask
1584    u32                                         mipLevel
1585    u32                                         arrayLayer
1586}
1587
1588class VkImageSubresourceRange {
1589    VkImageAspectFlags                          aspectMask
1590    u32                                         baseMipLevel
1591    u32                                         levelCount
1592    u32                                         baseArrayLayer
1593    u32                                         layerCount
1594}
1595
1596class VkMemoryBarrier {
1597    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_MEMORY_BARRIER
1598    const void*                                 pNext                      /// Pointer to next structure.
1599    VkAccessFlags                               srcAccessMask
1600    VkAccessFlags                               dstAccessMask
1601}
1602
1603class VkBufferMemoryBarrier {
1604    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER
1605    const void*                                 pNext                      /// Pointer to next structure.
1606    VkAccessFlags                               srcAccessMask
1607    VkAccessFlags                               dstAccessMask
1608    u32                                         srcQueueFamilyIndex        /// Queue family to transition ownership from
1609    u32                                         dstQueueFamilyIndex        /// Queue family to transition ownership to
1610    VkBuffer                                    buffer                     /// Buffer to sync
1611    VkDeviceSize                                offset                     /// Offset within the buffer to sync
1612    VkDeviceSize                                size                       /// Amount of bytes to sync
1613}
1614
1615class VkImageMemoryBarrier {
1616    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
1617    const void*                                 pNext                      /// Pointer to next structure.
1618    VkAccessFlags                               srcAccessMask
1619    VkAccessFlags                               dstAccessMask
1620    VkImageLayout                               oldLayout                  /// Current layout of the image
1621    VkImageLayout                               newLayout                  /// New layout to transition the image to
1622    u32                                         srcQueueFamilyIndex        /// Queue family to transition ownership from
1623    u32                                         dstQueueFamilyIndex        /// Queue family to transition ownership to
1624    VkImage                                     image                      /// Image to sync
1625    VkImageSubresourceRange                     subresourceRange           /// Subresource range to sync
1626}
1627
1628class VkImageCreateInfo {
1629    VkStructureType                             sType                      /// Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
1630    const void*                                 pNext                      /// Pointer to next structure.
1631    VkImageCreateFlags                          flags                      /// Image creation flags
1632    VkImageType                                 imageType
1633    VkFormat                                    format
1634    VkExtent3D                                  extent
1635    u32                                         mipLevels
1636    u32                                         arrayLayers
1637    VkSampleCountFlagBits                       samples
1638    VkImageTiling                               tiling
1639    VkImageUsageFlags                           usage                      /// Image usage flags
1640    VkSharingMode                               sharingMode                /// Cross-queue-family sharing mode
1641    u32                                         queueFamilyIndexCount      /// Number of queue families to share across
1642    const u32*                                  pQueueFamilyIndices        /// Array of queue family indices to share across
1643    VkImageLayout                               initialLayout              /// Initial image layout for all subresources
1644}
1645
1646class VkSubresourceLayout {
1647    VkDeviceSize                                offset                 /// Specified in bytes
1648    VkDeviceSize                                size                   /// Specified in bytes
1649    VkDeviceSize                                rowPitch               /// Specified in bytes
1650    VkDeviceSize                                arrayPitch             /// Specified in bytes
1651    VkDeviceSize                                depthPitch             /// Specified in bytes
1652}
1653
1654class VkImageViewCreateInfo {
1655    VkStructureType                             sType                  /// Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
1656    const void*                                 pNext                  /// Pointer to next structure
1657    VkImageViewCreateFlags                      flags
1658    VkImage                                     image
1659    VkImageViewType                             viewType
1660    VkFormat                                    format
1661    VkComponentMapping                          components
1662    VkImageSubresourceRange                     subresourceRange
1663}
1664
1665class VkBufferCopy {
1666    VkDeviceSize                                srcOffset              /// Specified in bytes
1667    VkDeviceSize                                dstOffset              /// Specified in bytes
1668    VkDeviceSize                                size                   /// Specified in bytes
1669}
1670
1671class VkSparseMemoryBind {
1672    VkDeviceSize                                resourceOffset        /// Specified in bytes
1673    VkDeviceSize                                size                  /// Specified in bytes
1674    VkDeviceMemory                              memory
1675    VkDeviceSize                                memoryOffset          /// Specified in bytes
1676    VkSparseMemoryBindFlags                     flags
1677}
1678
1679class VkSparseImageMemoryBind {
1680    VkImageSubresource                          subresource
1681    VkOffset3D                                  offset
1682    VkExtent3D                                  extent
1683    VkDeviceMemory                              memory
1684    VkDeviceSize                                memoryOffset          /// Specified in bytes
1685    VkSparseMemoryBindFlags                     flags
1686}
1687
1688class VkSparseBufferMemoryBindInfo {
1689    VkBuffer                                    buffer
1690    u32                                         bindCount
1691    const VkSparseMemoryBind*                   pBinds
1692}
1693
1694class VkSparseImageOpaqueMemoryBindInfo {
1695    VkImage                                     image
1696    u32                                         bindCount
1697    const VkSparseMemoryBind*                   pBinds
1698}
1699
1700class VkSparseImageMemoryBindInfo {
1701    VkImage                                     image
1702    u32                                         bindCount
1703    const VkSparseMemoryBind*                   pBinds
1704}
1705
1706class VkBindSparseInfo {
1707    VkStructureType                             sType                 /// Must be VK_STRUCTURE_TYPE_BIND_SPARSE_INFO
1708    const void*                                 pNext
1709    u32                                         waitSemaphoreCount
1710    const VkSemaphore*                          pWaitSemaphores
1711    u32                                         numBufferBinds
1712    const VkSparseBufferMemoryBindInfo*         pBufferBinds
1713    u32                                         numImageOpaqueBinds
1714    const VkSparseImageOpaqueMemoryBindInfo*    pImageOpaqueBinds
1715    u32                                         numImageBinds
1716    const VkSparseImageMemoryBindInfo*          pImageBinds
1717    u32                                         signalSemaphoreCount
1718    const VkSemaphore*                          pSignalSemaphores
1719}
1720
1721class VkImageSubresourceLayers {
1722    VkImageAspectFlags                          aspectMask
1723    u32                                         mipLevel
1724    u32                                         baseArrayLayer
1725    u32                                         layerCount
1726}
1727
1728class VkImageCopy {
1729    VkImageSubresourceLayers                    srcSubresource
1730    VkOffset3D                                  srcOffset             /// Specified in pixels for both compressed and uncompressed images
1731    VkImageSubresourceLayers                    dstSubresource
1732    VkOffset3D                                  dstOffset             /// Specified in pixels for both compressed and uncompressed images
1733    VkExtent3D                                  extent                /// Specified in pixels for both compressed and uncompressed images
1734}
1735
1736class VkImageBlit {
1737    VkImageSubresourceLayers                    srcSubresource
1738    VkOffset3D[2]                               srcOffsets
1739    VkImageSubresourceLayers                    dstSubresource
1740    VkOffset3D[2]                               dstOffsets
1741}
1742
1743class VkBufferImageCopy {
1744    VkDeviceSize                                bufferOffset           /// Specified in bytes
1745    u32                                         bufferRowLength        /// Specified in texels
1746    u32                                         bufferImageHeight
1747    VkImageSubresourceLayers                    imageSubresource
1748    VkOffset3D                                  imageOffset            /// Specified in pixels for both compressed and uncompressed images
1749    VkExtent3D                                  imageExtent            /// Specified in pixels for both compressed and uncompressed images
1750}
1751
1752class VkImageResolve {
1753    VkImageSubresourceLayers                    srcSubresource
1754    VkOffset3D                                  srcOffset
1755    VkImageSubresourceLayers                    dstSubresource
1756    VkOffset3D                                  dstOffset
1757    VkExtent3D                                  extent
1758}
1759
1760class VkShaderModuleCreateInfo {
1761    VkStructureType                             sType                  /// Must be VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
1762    const void*                                 pNext                  /// Pointer to next structure
1763    VkShaderModuleCreateFlags                   flags                  /// Reserved
1764    platform.size_t                             codeSize               /// Specified in bytes
1765    const u32*                                  pCode                  /// Binary code of size codeSize
1766}
1767
1768class VkDescriptorSetLayoutBinding {
1769    u32                                         binding
1770    VkDescriptorType                            descriptorType     /// Type of the descriptors in this binding
1771    u32                                         descriptorCount    /// Number of descriptors in this binding
1772    VkShaderStageFlags                          stageFlags         /// Shader stages this binding is visible to
1773    const VkSampler*                            pImmutableSamplers /// Immutable samplers (used if descriptor type is SAMPLER or COMBINED_IMAGE_SAMPLER, is either NULL or contains <count> number of elements)
1774}
1775
1776class VkDescriptorSetLayoutCreateInfo {
1777    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
1778    const void*                                 pNext              /// Pointer to next structure
1779    VkDescriptorSetLayoutCreateFlags            flags
1780    u32                                         bindingCount       /// Number of bindings in the descriptor set layout
1781    const VkDescriptorSetLayoutBinding*         pBindings          /// Array of descriptor set layout bindings
1782}
1783
1784class VkDescriptorPoolSize {
1785    VkDescriptorType                            type
1786    u32                                         descriptorCount
1787}
1788
1789class VkDescriptorPoolCreateInfo {
1790    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
1791    const void*                                 pNext              /// Pointer to next structure
1792    VkDescriptorPoolCreateFlags                 flags
1793    u32                                         maxSets
1794    u32                                         poolSizeCount
1795    const VkDescriptorPoolSize*                 pPoolSizes
1796}
1797
1798class VkDescriptorSetAllocateInfo {
1799    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
1800    const void*                                 pNext              /// Pointer to next structure
1801    VkDescriptorPool                            descriptorPool
1802    u32                                         setCount
1803    const VkDescriptorSetLayout*                pSetLayouts
1804}
1805
1806class VkSpecializationMapEntry {
1807    u32                                         constantID         /// The SpecConstant ID specified in the BIL
1808    u32                                         offset             /// Offset of the value in the data block
1809    platform.size_t                             size               /// Size in bytes of the SpecConstant
1810}
1811
1812class VkSpecializationInfo {
1813    u32                                         mapEntryCount      /// Number of entries in the map
1814    const VkSpecializationMapEntry*             pMapEntries        /// Array of map entries
1815    platform.size_t                             dataSize           /// Size in bytes of pData
1816    const void*                                 pData              /// Pointer to SpecConstant data
1817}
1818
1819class VkPipelineShaderStageCreateInfo {
1820    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
1821    const void*                                 pNext              /// Pointer to next structure
1822    VkPipelineShaderStageCreateFlags            flags
1823    VkShaderStageFlagBits                       stage
1824    VkShaderModule                              module
1825    const char*                                 pName
1826    const VkSpecializationInfo*                 pSpecializationInfo
1827}
1828
1829class VkComputePipelineCreateInfo {
1830    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO
1831    const void*                                 pNext              /// Pointer to next structure
1832    VkPipelineCreateFlags                       flags              /// Pipeline creation flags
1833    VkPipelineShaderStageCreateInfo             stage
1834    VkPipelineLayout                            layout             /// Interface layout of the pipeline
1835    VkPipeline                                  basePipelineHandle /// If VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is nonzero, it specifies the handle of the base pipeline this is a derivative of
1836    s32                                         basePipelineIndex  /// If VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is not -1, it specifies an index into pCreateInfos of the base pipeline this is a derivative of
1837}
1838
1839class VkVertexInputBindingDescription {
1840    u32                                         binding               /// Vertex buffer binding id
1841    u32                                         stride                /// Distance between vertices in bytes (0 = no advancement)
1842    VkVertexInputRate                           inputRate             /// Rate at which binding is incremented
1843}
1844
1845class VkVertexInputAttributeDescription {
1846    u32                                         location              /// location of the shader vertex attrib
1847    u32                                         binding               /// Vertex buffer binding id
1848    VkFormat                                    format                /// format of source data
1849    u32                                         offset                /// Offset of first element in bytes from base of vertex
1850}
1851
1852class VkPipelineVertexInputStateCreateInfo {
1853    VkStructureType                             sType                           /// Should be VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
1854    const void*                                 pNext                           /// Pointer to next structure
1855    VkPipelineVertexInputStateCreateFlags       flags
1856    u32                                         vertexBindingDescriptionCount   /// number of bindings
1857    const VkVertexInputBindingDescription*      pVertexBindingDescriptions
1858    u32                                         vertexAttributeDescriptionCount /// number of attributes
1859    const VkVertexInputAttributeDescription*    pVertexAttributeDescriptions
1860}
1861
1862class VkPipelineInputAssemblyStateCreateInfo {
1863    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
1864    const void*                                 pNext      /// Pointer to next structure
1865    VkPipelineInputAssemblyStateCreateFlags     flags
1866    VkPrimitiveTopology                         topology
1867    VkBool32                                    primitiveRestartEnable
1868}
1869
1870class VkPipelineTessellationStateCreateInfo {
1871    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO
1872    const void*                                 pNext      /// Pointer to next structure
1873    VkPipelineTessellationStateCreateFlags      flags
1874    u32                                         patchControlPoints
1875}
1876
1877class VkPipelineViewportStateCreateInfo {
1878    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
1879    const void*                                 pNext      /// Pointer to next structure
1880    VkPipelineViewportStateCreateFlags          flags
1881    u32                                         viewportCount
1882    const VkViewport*                           pViewports
1883    u32                                         scissorCount
1884    const VkRect2D*                             pScissors
1885}
1886
1887class VkPipelineRasterizationStateCreateInfo {
1888    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
1889    const void*                                 pNext      /// Pointer to next structure
1890    VkPipelineRasterizationStateCreateFlags     flags
1891    VkBool32                                    depthClampEnable
1892    VkBool32                                    rasterizerDiscardEnable
1893    VkPolygonMode                               polygonMode                   /// optional (GL45)
1894    VkCullModeFlags                             cullMode
1895    VkFrontFace                                 frontFace
1896    VkBool32                                    depthBiasEnable
1897    f32                                         depthBiasConstantFactor
1898    f32                                         depthBiasClamp
1899    f32                                         depthBiasSlopeFactor
1900    f32                                         lineWidth
1901}
1902
1903class VkPipelineMultisampleStateCreateInfo {
1904    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
1905    const void*                                 pNext      /// Pointer to next structure
1906    VkPipelineMultisampleStateCreateFlags       flags
1907    VkSampleCountFlagBits                       rasterizationSamples       /// Number of samples used for rasterization
1908    VkBool32                                    sampleShadingEnable        /// optional (GL45)
1909    f32                                         minSampleShading           /// optional (GL45)
1910    const VkSampleMask*                         pSampleMask
1911    VkBool32                                    alphaToCoverageEnable
1912    VkBool32                                    alphaToOneEnable
1913}
1914
1915class VkPipelineColorBlendAttachmentState {
1916    VkBool32                                    blendEnable
1917    VkBlendFactor                               srcColorBlendFactor
1918    VkBlendFactor                               dstColorBlendFactor
1919    VkBlendOp                                   colorBlendOp
1920    VkBlendFactor                               srcAlphaBlendFactor
1921    VkBlendFactor                               dstAlphaBlendFactor
1922    VkBlendOp                                   alphaBlendOp
1923    VkColorComponentFlags                       colorWriteMask
1924}
1925
1926class VkPipelineColorBlendStateCreateInfo {
1927    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
1928    const void*                                 pNext      /// Pointer to next structure
1929    VkPipelineColorBlendStateCreateFlags        flags
1930    VkBool32                                    logicOpEnable
1931    VkLogicOp                                   logicOp
1932    u32                                         attachmentCount    /// # of pAttachments
1933    const VkPipelineColorBlendAttachmentState*  pAttachments
1934    f32[4]                                      blendConstants
1935}
1936
1937class VkStencilOpState {
1938    VkStencilOp                                 failOp
1939    VkStencilOp                                 passOp
1940    VkStencilOp                                 depthFailOp
1941    VkCompareOp                                 compareOp
1942    u32                                         compareMask
1943    u32                                         writeMask
1944    u32                                         reference
1945}
1946
1947class VkPipelineDepthStencilStateCreateInfo {
1948    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO
1949    const void*                                 pNext      /// Pointer to next structure
1950    VkPipelineDepthStencilStateCreateFlags      flags
1951    VkBool32                                    depthTestEnable
1952    VkBool32                                    depthWriteEnable
1953    VkCompareOp                                 depthCompareOp
1954    VkBool32                                    depthBoundsTestEnable  /// optional (depth_bounds_test)
1955    VkBool32                                    stencilTestEnable
1956    VkStencilOpState                            front
1957    VkStencilOpState                            back
1958    f32                                         minDepthBounds
1959    f32                                         maxDepthBounds
1960}
1961
1962class VkPipelineDynamicStateCreateInfo {
1963    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
1964    const void*                                 pNext      /// Pointer to next structure
1965    VkPipelineDynamicStateCreateFlags           flags
1966    u32                                         dynamicStateCount
1967    const VkDynamicState*                       pDynamicStates
1968}
1969
1970class VkGraphicsPipelineCreateInfo {
1971    VkStructureType                                 sType               /// Must be VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
1972    const void*                                     pNext               /// Pointer to next structure
1973    VkPipelineCreateFlags                           flags               /// Pipeline creation flags
1974    u32                                             stageCount
1975    const VkPipelineShaderStageCreateInfo*          pStages             /// One entry for each active shader stage
1976    const VkPipelineVertexInputStateCreateInfo*     pVertexInputState
1977    const VkPipelineInputAssemblyStateCreateInfo*   pInputAssemblyState
1978    const VkPipelineTessellationStateCreateInfo*    pTessellationState
1979    const VkPipelineViewportStateCreateInfo*        pViewportState
1980    const VkPipelineRasterizationStateCreateInfo*   pRasterizationState
1981    const VkPipelineMultisampleStateCreateInfo*     pMultisampleState
1982    const VkPipelineDepthStencilStateCreateInfo*    pDepthStencilState
1983    const VkPipelineColorBlendStateCreateInfo*      pColorBlendState
1984    const VkPipelineDynamicStateCreateInfo*         pDynamicState
1985    VkPipelineLayout                                layout              /// Interface layout of the pipeline
1986    VkRenderPass                                    renderPass
1987    u32                                             subpass
1988    VkPipeline                                      basePipelineHandle  /// If VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is nonzero, it specifies the handle of the base pipeline this is a derivative of
1989    s32                                             basePipelineIndex   /// If VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is not -1, it specifies an index into pCreateInfos of the base pipeline this is a derivative of
1990}
1991
1992class VkPipelineCacheCreateInfo {
1993    VkStructureType                             sType                 /// Must be VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO
1994    const void*                                 pNext                 /// Pointer to next structure
1995    VkPipelineCacheCreateFlags                  flags
1996    platform.size_t                             initialDataSize       /// Size of initial data to populate cache, in bytes
1997    const void*                                 pInitialData          /// Initial data to populate cache
1998}
1999
2000class VkPushConstantRange {
2001    VkShaderStageFlags                          stageFlags   /// Which stages use the range
2002    u32                                         offset       /// Start of the range, in bytes
2003    u32                                         size        /// Length of the range, in bytes
2004}
2005
2006class VkPipelineLayoutCreateInfo {
2007    VkStructureType                             sType                   /// Must be VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
2008    const void*                                 pNext                   /// Pointer to next structure
2009    VkPipelineLayoutCreateFlags                 flags
2010    u32                                         descriptorSetCount      /// Number of descriptor sets interfaced by the pipeline
2011    const VkDescriptorSetLayout*                pSetLayouts             /// Array of <setCount> number of descriptor set layout objects defining the layout of the
2012    u32                                         pushConstantRangeCount  /// Number of push-constant ranges used by the pipeline
2013    const VkPushConstantRange*                  pPushConstantRanges     /// Array of pushConstantRangeCount number of ranges used by various shader stages
2014}
2015
2016class VkSamplerCreateInfo {
2017    VkStructureType                             sType          /// Must be VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
2018    const void*                                 pNext          /// Pointer to next structure
2019    VkSamplerCreateFlags                        flags
2020    VkFilter                                    magFilter      /// Filter mode for magnification
2021    VkFilter                                    minFilter      /// Filter mode for minifiation
2022    VkSamplerMipmapMode                         mipmapMode     /// Mipmap selection mode
2023    VkSamplerAddressMode                        addressModeU
2024    VkSamplerAddressMode                        addressModeV
2025    VkSamplerAddressMode                        addressModeW
2026    f32                                         mipLodBias
2027    VkBool32                                    anisotropyEnable
2028    f32                                         maxAnisotropy
2029    VkBool32                                    compareEnable
2030    VkCompareOp                                 compareOp
2031    f32                                         minLod
2032    f32                                         maxLod
2033    VkBorderColor                               borderColor
2034    VkBool32                                    unnormalizedCoordinates
2035}
2036
2037class VkCommandPoolCreateInfo {
2038    VkStructureType                             sType            /// Must be VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO
2039    const void*                                 pNext            /// Pointer to next structure
2040    VkCommandPoolCreateFlags                    flags            /// Command pool creation flags
2041    u32                                         queueFamilyIndex
2042}
2043
2044class VkCommandBufferAllocateInfo {
2045    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
2046    const void*                                 pNext      /// Pointer to next structure
2047    VkCommandPool                               commandPool
2048    VkCommandBufferLevel                        level
2049    u32                                         commandBufferCount
2050}
2051
2052class VkCommandBufferInheritanceInfo {
2053    VkStructureType                             sType       /// Must be VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO
2054    const void*                                 pNext       /// Pointer to next structure
2055    VkRenderPass                                renderPass  /// Render pass for secondary command buffers
2056    u32                                         subpass
2057    VkFramebuffer                               framebuffer /// Framebuffer for secondary command buffers
2058    VkBool32                                    occlusionQueryEnable
2059    VkQueryControlFlags                         queryFlags
2060    VkQueryPipelineStatisticFlags               pipelineStatistics
2061}
2062
2063class VkCommandBufferBeginInfo {
2064    VkStructureType                             sType       /// Must be VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
2065    const void*                                 pNext       /// Pointer to next structure
2066    VkCommandBufferUsageFlags                   flags       /// Command buffer usage flags
2067    const VkCommandBufferInheritanceInfo*       pInheritanceInfo
2068}
2069
2070class VkRenderPassBeginInfo {
2071    VkStructureType                             sType       /// Must be VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
2072    const void*                                 pNext       /// Pointer to next structure
2073    VkRenderPass                                renderPass
2074    VkFramebuffer                               framebuffer
2075    VkRect2D                                    renderArea
2076    u32                                         clearValueCount
2077    const VkClearValue*                         pClearValues
2078}
2079
2080@union
2081/// Union allowing specification of floating point, integer, or unsigned integer color data. Actual value selected is based on image/attachment being cleared.
2082class VkClearColorValue {
2083    f32[4]                                      float32
2084    s32[4]                                      int32
2085    u32[4]                                      uint32
2086}
2087
2088class VkClearDepthStencilValue {
2089    f32                                         depth
2090    u32                                         stencil
2091}
2092
2093@union
2094/// Union allowing specification of color, depth, and stencil color values. Actual value selected is based on attachment being cleared.
2095class VkClearValue {
2096    VkClearColorValue                           color
2097    VkClearDepthStencilValue                    depthStencil
2098}
2099
2100class VkClearAttachment {
2101    VkImageAspectFlags                          aspectMask
2102    u32                                         colorAttachment
2103    VkClearValue                                clearValue
2104}
2105
2106class VkAttachmentDescription {
2107    VkAttachmentDescriptionFlags                flags
2108    VkFormat                                    format
2109    VkSampleCountFlagBits                       samples
2110    VkAttachmentLoadOp                          loadOp          /// Load op for color or depth data
2111    VkAttachmentStoreOp                         storeOp         /// Store op for color or depth data
2112    VkAttachmentLoadOp                          stencilLoadOp   /// Load op for stencil data
2113    VkAttachmentStoreOp                         stencilStoreOp  /// Store op for stencil data
2114    VkImageLayout                               initialLayout
2115    VkImageLayout                               finalLayout
2116}
2117
2118class VkAttachmentReference {
2119    u32                                         attachment
2120    VkImageLayout                               layout
2121}
2122
2123class VkSubpassDescription {
2124    VkSubpassDescriptionFlags                   flags
2125    VkPipelineBindPoint                         pipelineBindPoint  /// Must be VK_PIPELINE_BIND_POINT_GRAPHICS for now
2126    u32                                         inputAttachmentCount
2127    const VkAttachmentReference*                pInputAttachments
2128    u32                                         colorAttachmentCount
2129    const VkAttachmentReference*                pColorAttachments
2130    const VkAttachmentReference*                pResolveAttachments
2131    const VkAttachmentReference*                pDepthStencilAttachment
2132    u32                                         preserveAttachmentCount
2133    const u32*                                  pPreserveAttachments
2134}
2135
2136class VkSubpassDependency {
2137    u32                                         srcSubpass
2138    u32                                         dstSubpass
2139    VkPipelineStageFlags                        srcStageMask
2140    VkPipelineStageFlags                        dstStageMask
2141    VkAccessFlags                               srcAccessMask
2142    VkAccessFlags                               dstAccessMask
2143    VkDependencyFlags                           dependencyFlags
2144}
2145
2146class VkRenderPassCreateInfo {
2147    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
2148    const void*                                 pNext      /// Pointer to next structure
2149    VkRenderPassCreateFlags                     flags
2150    u32                                         attachmentCount
2151    const VkAttachmentDescription*              pAttachments
2152    u32                                         subpassCount
2153    const VkSubpassDescription*                 pSubpasses
2154    u32                                         dependencyCount
2155    const VkSubpassDependency*                  pDependencies
2156}
2157
2158class VkEventCreateInfo {
2159    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_EVENT_CREATE_INFO
2160    const void*                                 pNext      /// Pointer to next structure
2161    VkEventCreateFlags                          flags      /// Event creation flags
2162}
2163
2164class VkFenceCreateInfo {
2165    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
2166    const void*                                 pNext      /// Pointer to next structure
2167    VkFenceCreateFlags                          flags      /// Fence creation flags
2168}
2169
2170class VkPhysicalDeviceFeatures {
2171    VkBool32                                    robustBufferAccess                        /// out of bounds buffer accesses are well defined
2172    VkBool32                                    fullDrawIndexUint32                       /// full 32-bit range of indices for indexed draw calls
2173    VkBool32                                    imageCubeArray                            /// image views which are arrays of cube maps
2174    VkBool32                                    independentBlend                          /// blending operations are controlled per-attachment
2175    VkBool32                                    geometryShader                            /// geometry stage
2176    VkBool32                                    tessellationShader                        /// tessellation control and evaluation stage
2177    VkBool32                                    sampleRateShading                         /// per-sample shading and interpolation
2178    VkBool32                                    dualSrcBlend                              /// blend operations which take two sources
2179    VkBool32                                    logicOp                                   /// logic operations
2180    VkBool32                                    multiDrawIndirect                         /// multi draw indirect
2181    VkBool32                                    drawIndirectFirstInstance
2182    VkBool32                                    depthClamp                                /// depth clamping
2183    VkBool32                                    depthBiasClamp                            /// depth bias clamping
2184    VkBool32                                    fillModeNonSolid                          /// point and wireframe fill modes
2185    VkBool32                                    depthBounds                               /// depth bounds test
2186    VkBool32                                    wideLines                                 /// lines with width greater than 1
2187    VkBool32                                    largePoints                               /// points with size greater than 1
2188    VkBool32                                    alphaToOne                                /// The fragment alpha channel can be forced to maximum representable alpha value
2189    VkBool32                                    multiViewport
2190    VkBool32                                    samplerAnisotropy
2191    VkBool32                                    textureCompressionETC2                    /// ETC texture compression formats
2192    VkBool32                                    textureCompressionASTC_LDR                /// ASTC LDR texture compression formats
2193    VkBool32                                    textureCompressionBC                      /// BC1-7 texture compressed formats
2194    VkBool32                                    occlusionQueryPrecise
2195    VkBool32                                    pipelineStatisticsQuery                   /// pipeline statistics query
2196    VkBool32                                    vertexPipelineStoresAndAtomics
2197    VkBool32                                    fragmentStoresAndAtomics
2198    VkBool32                                    shaderTessellationAndGeometryPointSize
2199    VkBool32                                    shaderImageGatherExtended                 /// texture gather with run-time values and independent offsets
2200    VkBool32                                    shaderStorageImageExtendedFormats         /// the extended set of formats can be used for storage images
2201    VkBool32                                    shaderStorageImageMultisample             /// multisample images can be used for storage images
2202    VkBool32                                    shaderStorageImageReadWithoutFormat
2203    VkBool32                                    shaderStorageImageWriteWithoutFormat
2204    VkBool32                                    shaderUniformBufferArrayDynamicIndexing   /// arrays of uniform buffers can be accessed with dynamically uniform indices
2205    VkBool32                                    shaderSampledImageArrayDynamicIndexing    /// arrays of sampled images can be accessed with dynamically uniform indices
2206    VkBool32                                    shaderStorageBufferArrayDynamicIndexing   /// arrays of storage buffers can be accessed with dynamically uniform indices
2207    VkBool32                                    shaderStorageImageArrayDynamicIndexing    /// arrays of storage images can be accessed with dynamically uniform indices
2208    VkBool32                                    shaderClipDistance                        /// clip distance in shaders
2209    VkBool32                                    shaderCullDistance                        /// cull distance in shaders
2210    VkBool32                                    shaderFloat64                             /// 64-bit floats (doubles) in shaders
2211    VkBool32                                    shaderInt64                               /// 64-bit integers in shaders
2212    VkBool32                                    shaderInt16                               /// 16-bit integers in shaders
2213    VkBool32                                    shaderResourceResidency                   /// shader can use texture operations that return resource residency information (requires sparseNonResident support)
2214    VkBool32                                    shaderResourceMinLod                      /// shader can use texture operations that specify minimum resource LOD
2215    VkBool32                                    sparseBinding                             /// Sparse resources support: Resource memory can be managed at opaque page level rather than object level
2216    VkBool32                                    sparseResidencyBuffer                     /// Sparse resources support: GPU can access partially resident buffers
2217    VkBool32                                    sparseResidencyImage2D                    /// Sparse resources support: GPU can access partially resident 2D (non-MSAA non-DepthStencil) images
2218    VkBool32                                    sparseResidencyImage3D                    /// Sparse resources support: GPU can access partially resident 3D images
2219    VkBool32                                    sparseResidency2Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 2 samples
2220    VkBool32                                    sparseResidency4Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 4 samples
2221    VkBool32                                    sparseResidency8Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 8 samples
2222    VkBool32                                    sparseResidency16Samples                  /// Sparse resources support: GPU can access partially resident MSAA 2D images with 16 samples
2223    VkBool32                                    sparseResidencyAliased                    /// Sparse resources support: GPU can correctly access data aliased into multiple locations (opt-in)
2224    VkBool32                                    variableMultisampleRate
2225    VkBool32                                    inheritedQueries
2226}
2227
2228class VkPhysicalDeviceLimits {
2229    /// resource maximum sizes
2230    u32                                         maxImageDimension1D                       /// max 1D image dimension
2231    u32                                         maxImageDimension2D                       /// max 2D image dimension
2232    u32                                         maxImageDimension3D                       /// max 3D image dimension
2233    u32                                         maxImageDimensionCube                     /// max cubemap image dimension
2234    u32                                         maxImageArrayLayers                       /// max layers for image arrays
2235    u32                                         maxTexelBufferElements
2236    u32                                         maxUniformBufferRange                     /// max uniform buffer size (bytes)
2237    u32                                         maxStorageBufferRange                     /// max storage buffer size (bytes)
2238    u32                                         maxPushConstantsSize                      /// max size of the push constants pool (bytes)
2239    /// memory limits
2240    u32                                         maxMemoryAllocationCount                  /// max number of device memory allocations supported
2241    u32                                         maxSamplerAllocationCount
2242    VkDeviceSize                                bufferImageGranularity                    /// Granularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage
2243    VkDeviceSize                                sparseAddressSpaceSize                    /// Total address space available for sparse allocations (bytes)
2244    /// descriptor set limits
2245    u32                                         maxBoundDescriptorSets                    /// max number of descriptors sets that can be bound to a pipeline
2246    u32                                         maxPerStageDescriptorSamplers             /// max num of samplers allowed per-stage in a descriptor set
2247    u32                                         maxPerStageDescriptorUniformBuffers       /// max num of uniform buffers allowed per-stage in a descriptor set
2248    u32                                         maxPerStageDescriptorStorageBuffers       /// max num of storage buffers allowed per-stage in a descriptor set
2249    u32                                         maxPerStageDescriptorSampledImages        /// max num of sampled images allowed per-stage in a descriptor set
2250    u32                                         maxPerStageDescriptorStorageImages        /// max num of storage images allowed per-stage in a descriptor set
2251    u32                                         maxPerStageDescriptorInputAttachments
2252    u32                                         maxPerStageResources
2253    u32                                         maxDescriptorSetSamplers                  /// max num of samplers allowed in all stages in a descriptor set
2254    u32                                         maxDescriptorSetUniformBuffers            /// max num of uniform buffers allowed in all stages in a descriptor set
2255    u32                                         maxDescriptorSetUniformBuffersDynamic     /// max num of dynamic uniform buffers allowed in all stages in a descriptor set
2256    u32                                         maxDescriptorSetStorageBuffers            /// max num of storage buffers allowed in all stages in a descriptor set
2257    u32                                         maxDescriptorSetStorageBuffersDynamic     /// max num of dynamic storage buffers allowed in all stages in a descriptor set
2258    u32                                         maxDescriptorSetSampledImages             /// max num of sampled images allowed in all stages in a descriptor set
2259    u32                                         maxDescriptorSetStorageImages             /// max num of storage images allowed in all stages in a descriptor set
2260    u32                                         maxDescriptorSetInputAttachments
2261    /// vertex stage limits
2262    u32                                         maxVertexInputAttributes                  /// max num of vertex input attribute slots
2263    u32                                         maxVertexInputBindings                    /// max num of vertex input binding slots
2264    u32                                         maxVertexInputAttributeOffset             /// max vertex input attribute offset added to vertex buffer offset
2265    u32                                         maxVertexInputBindingStride               /// max vertex input binding stride
2266    u32                                         maxVertexOutputComponents                 /// max num of output components written by vertex shader
2267    /// tessellation control stage limits
2268    u32                                         maxTessellationGenerationLevel                  /// max level supported by tess primitive generator
2269    u32                                         maxTessellationPatchSize                        /// max patch size (vertices)
2270    u32                                         maxTessellationControlPerVertexInputComponents  /// max num of input components per-vertex in TCS
2271    u32                                         maxTessellationControlPerVertexOutputComponents /// max num of output components per-vertex in TCS
2272    u32                                         maxTessellationControlPerPatchOutputComponents  /// max num of output components per-patch in TCS
2273    u32                                         maxTessellationControlTotalOutputComponents     /// max total num of per-vertex and per-patch output components in TCS
2274    u32                                         maxTessellationEvaluationInputComponents        /// max num of input components per vertex in TES
2275    u32                                         maxTessellationEvaluationOutputComponents       /// max num of output components per vertex in TES
2276    /// geometry stage limits
2277    u32                                         maxGeometryShaderInvocations              /// max invocation count supported in geometry shader
2278    u32                                         maxGeometryInputComponents                /// max num of input components read in geometry stage
2279    u32                                         maxGeometryOutputComponents               /// max num of output components written in geometry stage
2280    u32                                         maxGeometryOutputVertices                 /// max num of vertices that can be emitted in geometry stage
2281    u32                                         maxGeometryTotalOutputComponents          /// max total num of components (all vertices) written in geometry stage
2282    /// fragment stage limits
2283    u32                                         maxFragmentInputComponents                /// max num of input compontents read in fragment stage
2284    u32                                         maxFragmentOutputAttachments              /// max num of output attachments written in fragment stage
2285    u32                                         maxFragmentDualSrcAttachments             /// max num of output attachments written when using dual source blending
2286    u32                                         maxFragmentCombinedOutputResources        /// max total num of storage buffers, storage images and output buffers
2287    /// compute stage limits
2288    u32                                         maxComputeSharedMemorySize                /// max total storage size of work group local storage (bytes)
2289    u32[3]                                      maxComputeWorkGroupCount                  /// max num of compute work groups that may be dispatched by a single command (x,y,z)
2290    u32                                         maxComputeWorkGroupInvocations            /// max total compute invocations in a single local work group
2291    u32[3]                                      maxComputeWorkGroupSize                   /// max local size of a compute work group (x,y,z)
2292
2293    u32                                         subPixelPrecisionBits                     /// num bits of subpixel precision in screen x and y
2294    u32                                         subTexelPrecisionBits                     /// num bits of subtexel precision
2295    u32                                         mipmapPrecisionBits                       /// num bits of mipmap precision
2296
2297    u32                                         maxDrawIndexedIndexValue                  /// max index value for indexed draw calls (for 32-bit indices)
2298    u32                                         maxDrawIndirectCount
2299
2300    f32                                         maxSamplerLodBias                         /// max absolute sampler level of detail bias
2301    f32                                         maxSamplerAnisotropy                      /// max degree of sampler anisotropy
2302
2303    u32                                         maxViewports                              /// max number of active viewports
2304    u32[2]                                      maxViewportDimensions                     /// max viewport dimensions (x,y)
2305    f32[2]                                      viewportBoundsRange                       /// viewport bounds range (min,max)
2306    u32                                         viewportSubPixelBits                      /// num bits of subpixel precision for viewport
2307
2308    platform.size_t                             minMemoryMapAlignment                     /// min required alignment of pointers returned by MapMemory (bytes)
2309    VkDeviceSize                                minTexelBufferOffsetAlignment             /// min required alignment for texel buffer offsets (bytes)
2310    VkDeviceSize                                minUniformBufferOffsetAlignment           /// min required alignment for uniform buffer sizes and offsets (bytes)
2311    VkDeviceSize                                minStorageBufferOffsetAlignment           /// min required alignment for storage buffer offsets (bytes)
2312
2313    s32                                         minTexelOffset                            /// min texel offset for OpTextureSampleOffset
2314    u32                                         maxTexelOffset                            /// max texel offset for OpTextureSampleOffset
2315    s32                                         minTexelGatherOffset                      /// min texel offset for OpTextureGatherOffset
2316    u32                                         maxTexelGatherOffset                      /// max texel offset for OpTextureGatherOffset
2317    f32                                         minInterpolationOffset                    /// furthest negative offset for interpolateAtOffset
2318    f32                                         maxInterpolationOffset                    /// furthest positive offset for interpolateAtOffset
2319    u32                                         subPixelInterpolationOffsetBits           /// num of subpixel bits for interpolateAtOffset
2320
2321    u32                                         maxFramebufferWidth                       /// max width for a framebuffer
2322    u32                                         maxFramebufferHeight                      /// max height for a framebuffer
2323    u32                                         maxFramebufferLayers                      /// max layer count for a layered framebuffer
2324    VkSampleCountFlags                          framebufferColorSampleCounts
2325    VkSampleCountFlags                          framebufferDepthSampleCounts
2326    VkSampleCountFlags                          framebufferStencilSampleCounts
2327    VkSampleCountFlags                          framebufferNoAttachmentSampleCounts
2328    u32                                         maxColorAttachments                       /// max num of framebuffer color attachments
2329
2330    VkSampleCountFlags                          sampledImageColorSampleCounts
2331    VkSampleCountFlags                          sampledImageIntegerSampleCounts
2332    VkSampleCountFlags                          sampledImageDepthSampleCounts
2333    VkSampleCountFlags                          sampledImageStencilSampleCounts
2334    VkSampleCountFlags                          storageImageSampleCounts
2335    u32                                         maxSampleMaskWords                        /// max num of sample mask words
2336    VkBool32                                    timestampComputeAndGraphics
2337
2338    f32                                         timestampPeriod
2339
2340    u32                                         maxClipDistances                          /// max number of clip distances
2341    u32                                         maxCullDistances                          /// max number of cull distances
2342    u32                                         maxCombinedClipAndCullDistances           /// max combined number of user clipping
2343
2344    u32                                         discreteQueuePriorities
2345
2346    f32[2]                                      pointSizeRange                            /// range (min,max) of supported point sizes
2347    f32[2]                                      lineWidthRange                            /// range (min,max) of supported line widths
2348    f32                                         pointSizeGranularity                      /// granularity of supported point sizes
2349    f32                                         lineWidthGranularity                      /// granularity of supported line widths
2350    VkBool32                                    strictLines
2351    VkBool32                                    standardSampleLocations
2352
2353    VkDeviceSize                                optimalBufferCopyOffsetAlignment
2354    VkDeviceSize                                optimalBufferCopyRowPitchAlignment
2355    VkDeviceSize                                nonCoherentAtomSize
2356}
2357
2358class VkPhysicalDeviceSparseProperties {
2359    VkBool32                                    residencyStandard2DBlockShape             /// Sparse resources support: GPU will access all 2D (single sample) sparse resources using the standard block shapes (based on pixel format)
2360    VkBool32                                    residencyStandard2DMultisampleBlockShape  /// Sparse resources support: GPU will access all 2D (multisample) sparse resources using the standard block shapes (based on pixel format)
2361    VkBool32                                    residencyStandard3DBlockShape             /// Sparse resources support: GPU will access all 3D sparse resources using the standard block shapes (based on pixel format)
2362    VkBool32                                    residencyAlignedMipSize                   /// Sparse resources support: Images with mip-level dimensions that are NOT a multiple of the block size will be placed in the mip tail
2363    VkBool32                                    residencyNonResidentStrict                /// Sparse resources support: GPU can safely access non-resident regions of a resource, all reads return as if data is 0, writes are discarded
2364}
2365
2366class VkSemaphoreCreateInfo {
2367    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
2368    const void*                                 pNext      /// Pointer to next structure
2369    VkSemaphoreCreateFlags                      flags      /// Semaphore creation flags
2370}
2371
2372class VkQueryPoolCreateInfo {
2373    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
2374    const void*                                 pNext              /// Pointer to next structure
2375    VkQueryPoolCreateFlags                      flags
2376    VkQueryType                                 queryType
2377    u32                                         queryCount
2378    VkQueryPipelineStatisticFlags               pipelineStatistics /// Optional
2379}
2380
2381class VkFramebufferCreateInfo {
2382    VkStructureType                             sType  /// Must be VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
2383    const void*                                 pNext  /// Pointer to next structure
2384    VkFramebufferCreateFlags                    flags
2385    VkRenderPass                                renderPass
2386    u32                                         attachmentCount
2387    const VkImageView*                          pAttachments
2388    u32                                         width
2389    u32                                         height
2390    u32                                         layers
2391}
2392
2393class VkDrawIndirectCommand {
2394    u32                                         vertexCount
2395    u32                                         instanceCount
2396    u32                                         firstVertex
2397    u32                                         firstInstance
2398}
2399
2400class VkDrawIndexedIndirectCommand {
2401    u32                                         indexCount
2402    u32                                         instanceCount
2403    u32                                         firstIndex
2404    s32                                         vertexOffset
2405    u32                                         firstInstance
2406}
2407
2408class VkDispatchIndirectCommand {
2409    u32                                         x
2410    u32                                         y
2411    u32                                         z
2412}
2413
2414@extension("VK_KHR_surface")
2415class VkSurfaceCapabilitiesKHR {
2416    u32                                         minImageCount
2417    u32                                         maxImageCount
2418    VkExtent2D                                  currentExtent
2419    VkExtent2D                                  minImageExtent
2420    VkExtent2D                                  maxImageExtent
2421    u32                                         maxImageArrayLayers
2422    VkSurfaceTransformFlagsKHR                  supportedTransforms
2423    VkSurfaceTransformFlagBitsKHR               currentTransform
2424    VkCompositeAlphaFlagsKHR                    supportedCompositeAlpha
2425    VkImageUsageFlags                           supportedUsageFlags
2426}
2427
2428@extension("VK_KHR_surface")
2429class VkSurfaceFormatKHR {
2430    VkFormat                                    format
2431    VkColorSpaceKHR                             colorSpace
2432}
2433
2434@extension("VK_KHR_swapchain")
2435class VkSwapchainCreateInfoKHR {
2436    VkStructureType                             sType
2437    const void*                                 pNext
2438    VkSwapchainCreateFlagsKHR                   flags
2439    VkSurfaceKHR                                surface
2440    u32                                         minImageCount
2441    VkFormat                                    imageFormat
2442    VkColorSpaceKHR                             imageColorSpace
2443    VkExtent2D                                  imageExtent
2444    u32                                         imageArrayLayers
2445    VkImageUsageFlags                           imageUsage
2446    VkSharingMode                               sharingMode
2447    u32                                         queueFamilyIndexCount
2448    const u32*                                  pQueueFamilyIndices
2449    VkSurfaceTransformFlagBitsKHR               preTransform
2450    VkCompositeAlphaFlagBitsKHR                 compositeAlpha
2451    VkPresentModeKHR                            presentMode
2452    VkBool32                                    clipped
2453    VkSwapchainKHR                              oldSwapchain
2454}
2455
2456@extension("VK_KHR_swapchain")
2457class VkPresentInfoKHR {
2458    VkStructureType                             sType
2459    const void*                                 pNext
2460    u32                                         waitSemaphoreCount
2461    const VkSemaphore*                          pWaitSemaphores
2462    u32                                         swapchainCount
2463    const VkSwapchainKHR*                       pSwapchains
2464    const u32*                                  pImageIndices
2465    VkResult*                                   pResults
2466}
2467
2468@extension("VK_KHR_display")
2469class VkDisplayPropertiesKHR {
2470    VkDisplayKHR                                display
2471    const char*                                 displayName
2472    VkExtent2D                                  physicalDimensions
2473    VkExtent2D                                  physicalResolution
2474    VkSurfaceTransformFlagsKHR                  supportedTransforms
2475    VkBool32                                    planeReorderPossible
2476    VkBool32                                    persistentContent
2477}
2478
2479@extension("VK_KHR_display")
2480class VkDisplayModeParametersKHR {
2481    VkExtent2D                                  visibleRegion
2482    u32                                         refreshRate
2483}
2484
2485@extension("VK_KHR_display")
2486class VkDisplayModePropertiesKHR {
2487    VkDisplayModeKHR                            displayMode
2488    VkDisplayModeParametersKHR                  parameters
2489}
2490
2491@extension("VK_KHR_display")
2492class VkDisplayModeCreateInfoKHR {
2493    VkStructureType                             sType
2494    const void*                                 pNext
2495    VkDisplayModeCreateFlagsKHR                 flags
2496    VkDisplayModeParametersKHR                  parameters
2497}
2498
2499@extension("VK_KHR_display")
2500class VkDisplayPlanePropertiesKHR {
2501    VkDisplayKHR                                currentDisplay
2502    u32                                         currentStackIndex
2503}
2504
2505@extension("VK_KHR_display")
2506class VkDisplayPlaneCapabilitiesKHR {
2507    VkDisplayPlaneAlphaFlagsKHR                 supportedAlpha
2508    VkOffset2D                                  minSrcPosition
2509    VkOffset2D                                  maxSrcPosition
2510    VkExtent2D                                  minSrcExtent
2511    VkExtent2D                                  maxSrcExtent
2512    VkOffset2D                                  minDstPosition
2513    VkOffset2D                                  maxDstPosition
2514    VkExtent2D                                  minDstExtent
2515    VkExtent2D                                  maxDstExtent
2516}
2517
2518@extension("VK_KHR_display")
2519class VkDisplaySurfaceCreateInfoKHR {
2520    VkStructureType                             sType
2521    const void*                                 pNext
2522    VkDisplaySurfaceCreateFlagsKHR              flags
2523    VkDisplayModeKHR                            displayMode
2524    u32                                         planeIndex
2525    u32                                         planeStackIndex
2526    VkSurfaceTransformFlagBitsKHR               transform
2527    f32                                         globalAlpha
2528    VkDisplayPlaneAlphaFlagBitsKHR              alphaMode
2529    VkExtent2D                                  imageExtent
2530}
2531
2532@extension("VK_KHR_display_swapchain")
2533class VkDisplayPresentInfoKHR {
2534    VkStructureType                             sType
2535    const void*                                 pNext
2536    VkRect2D                                    srcRect
2537    VkRect2D                                    dstRect
2538    VkBool32                                    persistent
2539}
2540
2541@extension("VK_KHR_xlib_surface")
2542class VkXlibSurfaceCreateInfoKHR {
2543    VkStructureType                             sType
2544    const void*                                 pNext
2545    VkXlibSurfaceCreateFlagsKHR                 flags
2546    platform.Display*                           dpy
2547    platform.Window                             window
2548}
2549
2550@extension("VK_KHR_xcb_surface")
2551class VkXcbSurfaceCreateInfoKHR {
2552    VkStructureType                             sType
2553    const void*                                 pNext
2554    VkXcbSurfaceCreateFlagsKHR                  flags
2555    platform.xcb_connection_t*                  connection
2556    platform.xcb_window_t                       window
2557}
2558
2559@extension("VK_KHR_wayland_surface")
2560class VkWaylandSurfaceCreateInfoKHR {
2561    VkStructureType                             sType
2562    const void*                                 pNext
2563    VkWaylandSurfaceCreateFlagsKHR              flags
2564    platform.wl_display*                        display
2565    platform.wl_surface*                        surface
2566}
2567
2568@extension("VK_KHR_mir_surface")
2569class VkMirSurfaceCreateInfoKHR {
2570    VkStructureType                             sType
2571    const void*                                 pNext
2572    VkMirSurfaceCreateFlagsKHR                  flags
2573    platform.MirConnection*                     connection
2574    platform.MirSurface*                        mirSurface
2575}
2576
2577@extension("VK_KHR_android_surface")
2578class VkAndroidSurfaceCreateInfoKHR {
2579    VkStructureType                             sType
2580    const void*                                 pNext
2581    VkAndroidSurfaceCreateFlagsKHR              flags
2582    platform.ANativeWindow*                     window
2583}
2584
2585@extension("VK_KHR_win32_surface")
2586class VkWin32SurfaceCreateInfoKHR {
2587    VkStructureType                             sType
2588    const void*                                 pNext
2589    VkWin32SurfaceCreateFlagsKHR                flags
2590    platform.HINSTANCE                          hinstance
2591    platform.HWND                               hwnd
2592}
2593
2594@extension("VK_EXT_debug_report")
2595class VkDebugReportCallbackCreateInfoEXT {
2596    VkStructureType                             sType
2597    const void*                                 pNext
2598    VkDebugReportFlagsEXT                       flags
2599    PFN_vkDebugReportCallbackEXT                pfnCallback
2600    void*                                       pUserData
2601}
2602
2603
2604////////////////
2605//  Commands  //
2606////////////////
2607
2608// Function pointers. TODO: add support for function pointers.
2609
2610@external type void* PFN_vkVoidFunction
2611@pfn cmd void vkVoidFunction() {
2612}
2613
2614@external type void* PFN_vkAllocationFunction
2615@pfn cmd void* vkAllocationFunction(
2616        void*                                       pUserData,
2617        platform.size_t                             size,
2618        platform.size_t                             alignment,
2619        VkSystemAllocationScope                     allocationScope) {
2620    return ?
2621}
2622
2623@external type void* PFN_vkReallocationFunction
2624@pfn cmd void* vkReallocationFunction(
2625        void*                                       pUserData,
2626        void*                                       pOriginal,
2627        platform.size_t                             size,
2628        platform.size_t                             alignment,
2629        VkSystemAllocationScope                     allocationScope) {
2630    return ?
2631}
2632
2633@external type void* PFN_vkFreeFunction
2634@pfn cmd void vkFreeFunction(
2635        void*                                       pUserData,
2636        void*                                       pMemory) {
2637}
2638
2639@external type void* PFN_vkInternalAllocationNotification
2640@pfn cmd void vkInternalAllocationNotification(
2641        void*                                       pUserData,
2642        platform.size_t                             size,
2643        VkInternalAllocationType                    allocationType,
2644        VkSystemAllocationScope                     allocationScope) {
2645}
2646
2647@external type void* PFN_vkInternalFreeNotification
2648@pfn cmd void vkInternalFreeNotification(
2649        void*                                       pUserData,
2650        platform.size_t                             size,
2651        VkInternalAllocationType                    allocationType,
2652        VkSystemAllocationScope                     allocationScope) {
2653}
2654
2655// Global functions
2656
2657@threadSafety("system")
2658cmd VkResult vkCreateInstance(
2659        const VkInstanceCreateInfo*                 pCreateInfo,
2660        const VkAllocationCallbacks*                pAllocator,
2661        VkInstance*                                 pInstance) {
2662    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
2663
2664    instance := ?
2665    pInstance[0] = instance
2666    State.Instances[instance] = new!InstanceObject()
2667
2668    layers := pCreateInfo.ppEnabledLayerNames[0:pCreateInfo.enabledLayerCount]
2669    extensions := pCreateInfo.ppEnabledExtensionNames[0:pCreateInfo.enabledExtensionCount]
2670
2671    return ?
2672}
2673
2674@threadSafety("system")
2675cmd void vkDestroyInstance(
2676        VkInstance                                  instance,
2677        const VkAllocationCallbacks*                pAllocator) {
2678    instanceObject := GetInstance(instance)
2679
2680    State.Instances[instance] = null
2681}
2682
2683@threadSafety("system")
2684cmd VkResult vkEnumeratePhysicalDevices(
2685        VkInstance                                  instance,
2686        u32*                                        pPhysicalDeviceCount,
2687        VkPhysicalDevice*                           pPhysicalDevices) {
2688    instanceObject := GetInstance(instance)
2689
2690    physicalDeviceCount := as!u32(?)
2691    pPhysicalDeviceCount[0] = physicalDeviceCount
2692    physicalDevices := pPhysicalDevices[0:physicalDeviceCount]
2693
2694    for i in (0 .. physicalDeviceCount) {
2695        physicalDevice := ?
2696        physicalDevices[i] = physicalDevice
2697        if !(physicalDevice in State.PhysicalDevices) {
2698            State.PhysicalDevices[physicalDevice] = new!PhysicalDeviceObject(instance: instance)
2699        }
2700    }
2701
2702    return ?
2703}
2704
2705cmd PFN_vkVoidFunction vkGetDeviceProcAddr(
2706        VkDevice                                    device,
2707        const char*                                 pName) {
2708    if device != NULL_HANDLE {
2709        device := GetDevice(device)
2710    }
2711
2712    return ?
2713}
2714
2715cmd PFN_vkVoidFunction vkGetInstanceProcAddr(
2716        VkInstance                                  instance,
2717        const char*                                 pName) {
2718    if instance != NULL_HANDLE {
2719        instanceObject := GetInstance(instance)
2720    }
2721
2722    return ?
2723}
2724
2725cmd void vkGetPhysicalDeviceProperties(
2726        VkPhysicalDevice                            physicalDevice,
2727        VkPhysicalDeviceProperties*                 pProperties) {
2728    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2729
2730    properties := ?
2731    pProperties[0] = properties
2732}
2733
2734cmd void vkGetPhysicalDeviceQueueFamilyProperties(
2735        VkPhysicalDevice                            physicalDevice,
2736        u32*                                        pQueueFamilyPropertyCount,
2737        VkQueueFamilyProperties*                    pQueueFamilyProperties) {
2738    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2739    // TODO: Figure out how to express fetch-count-or-properties
2740    // This version fails 'apic validate' with 'fence not allowed in
2741    // *semantic.Branch'. Other attempts have failed with the same or other
2742    // errors.
2743    // if pQueueFamilyProperties != null {
2744    //     queuesProperties := pQueueFamilyProperties[0:pCount[0]]
2745    //     for i in (0 .. pCount[0]) {
2746    //         queueProperties := as!VkQueueFamilyProperties(?)
2747    //         queuesProperties[i] = queueProperties
2748    //    }
2749    // } else {
2750    //     count := ?
2751    //     pCount[0] = count
2752    // }
2753}
2754
2755cmd void vkGetPhysicalDeviceMemoryProperties(
2756        VkPhysicalDevice                            physicalDevice,
2757        VkPhysicalDeviceMemoryProperties*           pMemoryProperties) {
2758    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2759
2760    memoryProperties := ?
2761    pMemoryProperties[0] = memoryProperties
2762}
2763
2764cmd void vkGetPhysicalDeviceFeatures(
2765        VkPhysicalDevice                            physicalDevice,
2766        VkPhysicalDeviceFeatures*                   pFeatures) {
2767    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2768
2769    features := ?
2770    pFeatures[0] = features
2771}
2772
2773cmd void vkGetPhysicalDeviceFormatProperties(
2774        VkPhysicalDevice                            physicalDevice,
2775        VkFormat                                    format,
2776        VkFormatProperties*                         pFormatProperties) {
2777    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2778
2779    formatProperties := ?
2780    pFormatProperties[0] = formatProperties
2781}
2782
2783cmd VkResult vkGetPhysicalDeviceImageFormatProperties(
2784        VkPhysicalDevice                            physicalDevice,
2785        VkFormat                                    format,
2786        VkImageType                                 type,
2787        VkImageTiling                               tiling,
2788        VkImageUsageFlags                           usage,
2789        VkImageCreateFlags                          flags,
2790        VkImageFormatProperties*                    pImageFormatProperties) {
2791    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2792
2793    imageFormatProperties := ?
2794    pImageFormatProperties[0] = imageFormatProperties
2795
2796    return ?
2797}
2798
2799
2800// Device functions
2801
2802@threadSafety("system")
2803cmd VkResult vkCreateDevice(
2804        VkPhysicalDevice                            physicalDevice,
2805        const VkDeviceCreateInfo*                   pCreateInfo,
2806        const VkAllocationCallbacks*                pAllocator,
2807        VkDevice*                                   pDevice) {
2808    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO)
2809    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2810
2811    device := ?
2812    pDevice[0] = device
2813    State.Devices[device] = new!DeviceObject(physicalDevice: physicalDevice)
2814
2815    return ?
2816}
2817
2818@threadSafety("system")
2819cmd void vkDestroyDevice(
2820        VkDevice                                    device,
2821        const VkAllocationCallbacks*                pAllocator) {
2822    deviceObject := GetDevice(device)
2823
2824    State.Devices[device] = null
2825}
2826
2827
2828// Extension discovery functions
2829
2830cmd VkResult vkEnumerateInstanceLayerProperties(
2831        u32*                                        pPropertyCount,
2832        VkLayerProperties*                          pProperties) {
2833    count := as!u32(?)
2834    pPropertyCount[0] = count
2835
2836    properties := pProperties[0:count]
2837    for i in (0 .. count) {
2838        property := ?
2839        properties[i] = property
2840    }
2841
2842    return ?
2843}
2844
2845cmd VkResult vkEnumerateInstanceExtensionProperties(
2846        const char*                                 pLayerName,
2847        u32*                                        pPropertyCount,
2848        VkExtensionProperties*                      pProperties) {
2849    count := as!u32(?)
2850    pPropertyCount[0] = count
2851
2852    properties := pProperties[0:count]
2853    for i in (0 .. count) {
2854        property := ?
2855        properties[i] = property
2856    }
2857
2858    return ?
2859}
2860
2861cmd VkResult vkEnumerateDeviceLayerProperties(
2862        VkPhysicalDevice                            physicalDevice,
2863        u32*                                        pPropertyCount,
2864        VkLayerProperties*                          pProperties) {
2865    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2866    count := as!u32(?)
2867    pPropertyCount[0] = count
2868
2869    properties := pProperties[0:count]
2870    for i in (0 .. count) {
2871        property := ?
2872        properties[i] = property
2873    }
2874
2875    return ?
2876}
2877
2878cmd VkResult vkEnumerateDeviceExtensionProperties(
2879        VkPhysicalDevice                            physicalDevice,
2880        const char*                                 pLayerName,
2881        u32*                                        pPropertyCount,
2882        VkExtensionProperties*                      pProperties) {
2883    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2884
2885    count := as!u32(?)
2886    pPropertyCount[0] = count
2887
2888    properties := pProperties[0:count]
2889    for i in (0 .. count) {
2890        property := ?
2891        properties[i] = property
2892    }
2893
2894    return ?
2895}
2896
2897
2898// Queue functions
2899
2900@threadSafety("system")
2901cmd void vkGetDeviceQueue(
2902        VkDevice                                    device,
2903        u32                                         queueFamilyIndex,
2904        u32                                         queueIndex,
2905        VkQueue*                                    pQueue) {
2906    deviceObject := GetDevice(device)
2907
2908    queue := ?
2909    pQueue[0] = queue
2910
2911    if !(queue in State.Queues) {
2912        State.Queues[queue] = new!QueueObject(device: device)
2913    }
2914}
2915
2916@threadSafety("app")
2917cmd VkResult vkQueueSubmit(
2918        VkQueue                                     queue,
2919        u32                                         submitCount,
2920        const VkSubmitInfo*                         pSubmits,
2921        VkFence                                     fence) {
2922    queueObject := GetQueue(queue)
2923
2924    if fence != NULL_HANDLE {
2925        fenceObject := GetFence(fence)
2926        assert(fenceObject.device == queueObject.device)
2927    }
2928
2929    // commandBuffers := pcommandBuffers[0:commandBufferCount]
2930    // for i in (0 .. commandBufferCount) {
2931    //    commandBuffer := commandBuffers[i]
2932    //    commandBufferObject := GetCommandBuffer(commandBuffer)
2933    //    assert(commandBufferObject.device == queueObject.device)
2934    //
2935    //    validate("QueueCheck", commandBufferObject.queueFlags in queueObject.flags,
2936    //        "vkQueueSubmit: enqueued commandBuffer requires missing queue capabilities.")
2937    // }
2938
2939    return ?
2940}
2941
2942@threadSafety("system")
2943cmd VkResult vkQueueWaitIdle(
2944        VkQueue                                     queue) {
2945    queueObject := GetQueue(queue)
2946
2947    return ?
2948}
2949
2950@threadSafety("system")
2951cmd VkResult vkDeviceWaitIdle(
2952        VkDevice                                    device) {
2953    deviceObject := GetDevice(device)
2954
2955    return ?
2956}
2957
2958
2959// Memory functions
2960
2961@threadSafety("system")
2962cmd VkResult vkAllocateMemory(
2963        VkDevice                                    device,
2964        const VkMemoryAllocateInfo*                 pAllocateInfo,
2965        const VkAllocationCallbacks*                pAllocator,
2966        VkDeviceMemory*                             pMemory) {
2967    assert(pAllocateInfo.sType == VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO)
2968    deviceObject := GetDevice(device)
2969
2970    memory := ?
2971    pMemory[0] = memory
2972    State.DeviceMemories[memory] = new!DeviceMemoryObject(
2973        device: device,
2974        allocationSize: pAllocateInfo[0].allocationSize)
2975
2976    return ?
2977}
2978
2979@threadSafety("system")
2980cmd void vkFreeMemory(
2981        VkDevice                                    device,
2982        VkDeviceMemory                              memory,
2983        const VkAllocationCallbacks*                pAllocator) {
2984    deviceObject := GetDevice(device)
2985    memoryObject := GetDeviceMemory(memory)
2986    assert(memoryObject.device == device)
2987
2988    // Check that no objects are still bound before freeing.
2989    validate("MemoryCheck", len(memoryObject.boundObjects) == 0,
2990        "vkFreeMemory: objects still bound")
2991    validate("MemoryCheck", len(memoryObject.boundCommandBuffers) == 0,
2992        "vkFreeMemory: commandBuffers still bound")
2993    State.DeviceMemories[memory] = null
2994}
2995
2996@threadSafety("app")
2997cmd VkResult vkMapMemory(
2998        VkDevice                                    device,
2999        VkDeviceMemory                              memory,
3000        VkDeviceSize                                offset,
3001        VkDeviceSize                                size,
3002        VkMemoryMapFlags                            flags,
3003        void**                                      ppData) {
3004    deviceObject := GetDevice(device)
3005    memoryObject := GetDeviceMemory(memory)
3006    assert(memoryObject.device == device)
3007
3008    assert(flags == as!VkMemoryMapFlags(0))
3009    assert((offset + size) <= memoryObject.allocationSize)
3010
3011    return ?
3012}
3013
3014@threadSafety("app")
3015cmd void vkUnmapMemory(
3016        VkDevice                                    device,
3017        VkDeviceMemory                              memory) {
3018    deviceObject := GetDevice(device)
3019    memoryObject := GetDeviceMemory(memory)
3020    assert(memoryObject.device == device)
3021}
3022
3023cmd VkResult vkFlushMappedMemoryRanges(
3024        VkDevice                                    device,
3025        u32                                         memoryRangeCount
3026        const VkMappedMemoryRange*                  pMemoryRanges) {
3027    deviceObject := GetDevice(device)
3028
3029    memoryRanges := pMemoryRanges[0:memoryRangeCount]
3030    for i in (0 .. memoryRangeCount) {
3031        memoryRange := memoryRanges[i]
3032        memoryObject := GetDeviceMemory(memoryRange.memory)
3033        assert(memoryObject.device == device)
3034        assert((memoryRange.offset + memoryRange.size) <= memoryObject.allocationSize)
3035    }
3036
3037    return ?
3038}
3039
3040cmd VkResult vkInvalidateMappedMemoryRanges(
3041        VkDevice                                    device,
3042        u32                                         memoryRangeCount,
3043        const VkMappedMemoryRange*                  pMemoryRanges) {
3044    deviceObject := GetDevice(device)
3045
3046    memoryRanges := pMemoryRanges[0:memoryRangeCount]
3047    for i in (0 .. memoryRangeCount) {
3048        memoryRange := memoryRanges[i]
3049        memoryObject := GetDeviceMemory(memoryRange.memory)
3050        assert(memoryObject.device == device)
3051        assert((memoryRange.offset + memoryRange.size) <= memoryObject.allocationSize)
3052    }
3053
3054    return ?
3055}
3056
3057
3058// Memory management API functions
3059
3060cmd void vkGetDeviceMemoryCommitment(
3061        VkDevice                                    device,
3062        VkDeviceMemory                              memory,
3063        VkDeviceSize*                               pCommittedMemoryInBytes) {
3064    deviceObject := GetDevice(device)
3065
3066    if memory != NULL_HANDLE {
3067        memoryObject := GetDeviceMemory(memory)
3068        assert(memoryObject.device == device)
3069    }
3070
3071    committedMemoryInBytes := ?
3072    pCommittedMemoryInBytes[0] = committedMemoryInBytes
3073}
3074
3075cmd void vkGetBufferMemoryRequirements(
3076        VkDevice                                    device,
3077        VkBuffer                                    buffer,
3078        VkMemoryRequirements*                       pMemoryRequirements) {
3079    deviceObject := GetDevice(device)
3080    bufferObject := GetBuffer(buffer)
3081    assert(bufferObject.device == device)
3082}
3083
3084cmd VkResult vkBindBufferMemory(
3085        VkDevice                                    device,
3086        VkBuffer                                    buffer,
3087        VkDeviceMemory                              memory,
3088        VkDeviceSize                                memoryOffset) {
3089    deviceObject := GetDevice(device)
3090    bufferObject := GetBuffer(buffer)
3091    assert(bufferObject.device == device)
3092
3093    // Unbind buffer from previous memory object, if not VK_NULL_HANDLE.
3094    if bufferObject.memory != NULL_HANDLE {
3095        memoryObject := GetDeviceMemory(bufferObject.memory)
3096        memoryObject.boundObjects[as!u64(buffer)] = null
3097    }
3098
3099    // Bind buffer to given memory object, if not VK_NULL_HANDLE.
3100    if memory != NULL_HANDLE {
3101        memoryObject := GetDeviceMemory(memory)
3102        assert(memoryObject.device == device)
3103        memoryObject.boundObjects[as!u64(buffer)] = memoryOffset
3104    }
3105    bufferObject.memory = memory
3106    bufferObject.memoryOffset = memoryOffset
3107
3108    return ?
3109}
3110
3111cmd void vkGetImageMemoryRequirements(
3112        VkDevice                                    device,
3113        VkImage                                     image,
3114        VkMemoryRequirements*                       pMemoryRequirements) {
3115    deviceObject := GetDevice(device)
3116    imageObject := GetImage(image)
3117    assert(imageObject.device == device)
3118}
3119
3120cmd VkResult vkBindImageMemory(
3121        VkDevice                                    device,
3122        VkImage                                     image,
3123        VkDeviceMemory                              memory,
3124        VkDeviceSize                                memoryOffset) {
3125    deviceObject := GetDevice(device)
3126    imageObject := GetImage(image)
3127    assert(imageObject.device == device)
3128
3129    // Unbind image from previous memory object, if not VK_NULL_HANDLE.
3130    if imageObject.memory != NULL_HANDLE {
3131        memoryObject := GetDeviceMemory(imageObject.memory)
3132        memoryObject.boundObjects[as!u64(image)] = null
3133    }
3134
3135    // Bind image to given memory object, if not VK_NULL_HANDLE.
3136    if memory != NULL_HANDLE {
3137        memoryObject := GetDeviceMemory(memory)
3138        assert(memoryObject.device == device)
3139        memoryObject.boundObjects[as!u64(image)] = memoryOffset
3140    }
3141    imageObject.memory = memory
3142    imageObject.memoryOffset = memoryOffset
3143
3144    return ?
3145}
3146
3147cmd void vkGetImageSparseMemoryRequirements(
3148        VkDevice                                    device,
3149        VkImage                                     image,
3150        u32*                                        pSparseMemoryRequirementCount,
3151        VkSparseImageMemoryRequirements*            pSparseMemoryRequirements) {
3152    deviceObject := GetDevice(device)
3153    imageObject := GetImage(image)
3154    assert(imageObject.device == device)
3155}
3156
3157cmd void vkGetPhysicalDeviceSparseImageFormatProperties(
3158        VkPhysicalDevice                            physicalDevice,
3159        VkFormat                                    format,
3160        VkImageType                                 type,
3161        VkSampleCountFlagBits                       samples,
3162        VkImageUsageFlags                           usage,
3163        VkImageTiling                               tiling,
3164        u32*                                        pPropertyCount,
3165        VkSparseImageFormatProperties*              pProperties) {
3166    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
3167}
3168
3169cmd VkResult vkQueueBindSparse(
3170        VkQueue                                     queue,
3171        u32                                         bindInfoCount,
3172        const VkBindSparseInfo*                     pBindInfo,
3173        VkFence                                     fence) {
3174    queueObject := GetQueue(queue)
3175
3176    return ?
3177}
3178
3179
3180// Fence functions
3181
3182@threadSafety("system")
3183cmd VkResult vkCreateFence(
3184        VkDevice                                    device,
3185        const VkFenceCreateInfo*                    pCreateInfo,
3186        const VkAllocationCallbacks*                pAllocator,
3187        VkFence*                                    pFence) {
3188    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO)
3189    deviceObject := GetDevice(device)
3190
3191    fence := ?
3192    pFence[0] = fence
3193    State.Fences[fence] = new!FenceObject(
3194        device: device, signaled: (pCreateInfo.flags == as!VkFenceCreateFlags(VK_FENCE_CREATE_SIGNALED_BIT)))
3195
3196    return ?
3197}
3198
3199@threadSafety("system")
3200cmd void vkDestroyFence(
3201        VkDevice                                    device,
3202        VkFence                                     fence,
3203        const VkAllocationCallbacks*                pAllocator) {
3204    deviceObject := GetDevice(device)
3205    fenceObject := GetFence(fence)
3206    assert(fenceObject.device == device)
3207
3208    State.Fences[fence] = null
3209}
3210
3211@threadSafety("system")
3212cmd VkResult vkResetFences(
3213        VkDevice                                    device,
3214        u32                                         fenceCount,
3215        const VkFence*                              pFences) {
3216    deviceObject := GetDevice(device)
3217
3218    fences := pFences[0:fenceCount]
3219    for i in (0 .. fenceCount) {
3220        fence := fences[i]
3221        fenceObject := GetFence(fence)
3222        assert(fenceObject.device == device)
3223        fenceObject.signaled = false
3224    }
3225
3226    return ?
3227}
3228
3229@threadSafety("system")
3230cmd VkResult vkGetFenceStatus(
3231        VkDevice                                    device,
3232        VkFence                                     fence) {
3233    deviceObject := GetDevice(device)
3234    fenceObject := GetFence(fence)
3235    assert(fenceObject.device == device)
3236
3237    return ?
3238}
3239
3240@threadSafety("system")
3241cmd VkResult vkWaitForFences(
3242        VkDevice                                    device,
3243        u32                                         fenceCount,
3244        const VkFence*                              pFences,
3245        VkBool32                                    waitAll,
3246        u64                                         timeout) {  /// timeout in nanoseconds
3247    deviceObject := GetDevice(device)
3248
3249    fences := pFences[0:fenceCount]
3250    for i in (0 .. fenceCount) {
3251        fence := fences[i]
3252        fenceObject := GetFence(fence)
3253        assert(fenceObject.device == device)
3254    }
3255
3256    return ?
3257}
3258
3259
3260// Queue semaphore functions
3261
3262@threadSafety("system")
3263cmd VkResult vkCreateSemaphore(
3264        VkDevice                                    device,
3265        const VkSemaphoreCreateInfo*                pCreateInfo,
3266        const VkAllocationCallbacks*                pAllocator,
3267        VkSemaphore*                                pSemaphore) {
3268    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO)
3269    deviceObject := GetDevice(device)
3270
3271    semaphore := ?
3272    pSemaphore[0] = semaphore
3273    State.Semaphores[semaphore] = new!SemaphoreObject(device: device)
3274
3275    return ?
3276}
3277
3278@threadSafety("system")
3279cmd void vkDestroySemaphore(
3280        VkDevice                                    device,
3281        VkSemaphore                                 semaphore,
3282        const VkAllocationCallbacks*                pAllocator) {
3283    deviceObject := GetDevice(device)
3284    semaphoreObject := GetSemaphore(semaphore)
3285    assert(semaphoreObject.device == device)
3286
3287    State.Semaphores[semaphore] = null
3288}
3289
3290
3291// Event functions
3292
3293@threadSafety("system")
3294cmd VkResult vkCreateEvent(
3295        VkDevice                                    device,
3296        const VkEventCreateInfo*                    pCreateInfo,
3297        const VkAllocationCallbacks*                pAllocator,
3298        VkEvent*                                    pEvent) {
3299    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO)
3300    deviceObject := GetDevice(device)
3301
3302    event := ?
3303    pEvent[0] = event
3304    State.Events[event] = new!EventObject(device: device)
3305
3306    return ?
3307}
3308
3309@threadSafety("system")
3310cmd void vkDestroyEvent(
3311        VkDevice                                    device,
3312        VkEvent                                     event,
3313        const VkAllocationCallbacks*                pAllocator) {
3314    deviceObject := GetDevice(device)
3315    eventObject := GetEvent(event)
3316    assert(eventObject.device == device)
3317
3318    State.Events[event] = null
3319}
3320
3321@threadSafety("system")
3322cmd VkResult vkGetEventStatus(
3323        VkDevice                                    device,
3324        VkEvent                                     event) {
3325    deviceObject := GetDevice(device)
3326    eventObject := GetEvent(event)
3327    assert(eventObject.device == device)
3328
3329    return ?
3330}
3331
3332@threadSafety("system")
3333cmd VkResult vkSetEvent(
3334        VkDevice                                    device,
3335        VkEvent                                     event) {
3336    deviceObject := GetDevice(device)
3337    eventObject := GetEvent(event)
3338    assert(eventObject.device == device)
3339
3340    return ?
3341}
3342
3343@threadSafety("system")
3344cmd VkResult vkResetEvent(
3345        VkDevice                                    device,
3346        VkEvent                                     event) {
3347    deviceObject := GetDevice(device)
3348    eventObject := GetEvent(event)
3349    assert(eventObject.device == device)
3350
3351    return ?
3352}
3353
3354
3355// Query functions
3356
3357@threadSafety("system")
3358cmd VkResult vkCreateQueryPool(
3359        VkDevice                                    device,
3360        const VkQueryPoolCreateInfo*                pCreateInfo,
3361        const VkAllocationCallbacks*                pAllocator,
3362        VkQueryPool*                                pQueryPool) {
3363    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO)
3364    deviceObject := GetDevice(device)
3365
3366    queryPool := ?
3367    pQueryPool[0] = queryPool
3368    State.QueryPools[queryPool] = new!QueryPoolObject(device: device)
3369
3370    return ?
3371}
3372
3373@threadSafety("system")
3374cmd void vkDestroyQueryPool(
3375        VkDevice                                    device,
3376        VkQueryPool                                 queryPool,
3377        const VkAllocationCallbacks*                pAllocator) {
3378    deviceObject := GetDevice(device)
3379    queryPoolObject := GetQueryPool(queryPool)
3380    assert(queryPoolObject.device == device)
3381
3382    State.QueryPools[queryPool] = null
3383}
3384
3385@threadSafety("system")
3386cmd VkResult vkGetQueryPoolResults(
3387        VkDevice                                    device,
3388        VkQueryPool                                 queryPool,
3389        u32                                         firstQuery,
3390        u32                                         queryCount,
3391        platform.size_t                             dataSize,
3392        void*                                       pData,
3393        VkDeviceSize                                stride,
3394        VkQueryResultFlags                          flags) {
3395    deviceObject := GetDevice(device)
3396    queryPoolObject := GetQueryPool(queryPool)
3397    assert(queryPoolObject.device == device)
3398
3399    data := pData[0:dataSize]
3400
3401    return ?
3402}
3403
3404// Buffer functions
3405
3406@threadSafety("system")
3407cmd VkResult vkCreateBuffer(
3408        VkDevice                                    device,
3409        const VkBufferCreateInfo*                   pCreateInfo,
3410        const VkAllocationCallbacks*                pAllocator,
3411        VkBuffer*                                   pBuffer) {
3412    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO)
3413    deviceObject := GetDevice(device)
3414
3415    buffer := ?
3416    pBuffer[0] = buffer
3417    State.Buffers[buffer] = new!BufferObject(device: device)
3418
3419    return ?
3420}
3421
3422@threadSafety("system")
3423cmd void vkDestroyBuffer(
3424        VkDevice                                    device,
3425        VkBuffer                                    buffer,
3426        const VkAllocationCallbacks*                pAllocator) {
3427    deviceObject := GetDevice(device)
3428    bufferObject := GetBuffer(buffer)
3429    assert(bufferObject.device == device)
3430
3431    assert(bufferObject.memory == 0)
3432    State.Buffers[buffer] = null
3433}
3434
3435
3436// Buffer view functions
3437
3438@threadSafety("system")
3439cmd VkResult vkCreateBufferView(
3440        VkDevice                                    device,
3441        const VkBufferViewCreateInfo*               pCreateInfo,
3442        const VkAllocationCallbacks*                pAllocator,
3443        VkBufferView*                               pView) {
3444    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
3445    deviceObject := GetDevice(device)
3446
3447    bufferObject := GetBuffer(pCreateInfo.buffer)
3448    assert(bufferObject.device == device)
3449
3450    view := ?
3451    pView[0] = view
3452    State.BufferViews[view] = new!BufferViewObject(device: device, buffer: pCreateInfo.buffer)
3453
3454    return ?
3455}
3456
3457@threadSafety("system")
3458cmd void vkDestroyBufferView(
3459        VkDevice                                    device,
3460        VkBufferView                                bufferView,
3461        const VkAllocationCallbacks*                pAllocator) {
3462    deviceObject := GetDevice(device)
3463    bufferViewObject := GetBufferView(bufferView)
3464    assert(bufferViewObject.device == device)
3465
3466    State.BufferViews[bufferView] = null
3467}
3468
3469
3470// Image functions
3471
3472@threadSafety("system")
3473cmd VkResult vkCreateImage(
3474        VkDevice                                    device,
3475        const VkImageCreateInfo*                    pCreateInfo,
3476        const VkAllocationCallbacks*                pAllocator,
3477        VkImage*                                    pImage) {
3478    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
3479    deviceObject := GetDevice(device)
3480
3481    image := ?
3482    pImage[0] = image
3483    State.Images[image] = new!ImageObject(device: device)
3484
3485    return ?
3486}
3487
3488@threadSafety("system")
3489cmd void vkDestroyImage(
3490        VkDevice                                    device,
3491        VkImage                                     image,
3492        const VkAllocationCallbacks*                pAllocator) {
3493    deviceObject := GetDevice(device)
3494    imageObject := GetImage(image)
3495    assert(imageObject.device == device)
3496
3497    assert(imageObject.memory == 0)
3498    State.Images[image] = null
3499}
3500
3501cmd void vkGetImageSubresourceLayout(
3502        VkDevice                                    device,
3503        VkImage                                     image,
3504        const VkImageSubresource*                   pSubresource,
3505        VkSubresourceLayout*                        pLayout) {
3506    deviceObject := GetDevice(device)
3507    imageObject := GetImage(image)
3508    assert(imageObject.device == device)
3509}
3510
3511
3512// Image view functions
3513
3514@threadSafety("system")
3515cmd VkResult vkCreateImageView(
3516        VkDevice                                    device,
3517        const VkImageViewCreateInfo*                pCreateInfo,
3518        const VkAllocationCallbacks*                pAllocator,
3519        VkImageView*                                pView) {
3520    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO)
3521    deviceObject := GetDevice(device)
3522
3523    imageObject := GetImage(pCreateInfo.image)
3524    assert(imageObject.device == device)
3525
3526    view := ?
3527    pView[0] = view
3528    State.ImageViews[view] = new!ImageViewObject(device: device, image: pCreateInfo.image)
3529
3530    return ?
3531}
3532
3533@threadSafety("system")
3534cmd void vkDestroyImageView(
3535        VkDevice                                    device,
3536        VkImageView                                 imageView,
3537        const VkAllocationCallbacks*                pAllocator) {
3538    deviceObject := GetDevice(device)
3539    imageViewObject := GetImageView(imageView)
3540    assert(imageViewObject.device == device)
3541
3542    State.ImageViews[imageView] = null
3543}
3544
3545
3546// Shader functions
3547
3548cmd VkResult vkCreateShaderModule(
3549        VkDevice                                    device,
3550        const VkShaderModuleCreateInfo*             pCreateInfo,
3551        const VkAllocationCallbacks*                pAllocator,
3552        VkShaderModule*                             pShaderModule) {
3553    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO)
3554    deviceObject := GetDevice(device)
3555
3556    shaderModule := ?
3557    pShaderModule[0] = shaderModule
3558    State.ShaderModules[shaderModule] = new!ShaderModuleObject(device: device)
3559
3560    return ?
3561}
3562
3563cmd void vkDestroyShaderModule(
3564        VkDevice                                    device,
3565        VkShaderModule                              shaderModule,
3566        const VkAllocationCallbacks*                pAllocator) {
3567    deviceObject := GetDevice(device)
3568    shaderModuleObject := GetShaderModule(shaderModule)
3569    assert(shaderModuleObject.device == device)
3570
3571    State.ShaderModules[shaderModule] = null
3572}
3573
3574
3575// Pipeline functions
3576
3577cmd VkResult vkCreatePipelineCache(
3578        VkDevice                                    device,
3579        const VkPipelineCacheCreateInfo*            pCreateInfo,
3580        const VkAllocationCallbacks*                pAllocator,
3581        VkPipelineCache*                            pPipelineCache) {
3582    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO)
3583    deviceObject := GetDevice(device)
3584
3585    pipelineCache := ?
3586    pPipelineCache[0] = pipelineCache
3587    State.PipelineCaches[pipelineCache] = new!PipelineCacheObject(device: device)
3588
3589    return ?
3590}
3591
3592cmd void vkDestroyPipelineCache(
3593        VkDevice                                    device,
3594        VkPipelineCache                             pipelineCache,
3595        const VkAllocationCallbacks*                pAllocator) {
3596    deviceObject := GetDevice(device)
3597    pipelineCacheObject := GetPipelineCache(pipelineCache)
3598    assert(pipelineCacheObject.device == device)
3599
3600    State.PipelineCaches[pipelineCache] = null
3601}
3602
3603cmd VkResult vkGetPipelineCacheData(
3604        VkDevice                                    device,
3605        VkPipelineCache                             pipelineCache,
3606        platform.size_t*                            pDataSize,
3607        void*                                       pData) {
3608    deviceObject := GetDevice(device)
3609    pipelineCacheObject := GetPipelineCache(pipelineCache)
3610    assert(pipelineCacheObject.device == device)
3611
3612    return ?
3613}
3614
3615cmd VkResult vkMergePipelineCaches(
3616        VkDevice                                    device,
3617        VkPipelineCache                             dstCache,
3618        u32                                         srcCacheCount,
3619        const VkPipelineCache*                      pSrcCaches) {
3620    deviceObject := GetDevice(device)
3621    dstCacheObject := GetPipelineCache(dstCache)
3622    assert(dstCacheObject.device == device)
3623
3624    srcCaches := pSrcCaches[0:srcCacheCount]
3625    for i in (0 .. srcCacheCount) {
3626        srcCache := srcCaches[i]
3627        srcCacheObject := GetPipelineCache(srcCache)
3628        assert(srcCacheObject.device == device)
3629    }
3630
3631    return ?
3632}
3633
3634cmd VkResult vkCreateGraphicsPipelines(
3635        VkDevice                                    device,
3636        VkPipelineCache                             pipelineCache,
3637        u32                                         createInfoCount,
3638        const VkGraphicsPipelineCreateInfo*         pCreateInfos,
3639        const VkAllocationCallbacks*                pAllocator,
3640        VkPipeline*                                 pPipelines) {
3641    deviceObject := GetDevice(device)
3642    if pipelineCache != NULL_HANDLE {
3643        pipelineCacheObject := GetPipelineCache(pipelineCache)
3644        assert(pipelineCacheObject.device == device)
3645    }
3646
3647    createInfos := pCreateInfos[0:createInfoCount]
3648    pipelines := pPipelines[0:createInfoCount]
3649    for i in (0 .. createInfoCount) {
3650        pipeline := ?
3651        pipelines[i] = pipeline
3652        State.Pipelines[pipeline] = new!PipelineObject(device: device)
3653    }
3654
3655    return ?
3656}
3657
3658cmd VkResult vkCreateComputePipelines(
3659        VkDevice                                    device,
3660        VkPipelineCache                             pipelineCache,
3661        u32                                         createInfoCount,
3662        const VkComputePipelineCreateInfo*          pCreateInfos,
3663        const VkAllocationCallbacks*                pAllocator,
3664        VkPipeline*                                 pPipelines) {
3665    deviceObject := GetDevice(device)
3666    if pipelineCache != NULL_HANDLE {
3667        pipelineCacheObject := GetPipelineCache(pipelineCache)
3668        assert(pipelineCacheObject.device == device)
3669    }
3670
3671    createInfos := pCreateInfos[0:createInfoCount]
3672    pipelines := pPipelines[0:createInfoCount]
3673    for i in (0 .. createInfoCount) {
3674        pipeline := ?
3675        pipelines[i] = pipeline
3676        State.Pipelines[pipeline] = new!PipelineObject(device: device)
3677    }
3678
3679    return ?
3680}
3681
3682@threadSafety("system")
3683cmd void vkDestroyPipeline(
3684        VkDevice                                    device,
3685        VkPipeline                                  pipeline,
3686        const VkAllocationCallbacks*                pAllocator) {
3687    deviceObject := GetDevice(device)
3688    pipelineObjects := GetPipeline(pipeline)
3689    assert(pipelineObjects.device == device)
3690
3691    State.Pipelines[pipeline] = null
3692}
3693
3694
3695// Pipeline layout functions
3696
3697@threadSafety("system")
3698cmd VkResult vkCreatePipelineLayout(
3699        VkDevice                                    device,
3700        const VkPipelineLayoutCreateInfo*           pCreateInfo,
3701        const VkAllocationCallbacks*                pAllocator,
3702        VkPipelineLayout*                           pPipelineLayout) {
3703    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO)
3704    deviceObject := GetDevice(device)
3705
3706    pipelineLayout := ?
3707    pPipelineLayout[0] = pipelineLayout
3708    State.PipelineLayouts[pipelineLayout] = new!PipelineLayoutObject(device: device)
3709
3710    return ?
3711}
3712
3713@threadSafety("system")
3714cmd void vkDestroyPipelineLayout(
3715        VkDevice                                    device,
3716        VkPipelineLayout                            pipelineLayout,
3717        const VkAllocationCallbacks*                pAllocator) {
3718    deviceObject := GetDevice(device)
3719    pipelineLayoutObjects := GetPipelineLayout(pipelineLayout)
3720    assert(pipelineLayoutObjects.device == device)
3721
3722    State.PipelineLayouts[pipelineLayout] = null
3723}
3724
3725
3726// Sampler functions
3727
3728@threadSafety("system")
3729cmd VkResult vkCreateSampler(
3730        VkDevice                                    device,
3731        const VkSamplerCreateInfo*                  pCreateInfo,
3732        const VkAllocationCallbacks*                pAllocator,
3733        VkSampler*                                  pSampler) {
3734    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO)
3735    deviceObject := GetDevice(device)
3736
3737    sampler := ?
3738    pSampler[0] = sampler
3739    State.Samplers[sampler] = new!SamplerObject(device: device)
3740
3741    return ?
3742}
3743
3744@threadSafety("system")
3745cmd void vkDestroySampler(
3746        VkDevice                                    device,
3747        VkSampler                                   sampler,
3748        const VkAllocationCallbacks*                pAllocator) {
3749    deviceObject := GetDevice(device)
3750    samplerObject := GetSampler(sampler)
3751    assert(samplerObject.device == device)
3752
3753    State.Samplers[sampler] = null
3754}
3755
3756
3757// Descriptor set functions
3758
3759@threadSafety("system")
3760cmd VkResult vkCreateDescriptorSetLayout(
3761        VkDevice                                    device,
3762        const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
3763        const VkAllocationCallbacks*                pAllocator,
3764        VkDescriptorSetLayout*                      pSetLayout) {
3765    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)
3766    deviceObject := GetDevice(device)
3767
3768    setLayout := ?
3769    pSetLayout[0] = setLayout
3770    State.DescriptorSetLayouts[setLayout] = new!DescriptorSetLayoutObject(device: device)
3771
3772    return ?
3773}
3774
3775@threadSafety("system")
3776cmd void vkDestroyDescriptorSetLayout(
3777        VkDevice                                    device,
3778        VkDescriptorSetLayout                       descriptorSetLayout,
3779        const VkAllocationCallbacks*                pAllocator) {
3780    deviceObject := GetDevice(device)
3781    descriptorSetLayoutObject := GetDescriptorSetLayout(descriptorSetLayout)
3782    assert(descriptorSetLayoutObject.device == device)
3783
3784    State.DescriptorSetLayouts[descriptorSetLayout] = null
3785}
3786
3787@threadSafety("system")
3788cmd VkResult vkCreateDescriptorPool(
3789        VkDevice                                    device,
3790        const VkDescriptorPoolCreateInfo*           pCreateInfo,
3791        const VkAllocationCallbacks*                pAllocator,
3792        VkDescriptorPool*                           pDescriptorPool) {
3793    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO)
3794    deviceObject := GetDevice(device)
3795
3796    descriptorPool := ?
3797    pDescriptorPool[0] = descriptorPool
3798    State.DescriptorPools[descriptorPool] = new!DescriptorPoolObject(device: device)
3799
3800    return ?
3801}
3802
3803@threadSafety("system")
3804cmd void vkDestroyDescriptorPool(
3805        VkDevice                                    device,
3806        VkDescriptorPool                            descriptorPool,
3807        const VkAllocationCallbacks*                pAllocator) {
3808    deviceObject := GetDevice(device)
3809    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3810    assert(descriptorPoolObject.device == device)
3811
3812    State.DescriptorPools[descriptorPool] = null
3813}
3814
3815@threadSafety("app")
3816cmd VkResult vkResetDescriptorPool(
3817        VkDevice                                    device,
3818        VkDescriptorPool                            descriptorPool,
3819        VkDescriptorPoolResetFlags                  flags) {
3820    deviceObject := GetDevice(device)
3821    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3822    assert(descriptorPoolObject.device == device)
3823
3824    return ?
3825}
3826
3827@threadSafety("app")
3828cmd VkResult vkAllocateDescriptorSets(
3829        VkDevice                                    device,
3830        const VkDescriptorSetAllocateInfo*          pAllocateInfo,
3831        VkDescriptorSet*                            pDescriptorSets) {
3832    deviceObject := GetDevice(device)
3833    allocInfo := pAllocateInfo[0]
3834    descriptorPoolObject := GetDescriptorPool(allocInfo.descriptorPool)
3835
3836    setLayouts := allocInfo.pSetLayouts[0:allocInfo.setCount]
3837    for i in (0 .. allocInfo.setCount) {
3838        setLayout := setLayouts[i]
3839        setLayoutObject := GetDescriptorSetLayout(setLayout)
3840        assert(setLayoutObject.device == device)
3841    }
3842
3843    descriptorSets := pDescriptorSets[0:allocInfo.setCount]
3844    for i in (0 .. allocInfo.setCount) {
3845        descriptorSet := ?
3846        descriptorSets[i] = descriptorSet
3847        State.DescriptorSets[descriptorSet] = new!DescriptorSetObject(device: device)
3848    }
3849
3850    return ?
3851}
3852
3853cmd VkResult vkFreeDescriptorSets(
3854        VkDevice                                    device,
3855        VkDescriptorPool                            descriptorPool,
3856        u32                                         descriptorSetCount,
3857        const VkDescriptorSet*                      pDescriptorSets) {
3858    deviceObject := GetDevice(device)
3859    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3860
3861    descriptorSets := pDescriptorSets[0:descriptorSetCount]
3862    for i in (0 .. descriptorSetCount) {
3863        descriptorSet := descriptorSets[i]
3864        descriptorSetObject := GetDescriptorSet(descriptorSet)
3865        assert(descriptorSetObject.device == device)
3866        State.DescriptorSets[descriptorSet] = null
3867    }
3868
3869    return ?
3870}
3871
3872cmd void vkUpdateDescriptorSets(
3873        VkDevice                                    device,
3874        u32                                         descriptorWriteCount,
3875        const VkWriteDescriptorSet*                 pDescriptorWrites,
3876        u32                                         descriptorCopyCount,
3877        const VkCopyDescriptorSet*                  pDescriptorCopies) {
3878    deviceObject := GetDevice(device)
3879
3880    descriptorWrites := pDescriptorWrites[0:descriptorWriteCount]
3881    for i in (0 .. descriptorWriteCount) {
3882        descriptorWrite := descriptorWrites[i]
3883        descriptorWriteObject := GetDescriptorSet(descriptorWrite.dstSet)
3884        assert(descriptorWriteObject.device == device)
3885    }
3886
3887    descriptorCopies := pDescriptorCopies[0:descriptorCopyCount]
3888    for i in (0 .. descriptorCopyCount) {
3889        descriptorCopy := descriptorCopies[i]
3890        descriptorCopyObject := GetDescriptorSet(descriptorCopy.dstSet)
3891        assert(descriptorCopyObject.device == device)
3892    }
3893}
3894
3895
3896// Framebuffer functions
3897
3898@threadSafety("system")
3899cmd VkResult vkCreateFramebuffer(
3900        VkDevice                                    device,
3901        const VkFramebufferCreateInfo*              pCreateInfo,
3902        const VkAllocationCallbacks*                pAllocator,
3903        VkFramebuffer*                              pFramebuffer) {
3904    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO)
3905    deviceObject := GetDevice(device)
3906
3907    framebuffer := ?
3908    pFramebuffer[0] = framebuffer
3909    State.Framebuffers[framebuffer] = new!FramebufferObject(device: device)
3910
3911    return ?
3912}
3913
3914@threadSafety("system")
3915cmd void vkDestroyFramebuffer(
3916        VkDevice                                    device,
3917        VkFramebuffer                               framebuffer,
3918        const VkAllocationCallbacks*                pAllocator) {
3919    deviceObject := GetDevice(device)
3920    framebufferObject := GetFramebuffer(framebuffer)
3921    assert(framebufferObject.device == device)
3922
3923    State.Framebuffers[framebuffer] = null
3924}
3925
3926
3927// Renderpass functions
3928
3929@threadSafety("system")
3930cmd VkResult vkCreateRenderPass(
3931        VkDevice                                    device,
3932        const VkRenderPassCreateInfo*               pCreateInfo,
3933        const VkAllocationCallbacks*                pAllocator,
3934        VkRenderPass*                               pRenderPass) {
3935    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO)
3936    deviceObject := GetDevice(device)
3937
3938    renderpass := ?
3939    pRenderPass[0] = renderpass
3940    State.RenderPasses[renderpass] = new!RenderPassObject(device: device)
3941
3942    return ?
3943}
3944
3945@threadSafety("system")
3946cmd void vkDestroyRenderPass(
3947        VkDevice                                    device,
3948        VkRenderPass                                renderPass,
3949        const VkAllocationCallbacks*                pAllocator) {
3950    deviceObject := GetDevice(device)
3951    renderPassObject := GetRenderPass(renderPass)
3952    assert(renderPassObject.device == device)
3953
3954    State.RenderPasses[renderPass] = null
3955}
3956
3957cmd void vkGetRenderAreaGranularity(
3958        VkDevice                                    device,
3959        VkRenderPass                                renderPass,
3960        VkExtent2D*                                 pGranularity) {
3961    deviceObject := GetDevice(device)
3962    renderPassObject := GetRenderPass(renderPass)
3963
3964    granularity := ?
3965    pGranularity[0] = granularity
3966}
3967
3968// Command pool functions
3969
3970cmd VkResult vkCreateCommandPool(
3971        VkDevice                                    device,
3972        const VkCommandPoolCreateInfo*              pCreateInfo,
3973        const VkAllocationCallbacks*                pAllocator,
3974        VkCommandPool*                              pCommandPool) {
3975    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
3976    deviceObject := GetDevice(device)
3977
3978    commandPool := ?
3979    pCommandPool[0] = commandPool
3980    State.CommandPools[commandPool] = new!CommandPoolObject(device: device)
3981
3982    return ?
3983}
3984
3985cmd void vkDestroyCommandPool(
3986        VkDevice                                    device,
3987        VkCommandPool                               commandPool,
3988        const VkAllocationCallbacks*                pAllocator) {
3989    deviceObject := GetDevice(device)
3990    commandPoolObject := GetCommandPool(commandPool)
3991    assert(commandPoolObject.device == device)
3992
3993    State.CommandPools[commandPool] = null
3994}
3995
3996cmd VkResult vkResetCommandPool(
3997        VkDevice                                    device,
3998        VkCommandPool                               commandPool,
3999        VkCommandPoolResetFlags                     flags) {
4000    deviceObject := GetDevice(device)
4001    commandPoolObject := GetCommandPool(commandPool)
4002    assert(commandPoolObject.device == device)
4003
4004    return ?
4005}
4006
4007// Command buffer functions
4008
4009macro void bindCommandBuffer(VkCommandBuffer commandBuffer, any obj, VkDeviceMemory memory) {
4010    memoryObject := GetDeviceMemory(memory)
4011    memoryObject.boundCommandBuffers[commandBuffer] = commandBuffer
4012
4013    commandBufferObject := GetCommandBuffer(commandBuffer)
4014    commandBufferObject.boundObjects[as!u64(obj)] = memory
4015}
4016
4017macro void unbindCommandBuffer(VkCommandBuffer commandBuffer, any obj, VkDeviceMemory memory) {
4018    memoryObject := GetDeviceMemory(memory)
4019    memoryObject.boundCommandBuffers[commandBuffer] = null
4020
4021    commandBufferObject := GetCommandBuffer(commandBuffer)
4022    commandBufferObject.boundObjects[as!u64(obj)] = null
4023}
4024
4025@threadSafety("system")
4026cmd VkResult vkAllocateCommandBuffers(
4027        VkDevice                                    device,
4028        const VkCommandBufferAllocateInfo*          pAllocateInfo,
4029        VkCommandBuffer*                            pCommandBuffers) {
4030    assert(pAllocateInfo[0].sType == VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO)
4031
4032    count := pAllocateInfo[0].commandBufferCount
4033    commandBuffers := pCommandBuffers[0:count]
4034    for i in (0 .. count) {
4035        commandBuffer := ?
4036        commandBuffers[i] = commandBuffer
4037        State.CommandBuffers[commandBuffer] = new!CommandBufferObject(device: device)
4038    }
4039
4040    return ?
4041}
4042
4043@threadSafety("system")
4044cmd void vkFreeCommandBuffers(
4045        VkDevice                                    device,
4046        VkCommandPool                               commandPool,
4047        u32                                         commandBufferCount,
4048        const VkCommandBuffer*                      pCommandBuffers) {
4049    deviceObject := GetDevice(device)
4050
4051    commandBuffers := pCommandBuffers[0:commandBufferCount]
4052    for i in (0 .. commandBufferCount) {
4053        commandBufferObject := GetCommandBuffer(commandBuffers[i])
4054        assert(commandBufferObject.device == device)
4055        // TODO: iterate over boundObjects and clear memory bindings
4056        State.CommandBuffers[commandBuffers[i]] = null
4057    }
4058}
4059
4060@threadSafety("app")
4061cmd VkResult vkBeginCommandBuffer(
4062        VkCommandBuffer                             commandBuffer,
4063        const VkCommandBufferBeginInfo*             pBeginInfo) {
4064    assert(pBeginInfo.sType == VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO)
4065    commandBufferObject := GetCommandBuffer(commandBuffer)
4066
4067    // TODO: iterate over boundObjects and clear memory bindings
4068
4069    return ?
4070}
4071
4072@threadSafety("app")
4073cmd VkResult vkEndCommandBuffer(
4074        VkCommandBuffer                             commandBuffer) {
4075    commandBufferObject := GetCommandBuffer(commandBuffer)
4076
4077    return ?
4078}
4079
4080@threadSafety("app")
4081cmd VkResult vkResetCommandBuffer(
4082        VkCommandBuffer                             commandBuffer,
4083        VkCommandBufferResetFlags                   flags) {
4084    commandBufferObject := GetCommandBuffer(commandBuffer)
4085
4086    // TODO: iterate over boundObjects and clear memory bindings
4087
4088    return ?
4089}
4090
4091
4092// Command buffer building functions
4093
4094@threadSafety("app")
4095cmd void vkCmdBindPipeline(
4096        VkCommandBuffer                             commandBuffer,
4097        VkPipelineBindPoint                         pipelineBindPoint,
4098        VkPipeline                                  pipeline) {
4099    commandBufferObject := GetCommandBuffer(commandBuffer)
4100    pipelineObject := GetPipeline(pipeline)
4101    assert(commandBufferObject.device == pipelineObject.device)
4102
4103    queue := switch (pipelineBindPoint) {
4104        case VK_PIPELINE_BIND_POINT_COMPUTE:  VK_QUEUE_COMPUTE_BIT
4105        case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT
4106    }
4107    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, queue)
4108}
4109
4110@threadSafety("app")
4111cmd void vkCmdSetViewport(
4112        VkCommandBuffer                             commandBuffer,
4113        u32                                         firstViewport,
4114        u32                                         viewportCount,
4115        const VkViewport*                           pViewports) {
4116    commandBufferObject := GetCommandBuffer(commandBuffer)
4117    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4118}
4119
4120@threadSafety("app")
4121cmd void vkCmdSetScissor(
4122        VkCommandBuffer                             commandBuffer,
4123        u32                                         firstScissor,
4124        u32                                         scissorCount,
4125        const VkRect2D*                             pScissors) {
4126    commandBufferObject := GetCommandBuffer(commandBuffer)
4127    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4128}
4129
4130@threadSafety("app")
4131cmd void vkCmdSetLineWidth(
4132        VkCommandBuffer                             commandBuffer,
4133        f32                                         lineWidth) {
4134    commandBufferObject := GetCommandBuffer(commandBuffer)
4135    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4136}
4137
4138@threadSafety("app")
4139cmd void vkCmdSetDepthBias(
4140        VkCommandBuffer                             commandBuffer,
4141        f32                                         depthBiasConstantFactor,
4142        f32                                         depthBiasClamp,
4143        f32                                         depthBiasSlopeFactor) {
4144    commandBufferObject := GetCommandBuffer(commandBuffer)
4145    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4146}
4147
4148@threadSafety("app")
4149cmd void vkCmdSetBlendConstants(
4150        VkCommandBuffer                             commandBuffer,
4151        // TODO(jessehall): apic only supports 'const' on pointer types. Using
4152        // an annotation as a quick hack to pass this to the template without
4153        // having to modify the AST and semantic model.
4154        @readonly f32[4]                            blendConstants) {
4155    commandBufferObject := GetCommandBuffer(commandBuffer)
4156    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4157}
4158
4159@threadSafety("app")
4160cmd void vkCmdSetDepthBounds(
4161        VkCommandBuffer                             commandBuffer,
4162        f32                                         minDepthBounds,
4163        f32                                         maxDepthBounds) {
4164    commandBufferObject := GetCommandBuffer(commandBuffer)
4165    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4166}
4167
4168@threadSafety("app")
4169cmd void vkCmdSetStencilCompareMask(
4170        VkCommandBuffer                             commandBuffer,
4171        VkStencilFaceFlags                          faceMask,
4172        u32                                         compareMask) {
4173    commandBufferObject := GetCommandBuffer(commandBuffer)
4174    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4175}
4176
4177@threadSafety("app")
4178cmd void vkCmdSetStencilWriteMask(
4179        VkCommandBuffer                             commandBuffer,
4180        VkStencilFaceFlags                          faceMask,
4181        u32                                         writeMask) {
4182    commandBufferObject := GetCommandBuffer(commandBuffer)
4183    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4184}
4185
4186@threadSafety("app")
4187cmd void vkCmdSetStencilReference(
4188        VkCommandBuffer                             commandBuffer,
4189        VkStencilFaceFlags                          faceMask,
4190        u32                                         reference) {
4191    commandBufferObject := GetCommandBuffer(commandBuffer)
4192    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4193}
4194
4195@threadSafety("app")
4196cmd void vkCmdBindDescriptorSets(
4197        VkCommandBuffer                             commandBuffer,
4198        VkPipelineBindPoint                         pipelineBindPoint,
4199        VkPipelineLayout                            layout,
4200        u32                                         firstSet,
4201        u32                                         descriptorSetCount,
4202        const VkDescriptorSet*                      pDescriptorSets,
4203        u32                                         dynamicOffsetCount,
4204        const u32*                                  pDynamicOffsets) {
4205    commandBufferObject := GetCommandBuffer(commandBuffer)
4206
4207    descriptorSets := pDescriptorSets[0:descriptorSetCount]
4208    for i in (0 .. descriptorSetCount) {
4209        descriptorSet := descriptorSets[i]
4210        descriptorSetObject := GetDescriptorSet(descriptorSet)
4211        assert(commandBufferObject.device == descriptorSetObject.device)
4212    }
4213
4214    dynamicOffsets := pDynamicOffsets[0:dynamicOffsetCount]
4215    for i in (0 .. dynamicOffsetCount) {
4216        dynamicOffset := dynamicOffsets[i]
4217    }
4218
4219    queue := switch (pipelineBindPoint) {
4220        case VK_PIPELINE_BIND_POINT_COMPUTE:  VK_QUEUE_COMPUTE_BIT
4221        case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT
4222    }
4223    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, queue)
4224}
4225
4226@threadSafety("app")
4227cmd void vkCmdBindIndexBuffer(
4228        VkCommandBuffer                             commandBuffer,
4229        VkBuffer                                    buffer,
4230        VkDeviceSize                                offset,
4231        VkIndexType                                 indexType) {
4232    commandBufferObject := GetCommandBuffer(commandBuffer)
4233    bufferObject := GetBuffer(buffer)
4234    assert(commandBufferObject.device == bufferObject.device)
4235
4236    bindCommandBuffer(commandBuffer, buffer, bufferObject.memory)
4237
4238    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4239}
4240
4241@threadSafety("app")
4242cmd void vkCmdBindVertexBuffers(
4243        VkCommandBuffer                             commandBuffer,
4244        u32                                         firstBinding,
4245        u32                                         bindingCount,
4246        const VkBuffer*                             pBuffers,
4247        const VkDeviceSize*                         pOffsets) {
4248    commandBufferObject := GetCommandBuffer(commandBuffer)
4249
4250    // TODO: check if not [firstBinding:firstBinding+bindingCount]
4251    buffers := pBuffers[0:bindingCount]
4252    offsets := pOffsets[0:bindingCount]
4253    for i in (0 .. bindingCount) {
4254        buffer := buffers[i]
4255        offset := offsets[i]
4256        bufferObject := GetBuffer(buffer)
4257        assert(commandBufferObject.device == bufferObject.device)
4258
4259        bindCommandBuffer(commandBuffer, buffer, bufferObject.memory)
4260    }
4261
4262    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4263}
4264
4265@threadSafety("app")
4266cmd void vkCmdDraw(
4267        VkCommandBuffer                             commandBuffer,
4268        u32                                         vertexCount,
4269        u32                                         instanceCount,
4270        u32                                         firstVertex,
4271        u32                                         firstInstance) {
4272    commandBufferObject := GetCommandBuffer(commandBuffer)
4273
4274    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4275}
4276
4277@threadSafety("app")
4278cmd void vkCmdDrawIndexed(
4279        VkCommandBuffer                             commandBuffer,
4280        u32                                         indexCount,
4281        u32                                         instanceCount,
4282        u32                                         firstIndex,
4283        s32                                         vertexOffset,
4284        u32                                         firstInstance) {
4285    commandBufferObject := GetCommandBuffer(commandBuffer)
4286
4287    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4288}
4289
4290@threadSafety("app")
4291cmd void vkCmdDrawIndirect(
4292        VkCommandBuffer                             commandBuffer,
4293        VkBuffer                                    buffer,
4294        VkDeviceSize                                offset,
4295        u32                                         drawCount,
4296        u32                                         stride) {
4297    commandBufferObject := GetCommandBuffer(commandBuffer)
4298    bufferObject := GetBuffer(buffer)
4299    assert(commandBufferObject.device == bufferObject.device)
4300
4301    bindCommandBuffer(commandBuffer, buffer, bufferObject.memory)
4302
4303    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4304}
4305
4306@threadSafety("app")
4307cmd void vkCmdDrawIndexedIndirect(
4308        VkCommandBuffer                             commandBuffer,
4309        VkBuffer                                    buffer,
4310        VkDeviceSize                                offset,
4311        u32                                         drawCount,
4312        u32                                         stride) {
4313    commandBufferObject := GetCommandBuffer(commandBuffer)
4314    bufferObject := GetBuffer(buffer)
4315    assert(commandBufferObject.device == bufferObject.device)
4316
4317    bindCommandBuffer(commandBuffer, buffer, bufferObject.memory)
4318
4319    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4320}
4321
4322@threadSafety("app")
4323cmd void vkCmdDispatch(
4324        VkCommandBuffer                             commandBuffer,
4325        u32                                         x,
4326        u32                                         y,
4327        u32                                         z) {
4328    commandBufferObject := GetCommandBuffer(commandBuffer)
4329
4330    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_COMPUTE_BIT)
4331}
4332
4333@threadSafety("app")
4334cmd void vkCmdDispatchIndirect(
4335        VkCommandBuffer                             commandBuffer,
4336        VkBuffer                                    buffer,
4337        VkDeviceSize                                offset) {
4338    commandBufferObject := GetCommandBuffer(commandBuffer)
4339    bufferObject := GetBuffer(buffer)
4340    assert(commandBufferObject.device == bufferObject.device)
4341
4342    bindCommandBuffer(commandBuffer, buffer, bufferObject.memory)
4343
4344    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_COMPUTE_BIT)
4345}
4346
4347@threadSafety("app")
4348cmd void vkCmdCopyBuffer(
4349        VkCommandBuffer                             commandBuffer,
4350        VkBuffer                                    srcBuffer,
4351        VkBuffer                                    dstBuffer,
4352        u32                                         regionCount,
4353        const VkBufferCopy*                         pRegions) {
4354    commandBufferObject := GetCommandBuffer(commandBuffer)
4355    srcBufferObject := GetBuffer(srcBuffer)
4356    dstBufferObject := GetBuffer(dstBuffer)
4357    assert(commandBufferObject.device == srcBufferObject.device)
4358    assert(commandBufferObject.device == dstBufferObject.device)
4359
4360    regions := pRegions[0:regionCount]
4361    for i in (0 .. regionCount) {
4362        region := regions[i]
4363    }
4364
4365    bindCommandBuffer(commandBuffer, srcBuffer, srcBufferObject.memory)
4366    bindCommandBuffer(commandBuffer, dstBuffer, dstBufferObject.memory)
4367
4368    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4369}
4370
4371@threadSafety("app")
4372cmd void vkCmdCopyImage(
4373        VkCommandBuffer                             commandBuffer,
4374        VkImage                                     srcImage,
4375        VkImageLayout                               srcImageLayout,
4376        VkImage                                     dstImage,
4377        VkImageLayout                               dstImageLayout,
4378        u32                                         regionCount,
4379        const VkImageCopy*                          pRegions) {
4380    commandBufferObject := GetCommandBuffer(commandBuffer)
4381    srcImageObject := GetImage(srcImage)
4382    dstImageObject := GetImage(dstImage)
4383    assert(commandBufferObject.device == srcImageObject.device)
4384    assert(commandBufferObject.device == dstImageObject.device)
4385
4386    regions := pRegions[0:regionCount]
4387    for i in (0 .. regionCount) {
4388        region := regions[i]
4389    }
4390
4391    bindCommandBuffer(commandBuffer, srcImage, srcImageObject.memory)
4392    bindCommandBuffer(commandBuffer, dstImage, dstImageObject.memory)
4393
4394    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4395}
4396
4397@threadSafety("app")
4398cmd void vkCmdBlitImage(
4399        VkCommandBuffer                             commandBuffer,
4400        VkImage                                     srcImage,
4401        VkImageLayout                               srcImageLayout,
4402        VkImage                                     dstImage,
4403        VkImageLayout                               dstImageLayout,
4404        u32                                         regionCount,
4405        const VkImageBlit*                          pRegions,
4406        VkFilter                                    filter) {
4407    commandBufferObject := GetCommandBuffer(commandBuffer)
4408    srcImageObject := GetImage(srcImage)
4409    dstImageObject := GetImage(dstImage)
4410    assert(commandBufferObject.device == srcImageObject.device)
4411    assert(commandBufferObject.device == dstImageObject.device)
4412
4413    regions := pRegions[0:regionCount]
4414    for i in (0 .. regionCount) {
4415        region := regions[i]
4416    }
4417
4418    bindCommandBuffer(commandBuffer, srcImage, srcImageObject.memory)
4419    bindCommandBuffer(commandBuffer, dstImage, dstImageObject.memory)
4420
4421    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4422}
4423
4424@threadSafety("app")
4425cmd void vkCmdCopyBufferToImage(
4426        VkCommandBuffer                             commandBuffer,
4427        VkBuffer                                    srcBuffer,
4428        VkImage                                     dstImage,
4429        VkImageLayout                               dstImageLayout,
4430        u32                                         regionCount,
4431        const VkBufferImageCopy*                    pRegions) {
4432    commandBufferObject := GetCommandBuffer(commandBuffer)
4433    srcBufferObject := GetBuffer(srcBuffer)
4434    dstImageObject := GetImage(dstImage)
4435    assert(commandBufferObject.device == srcBufferObject.device)
4436    assert(commandBufferObject.device == dstImageObject.device)
4437
4438    regions := pRegions[0:regionCount]
4439    for i in (0 .. regionCount) {
4440        region := regions[i]
4441    }
4442
4443    bindCommandBuffer(commandBuffer, srcBuffer, srcBufferObject.memory)
4444    bindCommandBuffer(commandBuffer, dstImage, dstImageObject.memory)
4445
4446    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4447}
4448
4449@threadSafety("app")
4450cmd void vkCmdCopyImageToBuffer(
4451        VkCommandBuffer                             commandBuffer,
4452        VkImage                                     srcImage,
4453        VkImageLayout                               srcImageLayout,
4454        VkBuffer                                    dstBuffer,
4455        u32                                         regionCount,
4456        const VkBufferImageCopy*                    pRegions) {
4457    commandBufferObject := GetCommandBuffer(commandBuffer)
4458    srcImageObject := GetImage(srcImage)
4459    dstBufferObject := GetBuffer(dstBuffer)
4460    assert(commandBufferObject.device == srcImageObject.device)
4461    assert(commandBufferObject.device == dstBufferObject.device)
4462
4463    regions := pRegions[0:regionCount]
4464    for i in (0 .. regionCount) {
4465        region := regions[i]
4466    }
4467
4468    bindCommandBuffer(commandBuffer, srcImage, srcImageObject.memory)
4469    bindCommandBuffer(commandBuffer, dstBuffer, dstBufferObject.memory)
4470
4471    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4472}
4473
4474@threadSafety("app")
4475cmd void vkCmdUpdateBuffer(
4476        VkCommandBuffer                             commandBuffer,
4477        VkBuffer                                    dstBuffer,
4478        VkDeviceSize                                dstOffset,
4479        VkDeviceSize                                dataSize,
4480        const u32*                                  pData) {
4481    commandBufferObject := GetCommandBuffer(commandBuffer)
4482    dstBufferObject := GetBuffer(dstBuffer)
4483    assert(commandBufferObject.device == dstBufferObject.device)
4484
4485    data := pData[0:dataSize]
4486
4487    bindCommandBuffer(commandBuffer, dstBuffer, dstBufferObject.memory)
4488
4489    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4490}
4491
4492@threadSafety("app")
4493cmd void vkCmdFillBuffer(
4494        VkCommandBuffer                             commandBuffer,
4495        VkBuffer                                    dstBuffer,
4496        VkDeviceSize                                dstOffset,
4497        VkDeviceSize                                size,
4498        u32                                         data) {
4499    commandBufferObject := GetCommandBuffer(commandBuffer)
4500    dstBufferObject := GetBuffer(dstBuffer)
4501    assert(commandBufferObject.device == dstBufferObject.device)
4502
4503    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_TRANSFER_BIT)
4504}
4505
4506@threadSafety("app")
4507cmd void vkCmdClearColorImage(
4508        VkCommandBuffer                             commandBuffer,
4509        VkImage                                     image,
4510        VkImageLayout                               imageLayout,
4511        const VkClearColorValue*                    pColor,
4512        u32                                         rangeCount,
4513        const VkImageSubresourceRange*              pRanges) {
4514    commandBufferObject := GetCommandBuffer(commandBuffer)
4515    imageObject := GetImage(image)
4516    assert(commandBufferObject.device == imageObject.device)
4517
4518    ranges := pRanges[0:rangeCount]
4519    for i in (0 .. rangeCount) {
4520        range := ranges[i]
4521    }
4522
4523    bindCommandBuffer(commandBuffer, image, imageObject.memory)
4524
4525    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4526}
4527
4528@threadSafety("app")
4529cmd void vkCmdClearDepthStencilImage(
4530        VkCommandBuffer                             commandBuffer,
4531        VkImage                                     image,
4532        VkImageLayout                               imageLayout,
4533        const VkClearDepthStencilValue*             pDepthStencil,
4534        u32                                         rangeCount,
4535        const VkImageSubresourceRange*              pRanges) {
4536    commandBufferObject := GetCommandBuffer(commandBuffer)
4537    imageObject := GetImage(image)
4538    assert(commandBufferObject.device == imageObject.device)
4539
4540    ranges := pRanges[0:rangeCount]
4541    for i in (0 .. rangeCount) {
4542        range := ranges[i]
4543    }
4544
4545    bindCommandBuffer(commandBuffer, image, imageObject.memory)
4546
4547    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4548}
4549
4550@threadSafety("app")
4551cmd void vkCmdClearAttachments(
4552        VkCommandBuffer                             commandBuffer,
4553        u32                                         attachmentCount,
4554        const VkClearAttachment*                    pAttachments,
4555        u32                                         rectCount,
4556        const VkClearRect*                          pRects) {
4557    commandBufferObject := GetCommandBuffer(commandBuffer)
4558
4559    rects := pRects[0:rectCount]
4560    for i in (0 .. rectCount) {
4561        rect := rects[i]
4562    }
4563
4564    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4565}
4566
4567@threadSafety("app")
4568cmd void vkCmdResolveImage(
4569        VkCommandBuffer                             commandBuffer,
4570        VkImage                                     srcImage,
4571        VkImageLayout                               srcImageLayout,
4572        VkImage                                     dstImage,
4573        VkImageLayout                               dstImageLayout,
4574        u32                                         regionCount,
4575        const VkImageResolve*                       pRegions) {
4576    commandBufferObject := GetCommandBuffer(commandBuffer)
4577    srcImageObject := GetImage(srcImage)
4578    dstImageObject := GetImage(dstImage)
4579    assert(commandBufferObject.device == srcImageObject.device)
4580    assert(commandBufferObject.device == dstImageObject.device)
4581
4582    regions := pRegions[0:regionCount]
4583    for i in (0 .. regionCount) {
4584        region := regions[i]
4585    }
4586
4587    bindCommandBuffer(commandBuffer, srcImage, srcImageObject.memory)
4588    bindCommandBuffer(commandBuffer, dstImage, dstImageObject.memory)
4589
4590    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4591}
4592
4593@threadSafety("app")
4594cmd void vkCmdSetEvent(
4595        VkCommandBuffer                             commandBuffer,
4596        VkEvent                                     event,
4597        VkPipelineStageFlags                        stageMask) {
4598    commandBufferObject := GetCommandBuffer(commandBuffer)
4599    eventObject := GetEvent(event)
4600    assert(commandBufferObject.device == eventObject.device)
4601}
4602
4603@threadSafety("app")
4604cmd void vkCmdResetEvent(
4605        VkCommandBuffer                             commandBuffer,
4606        VkEvent                                     event,
4607        VkPipelineStageFlags                        stageMask) {
4608    commandBufferObject := GetCommandBuffer(commandBuffer)
4609    eventObject := GetEvent(event)
4610    assert(commandBufferObject.device == eventObject.device)
4611}
4612
4613@threadSafety("app")
4614cmd void vkCmdWaitEvents(
4615        VkCommandBuffer                             commandBuffer,
4616        u32                                         eventCount,
4617        const VkEvent*                              pEvents,
4618        VkPipelineStageFlags                        srcStageMask,
4619        VkPipelineStageFlags                        dstStageMask,
4620        u32                                         memoryBarrierCount,
4621        const VkMemoryBarrier*                      pMemoryBarriers,
4622        u32                                         bufferMemoryBarrierCount,
4623        const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
4624        u32                                         imageMemoryBarrierCount,
4625        const VkImageMemoryBarrier*                 pImageMemoryBarriers) {
4626    commandBufferObject := GetCommandBuffer(commandBuffer)
4627
4628    events := pEvents[0:eventCount]
4629    for i in (0 .. eventCount) {
4630        event := events[i]
4631        eventObject := GetEvent(event)
4632        assert(commandBufferObject.device == eventObject.device)
4633    }
4634
4635    memoryBarriers := pMemoryBarriers[0:memoryBarrierCount]
4636    for i in (0 .. memoryBarrierCount) {
4637        memoryBarrier := memoryBarriers[i]
4638    }
4639    bufferMemoryBarriers := pBufferMemoryBarriers[0:bufferMemoryBarrierCount]
4640    for i in (0 .. bufferMemoryBarrierCount) {
4641        bufferMemoryBarrier := bufferMemoryBarriers[i]
4642        bufferObject := GetBuffer(bufferMemoryBarrier.buffer)
4643        assert(bufferObject.device == commandBufferObject.device)
4644    }
4645    imageMemoryBarriers := pImageMemoryBarriers[0:imageMemoryBarrierCount]
4646    for i in (0 .. imageMemoryBarrierCount) {
4647        imageMemoryBarrier := imageMemoryBarriers[i]
4648        imageObject := GetImage(imageMemoryBarrier.image)
4649        assert(imageObject.device == commandBufferObject.device)
4650    }
4651}
4652
4653@threadSafety("app")
4654cmd void vkCmdPipelineBarrier(
4655        VkCommandBuffer                             commandBuffer,
4656        VkPipelineStageFlags                        srcStageMask,
4657        VkPipelineStageFlags                        dstStageMask,
4658        VkDependencyFlags                           dependencyFlags,
4659        u32                                         memoryBarrierCount,
4660        const VkMemoryBarrier*                      pMemoryBarriers,
4661        u32                                         bufferMemoryBarrierCount,
4662        const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
4663        u32                                         imageMemoryBarrierCount,
4664        const VkImageMemoryBarrier*                 pImageMemoryBarriers) {
4665    commandBufferObject := GetCommandBuffer(commandBuffer)
4666
4667    memoryBarriers := pMemoryBarriers[0:memoryBarrierCount]
4668    for i in (0 .. memoryBarrierCount) {
4669        memoryBarrier := memoryBarriers[i]
4670    }
4671    bufferMemoryBarriers := pBufferMemoryBarriers[0:bufferMemoryBarrierCount]
4672    for i in (0 .. bufferMemoryBarrierCount) {
4673        bufferMemoryBarrier := bufferMemoryBarriers[i]
4674        bufferObject := GetBuffer(bufferMemoryBarrier.buffer)
4675        assert(bufferObject.device == commandBufferObject.device)
4676    }
4677    imageMemoryBarriers := pImageMemoryBarriers[0:imageMemoryBarrierCount]
4678    for i in (0 .. imageMemoryBarrierCount) {
4679        imageMemoryBarrier := imageMemoryBarriers[i]
4680        imageObject := GetImage(imageMemoryBarrier.image)
4681        assert(imageObject.device == commandBufferObject.device)
4682    }
4683}
4684
4685@threadSafety("app")
4686cmd void vkCmdBeginQuery(
4687        VkCommandBuffer                             commandBuffer,
4688        VkQueryPool                                 queryPool,
4689        u32                                         query,
4690        VkQueryControlFlags                         flags) {
4691    commandBufferObject := GetCommandBuffer(commandBuffer)
4692    queryPoolObject := GetQueryPool(queryPool)
4693    assert(commandBufferObject.device == queryPoolObject.device)
4694}
4695
4696@threadSafety("app")
4697cmd void vkCmdEndQuery(
4698        VkCommandBuffer                             commandBuffer,
4699        VkQueryPool                                 queryPool,
4700        u32                                         query) {
4701    commandBufferObject := GetCommandBuffer(commandBuffer)
4702    queryPoolObject := GetQueryPool(queryPool)
4703    assert(commandBufferObject.device == queryPoolObject.device)
4704}
4705
4706@threadSafety("app")
4707cmd void vkCmdResetQueryPool(
4708        VkCommandBuffer                             commandBuffer,
4709        VkQueryPool                                 queryPool,
4710        u32                                         firstQuery,
4711        u32                                         queryCount) {
4712    commandBufferObject := GetCommandBuffer(commandBuffer)
4713    queryPoolObject := GetQueryPool(queryPool)
4714    assert(commandBufferObject.device == queryPoolObject.device)
4715}
4716
4717@threadSafety("app")
4718cmd void vkCmdWriteTimestamp(
4719        VkCommandBuffer                             commandBuffer,
4720        VkPipelineStageFlagBits                     pipelineStage,
4721        VkQueryPool                                 queryPool,
4722        u32                                         query) {
4723    commandBufferObject := GetCommandBuffer(commandBuffer)
4724    queryPoolObject := GetQueryPool(queryPool)
4725    assert(commandBufferObject.device == queryPoolObject.device)
4726}
4727
4728@threadSafety("app")
4729cmd void vkCmdCopyQueryPoolResults(
4730        VkCommandBuffer                             commandBuffer,
4731        VkQueryPool                                 queryPool,
4732        u32                                         firstQuery,
4733        u32                                         queryCount,
4734        VkBuffer                                    dstBuffer,
4735        VkDeviceSize                                dstOffset,
4736        VkDeviceSize                                stride,
4737        VkQueryResultFlags                          flags) {
4738    commandBufferObject := GetCommandBuffer(commandBuffer)
4739    queryPoolObject := GetQueryPool(queryPool)
4740    dstBufferObject := GetBuffer(dstBuffer)
4741    assert(commandBufferObject.device == queryPoolObject.device)
4742    assert(commandBufferObject.device == dstBufferObject.device)
4743}
4744
4745cmd void vkCmdPushConstants(
4746        VkCommandBuffer                             commandBuffer,
4747        VkPipelineLayout                            layout,
4748        VkShaderStageFlags                          stageFlags,
4749        u32                                         offset,
4750        u32                                         size,
4751        const void*                                 pValues) {
4752    commandBufferObject := GetCommandBuffer(commandBuffer)
4753    layoutObject := GetPipelineLayout(layout)
4754    assert(commandBufferObject.device == layoutObject.device)
4755}
4756
4757@threadSafety("app")
4758cmd void vkCmdBeginRenderPass(
4759        VkCommandBuffer                             commandBuffer,
4760        const VkRenderPassBeginInfo*                pRenderPassBegin,
4761        VkSubpassContents                           contents) {
4762    commandBufferObject := GetCommandBuffer(commandBuffer)
4763    renderPassObject := GetRenderPass(pRenderPassBegin.renderPass)
4764    framebufferObject := GetFramebuffer(pRenderPassBegin.framebuffer)
4765    assert(commandBufferObject.device == renderPassObject.device)
4766    assert(commandBufferObject.device == framebufferObject.device)
4767
4768    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4769}
4770
4771cmd void vkCmdNextSubpass(
4772        VkCommandBuffer                             commandBuffer,
4773        VkSubpassContents                           contents) {
4774    commandBufferObject := GetCommandBuffer(commandBuffer)
4775}
4776
4777@threadSafety("app")
4778cmd void vkCmdEndRenderPass(
4779        VkCommandBuffer                             commandBuffer) {
4780    commandBufferObject := GetCommandBuffer(commandBuffer)
4781
4782    commandBufferObject.queueFlags = AddQueueFlag(commandBufferObject.queueFlags, VK_QUEUE_GRAPHICS_BIT)
4783}
4784
4785cmd void vkCmdExecuteCommands(
4786        VkCommandBuffer                             commandBuffer,
4787        u32                                         commandBufferCount,
4788        const VkCommandBuffer*                      pCommandBuffers) {
4789    commandBufferObject := GetCommandBuffer(commandBuffer)
4790
4791    commandBuffers := pCommandBuffers[0:commandBufferCount]
4792    for i in (0 .. commandBufferCount) {
4793        secondaryCommandBuffer := commandBuffers[i]
4794        secondaryCommandBufferObject := GetCommandBuffer(secondaryCommandBuffer)
4795        assert(commandBufferObject.device == secondaryCommandBufferObject.device)
4796    }
4797}
4798
4799@extension("VK_KHR_surface")
4800cmd void vkDestroySurfaceKHR(
4801        VkInstance                                  instance,
4802        VkSurfaceKHR                                surface,
4803        const VkAllocationCallbacks*                pAllocator) {
4804    instanceObject := GetInstance(instance)
4805    surfaceObject := GetSurface(surface)
4806    assert(surfaceObject.instance == instance)
4807
4808    State.Surfaces[surface] = null
4809}
4810
4811@extension("VK_KHR_surface")
4812cmd VkResult vkGetPhysicalDeviceSurfaceSupportKHR(
4813        VkPhysicalDevice                            physicalDevice,
4814        u32                                         queueFamilyIndex,
4815        VkSurfaceKHR                                surface,
4816        VkBool32*                                   pSupported) {
4817    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4818
4819    return ?
4820}
4821
4822@extension("VK_KHR_surface")
4823cmd VkResult vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
4824        VkPhysicalDevice                            physicalDevice,
4825        VkSurfaceKHR                                surface,
4826        VkSurfaceCapabilitiesKHR*                   pSurfaceCapabilities) {
4827    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4828
4829    surfaceCapabilities := ?
4830    pSurfaceCapabilities[0] = surfaceCapabilities
4831
4832    return ?
4833}
4834
4835@extension("VK_KHR_surface")
4836cmd VkResult vkGetPhysicalDeviceSurfaceFormatsKHR(
4837        VkPhysicalDevice                            physicalDevice,
4838        VkSurfaceKHR                                surface,
4839        u32*                                        pSurfaceFormatCount,
4840        VkSurfaceFormatKHR*                         pSurfaceFormats) {
4841    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4842
4843    count := as!u32(?)
4844    pSurfaceFormatCount[0] = count
4845    surfaceFormats := pSurfaceFormats[0:count]
4846
4847    for i in (0 .. count) {
4848        surfaceFormat := ?
4849        surfaceFormats[i] = surfaceFormat
4850    }
4851
4852    return ?
4853}
4854
4855@extension("VK_KHR_surface")
4856cmd VkResult vkGetPhysicalDeviceSurfacePresentModesKHR(
4857        VkPhysicalDevice                            physicalDevice,
4858        VkSurfaceKHR                                surface,
4859        u32*                                        pPresentModeCount,
4860        VkPresentModeKHR*                           pPresentModes) {
4861    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4862
4863    count := as!u32(?)
4864    pPresentModeCount[0] = count
4865    presentModes := pPresentModes[0:count]
4866
4867    for i in (0 .. count) {
4868        presentMode := ?
4869        presentModes[i] = presentMode
4870    }
4871
4872    return ?
4873}
4874
4875@extension("VK_KHR_swapchain")
4876cmd VkResult vkCreateSwapchainKHR(
4877        VkDevice                                 device,
4878        const VkSwapchainCreateInfoKHR*          pCreateInfo,
4879        const VkAllocationCallbacks*             pAllocator,
4880        VkSwapchainKHR*                          pSwapchain) {
4881    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR)
4882    deviceObject := GetDevice(device)
4883
4884    swapchain := ?
4885    pSwapchain[0] = swapchain
4886    State.Swapchains[swapchain] = new!SwapchainObject(device: device)
4887
4888    return ?
4889}
4890
4891@extension("VK_KHR_swapchain")
4892cmd void vkDestroySwapchainKHR(
4893        VkDevice                                 device,
4894        VkSwapchainKHR                           swapchain,
4895        const VkAllocationCallbacks*             pAllocator) {
4896    deviceObject := GetDevice(device)
4897    swapchainObject := GetSwapchain(swapchain)
4898    assert(swapchainObject.device == device)
4899
4900    State.Swapchains[swapchain] = null
4901}
4902
4903@extension("VK_KHR_swapchain")
4904cmd VkResult vkGetSwapchainImagesKHR(
4905        VkDevice                                 device,
4906        VkSwapchainKHR                           swapchain,
4907        u32*                                     pSwapchainImageCount,
4908        VkImage*                                 pSwapchainImages) {
4909    deviceObject := GetDevice(device)
4910
4911    count := as!u32(?)
4912    pSwapchainImageCount[0] = count
4913    swapchainImages := pSwapchainImages[0:count]
4914
4915    for i in (0 .. count) {
4916        swapchainImage := ?
4917        swapchainImages[i] = swapchainImage
4918        State.Images[swapchainImage] = new!ImageObject(device: device)
4919    }
4920
4921    return ?
4922}
4923
4924@extension("VK_KHR_swapchain")
4925cmd VkResult vkAcquireNextImageKHR(
4926        VkDevice                                 device,
4927        VkSwapchainKHR                           swapchain,
4928        u64                                      timeout,
4929        VkSemaphore                              semaphore,
4930        VkFence                                  fence,
4931        u32*                                     pImageIndex) {
4932    deviceObject := GetDevice(device)
4933    swapchainObject := GetSwapchain(swapchain)
4934
4935    imageIndex := ?
4936    pImageIndex[0] = imageIndex
4937
4938    return ?
4939}
4940
4941@extension("VK_KHR_swapchain")
4942cmd VkResult vkQueuePresentKHR(
4943        VkQueue                                  queue,
4944        const VkPresentInfoKHR*                  pPresentInfo) {
4945    queueObject := GetQueue(queue)
4946
4947    presentInfo := ?
4948    pPresentInfo[0] = presentInfo
4949
4950    return ?
4951}
4952
4953@extension("VK_KHR_display")
4954cmd VkResult vkGetPhysicalDeviceDisplayPropertiesKHR(
4955        VkPhysicalDevice                        physicalDevice,
4956        u32*                                    pPropertyCount,
4957        VkDisplayPropertiesKHR*                 pProperties) {
4958    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4959    return ?
4960}
4961
4962@extension("VK_KHR_display")
4963cmd VkResult vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
4964        VkPhysicalDevice                        physicalDevice,
4965        u32*                                    pPropertyCount,
4966        VkDisplayPlanePropertiesKHR*            pProperties) {
4967    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4968    return ?
4969}
4970
4971@extension("VK_KHR_display")
4972cmd VkResult vkGetDisplayPlaneSupportedDisplaysKHR(
4973        VkPhysicalDevice                        physicalDevice,
4974        u32                                     planeIndex,
4975        u32*                                    pDisplayCount,
4976        VkDisplayKHR*                           pDisplays) {
4977    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4978    return ?
4979}
4980
4981@extension("VK_KHR_display")
4982cmd VkResult vkGetDisplayModePropertiesKHR(
4983        VkPhysicalDevice                        physicalDevice,
4984        VkDisplayKHR                            display,
4985        u32*                                    pPropertyCount,
4986        VkDisplayModePropertiesKHR*             pProperties) {
4987    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4988    return ?
4989}
4990
4991@extension("VK_KHR_display")
4992cmd VkResult vkCreateDisplayModeKHR(
4993        VkPhysicalDevice                        physicalDevice,
4994        VkDisplayKHR                            display,
4995        const VkDisplayModeCreateInfoKHR*       pCreateInfo,
4996        const VkAllocationCallbacks*            pAllocator,
4997        VkDisplayModeKHR*                       pMode) {
4998    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4999    return ?
5000}
5001
5002@extension("VK_KHR_display")
5003cmd VkResult vkGetDisplayPlaneCapabilitiesKHR(
5004        VkPhysicalDevice                        physicalDevice,
5005        VkDisplayModeKHR                        mode,
5006        u32                                     planeIndex,
5007        VkDisplayPlaneCapabilitiesKHR*          pCapabilities) {
5008    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
5009    return ?
5010}
5011
5012@extension("VK_KHR_display")
5013cmd VkResult vkCreateDisplayPlaneSurfaceKHR(
5014        VkInstance                              instance,
5015        const VkDisplaySurfaceCreateInfoKHR*    pCreateInfo,
5016        const VkAllocationCallbacks*            pAllocator,
5017        VkSurfaceKHR*                           pSurface) {
5018    return ?
5019}
5020
5021@extension("VK_KHR_display_swapchain")
5022cmd VkResult vkCreateSharedSwapchainsKHR(
5023        VkDevice                                device,
5024        u32                                     swapchainCount,
5025        const VkSwapchainCreateInfoKHR*         pCreateInfos,
5026        const VkAllocationCallbacks*            pAllocator,
5027        VkSwapchainKHR*                         pSwapchains) {
5028    return ?
5029}
5030
5031@extension("VK_KHR_xlib_surface")
5032cmd VkResult vkCreateXlibSurfaceKHR(
5033        VkInstance                              instance,
5034        const VkXlibSurfaceCreateInfoKHR*       pCreateInfo,
5035        const VkAllocationCallbacks*            pAllocator,
5036        VkSurfaceKHR*                           pSurface) {
5037    instanceObject := GetInstance(instance)
5038    return ?
5039}
5040
5041@extension("VK_KHR_xlib_surface")
5042cmd VkBool32 vkGetPhysicalDeviceXlibPresentationSupportKHR(
5043        VkPhysicalDevice                        physicalDevice,
5044        u32                                     queueFamilyIndex,
5045        platform.Display*                       dpy,
5046        platform.VisualID                       visualID) {
5047    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
5048    return ?
5049}
5050
5051@extension("VK_KHR_xcb_surface")
5052cmd VkResult vkCreateXcbSurfaceKHR(
5053        VkInstance                              instance,
5054        const VkXcbSurfaceCreateInfoKHR*        pCreateInfo,
5055        const VkAllocationCallbacks*            pAllocator,
5056        VkSurfaceKHR*                           pSurface) {
5057    instanceObject := GetInstance(instance)
5058    return ?
5059}
5060
5061@extension("VK_KHR_xcb_surface")
5062cmd VkBool32 vkGetPhysicalDeviceXcbPresentationSupportKHR(
5063        VkPhysicalDevice                        physicalDevice,
5064        u32                                     queueFamilyIndex,
5065        platform.xcb_connection_t*              connection,
5066        platform.xcb_visualid_t                 visual_id) {
5067    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
5068    return ?
5069}
5070
5071@extension("VK_KHR_wayland_surface")
5072cmd VkResult vkCreateWaylandSurfaceKHR(
5073        VkInstance                              instance,
5074        const VkWaylandSurfaceCreateInfoKHR*    pCreateInfo,
5075        const VkAllocationCallbacks*            pAllocator,
5076        VkSurfaceKHR*                           pSurface) {
5077    instanceObject := GetInstance(instance)
5078    return ?
5079}
5080
5081@extension("VK_KHR_wayland_surface")
5082cmd VkBool32 vkGetPhysicalDeviceWaylandPresentationSupportKHR(
5083        VkPhysicalDevice                        physicalDevice,
5084        u32                                     queueFamilyIndex,
5085        platform.wl_display*                    display) {
5086    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
5087    return ?
5088}
5089
5090@extension("VK_KHR_mir_surface")
5091cmd VkResult vkCreateMirSurfaceKHR(
5092        VkInstance                              instance,
5093        const VkMirSurfaceCreateInfoKHR*        pCreateInfo,
5094        const VkAllocationCallbacks*            pAllocator,
5095        VkSurfaceKHR*                           pSurface) {
5096    instanceObject := GetInstance(instance)
5097    return ?
5098}
5099
5100@extension("VK_KHR_mir_surface")
5101cmd VkBool32 vkGetPhysicalDeviceMirPresentationSupportKHR(
5102        VkPhysicalDevice                        physicalDevice,
5103        u32                                     queueFamilyIndex,
5104        platform.MirConnection*                 connection) {
5105    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
5106    return ?
5107}
5108
5109@extension("VK_KHR_android_surface")
5110cmd VkResult vkCreateAndroidSurfaceKHR(
5111        VkInstance                              instance,
5112        const VkAndroidSurfaceCreateInfoKHR*    pCreateInfo,
5113        const VkAllocationCallbacks*            pAllocator,
5114        VkSurfaceKHR*                           pSurface) {
5115    instanceObject := GetInstance(instance)
5116    return ?
5117}
5118
5119@extension("VK_KHR_win32_surface")
5120cmd VkResult vkCreateWin32SurfaceKHR(
5121        VkInstance                              instance,
5122        const VkWin32SurfaceCreateInfoKHR*      pCreateInfo,
5123        const VkAllocationCallbacks*            pAllocator,
5124        VkSurfaceKHR*                           pSurface) {
5125    instanceObject := GetInstance(instance)
5126    return ?
5127}
5128
5129@extension("VK_KHR_win32_surface")
5130cmd VkResult vkGetPhysicalDeviceWin32PresentationSupportKHR(
5131        VkPhysicalDevice                        physicalDevice,
5132        u32                                     queueFamilyIndex) {
5133    physicalDeviceObject := GetPhysicalDevice(physicalDevice)    
5134    return ?
5135}
5136
5137@extension("VK_EXT_debug_report")
5138@external type void* PFN_vkDebugReportCallbackEXT
5139@extension("VK_EXT_debug_report")
5140@pfn cmd VkBool32 vkDebugReportCallbackEXT(
5141        VkDebugReportFlagsEXT                   flags,
5142        VkDebugReportObjectTypeEXT              objectType,
5143        u64                                     object,
5144        platform.size_t                         location,
5145        s32                                     messageCode,
5146        const char*                             pLayerPrefix,
5147        const char*                             pMessage,
5148        void*                                   pUserData) {
5149    return ?
5150}
5151
5152@extension("VK_EXT_debug_report")
5153cmd VkResult vkCreateDebugReportCallbackEXT(
5154        VkInstance                                  instance,
5155        const VkDebugReportCallbackCreateInfoEXT*   pCreateInfo,
5156        const VkAllocationCallbacks*                pAllocator,
5157        VkDebugReportCallbackEXT*                   pCallback) {
5158    return ?
5159}
5160
5161@extension("VK_EXT_debug_report")
5162cmd void vkDestroyDebugReportCallbackEXT(
5163        VkInstance                                  instance,
5164        VkDebugReportCallbackEXT                    callback,
5165        const VkAllocationCallbacks*                pAllocator) {
5166}
5167
5168@extension("VK_EXT_debug_report")
5169cmd void vkDebugReportMessageEXT(
5170        VkInstance                                  instance,
5171        VkDebugReportFlagsEXT                       flags,
5172        VkDebugReportObjectTypeEXT                  objectType,
5173        u64                                         object,
5174        platform.size_t                             location,
5175        s32                                         messageCode,
5176        const char*                                 pLayerPrefix,
5177        const char*                                 pMessage) {
5178}
5179
5180
5181////////////////
5182// Validation //
5183////////////////
5184
5185extern void validate(string layerName, bool condition, string message)
5186
5187
5188/////////////////////////////
5189// Internal State Tracking //
5190/////////////////////////////
5191
5192StateObject State
5193
5194@internal class StateObject {
5195    // Dispatchable objects.
5196    map!(VkInstance,       ref!InstanceObject)       Instances
5197    map!(VkPhysicalDevice, ref!PhysicalDeviceObject) PhysicalDevices
5198    map!(VkDevice,         ref!DeviceObject)         Devices
5199    map!(VkQueue,          ref!QueueObject)          Queues
5200    map!(VkCommandBuffer,  ref!CommandBufferObject)  CommandBuffers
5201
5202    // Non-dispatchable objects.
5203    map!(VkDeviceMemory,             ref!DeviceMemoryObject)             DeviceMemories
5204    map!(VkBuffer,                   ref!BufferObject)                   Buffers
5205    map!(VkBufferView,               ref!BufferViewObject)               BufferViews
5206    map!(VkImage,                    ref!ImageObject)                    Images
5207    map!(VkImageView,                ref!ImageViewObject)                ImageViews
5208    map!(VkShaderModule,             ref!ShaderModuleObject)             ShaderModules
5209    map!(VkPipeline,                 ref!PipelineObject)                 Pipelines
5210    map!(VkPipelineLayout,           ref!PipelineLayoutObject)           PipelineLayouts
5211    map!(VkSampler,                  ref!SamplerObject)                  Samplers
5212    map!(VkDescriptorSet,            ref!DescriptorSetObject)            DescriptorSets
5213    map!(VkDescriptorSetLayout,      ref!DescriptorSetLayoutObject)      DescriptorSetLayouts
5214    map!(VkDescriptorPool,           ref!DescriptorPoolObject)           DescriptorPools
5215    map!(VkFence,                    ref!FenceObject)                    Fences
5216    map!(VkSemaphore,                ref!SemaphoreObject)                Semaphores
5217    map!(VkEvent,                    ref!EventObject)                    Events
5218    map!(VkQueryPool,                ref!QueryPoolObject)                QueryPools
5219    map!(VkFramebuffer,              ref!FramebufferObject)              Framebuffers
5220    map!(VkRenderPass,               ref!RenderPassObject)               RenderPasses
5221    map!(VkPipelineCache,            ref!PipelineCacheObject)            PipelineCaches
5222    map!(VkCommandPool,              ref!CommandPoolObject)              CommandPools
5223    map!(VkSurfaceKHR,               ref!SurfaceObject)                  Surfaces
5224    map!(VkSwapchainKHR,             ref!SwapchainObject)                Swapchains
5225}
5226
5227@internal class InstanceObject {
5228}
5229
5230@internal class PhysicalDeviceObject {
5231    VkInstance instance
5232}
5233
5234@internal class DeviceObject {
5235    VkPhysicalDevice physicalDevice
5236}
5237
5238@internal class QueueObject {
5239    VkDevice      device
5240    VkQueueFlags  flags
5241}
5242
5243@internal class CommandBufferObject {
5244    VkDevice                  device
5245    map!(u64, VkDeviceMemory) boundObjects
5246    VkQueueFlags              queueFlags
5247}
5248
5249@internal class DeviceMemoryObject {
5250    VkDevice                                device
5251    VkDeviceSize                            allocationSize
5252    map!(u64, VkDeviceSize)                 boundObjects
5253    map!(VkCommandBuffer, VkCommandBuffer)  boundCommandBuffers
5254}
5255
5256@internal class BufferObject {
5257    VkDevice              device
5258    VkDeviceMemory        memory
5259    VkDeviceSize          memoryOffset
5260}
5261
5262@internal class BufferViewObject {
5263    VkDevice      device
5264    VkBuffer      buffer
5265}
5266
5267@internal class ImageObject {
5268    VkDevice              device
5269    VkDeviceMemory        memory
5270    VkDeviceSize          memoryOffset
5271}
5272
5273@internal class ImageViewObject {
5274    VkDevice      device
5275    VkImage       image
5276}
5277
5278@internal class ShaderObject {
5279    VkDevice      device
5280}
5281
5282@internal class ShaderModuleObject {
5283    VkDevice      device
5284}
5285
5286@internal class PipelineObject {
5287    VkDevice      device
5288}
5289
5290@internal class PipelineLayoutObject {
5291    VkDevice      device
5292}
5293
5294@internal class SamplerObject {
5295    VkDevice      device
5296}
5297
5298@internal class DescriptorSetObject {
5299    VkDevice      device
5300}
5301
5302@internal class DescriptorSetLayoutObject {
5303    VkDevice      device
5304}
5305
5306@internal class DescriptorPoolObject {
5307    VkDevice      device
5308}
5309
5310@internal class FenceObject {
5311    VkDevice      device
5312    bool          signaled
5313}
5314
5315@internal class SemaphoreObject {
5316    VkDevice      device
5317}
5318
5319@internal class EventObject {
5320    VkDevice      device
5321}
5322
5323@internal class QueryPoolObject {
5324    VkDevice      device
5325}
5326
5327@internal class FramebufferObject {
5328    VkDevice      device
5329}
5330
5331@internal class RenderPassObject {
5332    VkDevice      device
5333}
5334
5335@internal class PipelineCacheObject {
5336    VkDevice      device
5337}
5338
5339@internal class CommandPoolObject {
5340    VkDevice      device
5341}
5342
5343@internal class SurfaceObject {
5344    VkInstance    instance
5345}
5346
5347@internal class SwapchainObject {
5348    VkDevice      device
5349}
5350
5351macro ref!InstanceObject GetInstance(VkInstance instance) {
5352    assert(instance in State.Instances)
5353    return State.Instances[instance]
5354}
5355
5356macro ref!PhysicalDeviceObject GetPhysicalDevice(VkPhysicalDevice physicalDevice) {
5357    assert(physicalDevice in State.PhysicalDevices)
5358    return State.PhysicalDevices[physicalDevice]
5359}
5360
5361macro ref!DeviceObject GetDevice(VkDevice device) {
5362    assert(device in State.Devices)
5363    return State.Devices[device]
5364}
5365
5366macro ref!QueueObject GetQueue(VkQueue queue) {
5367    assert(queue in State.Queues)
5368    return State.Queues[queue]
5369}
5370
5371macro ref!CommandBufferObject GetCommandBuffer(VkCommandBuffer commandBuffer) {
5372    assert(commandBuffer in State.CommandBuffers)
5373    return State.CommandBuffers[commandBuffer]
5374}
5375
5376macro ref!DeviceMemoryObject GetDeviceMemory(VkDeviceMemory memory) {
5377    assert(memory in State.DeviceMemories)
5378    return State.DeviceMemories[memory]
5379}
5380
5381macro ref!BufferObject GetBuffer(VkBuffer buffer) {
5382    assert(buffer in State.Buffers)
5383    return State.Buffers[buffer]
5384}
5385
5386macro ref!BufferViewObject GetBufferView(VkBufferView bufferView) {
5387    assert(bufferView in State.BufferViews)
5388    return State.BufferViews[bufferView]
5389}
5390
5391macro ref!ImageObject GetImage(VkImage image) {
5392    assert(image in State.Images)
5393    return State.Images[image]
5394}
5395
5396macro ref!ImageViewObject GetImageView(VkImageView imageView) {
5397    assert(imageView in State.ImageViews)
5398    return State.ImageViews[imageView]
5399}
5400
5401macro ref!ShaderModuleObject GetShaderModule(VkShaderModule shaderModule) {
5402    assert(shaderModule in State.ShaderModules)
5403    return State.ShaderModules[shaderModule]
5404}
5405
5406macro ref!PipelineObject GetPipeline(VkPipeline pipeline) {
5407    assert(pipeline in State.Pipelines)
5408    return State.Pipelines[pipeline]
5409}
5410
5411macro ref!PipelineLayoutObject GetPipelineLayout(VkPipelineLayout pipelineLayout) {
5412    assert(pipelineLayout in State.PipelineLayouts)
5413    return State.PipelineLayouts[pipelineLayout]
5414}
5415
5416macro ref!SamplerObject GetSampler(VkSampler sampler) {
5417    assert(sampler in State.Samplers)
5418    return State.Samplers[sampler]
5419}
5420
5421macro ref!DescriptorSetObject GetDescriptorSet(VkDescriptorSet descriptorSet) {
5422    assert(descriptorSet in State.DescriptorSets)
5423    return State.DescriptorSets[descriptorSet]
5424}
5425
5426macro ref!DescriptorSetLayoutObject GetDescriptorSetLayout(VkDescriptorSetLayout descriptorSetLayout) {
5427    assert(descriptorSetLayout in State.DescriptorSetLayouts)
5428    return State.DescriptorSetLayouts[descriptorSetLayout]
5429}
5430
5431macro ref!DescriptorPoolObject GetDescriptorPool(VkDescriptorPool descriptorPool) {
5432    assert(descriptorPool in State.DescriptorPools)
5433    return State.DescriptorPools[descriptorPool]
5434}
5435
5436macro ref!FenceObject GetFence(VkFence fence) {
5437    assert(fence in State.Fences)
5438    return State.Fences[fence]
5439}
5440
5441macro ref!SemaphoreObject GetSemaphore(VkSemaphore semaphore) {
5442    assert(semaphore in State.Semaphores)
5443    return State.Semaphores[semaphore]
5444}
5445
5446macro ref!EventObject GetEvent(VkEvent event) {
5447    assert(event in State.Events)
5448    return State.Events[event]
5449}
5450
5451macro ref!QueryPoolObject GetQueryPool(VkQueryPool queryPool) {
5452    assert(queryPool in State.QueryPools)
5453    return State.QueryPools[queryPool]
5454}
5455
5456macro ref!FramebufferObject GetFramebuffer(VkFramebuffer framebuffer) {
5457    assert(framebuffer in State.Framebuffers)
5458    return State.Framebuffers[framebuffer]
5459}
5460
5461macro ref!RenderPassObject GetRenderPass(VkRenderPass renderPass) {
5462    assert(renderPass in State.RenderPasses)
5463    return State.RenderPasses[renderPass]
5464}
5465
5466macro ref!PipelineCacheObject GetPipelineCache(VkPipelineCache pipelineCache) {
5467    assert(pipelineCache in State.PipelineCaches)
5468    return State.PipelineCaches[pipelineCache]
5469}
5470
5471macro ref!CommandPoolObject GetCommandPool(VkCommandPool commandPool) {
5472    assert(commandPool in State.CommandPools)
5473    return State.CommandPools[commandPool]
5474}
5475
5476macro ref!SurfaceObject GetSurface(VkSurfaceKHR surface) {
5477    assert(surface in State.Surfaces)
5478    return State.Surfaces[surface]
5479}
5480
5481macro ref!SwapchainObject GetSwapchain(VkSwapchainKHR swapchain) {
5482    assert(swapchain in State.Swapchains)
5483    return State.Swapchains[swapchain]
5484}
5485
5486macro VkQueueFlags AddQueueFlag(VkQueueFlags flags, VkQueueFlagBits bit) {
5487    return as!VkQueueFlags(as!u32(flags) | as!u32(bit))
5488}
5489