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