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