vulkan.api revision a9bb62b44be381292b893055cd01cdc89ba55c97
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 184
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_BLOCK_BIT               = 0x00000001,
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 u32*                                  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                                         depthBiasConstantFactor
1570    f32                                         depthBiasClamp
1571    f32                                         depthBiasSlopeFactor
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                                    strictLines
1848    VkBool32                                    largePoints                               /// points with size greater than 1
1849    VkBool32                                    alphaToOne                                /// The fragment alpha channel can be forced to maximum representable alpha value
1850    VkBool32                                    multiViewport
1851    VkBool32                                    samplerAnisotropy
1852    VkBool32                                    textureCompressionETC2                    /// ETC texture compression formats
1853    VkBool32                                    textureCompressionASTC_LDR                /// ASTC LDR texture compression formats
1854    VkBool32                                    textureCompressionBC                      /// BC1-7 texture compressed formats
1855    VkBool32                                    occlusionQueryNonConservative             /// non-conservative (exact) occlusion queries
1856    VkBool32                                    pipelineStatisticsQuery                   /// pipeline statistics query
1857    VkBool32                                    vertexSideEffects                         /// storage buffers and images in vertex stage
1858    VkBool32                                    tessellationSideEffects                   /// storage buffers and images in tessellation stage
1859    VkBool32                                    geometrySideEffects                       /// storage buffers and images in geometry stage
1860    VkBool32                                    fragmentSideEffects                       /// storage buffers and images in fragment stage
1861    VkBool32                                    shaderTessellationPointSize               /// tessellation stage can export point size
1862    VkBool32                                    shaderGeometryPointSize                   /// geometry stage can export point size
1863    VkBool32                                    shaderImageGatherExtended                 /// texture gather with run-time values and independent offsets
1864    VkBool32                                    shaderStorageImageExtendedFormats         /// the extended set of formats can be used for storage images
1865    VkBool32                                    shaderStorageImageMultisample             /// multisample images can be used for storage images
1866    VkBool32                                    shaderUniformBufferArrayDynamicIndexing   /// arrays of uniform buffers can be accessed with dynamically uniform indices
1867    VkBool32                                    shaderSampledImageArrayDynamicIndexing    /// arrays of sampled images can be accessed with dynamically uniform indices
1868    VkBool32                                    shaderStorageBufferArrayDynamicIndexing   /// arrays of storage buffers can be accessed with dynamically uniform indices
1869    VkBool32                                    shaderStorageImageArrayDynamicIndexing    /// arrays of storage images can be accessed with dynamically uniform indices
1870    VkBool32                                    shaderClipDistance                        /// clip distance in shaders
1871    VkBool32                                    shaderCullDistance                        /// cull distance in shaders
1872    VkBool32                                    shaderFloat64                             /// 64-bit floats (doubles) in shaders
1873    VkBool32                                    shaderInt64                               /// 64-bit integers in shaders
1874    VkBool32                                    shaderInt16                               /// 16-bit integers in shaders
1875    VkBool32                                    shaderResourceResidency                   /// shader can use texture operations that return resource residency information (requires sparseNonResident support)
1876    VkBool32                                    shaderResourceMinLOD                      /// shader can use texture operations that specify minimum resource LOD
1877    VkBool32                                    sparseBinding                             /// Sparse resources support: Resource memory can be managed at opaque page level rather than object level
1878    VkBool32                                    sparseResidencyBuffer                     /// Sparse resources support: GPU can access partially resident buffers
1879    VkBool32                                    sparseResidencyImage2D                    /// Sparse resources support: GPU can access partially resident 2D (non-MSAA non-DepthStencil) images
1880    VkBool32                                    sparseResidencyImage3D                    /// Sparse resources support: GPU can access partially resident 3D images
1881    VkBool32                                    sparseResidency2Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 2 samples
1882    VkBool32                                    sparseResidency4Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 4 samples
1883    VkBool32                                    sparseResidency8Samples                   /// Sparse resources support: GPU can access partially resident MSAA 2D images with 8 samples
1884    VkBool32                                    sparseResidency16Samples                  /// Sparse resources support: GPU can access partially resident MSAA 2D images with 16 samples
1885    VkBool32                                    sparseResidencyAliased                    /// Sparse resources support: GPU can correctly access data aliased into multiple locations (opt-in)
1886}
1887
1888class VkPhysicalDeviceLimits {
1889    /// resource maximum sizes
1890    u32                                         maxImageDimension1D                       /// max 1D image dimension
1891    u32                                         maxImageDimension2D                       /// max 2D image dimension
1892    u32                                         maxImageDimension3D                       /// max 3D image dimension
1893    u32                                         maxImageDimensionCube                     /// max cubemap image dimension
1894    u32                                         maxImageArrayLayers                       /// max layers for image arrays
1895    VkSampleCountFlags                          sampleCounts                              /// sample counts supported for all images supporting rendering and sampling
1896    u32                                         maxTexelBufferSize                        /// max texel buffer size (bytes)
1897    u32                                         maxUniformBufferRange                     /// max uniform buffer size (bytes)
1898    u32                                         maxStorageBufferRange                     /// max storage buffer size (bytes)
1899    u32                                         maxPushConstantsSize                      /// max size of the push constants pool (bytes)
1900    /// memory limits
1901    u32                                         maxMemoryAllocationCount                  /// max number of device memory allocations supported
1902    VkDeviceSize                                bufferImageGranularity                    /// Granularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage
1903    VkDeviceSize                                sparseAddressSpaceSize                    /// Total address space available for sparse allocations (bytes)
1904    /// descriptor set limits
1905    u32                                         maxBoundDescriptorSets                    /// max number of descriptors sets that can be bound to a pipeline
1906    u32                                         maxPerStageDescriptorSamplers             /// max num of samplers allowed per-stage in a descriptor set
1907    u32                                         maxPerStageDescriptorUniformBuffers       /// max num of uniform buffers allowed per-stage in a descriptor set
1908    u32                                         maxPerStageDescriptorStorageBuffers       /// max num of storage buffers allowed per-stage in a descriptor set
1909    u32                                         maxPerStageDescriptorSampledImages        /// max num of sampled images allowed per-stage in a descriptor set
1910    u32                                         maxPerStageDescriptorStorageImages        /// max num of storage images allowed per-stage in a descriptor set
1911    u32                                         maxDescriptorSetSamplers                  /// max num of samplers allowed in all stages in a descriptor set
1912    u32                                         maxDescriptorSetUniformBuffers            /// max num of uniform buffers allowed in all stages in a descriptor set
1913    u32                                         maxDescriptorSetUniformBuffersDynamic     /// max num of dynamic uniform buffers allowed in all stages in a descriptor set
1914    u32                                         maxDescriptorSetStorageBuffers            /// max num of storage buffers allowed in all stages in a descriptor set
1915    u32                                         maxDescriptorSetStorageBuffersDynamic     /// max num of dynamic storage buffers allowed in all stages in a descriptor set
1916    u32                                         maxDescriptorSetSampledImages             /// max num of sampled images allowed in all stages in a descriptor set
1917    u32                                         maxDescriptorSetStorageImages             /// max num of storage images allowed in all stages in a descriptor set
1918    /// vertex stage limits
1919    u32                                         maxVertexInputAttributes                  /// max num of vertex input attribute slots
1920    u32                                         maxVertexInputBindings                    /// max num of vertex input binding slots
1921    u32                                         maxVertexInputAttributeOffset             /// max vertex input attribute offset added to vertex buffer offset
1922    u32                                         maxVertexInputBindingStride               /// max vertex input binding stride
1923    u32                                         maxVertexOutputComponents                 /// max num of output components written by vertex shader
1924    /// tessellation control stage limits
1925    u32                                         maxTessellationGenLevel                         /// max level supported by tess primitive generator
1926    u32                                         maxTessellationPatchSize                        /// max patch size (vertices)
1927    u32                                         maxTessellationControlPerVertexInputComponents  /// max num of input components per-vertex in TCS
1928    u32                                         maxTessellationControlPerVertexOutputComponents /// max num of output components per-vertex in TCS
1929    u32                                         maxTessellationControlPerPatchOutputComponents  /// max num of output components per-patch in TCS
1930    u32                                         maxTessellationControlTotalOutputComponents     /// max total num of per-vertex and per-patch output components in TCS
1931    u32                                         maxTessellationEvaluationInputComponents        /// max num of input components per vertex in TES
1932    u32                                         maxTessellationEvaluationOutputComponents       /// max num of output components per vertex in TES
1933    /// geometry stage limits
1934    u32                                         maxGeometryShaderInvocations              /// max invocation count supported in geometry shader
1935    u32                                         maxGeometryInputComponents                /// max num of input components read in geometry stage
1936    u32                                         maxGeometryOutputComponents               /// max num of output components written in geometry stage
1937    u32                                         maxGeometryOutputVertices                 /// max num of vertices that can be emitted in geometry stage
1938    u32                                         maxGeometryTotalOutputComponents          /// max total num of components (all vertices) written in geometry stage
1939    /// fragment stage limits
1940    u32                                         maxFragmentInputComponents                /// max num of input compontents read in fragment stage
1941    u32                                         maxFragmentOutputAttachments              /// max num of output attachments written in fragment stage
1942    u32                                         maxFragmentDualSourceAttachments          /// max num of output attachments written when using dual source blending
1943    u32                                         maxFragmentCombinedOutputResources        /// max total num of storage buffers, storage images and output buffers
1944    /// compute stage limits
1945    u32                                         maxComputeSharedMemorySize                /// max total storage size of work group local storage (bytes)
1946    u32[3]                                      maxComputeWorkGroupCount                  /// max num of compute work groups that may be dispatched by a single command (x,y,z)
1947    u32                                         maxComputeWorkGroupInvocations            /// max total compute invocations in a single local work group
1948    u32[3]                                      maxComputeWorkGroupSize                   /// max local size of a compute work group (x,y,z)
1949
1950    u32                                         subPixelPrecisionBits                     /// num bits of subpixel precision in screen x and y
1951    u32                                         subTexelPrecisionBits                     /// num bits of subtexel precision
1952    u32                                         mipmapPrecisionBits                       /// num bits of mipmap precision
1953
1954    u32                                         maxDrawIndexedIndexValue                  /// max index value for indexed draw calls (for 32-bit indices)
1955    u32                                         maxDrawIndirectInstanceCount              /// max instance count for indirect draw calls
1956    VkBool32                                    primitiveRestartForPatches                /// is primitive restart supported for PATCHES
1957
1958    f32                                         maxSamplerLodBias                         /// max absolute sampler level of detail bias
1959    f32                                         maxSamplerAnisotropy                      /// max degree of sampler anisotropy
1960
1961    u32                                         maxViewports                              /// max number of active viewports
1962    u32[2]                                      maxViewportDimensions                     /// max viewport dimensions (x,y)
1963    f32[2]                                      viewportBoundsRange                       /// viewport bounds range (min,max)
1964    u32                                         viewportSubPixelBits                      /// num bits of subpixel precision for viewport
1965
1966    u32                                         minMemoryMapAlignment                     /// min required alignment of pointers returned by MapMemory (bytes)
1967    u32                                         minTexelBufferOffsetAlignment             /// min required alignment for texel buffer offsets (bytes)
1968    u32                                         minUniformBufferOffsetAlignment           /// min required alignment for uniform buffer sizes and offsets (bytes)
1969    u32                                         minStorageBufferOffsetAlignment           /// min required alignment for storage buffer offsets (bytes)
1970
1971    s32                                         minTexelOffset                            /// min texel offset for OpTextureSampleOffset
1972    u32                                         maxTexelOffset                            /// max texel offset for OpTextureSampleOffset
1973    s32                                         minTexelGatherOffset                      /// min texel offset for OpTextureGatherOffset
1974    u32                                         maxTexelGatherOffset                      /// max texel offset for OpTextureGatherOffset
1975    f32                                         minInterpolationOffset                    /// furthest negative offset for interpolateAtOffset
1976    f32                                         maxInterpolationOffset                    /// furthest positive offset for interpolateAtOffset
1977    u32                                         subPixelInterpolationOffsetBits           /// num of subpixel bits for interpolateAtOffset
1978
1979    u32                                         maxFramebufferWidth                       /// max width for a framebuffer
1980    u32                                         maxFramebufferHeight                      /// max height for a framebuffer
1981    u32                                         maxFramebufferLayers                      /// max layer count for a layered framebuffer
1982    u32                                         maxFramebufferColorSamples                /// max color sample count for a framebuffer
1983    u32                                         maxFramebufferDepthSamples                /// max depth sample count for a framebuffer
1984    u32                                         maxFramebufferStencilSamples              /// max stencil sample count for a framebuffer
1985    u32                                         maxColorAttachments                       /// max num of framebuffer color attachments
1986
1987    u32                                         maxSampledImageColorSamples               /// max num of color samples for a non-integer sampled image
1988    u32                                         maxSampledImageDepthSamples               /// max num of depth/stencil samples for a sampled image
1989    u32                                         maxSampledImageIntegerSamples             /// max num of samples supported for an integer image
1990    u32                                         maxStorageImageSamples                    /// max num of samples for a storage image
1991    u32                                         maxSampleMaskWords                        /// max num of sample mask words
1992
1993    f32                                         timestampPeriod
1994
1995    u32                                         maxClipDistances                          /// max number of clip distances
1996    u32                                         maxCullDistances                          /// max number of cull distances
1997    u32                                         maxCombinedClipAndCullDistances           /// max combined number of user clipping
1998
1999    u32                                         discreteQueuePriorities
2000
2001    f32[2]                                      pointSizeRange                            /// range (min,max) of supported point sizes
2002    f32[2]                                      lineWidthRange                            /// range (min,max) of supported line widths
2003    f32                                         pointSizeGranularity                      /// granularity of supported point sizes
2004    f32                                         lineWidthGranularity                      /// granularity of supported line widths
2005
2006    u32                                         recommendedBufferCopyOffsetAlignment
2007    u32                                         recommendedBufferCopyRowPitchAlignment
2008}
2009
2010class VkPhysicalDeviceSparseProperties {
2011    VkBool32                                    residencyStandard2DBlockShape             /// Sparse resources support: GPU will access all 2D (single sample) sparse resources using the standard block shapes (based on pixel format)
2012    VkBool32                                    residencyStandard2DMSBlockShape           /// Sparse resources support: GPU will access all 2D (multisample) sparse resources using the standard block shapes (based on pixel format)
2013    VkBool32                                    residencyStandard3DBlockShape             /// Sparse resources support: GPU will access all 3D sparse resources using the standard block shapes (based on pixel format)
2014    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
2015    VkBool32                                    residencyNonResident                      /// Sparse resources support: GPU can safely access non-resident regions of a resource, read values from read-write resources are undefined
2016    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
2017}
2018
2019class VkSemaphoreCreateInfo {
2020    VkStructureType                             sType      /// Must be VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
2021    const void*                                 pNext      /// Pointer to next structure
2022    VkSemaphoreCreateFlags                      flags      /// Semaphore creation flags
2023}
2024
2025class VkQueryPoolCreateInfo {
2026    VkStructureType                             sType              /// Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
2027    const void*                                 pNext              /// Pointer to next structure
2028    VkQueryType                                 queryType
2029    u32                                         slots
2030    VkQueryPipelineStatisticFlags               pipelineStatistics /// Optional
2031}
2032
2033class VkFramebufferCreateInfo {
2034    VkStructureType                             sType  /// Must be VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
2035    const void*                                 pNext  /// Pointer to next structure
2036    VkRenderPass                                renderPass
2037    u32                                         attachmentCount
2038    const VkImageView*                          pAttachments
2039    u32                                         width
2040    u32                                         height
2041    u32                                         layers
2042}
2043
2044class VkDrawIndirectCmd {
2045    u32                                         vertexCount
2046    u32                                         instanceCount
2047    u32                                         firstVertex
2048    u32                                         firstInstance
2049}
2050
2051class VkDrawIndexedIndirectCmd {
2052    u32                                         indexCount
2053    u32                                         instanceCount
2054    u32                                         firstIndex
2055    s32                                         vertexOffset
2056    u32                                         firstInstance
2057}
2058
2059class VkDispatchIndirectCmd {
2060    u32                                         x
2061    u32                                         y
2062    u32                                         z
2063}
2064
2065@extension("VK_EXT_KHR_swapchain")
2066class VkSurfacePropertiesKHR {
2067    u32                                         minImageCount
2068    u32                                         maxImageCount
2069    VkExtent2D                                  currentExtent
2070    VkExtent2D                                  minImageExtent
2071    VkExtent2D                                  maxImageExtent
2072    VkSurfaceTransformFlagsKHR                  supportedTransforms
2073    VkSurfaceTransformKHR                       currentTransform
2074    u32                                         maxImageArraySize
2075    VkImageUsageFlags                           supportedUsageFlags
2076}
2077
2078@extension("VK_EXT_KHR_swapchain")
2079class VkSurfaceFormatKHR {
2080    VkFormat                                    format
2081    VkColorSpaceKHR                             colorSpace
2082}
2083
2084@extension("VK_EXT_KHR_swapchain")
2085class VkSwapchainCreateInfoKHR {
2086    VkStructureType                             sType
2087    const void*                                 pNext
2088    VkSurfaceKHR                                surface
2089    u32                                         minImageCount
2090    VkFormat                                    imageFormat
2091    VkColorSpaceKHR                             imageColorSpace
2092    VkExtent2D                                  imageExtent
2093    VkImageUsageFlags                           imageUsageFlags
2094    VkSurfaceTransformKHR                       preTransform
2095    u32                                         imageArraySize
2096    VkSharingMode                               sharingMode
2097    u32                                         queueFamilyCount
2098    const u32*                                  pQueueFamilyIndices
2099    VkPresentModeKHR                            presentMode
2100    VkSwapchainKHR                              oldSwapchain
2101    VkBool32                                    clipped
2102}
2103
2104@extension("VK_EXT_KHR_swapchain")
2105class VkPresentInfoKHR {
2106    VkStructureType                             sType
2107    const void*                                 pNext
2108    u32                                         swapchainCount
2109    const VkSwapchainKHR*                       swapchains
2110    const u32*                                  imageIndices
2111}
2112
2113@extension("VK_EXT_KHR_display")
2114class VkDisplayPropertiesKHR {
2115    VkDisplayKHR                                display
2116    const char*                                 displayName
2117    VkExtent2D                                  physicalDimensions
2118    VkExtent2D                                  physicalResolution
2119    VkSurfaceTransformFlagsKHR                  supportedTransforms
2120    u32                                         planeCount
2121    VkBool32                                    planeReorderPossible
2122}
2123
2124@extension("VK_EXT_KHR_display")
2125class VkDisplayTimingKHR {
2126    u32                                         pixelClock
2127    VkExtent2D                                  visibleRegion
2128    VkExtent2D                                  totalRegion
2129    VkExtent2D                                  physicalDimensions
2130    u32                                         hSyncStart
2131    u32                                         hSyncEnd
2132    u32                                         vSyncStart
2133    u32                                         vSyncEnd
2134    VkBool32                                    interlaced
2135    VkBool32                                    doublescan
2136    VkBool32                                    hSyncPos
2137    VkBool32                                    vSyncPos
2138}
2139
2140@extension("VK_EXT_KHR_display")
2141class VkDisplayModePropertiesKHR {
2142    VkDisplayModeKHR                            displayMode
2143    VkDisplayTimingKHR                          timing
2144}
2145
2146@extension("VK_EXT_KHR_display")
2147class VkDisplayModeCreateInfoKHR {
2148    VkStructureType                             sType
2149    const void*                                 pNext
2150    VkDisplayTimingKHR                          timing
2151}
2152
2153@extension("VK_EXT_KHR_display")
2154class VkDisplayPlanePropertiesKHR {
2155    VkDisplayPlaneAlphaFlagsKHR                 supportedAlpha
2156    VkOffset2D                                  minSrcPosition
2157    VkOffset2D                                  maxSrcPosition
2158    VkExtent2D                                  minSrcExtent
2159    VkExtent2D                                  maxSrcExtent
2160    VkOffset2D                                  minDstPosition
2161    VkOffset2D                                  maxDstPosition
2162    VkExtent2D                                  minDstExtent
2163    VkExtent2D                                  maxDstExtent
2164}
2165
2166@extension("VK_EXT_KHR_display")
2167class VkSurfaceDescriptionDisplayPlaneKHR {
2168    VkStructureType                             sType
2169    const void*                                 pNext
2170    VkDisplayModeKHR                            displayMode
2171    u32                                         planeIndex
2172    u32                                         planeStackIndex
2173    VkSurfaceTransformKHR                       transform
2174    f32                                         globalAlpha
2175    VkDisplayPlaneAlphaFlagsKHR                 alphaMode
2176    VkExtent2D                                  imageSize
2177}
2178
2179@extension("VK_EXT_KHR_display_swapchain")
2180class VkDisplaySwapchainCreateInfoKHR {
2181    VkStructureType                             sType
2182    const void*                                 pNext
2183    const VkSwapchainCreateInfoKHR*             pNextSwapchainCreateInfo
2184}
2185
2186@extension("VK_EXT_KHR_display_swapchain")
2187class VkDisplayPresentInfoKHR {
2188    VkStructureType                             sType
2189    const void*                                 pNext
2190    VkRect2D                                    srcRect
2191    VkRect2D                                    dstRect
2192}
2193
2194
2195////////////////
2196//  Commands  //
2197////////////////
2198
2199// Function pointers. TODO: add support for function pointers.
2200
2201@external type void* PFN_vkVoidFunction
2202@pfn cmd void vkVoidFunction() {
2203}
2204
2205@external type void* PFN_vkAllocFunction
2206@pfn cmd void* vkAllocFunction(
2207        void*                                       pUserData,
2208        platform.size_t                             size,
2209        platform.size_t                             alignment,
2210        VkSystemAllocType                           allocType) {
2211    return ?
2212}
2213
2214@external type void* PFN_vkFreeFunction
2215@pfn cmd void vkFreeFunction(
2216        void*                                       pUserData,
2217        void*                                       pMem) {
2218}
2219
2220
2221// Global functions
2222
2223@threadSafety("system")
2224cmd VkResult vkCreateInstance(
2225        const VkInstanceCreateInfo*                 pCreateInfo,
2226        VkInstance*                                 pInstance) {
2227    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
2228
2229    instance := ?
2230    pInstance[0] = instance
2231    State.Instances[instance] = new!InstanceObject()
2232
2233    layers := pCreateInfo.ppEnabledLayerNames[0:pCreateInfo.layerCount]
2234    extensions := pCreateInfo.ppEnabledExtensionNames[0:pCreateInfo.extensionCount]
2235
2236    return ?
2237}
2238
2239@threadSafety("system")
2240cmd void vkDestroyInstance(
2241        VkInstance                                  instance) {
2242    instanceObject := GetInstance(instance)
2243
2244    State.Instances[instance] = null
2245}
2246
2247@threadSafety("system")
2248cmd VkResult vkEnumeratePhysicalDevices(
2249        VkInstance                                  instance,
2250        u32*                                        pPhysicalDeviceCount,
2251        VkPhysicalDevice*                           pPhysicalDevices) {
2252    instanceObject := GetInstance(instance)
2253
2254    physicalDeviceCount := as!u32(?)
2255    pPhysicalDeviceCount[0] = physicalDeviceCount
2256    physicalDevices := pPhysicalDevices[0:physicalDeviceCount]
2257
2258    for i in (0 .. physicalDeviceCount) {
2259        physicalDevice := ?
2260        physicalDevices[i] = physicalDevice
2261        if !(physicalDevice in State.PhysicalDevices) {
2262            State.PhysicalDevices[physicalDevice] = new!PhysicalDeviceObject(instance: instance)
2263        }
2264    }
2265
2266    return ?
2267}
2268
2269cmd PFN_vkVoidFunction vkGetDeviceProcAddr(
2270        VkDevice                                    device,
2271        const char*                                 pName) {
2272    if device != NULL_HANDLE {
2273        device := GetDevice(device)
2274    }
2275
2276    return ?
2277}
2278
2279cmd PFN_vkVoidFunction vkGetInstanceProcAddr(
2280        VkInstance                                  instance,
2281        const char*                                 pName) {
2282    if instance != NULL_HANDLE {
2283        instanceObject := GetInstance(instance)
2284    }
2285
2286    return ?
2287}
2288
2289cmd void vkGetPhysicalDeviceProperties(
2290        VkPhysicalDevice                            physicalDevice,
2291        VkPhysicalDeviceProperties*                 pProperties) {
2292    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2293
2294    properties := ?
2295    pProperties[0] = properties
2296}
2297
2298cmd void vkGetPhysicalDeviceQueueFamilyProperties(
2299        VkPhysicalDevice                            physicalDevice,
2300        u32*                                        pCount,
2301        VkQueueFamilyProperties*                    pQueueFamilyProperties) {
2302    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2303    // TODO: Figure out how to express fetch-count-or-properties
2304    // This version fails 'apic validate' with 'fence not allowed in
2305    // *semantic.Branch'. Other attempts have failed with the same or other
2306    // errors.
2307    // if pQueueFamilyProperties != null {
2308    //     queuesProperties := pQueueFamilyProperties[0:pCount[0]]
2309    //     for i in (0 .. pCount[0]) {
2310    //         queueProperties := as!VkQueueFamilyProperties(?)
2311    //         queuesProperties[i] = queueProperties
2312    //    }
2313    // } else {
2314    //     count := ?
2315    //     pCount[0] = count
2316    // }
2317}
2318
2319cmd void vkGetPhysicalDeviceMemoryProperties(
2320        VkPhysicalDevice                            physicalDevice,
2321        VkPhysicalDeviceMemoryProperties*           pMemoryProperties) {
2322    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2323
2324    memoryProperties := ?
2325    pMemoryProperties[0] = memoryProperties
2326}
2327
2328cmd void vkGetPhysicalDeviceFeatures(
2329        VkPhysicalDevice                            physicalDevice,
2330        VkPhysicalDeviceFeatures*                   pFeatures) {
2331    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2332
2333    features := ?
2334    pFeatures[0] = features
2335}
2336
2337cmd void vkGetPhysicalDeviceFormatProperties(
2338        VkPhysicalDevice                            physicalDevice,
2339        VkFormat                                    format,
2340        VkFormatProperties*                         pFormatProperties) {
2341    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2342
2343    formatProperties := ?
2344    pFormatProperties[0] = formatProperties
2345}
2346
2347cmd void vkGetPhysicalDeviceImageFormatProperties(
2348        VkPhysicalDevice                            physicalDevice,
2349        VkFormat                                    format,
2350        VkImageType                                 type,
2351        VkImageTiling                               tiling,
2352        VkImageUsageFlags                           usage,
2353        VkImageCreateFlags                          flags,
2354        VkImageFormatProperties*                    pImageFormatProperties) {
2355    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2356
2357    imageFormatProperties := ?
2358    pImageFormatProperties[0] = imageFormatProperties
2359}
2360
2361
2362// Device functions
2363
2364@threadSafety("system")
2365cmd VkResult vkCreateDevice(
2366        VkPhysicalDevice                            physicalDevice,
2367        const VkDeviceCreateInfo*                   pCreateInfo,
2368        VkDevice*                                   pDevice) {
2369    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO)
2370    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2371
2372    device := ?
2373    pDevice[0] = device
2374    State.Devices[device] = new!DeviceObject(physicalDevice: physicalDevice)
2375
2376    return ?
2377}
2378
2379@threadSafety("system")
2380cmd void vkDestroyDevice(
2381        VkDevice                                    device) {
2382    deviceObject := GetDevice(device)
2383
2384    State.Devices[device] = null
2385}
2386
2387
2388// Extension discovery functions
2389
2390cmd VkResult vkEnumerateInstanceLayerProperties(
2391        u32*                                        pCount,
2392        VkLayerProperties*                          pProperties) {
2393    count := as!u32(?)
2394    pCount[0] = count
2395
2396    properties := pProperties[0:count]
2397    for i in (0 .. count) {
2398        property := ?
2399        properties[i] = property
2400    }
2401
2402    return ?
2403}
2404
2405cmd VkResult vkEnumerateInstanceExtensionProperties(
2406        const char*                                 pLayerName,
2407        u32*                                        pCount,
2408        VkExtensionProperties*                      pProperties) {
2409    count := as!u32(?)
2410    pCount[0] = count
2411
2412    properties := pProperties[0:count]
2413    for i in (0 .. count) {
2414        property := ?
2415        properties[i] = property
2416    }
2417
2418    return ?
2419}
2420
2421cmd VkResult vkEnumerateDeviceLayerProperties(
2422        VkPhysicalDevice                            physicalDevice,
2423        u32*                                        pCount,
2424        VkLayerProperties*                          pProperties) {
2425    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2426    count := as!u32(?)
2427    pCount[0] = count
2428
2429    properties := pProperties[0:count]
2430    for i in (0 .. count) {
2431        property := ?
2432        properties[i] = property
2433    }
2434
2435    return ?
2436}
2437
2438cmd VkResult vkEnumerateDeviceExtensionProperties(
2439        VkPhysicalDevice                            physicalDevice,
2440        const char*                                 pLayerName,
2441        u32*                                        pCount,
2442        VkExtensionProperties*                      pProperties) {
2443    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2444
2445    count := as!u32(?)
2446    pCount[0] = count
2447
2448    properties := pProperties[0:count]
2449    for i in (0 .. count) {
2450        property := ?
2451        properties[i] = property
2452    }
2453
2454    return ?
2455}
2456
2457
2458// Queue functions
2459
2460@threadSafety("system")
2461cmd void vkGetDeviceQueue(
2462        VkDevice                                    device,
2463        u32                                         queueFamilyIndex,
2464        u32                                         queueIndex,
2465        VkQueue*                                    pQueue) {
2466    deviceObject := GetDevice(device)
2467
2468    queue := ?
2469    pQueue[0] = queue
2470
2471    if !(queue in State.Queues) {
2472        State.Queues[queue] = new!QueueObject(device: device)
2473    }
2474}
2475
2476@threadSafety("app")
2477cmd VkResult vkQueueSubmit(
2478        VkQueue                                     queue,
2479        u32                                         submitCount,
2480        const VkSubmitInfo*                         pSubmitInfo,
2481        VkFence                                     fence) {
2482    queueObject := GetQueue(queue)
2483
2484    if fence != NULL_HANDLE {
2485        fenceObject := GetFence(fence)
2486        assert(fenceObject.device == queueObject.device)
2487    }
2488
2489    // cmdBuffers := pCmdBuffers[0:cmdBufferCount]
2490    // for i in (0 .. cmdBufferCount) {
2491    //    cmdBuffer := cmdBuffers[i]
2492    //    cmdBufferObject := GetCmdBuffer(cmdBuffer)
2493    //    assert(cmdBufferObject.device == queueObject.device)
2494    //
2495    //    validate("QueueCheck", cmdBufferObject.queueFlags in queueObject.flags,
2496    //        "vkQueueSubmit: enqueued cmdBuffer requires missing queue capabilities.")
2497    // }
2498
2499    return ?
2500}
2501
2502@threadSafety("system")
2503cmd VkResult vkQueueWaitIdle(
2504        VkQueue                                     queue) {
2505    queueObject := GetQueue(queue)
2506
2507    return ?
2508}
2509
2510@threadSafety("system")
2511cmd VkResult vkDeviceWaitIdle(
2512        VkDevice                                    device) {
2513    deviceObject := GetDevice(device)
2514
2515    return ?
2516}
2517
2518
2519// Memory functions
2520
2521@threadSafety("system")
2522cmd VkResult vkAllocMemory(
2523        VkDevice                                    device,
2524        const VkMemoryAllocInfo*                    pAllocInfo,
2525        VkDeviceMemory*                             pMem) {
2526    assert(pAllocInfo.sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO)
2527    deviceObject := GetDevice(device)
2528
2529    mem := ?
2530    pMem[0] = mem
2531    State.DeviceMemories[mem] = new!DeviceMemoryObject(
2532        device: device,
2533        allocationSize: pAllocInfo[0].allocationSize)
2534
2535    return ?
2536}
2537
2538@threadSafety("system")
2539cmd void vkFreeMemory(
2540        VkDevice                                    device,
2541        VkDeviceMemory                              mem) {
2542    deviceObject := GetDevice(device)
2543    memObject := GetDeviceMemory(mem)
2544    assert(memObject.device == device)
2545
2546    // Check that no objects are still bound before freeing.
2547    validate("MemoryCheck", len(memObject.boundObjects) == 0,
2548        "vkFreeMemory: objects still bound")
2549    validate("MemoryCheck", len(memObject.boundCommandBuffers) == 0,
2550        "vkFreeMemory: cmdBuffers still bound")
2551    State.DeviceMemories[mem] = null
2552}
2553
2554@threadSafety("app")
2555cmd VkResult vkMapMemory(
2556        VkDevice                                    device,
2557        VkDeviceMemory                              mem,
2558        VkDeviceSize                                offset,
2559        VkDeviceSize                                size,
2560        VkMemoryMapFlags                            flags,
2561        void**                                      ppData) {
2562    deviceObject := GetDevice(device)
2563    memObject := GetDeviceMemory(mem)
2564    assert(memObject.device == device)
2565
2566    assert(flags == as!VkMemoryMapFlags(0))
2567    assert((offset + size) <= memObject.allocationSize)
2568
2569    return ?
2570}
2571
2572@threadSafety("app")
2573cmd void vkUnmapMemory(
2574        VkDevice                                    device,
2575        VkDeviceMemory                              mem) {
2576    deviceObject := GetDevice(device)
2577    memObject := GetDeviceMemory(mem)
2578    assert(memObject.device == device)
2579}
2580
2581cmd VkResult vkFlushMappedMemoryRanges(
2582        VkDevice                                    device,
2583        u32                                         memRangeCount
2584        const VkMappedMemoryRange*                  pMemRanges) {
2585    deviceObject := GetDevice(device)
2586
2587    memRanges := pMemRanges[0:memRangeCount]
2588    for i in (0 .. memRangeCount) {
2589        memRange := memRanges[i]
2590        memObject := GetDeviceMemory(memRange.mem)
2591        assert(memObject.device == device)
2592        assert((memRange.offset + memRange.size) <= memObject.allocationSize)
2593    }
2594
2595    return ?
2596}
2597
2598cmd VkResult vkInvalidateMappedMemoryRanges(
2599        VkDevice                                    device,
2600        u32                                         memRangeCount,
2601        const VkMappedMemoryRange*                  pMemRanges) {
2602    deviceObject := GetDevice(device)
2603
2604    memRanges := pMemRanges[0:memRangeCount]
2605    for i in (0 .. memRangeCount) {
2606        memRange := memRanges[i]
2607        memObject := GetDeviceMemory(memRange.mem)
2608        assert(memObject.device == device)
2609        assert((memRange.offset + memRange.size) <= memObject.allocationSize)
2610    }
2611
2612    return ?
2613}
2614
2615
2616// Memory management API functions
2617
2618cmd void vkGetDeviceMemoryCommitment(
2619        VkDevice                                    device,
2620        VkDeviceMemory                              memory,
2621        VkDeviceSize*                               pCommittedMemoryInBytes) {
2622    deviceObject := GetDevice(device)
2623
2624    if memory != NULL_HANDLE {
2625        memoryObject := GetDeviceMemory(memory)
2626        assert(memoryObject.device == device)
2627    }
2628
2629    committedMemoryInBytes := ?
2630    pCommittedMemoryInBytes[0] = committedMemoryInBytes
2631}
2632
2633cmd void vkGetBufferMemoryRequirements(
2634        VkDevice                                    device,
2635        VkBuffer                                    buffer,
2636        VkMemoryRequirements*                       pMemoryRequirements) {
2637    deviceObject := GetDevice(device)
2638    bufferObject := GetBuffer(buffer)
2639    assert(bufferObject.device == device)
2640}
2641
2642cmd VkResult vkBindBufferMemory(
2643        VkDevice                                    device,
2644        VkBuffer                                    buffer,
2645        VkDeviceMemory                              mem,
2646        VkDeviceSize                                memOffset) {
2647    deviceObject := GetDevice(device)
2648    bufferObject := GetBuffer(buffer)
2649    assert(bufferObject.device == device)
2650
2651    // Unbind buffer from previous memory object, if not VK_NULL_HANDLE.
2652    if bufferObject.mem != NULL_HANDLE {
2653        memObject := GetDeviceMemory(bufferObject.mem)
2654        memObject.boundObjects[as!u64(buffer)] = null
2655    }
2656
2657    // Bind buffer to given memory object, if not VK_NULL_HANDLE.
2658    if mem != NULL_HANDLE {
2659        memObject := GetDeviceMemory(mem)
2660        assert(memObject.device == device)
2661        memObject.boundObjects[as!u64(buffer)] = memOffset
2662    }
2663    bufferObject.mem = mem
2664    bufferObject.memOffset = memOffset
2665
2666    return ?
2667}
2668
2669cmd void vkGetImageMemoryRequirements(
2670        VkDevice                                    device,
2671        VkImage                                     image,
2672        VkMemoryRequirements*                       pMemoryRequirements) {
2673    deviceObject := GetDevice(device)
2674    imageObject := GetImage(image)
2675    assert(imageObject.device == device)
2676}
2677
2678cmd VkResult vkBindImageMemory(
2679        VkDevice                                    device,
2680        VkImage                                     image,
2681        VkDeviceMemory                              mem,
2682        VkDeviceSize                                memOffset) {
2683    deviceObject := GetDevice(device)
2684    imageObject := GetImage(image)
2685    assert(imageObject.device == device)
2686
2687    // Unbind image from previous memory object, if not VK_NULL_HANDLE.
2688    if imageObject.mem != NULL_HANDLE {
2689        memObject := GetDeviceMemory(imageObject.mem)
2690        memObject.boundObjects[as!u64(image)] = null
2691    }
2692
2693    // Bind image to given memory object, if not VK_NULL_HANDLE.
2694    if mem != NULL_HANDLE {
2695        memObject := GetDeviceMemory(mem)
2696        assert(memObject.device == device)
2697        memObject.boundObjects[as!u64(image)] = memOffset
2698    }
2699    imageObject.mem = mem
2700    imageObject.memOffset = memOffset
2701
2702    return ?
2703}
2704
2705cmd void vkGetImageSparseMemoryRequirements(
2706        VkDevice                                    device,
2707        VkImage                                     image,
2708        u32*                                        pNumRequirements,
2709        VkSparseImageMemoryRequirements*            pSparseMemoryRequirements) {
2710    deviceObject := GetDevice(device)
2711    imageObject := GetImage(image)
2712    assert(imageObject.device == device)
2713}
2714
2715cmd void vkGetPhysicalDeviceSparseImageFormatProperties(
2716        VkPhysicalDevice                            physicalDevice,
2717        VkFormat                                    format,
2718        VkImageType                                 type,
2719        u32                                         samples,
2720        VkImageUsageFlags                           usage,
2721        VkImageTiling                               tiling,
2722        u32*                                        pNumProperties,
2723        VkSparseImageFormatProperties*              pProperties) {
2724    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
2725}
2726
2727cmd VkResult vkQueueBindSparseBufferMemory(
2728        VkQueue                                     queue,
2729        VkBuffer                                    buffer,
2730        u32                                         numBindings,
2731        const VkSparseMemoryBindInfo*               pBindInfo) {
2732    queueObject := GetQueue(queue)
2733    bufferObject := GetBuffer(buffer)
2734    assert(bufferObject.device == queueObject.device)
2735
2736    return ?
2737}
2738
2739cmd VkResult vkQueueBindSparseImageOpaqueMemory(
2740        VkQueue                                     queue,
2741        VkImage                                     image,
2742        u32                                         numBindings,
2743        const VkSparseMemoryBindInfo*               pBindInfo) {
2744    queueObject := GetQueue(queue)
2745    imageObject := GetImage(image)
2746    assert(imageObject.device == queueObject.device)
2747
2748    return ?
2749}
2750
2751
2752cmd VkResult vkQueueBindSparseImageMemory(
2753        VkQueue                                     queue,
2754        VkImage                                     image,
2755        u32                                         numBindings,
2756        const VkSparseImageMemoryBindInfo*          pBindInfo) {
2757    queueObject := GetQueue(queue)
2758    imageObject := GetImage(image)
2759
2760    return ?
2761}
2762
2763
2764// Fence functions
2765
2766@threadSafety("system")
2767cmd VkResult vkCreateFence(
2768        VkDevice                                    device,
2769        const VkFenceCreateInfo*                    pCreateInfo,
2770        VkFence*                                    pFence) {
2771    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO)
2772    deviceObject := GetDevice(device)
2773
2774    fence := ?
2775    pFence[0] = fence
2776    State.Fences[fence] = new!FenceObject(
2777        device: device, signaled: (pCreateInfo.flags == VK_FENCE_CREATE_SIGNALED_BIT))
2778
2779    return ?
2780}
2781
2782@threadSafety("system")
2783cmd void vkDestroyFence(
2784        VkDevice                                    device,
2785        VkFence                                     fence) {
2786    deviceObject := GetDevice(device)
2787    fenceObject := GetFence(fence)
2788    assert(fenceObject.device == device)
2789
2790    State.Fences[fence] = null
2791}
2792
2793@threadSafety("system")
2794cmd VkResult vkResetFences(
2795        VkDevice                                    device,
2796        u32                                         fenceCount,
2797        const VkFence*                              pFences) {
2798    deviceObject := GetDevice(device)
2799
2800    fences := pFences[0:fenceCount]
2801    for i in (0 .. fenceCount) {
2802        fence := fences[i]
2803        fenceObject := GetFence(fence)
2804        assert(fenceObject.device == device)
2805        fenceObject.signaled = false
2806    }
2807
2808    return ?
2809}
2810
2811@threadSafety("system")
2812cmd VkResult vkGetFenceStatus(
2813        VkDevice                                    device,
2814        VkFence                                     fence) {
2815    deviceObject := GetDevice(device)
2816    fenceObject := GetFence(fence)
2817    assert(fenceObject.device == device)
2818
2819    return ?
2820}
2821
2822@threadSafety("system")
2823cmd VkResult vkWaitForFences(
2824        VkDevice                                    device,
2825        u32                                         fenceCount,
2826        const VkFence*                              pFences,
2827        VkBool32                                    waitAll,
2828        u64                                         timeout) {  /// timeout in nanoseconds
2829    deviceObject := GetDevice(device)
2830
2831    fences := pFences[0:fenceCount]
2832    for i in (0 .. fenceCount) {
2833        fence := fences[i]
2834        fenceObject := GetFence(fence)
2835        assert(fenceObject.device == device)
2836    }
2837
2838    return ?
2839}
2840
2841
2842// Queue semaphore functions
2843
2844@threadSafety("system")
2845cmd VkResult vkCreateSemaphore(
2846        VkDevice                                    device,
2847        const VkSemaphoreCreateInfo*                pCreateInfo,
2848        VkSemaphore*                                pSemaphore) {
2849    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO)
2850    deviceObject := GetDevice(device)
2851
2852    semaphore := ?
2853    pSemaphore[0] = semaphore
2854    State.Semaphores[semaphore] = new!SemaphoreObject(device: device)
2855
2856    return ?
2857}
2858
2859@threadSafety("system")
2860cmd void vkDestroySemaphore(
2861        VkDevice                                    device,
2862        VkSemaphore                                 semaphore) {
2863    deviceObject := GetDevice(device)
2864    semaphoreObject := GetSemaphore(semaphore)
2865    assert(semaphoreObject.device == device)
2866
2867    State.Semaphores[semaphore] = null
2868}
2869
2870@threadSafety("app")
2871cmd VkResult vkQueueSignalSemaphore(
2872        VkQueue                                     queue,
2873        VkSemaphore                                 semaphore) {
2874    queueObject := GetQueue(queue)
2875    semaphoreObject := GetSemaphore(semaphore)
2876    assert(queueObject.device == semaphoreObject.device)
2877
2878    return ?
2879}
2880
2881@threadSafety("system")
2882cmd VkResult vkQueueWaitSemaphore(
2883        VkQueue                                     queue,
2884        VkSemaphore                                 semaphore) {
2885    queueObject := GetQueue(queue)
2886    semaphoreObject := GetSemaphore(semaphore)
2887    assert(queueObject.device == semaphoreObject.device)
2888
2889    return ?
2890}
2891
2892
2893// Event functions
2894
2895@threadSafety("system")
2896cmd VkResult vkCreateEvent(
2897        VkDevice                                    device,
2898        const VkEventCreateInfo*                    pCreateInfo,
2899        VkEvent*                                    pEvent) {
2900    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO)
2901    deviceObject := GetDevice(device)
2902
2903    event := ?
2904    pEvent[0] = event
2905    State.Events[event] = new!EventObject(device: device)
2906
2907    return ?
2908}
2909
2910@threadSafety("system")
2911cmd void vkDestroyEvent(
2912        VkDevice                                    device,
2913        VkEvent                                     event) {
2914    deviceObject := GetDevice(device)
2915    eventObject := GetEvent(event)
2916    assert(eventObject.device == device)
2917
2918    State.Events[event] = null
2919}
2920
2921@threadSafety("system")
2922cmd VkResult vkGetEventStatus(
2923        VkDevice                                    device,
2924        VkEvent                                     event) {
2925    deviceObject := GetDevice(device)
2926    eventObject := GetEvent(event)
2927    assert(eventObject.device == device)
2928
2929    return ?
2930}
2931
2932@threadSafety("system")
2933cmd VkResult vkSetEvent(
2934        VkDevice                                    device,
2935        VkEvent                                     event) {
2936    deviceObject := GetDevice(device)
2937    eventObject := GetEvent(event)
2938    assert(eventObject.device == device)
2939
2940    return ?
2941}
2942
2943@threadSafety("system")
2944cmd VkResult vkResetEvent(
2945        VkDevice                                    device,
2946        VkEvent                                     event) {
2947    deviceObject := GetDevice(device)
2948    eventObject := GetEvent(event)
2949    assert(eventObject.device == device)
2950
2951    return ?
2952}
2953
2954
2955// Query functions
2956
2957@threadSafety("system")
2958cmd VkResult vkCreateQueryPool(
2959        VkDevice                                    device,
2960        const VkQueryPoolCreateInfo*                pCreateInfo,
2961        VkQueryPool*                                pQueryPool) {
2962    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO)
2963    deviceObject := GetDevice(device)
2964
2965    queryPool := ?
2966    pQueryPool[0] = queryPool
2967    State.QueryPools[queryPool] = new!QueryPoolObject(device: device)
2968
2969    return ?
2970}
2971
2972@threadSafety("system")
2973cmd void vkDestroyQueryPool(
2974        VkDevice                                    device,
2975        VkQueryPool                                 queryPool) {
2976    deviceObject := GetDevice(device)
2977    queryPoolObject := GetQueryPool(queryPool)
2978    assert(queryPoolObject.device == device)
2979
2980    State.QueryPools[queryPool] = null
2981}
2982
2983@threadSafety("system")
2984cmd VkResult vkGetQueryPoolResults(
2985        VkDevice                                    device,
2986        VkQueryPool                                 queryPool,
2987        u32                                         startQuery,
2988        u32                                         queryCount,
2989        platform.size_t                             dataSize,
2990        void*                                       pData,
2991        VkDeviceSize                                stride,
2992        VkQueryResultFlags                          flags) {
2993    deviceObject := GetDevice(device)
2994    queryPoolObject := GetQueryPool(queryPool)
2995    assert(queryPoolObject.device == device)
2996
2997    data := pData[0:dataSize]
2998
2999    return ?
3000}
3001
3002// Buffer functions
3003
3004@threadSafety("system")
3005cmd VkResult vkCreateBuffer(
3006        VkDevice                                    device,
3007        const VkBufferCreateInfo*                   pCreateInfo,
3008        VkBuffer*                                   pBuffer) {
3009    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO)
3010    deviceObject := GetDevice(device)
3011
3012    buffer := ?
3013    pBuffer[0] = buffer
3014    State.Buffers[buffer] = new!BufferObject(device: device)
3015
3016    return ?
3017}
3018
3019@threadSafety("system")
3020cmd void vkDestroyBuffer(
3021        VkDevice                                    device,
3022        VkBuffer                                    buffer) {
3023    deviceObject := GetDevice(device)
3024    bufferObject := GetBuffer(buffer)
3025    assert(bufferObject.device == device)
3026
3027    assert(bufferObject.mem == 0)
3028    State.Buffers[buffer] = null
3029}
3030
3031
3032// Buffer view functions
3033
3034@threadSafety("system")
3035cmd VkResult vkCreateBufferView(
3036        VkDevice                                    device,
3037        const VkBufferViewCreateInfo*               pCreateInfo,
3038        VkBufferView*                               pView) {
3039    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
3040    deviceObject := GetDevice(device)
3041
3042    bufferObject := GetBuffer(pCreateInfo.buffer)
3043    assert(bufferObject.device == device)
3044
3045    view := ?
3046    pView[0] = view
3047    State.BufferViews[view] = new!BufferViewObject(device: device, buffer: pCreateInfo.buffer)
3048
3049    return ?
3050}
3051
3052@threadSafety("system")
3053cmd void vkDestroyBufferView(
3054        VkDevice                                    device,
3055        VkBufferView                                bufferView) {
3056    deviceObject := GetDevice(device)
3057    bufferViewObject := GetBufferView(bufferView)
3058    assert(bufferViewObject.device == device)
3059
3060    State.BufferViews[bufferView] = null
3061}
3062
3063
3064// Image functions
3065
3066@threadSafety("system")
3067cmd VkResult vkCreateImage(
3068        VkDevice                                    device,
3069        const VkImageCreateInfo*                    pCreateInfo,
3070        VkImage*                                    pImage) {
3071    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
3072    deviceObject := GetDevice(device)
3073
3074    image := ?
3075    pImage[0] = image
3076    State.Images[image] = new!ImageObject(device: device)
3077
3078    return ?
3079}
3080
3081@threadSafety("system")
3082cmd void vkDestroyImage(
3083        VkDevice                                    device,
3084        VkImage                                     image) {
3085    deviceObject := GetDevice(device)
3086    imageObject := GetImage(image)
3087    assert(imageObject.device == device)
3088
3089    assert(imageObject.mem == 0)
3090    State.Images[image] = null
3091}
3092
3093cmd void vkGetImageSubresourceLayout(
3094        VkDevice                                    device,
3095        VkImage                                     image,
3096        const VkImageSubresource*                   pSubresource,
3097        VkSubresourceLayout*                        pLayout) {
3098    deviceObject := GetDevice(device)
3099    imageObject := GetImage(image)
3100    assert(imageObject.device == device)
3101}
3102
3103
3104// Image view functions
3105
3106@threadSafety("system")
3107cmd VkResult vkCreateImageView(
3108        VkDevice                                    device,
3109        const VkImageViewCreateInfo*                pCreateInfo,
3110        VkImageView*                                pView) {
3111    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO)
3112    deviceObject := GetDevice(device)
3113
3114    imageObject := GetImage(pCreateInfo.image)
3115    assert(imageObject.device == device)
3116
3117    view := ?
3118    pView[0] = view
3119    State.ImageViews[view] = new!ImageViewObject(device: device, image: pCreateInfo.image)
3120
3121    return ?
3122}
3123
3124@threadSafety("system")
3125cmd void vkDestroyImageView(
3126        VkDevice                                    device,
3127        VkImageView                                 imageView) {
3128    deviceObject := GetDevice(device)
3129    imageViewObject := GetImageView(imageView)
3130    assert(imageViewObject.device == device)
3131
3132    State.ImageViews[imageView] = null
3133}
3134
3135
3136// Shader functions
3137
3138cmd VkResult vkCreateShaderModule(
3139        VkDevice                                    device,
3140        const VkShaderModuleCreateInfo*             pCreateInfo,
3141        VkShaderModule*                             pShaderModule) {
3142    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO)
3143    deviceObject := GetDevice(device)
3144
3145    shaderModule := ?
3146    pShaderModule[0] = shaderModule
3147    State.ShaderModules[shaderModule] = new!ShaderModuleObject(device: device)
3148
3149    return ?
3150}
3151
3152cmd void vkDestroyShaderModule(
3153        VkDevice                                    device,
3154        VkShaderModule                              shaderModule) {
3155    deviceObject := GetDevice(device)
3156    shaderModuleObject := GetShaderModule(shaderModule)
3157    assert(shaderModuleObject.device == device)
3158
3159    State.ShaderModules[shaderModule] = null
3160}
3161
3162@threadSafety("system")
3163cmd VkResult vkCreateShader(
3164        VkDevice                                    device,
3165        const VkShaderCreateInfo*                   pCreateInfo,
3166        VkShader*                                   pShader) {
3167    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO)
3168    deviceObject := GetDevice(device)
3169
3170    shader := ?
3171    pShader[0] = shader
3172    State.Shaders[shader] = new!ShaderObject(device: device)
3173
3174    return ?
3175}
3176
3177@threadSafety("system")
3178cmd void vkDestroyShader(
3179        VkDevice                                    device,
3180        VkShader                                    shader) {
3181    deviceObject := GetDevice(device)
3182    shaderObject := GetShader(shader)
3183    assert(shaderObject.device == device)
3184
3185    State.Shaders[shader] = null
3186}
3187
3188
3189// Pipeline functions
3190
3191cmd VkResult vkCreatePipelineCache(
3192        VkDevice                                    device,
3193        const VkPipelineCacheCreateInfo*            pCreateInfo,
3194        VkPipelineCache*                            pPipelineCache) {
3195    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO)
3196    deviceObject := GetDevice(device)
3197
3198    pipelineCache := ?
3199    pPipelineCache[0] = pipelineCache
3200    State.PipelineCaches[pipelineCache] = new!PipelineCacheObject(device: device)
3201
3202    return ?
3203}
3204
3205cmd void vkDestroyPipelineCache(
3206        VkDevice                                    device,
3207        VkPipelineCache                             pipelineCache) {
3208    deviceObject := GetDevice(device)
3209    pipelineCacheObject := GetPipelineCache(pipelineCache)
3210    assert(pipelineCacheObject.device == device)
3211
3212    State.PipelineCaches[pipelineCache] = null
3213}
3214
3215cmd VkResult vkGetPipelineCacheData(
3216        VkDevice                                    device,
3217        VkPipelineCache                             pipelineCache,
3218        platform.size_t*                            pDataSize,
3219        void*                                       pData) {
3220    deviceObject := GetDevice(device)
3221    pipelineCacheObject := GetPipelineCache(pipelineCache)
3222    assert(pipelineCacheObject.device == device)
3223
3224    return ?
3225}
3226
3227cmd VkResult vkMergePipelineCaches(
3228        VkDevice                                    device,
3229        VkPipelineCache                             destCache,
3230        u32                                         srcCacheCount,
3231        const VkPipelineCache*                      pSrcCaches) {
3232    deviceObject := GetDevice(device)
3233    destCacheObject := GetPipelineCache(destCache)
3234    assert(destCacheObject.device == device)
3235
3236    srcCaches := pSrcCaches[0:srcCacheCount]
3237    for i in (0 .. srcCacheCount) {
3238        srcCache := srcCaches[i]
3239        srcCacheObject := GetPipelineCache(srcCache)
3240        assert(srcCacheObject.device == device)
3241    }
3242
3243    return ?
3244}
3245
3246cmd VkResult vkCreateGraphicsPipelines(
3247        VkDevice                                    device,
3248        VkPipelineCache                             pipelineCache,
3249        u32                                         count,
3250        const VkGraphicsPipelineCreateInfo*         pCreateInfos,
3251        VkPipeline*                                 pPipelines) {
3252    deviceObject := GetDevice(device)
3253    if pipelineCache != NULL_HANDLE {
3254        pipelineCacheObject := GetPipelineCache(pipelineCache)
3255        assert(pipelineCacheObject.device == device)
3256    }
3257
3258    createInfos := pCreateInfos[0:count]
3259    pipelines := pPipelines[0:count]
3260    for i in (0 .. count) {
3261        pipeline := ?
3262        pipelines[i] = pipeline
3263        State.Pipelines[pipeline] = new!PipelineObject(device: device)
3264    }
3265
3266    return ?
3267}
3268
3269cmd VkResult vkCreateComputePipelines(
3270        VkDevice                                    device,
3271        VkPipelineCache                             pipelineCache,
3272        u32                                         count,
3273        const VkComputePipelineCreateInfo*          pCreateInfos,
3274        VkPipeline*                                 pPipelines) {
3275    deviceObject := GetDevice(device)
3276    if pipelineCache != NULL_HANDLE {
3277        pipelineCacheObject := GetPipelineCache(pipelineCache)
3278        assert(pipelineCacheObject.device == device)
3279    }
3280
3281    createInfos := pCreateInfos[0:count]
3282    pipelines := pPipelines[0:count]
3283    for i in (0 .. count) {
3284        pipeline := ?
3285        pipelines[i] = pipeline
3286        State.Pipelines[pipeline] = new!PipelineObject(device: device)
3287    }
3288
3289    return ?
3290}
3291
3292@threadSafety("system")
3293cmd void vkDestroyPipeline(
3294        VkDevice                                    device,
3295        VkPipeline                                  pipeline) {
3296    deviceObject := GetDevice(device)
3297    pipelineObjects := GetPipeline(pipeline)
3298    assert(pipelineObjects.device == device)
3299
3300    State.Pipelines[pipeline] = null
3301}
3302
3303
3304// Pipeline layout functions
3305
3306@threadSafety("system")
3307cmd VkResult vkCreatePipelineLayout(
3308        VkDevice                                    device,
3309        const VkPipelineLayoutCreateInfo*           pCreateInfo,
3310        VkPipelineLayout*                           pPipelineLayout) {
3311    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO)
3312    deviceObject := GetDevice(device)
3313
3314    pipelineLayout := ?
3315    pPipelineLayout[0] = pipelineLayout
3316    State.PipelineLayouts[pipelineLayout] = new!PipelineLayoutObject(device: device)
3317
3318    return ?
3319}
3320
3321@threadSafety("system")
3322cmd void vkDestroyPipelineLayout(
3323        VkDevice                                    device,
3324        VkPipelineLayout                            pipelineLayout) {
3325    deviceObject := GetDevice(device)
3326    pipelineLayoutObjects := GetPipelineLayout(pipelineLayout)
3327    assert(pipelineLayoutObjects.device == device)
3328
3329    State.PipelineLayouts[pipelineLayout] = null
3330}
3331
3332
3333// Sampler functions
3334
3335@threadSafety("system")
3336cmd VkResult vkCreateSampler(
3337        VkDevice                                    device,
3338        const VkSamplerCreateInfo*                  pCreateInfo,
3339        VkSampler*                                  pSampler) {
3340    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO)
3341    deviceObject := GetDevice(device)
3342
3343    sampler := ?
3344    pSampler[0] = sampler
3345    State.Samplers[sampler] = new!SamplerObject(device: device)
3346
3347    return ?
3348}
3349
3350@threadSafety("system")
3351cmd void vkDestroySampler(
3352        VkDevice                                    device,
3353        VkSampler                                   sampler) {
3354    deviceObject := GetDevice(device)
3355    samplerObject := GetSampler(sampler)
3356    assert(samplerObject.device == device)
3357
3358    State.Samplers[sampler] = null
3359}
3360
3361
3362// Descriptor set functions
3363
3364@threadSafety("system")
3365cmd VkResult vkCreateDescriptorSetLayout(
3366        VkDevice                                    device,
3367        const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
3368        VkDescriptorSetLayout*                      pSetLayout) {
3369    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)
3370    deviceObject := GetDevice(device)
3371
3372    setLayout := ?
3373    pSetLayout[0] = setLayout
3374    State.DescriptorSetLayouts[setLayout] = new!DescriptorSetLayoutObject(device: device)
3375
3376    return ?
3377}
3378
3379@threadSafety("system")
3380cmd void vkDestroyDescriptorSetLayout(
3381        VkDevice                                    device,
3382        VkDescriptorSetLayout                       descriptorSetLayout) {
3383    deviceObject := GetDevice(device)
3384    descriptorSetLayoutObject := GetDescriptorSetLayout(descriptorSetLayout)
3385    assert(descriptorSetLayoutObject.device == device)
3386
3387    State.DescriptorSetLayouts[descriptorSetLayout] = null
3388}
3389
3390@threadSafety("system")
3391cmd VkResult vkCreateDescriptorPool(
3392        VkDevice                                    device,
3393        const VkDescriptorPoolCreateInfo*           pCreateInfo
3394        VkDescriptorPool*                           pDescriptorPool) {
3395    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO)
3396    deviceObject := GetDevice(device)
3397
3398    descriptorPool := ?
3399    pDescriptorPool[0] = descriptorPool
3400    State.DescriptorPools[descriptorPool] = new!DescriptorPoolObject(device: device)
3401
3402    return ?
3403}
3404
3405@threadSafety("system")
3406cmd void vkDestroyDescriptorPool(
3407        VkDevice                                    device,
3408        VkDescriptorPool                            descriptorPool) {
3409    deviceObject := GetDevice(device)
3410    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3411    assert(descriptorPoolObject.device == device)
3412
3413    State.DescriptorPools[descriptorPool] = null
3414}
3415
3416@threadSafety("app")
3417cmd VkResult vkResetDescriptorPool(
3418        VkDevice                                    device,
3419        VkDescriptorPool                            descriptorPool,
3420        VkDescriptorPoolResetFlags                  flags) {
3421    deviceObject := GetDevice(device)
3422    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3423    assert(descriptorPoolObject.device == device)
3424
3425    return ?
3426}
3427
3428@threadSafety("app")
3429cmd VkResult vkAllocDescriptorSets(
3430        VkDevice                                    device,
3431        const VkDescriptorSetAllocInfo*             pAllocInfo,
3432        VkDescriptorSet*                            pDescriptorSets) {
3433    deviceObject := GetDevice(device)
3434    allocInfo := pAllocInfo[0]
3435    descriptorPoolObject := GetDescriptorPool(allocInfo.descriptorPool)
3436
3437    setLayouts := allocInfo.pSetLayouts[0:allocInfo.count]
3438    for i in (0 .. allocInfo.count) {
3439        setLayout := setLayouts[i]
3440        setLayoutObject := GetDescriptorSetLayout(setLayout)
3441        assert(setLayoutObject.device == device)
3442    }
3443
3444    descriptorSets := pDescriptorSets[0:allocInfo.count]
3445    for i in (0 .. allocInfo.count) {
3446        descriptorSet := ?
3447        descriptorSets[i] = descriptorSet
3448        State.DescriptorSets[descriptorSet] = new!DescriptorSetObject(device: device)
3449    }
3450
3451    return ?
3452}
3453
3454cmd VkResult vkFreeDescriptorSets(
3455        VkDevice                                    device,
3456        VkDescriptorPool                            descriptorPool,
3457        u32                                         count,
3458        const VkDescriptorSet*                      pDescriptorSets) {
3459    deviceObject := GetDevice(device)
3460    descriptorPoolObject := GetDescriptorPool(descriptorPool)
3461
3462    descriptorSets := pDescriptorSets[0:count]
3463    for i in (0 .. count) {
3464        descriptorSet := descriptorSets[i]
3465        descriptorSetObject := GetDescriptorSet(descriptorSet)
3466        assert(descriptorSetObject.device == device)
3467        State.DescriptorSets[descriptorSet] = null
3468    }
3469
3470    return ?
3471}
3472
3473cmd void vkUpdateDescriptorSets(
3474        VkDevice                                    device,
3475        u32                                         writeCount,
3476        const VkWriteDescriptorSet*                 pDescriptorWrites,
3477        u32                                         copyCount,
3478        const VkCopyDescriptorSet*                  pDescriptorCopies) {
3479    deviceObject := GetDevice(device)
3480
3481    descriptorWrites := pDescriptorWrites[0:writeCount]
3482    for i in (0 .. writeCount) {
3483        descriptorWrite := descriptorWrites[i]
3484        descriptorWriteObject := GetDescriptorSet(descriptorWrite.destSet)
3485        assert(descriptorWriteObject.device == device)
3486    }
3487
3488    descriptorCopies := pDescriptorCopies[0:copyCount]
3489    for i in (0 .. copyCount) {
3490        descriptorCopy := descriptorCopies[i]
3491        descriptorCopyObject := GetDescriptorSet(descriptorCopy.destSet)
3492        assert(descriptorCopyObject.device == device)
3493    }
3494}
3495
3496
3497// Framebuffer functions
3498
3499@threadSafety("system")
3500cmd VkResult vkCreateFramebuffer(
3501        VkDevice                                    device,
3502        const VkFramebufferCreateInfo*              pCreateInfo,
3503        VkFramebuffer*                              pFramebuffer) {
3504    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO)
3505    deviceObject := GetDevice(device)
3506
3507    framebuffer := ?
3508    pFramebuffer[0] = framebuffer
3509    State.Framebuffers[framebuffer] = new!FramebufferObject(device: device)
3510
3511    return ?
3512}
3513
3514@threadSafety("system")
3515cmd void vkDestroyFramebuffer(
3516        VkDevice                                    device,
3517        VkFramebuffer                               framebuffer) {
3518    deviceObject := GetDevice(device)
3519    framebufferObject := GetFramebuffer(framebuffer)
3520    assert(framebufferObject.device == device)
3521
3522    State.Framebuffers[framebuffer] = null
3523}
3524
3525
3526// Renderpass functions
3527
3528@threadSafety("system")
3529cmd VkResult vkCreateRenderPass(
3530        VkDevice                                    device,
3531        const VkRenderPassCreateInfo*               pCreateInfo,
3532        VkRenderPass*                               pRenderPass) {
3533    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO)
3534    deviceObject := GetDevice(device)
3535
3536    renderpass := ?
3537    pRenderPass[0] = renderpass
3538    State.RenderPasses[renderpass] = new!RenderPassObject(device: device)
3539
3540    return ?
3541}
3542
3543@threadSafety("system")
3544cmd void vkDestroyRenderPass(
3545        VkDevice                                    device,
3546        VkRenderPass                                renderPass) {
3547    deviceObject := GetDevice(device)
3548    renderPassObject := GetRenderPass(renderPass)
3549    assert(renderPassObject.device == device)
3550
3551    State.RenderPasses[renderPass] = null
3552}
3553
3554cmd void vkGetRenderAreaGranularity(
3555        VkDevice                                    device,
3556        VkRenderPass                                renderPass,
3557        VkExtent2D*                                 pGranularity) {
3558    deviceObject := GetDevice(device)
3559    renderPassObject := GetRenderPass(renderPass)
3560
3561    granularity := ?
3562    pGranularity[0] = granularity
3563}
3564
3565// Command pool functions
3566
3567cmd VkResult vkCreateCommandPool(
3568        VkDevice                                    device,
3569        const VkCmdPoolCreateInfo*                  pCreateInfo,
3570        VkCmdPool*                                  pCmdPool) {
3571    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO)
3572    deviceObject := GetDevice(device)
3573
3574    cmdPool := ?
3575    pCmdPool[0] = cmdPool
3576    State.CmdPools[cmdPool] = new!CmdPoolObject(device: device)
3577
3578    return ?
3579}
3580
3581cmd void vkDestroyCommandPool(
3582        VkDevice                                    device,
3583        VkCmdPool                                   cmdPool) {
3584    deviceObject := GetDevice(device)
3585    cmdPoolObject := GetCmdPool(cmdPool)
3586    assert(cmdPoolObject.device == device)
3587
3588    State.CmdPools[cmdPool] = null
3589}
3590
3591cmd VkResult vkResetCommandPool(
3592        VkDevice                                    device,
3593        VkCmdPool                                   cmdPool,
3594        VkCmdPoolResetFlags                         flags) {
3595    deviceObject := GetDevice(device)
3596    cmdPoolObject := GetCmdPool(cmdPool)
3597    assert(cmdPoolObject.device == device)
3598
3599    return ?
3600}
3601
3602// Command buffer functions
3603
3604macro void bindCmdBuffer(VkCmdBuffer cmdBuffer, any obj, VkDeviceMemory mem) {
3605    memoryObject := GetDeviceMemory(mem)
3606    memoryObject.boundCommandBuffers[cmdBuffer] = cmdBuffer
3607
3608    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3609    cmdBufferObject.boundObjects[as!u64(obj)] = mem
3610}
3611
3612macro void unbindCmdBuffer(VkCmdBuffer cmdBuffer, any obj, VkDeviceMemory mem) {
3613    memoryObject := GetDeviceMemory(mem)
3614    memoryObject.boundCommandBuffers[cmdBuffer] = null
3615
3616    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3617    cmdBufferObject.boundObjects[as!u64(obj)] = null
3618}
3619
3620@threadSafety("system")
3621cmd VkResult vkAllocCommandBuffers(
3622        VkDevice                                    device,
3623        const VkCmdBufferAllocInfo*                 pAllocInfo,
3624        VkCmdBuffer*                                pCmdBuffers) {
3625    assert(pAllocInfo[0].sType == VK_STRUCTURE_TYPE_CMD_BUFFER_ALLOC_INFO)
3626
3627    count := pAllocInfo[0].count
3628    cmdBuffers := pCmdBuffers[0:count]
3629    for i in (0 .. count) {
3630        cmdBuffer := ?
3631        cmdBuffers[i] = cmdBuffer
3632        State.CmdBuffers[cmdBuffer] = new!CmdBufferObject(device: device)
3633    }
3634
3635    return ?
3636}
3637
3638@threadSafety("system")
3639cmd void vkFreeCommandBuffers(
3640        VkDevice                                    device,
3641        VkCmdPool                                   cmdPool,
3642        u32                                         count,
3643        const VkCmdBuffer*                          pCommandBuffers) {
3644    deviceObject := GetDevice(device)
3645
3646    cmdBuffers := pCommandBuffers[0:count]
3647    for i in (0 .. count) {
3648        cmdBufferObject := GetCmdBuffer(cmdBuffers[i])
3649        assert(cmdBufferObject.device == device)
3650        // TODO: iterate over boundObjects and clear memory bindings
3651        State.CmdBuffers[cmdBuffers[i]] = null
3652    }
3653}
3654
3655@threadSafety("app")
3656cmd VkResult vkBeginCommandBuffer(
3657        VkCmdBuffer                                 cmdBuffer,
3658        const VkCmdBufferBeginInfo*                 pBeginInfo) {
3659    assert(pBeginInfo.sType == VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO)
3660    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3661
3662    // TODO: iterate over boundObjects and clear memory bindings
3663
3664    return ?
3665}
3666
3667@threadSafety("app")
3668cmd VkResult vkEndCommandBuffer(
3669        VkCmdBuffer                                 cmdBuffer) {
3670    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3671
3672    return ?
3673}
3674
3675@threadSafety("app")
3676cmd VkResult vkResetCommandBuffer(
3677        VkCmdBuffer                                 cmdBuffer,
3678        VkCmdBufferResetFlags                       flags) {
3679    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3680
3681    // TODO: iterate over boundObjects and clear memory bindings
3682
3683    return ?
3684}
3685
3686
3687// Command buffer building functions
3688
3689@threadSafety("app")
3690cmd void vkCmdBindPipeline(
3691        VkCmdBuffer                                 cmdBuffer,
3692        VkPipelineBindPoint                         pipelineBindPoint,
3693        VkPipeline                                  pipeline) {
3694    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3695    pipelineObject := GetPipeline(pipeline)
3696    assert(cmdBufferObject.device == pipelineObject.device)
3697
3698    queueFlags := cmdBufferObject.queueFlags | switch (pipelineBindPoint) {
3699        case VK_PIPELINE_BIND_POINT_COMPUTE:  VK_QUEUE_COMPUTE_BIT
3700        case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT
3701    }
3702    cmdBufferObject.queueFlags = queueFlags
3703}
3704
3705@threadSafety("app")
3706cmd void vkCmdSetViewport(
3707        VkCmdBuffer                                 cmdBuffer,
3708        u32                                         viewportCount,
3709        const VkViewport*                           pViewports) {
3710    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3711    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3712    cmdBufferObject.queueFlags = queueFlags
3713}
3714
3715@threadSafety("app")
3716cmd void vkCmdSetScissor(
3717        VkCmdBuffer                                 cmdBuffer,
3718        u32                                         scissorCount,
3719        const VkRect2D*                             pScissors) {
3720    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3721    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3722    cmdBufferObject.queueFlags = queueFlags
3723}
3724
3725@threadSafety("app")
3726cmd void vkCmdSetLineWidth(
3727        VkCmdBuffer                                 cmdBuffer,
3728        f32                                         lineWidth) {
3729    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3730    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3731    cmdBufferObject.queueFlags = queueFlags
3732}
3733
3734@threadSafety("app")
3735cmd void vkCmdSetDepthBias(
3736        VkCmdBuffer                                 cmdBuffer,
3737        f32                                         depthBiasConstantFactor,
3738        f32                                         depthBiasClamp,
3739        f32                                         depthBiasSlopeFactor) {
3740    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3741    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3742    cmdBufferObject.queueFlags = queueFlags
3743}
3744
3745@threadSafety("app")
3746cmd void vkCmdSetBlendConstants(
3747        VkCmdBuffer                                 cmdBuffer,
3748        // TODO(jessehall): apic only supports 'const' on pointer types. Using
3749        // an annotation as a quick hack to pass this to the template without
3750        // having to modify the AST and semantic model.
3751        @readonly f32[4]                            blendConst) {
3752    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3753    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3754    cmdBufferObject.queueFlags = queueFlags
3755}
3756
3757@threadSafety("app")
3758cmd void vkCmdSetDepthBounds(
3759        VkCmdBuffer                                 cmdBuffer,
3760        f32                                         minDepthBounds,
3761        f32                                         maxDepthBounds) {
3762    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3763    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3764    cmdBufferObject.queueFlags = queueFlags
3765}
3766
3767@threadSafety("app")
3768cmd void vkCmdSetStencilCompareMask(
3769        VkCmdBuffer                                 cmdBuffer,
3770        VkStencilFaceFlags                          faceMask,
3771        u32                                         stencilCompareMask) {
3772    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3773    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3774    cmdBufferObject.queueFlags = queueFlags
3775}
3776
3777@threadSafety("app")
3778cmd void vkCmdSetStencilWriteMask(
3779        VkCmdBuffer                                 cmdBuffer,
3780        VkStencilFaceFlags                          faceMask,
3781        u32                                         stencilWriteMask) {
3782    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3783    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3784    cmdBufferObject.queueFlags = queueFlags
3785}
3786
3787@threadSafety("app")
3788cmd void vkCmdSetStencilReference(
3789        VkCmdBuffer                                 cmdBuffer,
3790        VkStencilFaceFlags                          faceMask,
3791        u32                                         stencilReference) {
3792    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3793    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3794    cmdBufferObject.queueFlags = queueFlags
3795}
3796
3797@threadSafety("app")
3798cmd void vkCmdBindDescriptorSets(
3799        VkCmdBuffer                                 cmdBuffer,
3800        VkPipelineBindPoint                         pipelineBindPoint,
3801        VkPipelineLayout                            layout,
3802        u32                                         firstSet,
3803        u32                                         setCount,
3804        const VkDescriptorSet*                      pDescriptorSets,
3805        u32                                         dynamicOffsetCount,
3806        const u32*                                  pDynamicOffsets) {
3807    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3808
3809    descriptorSets := pDescriptorSets[0:setCount]
3810    for i in (0 .. setCount) {
3811        descriptorSet := descriptorSets[i]
3812        descriptorSetObject := GetDescriptorSet(descriptorSet)
3813        assert(cmdBufferObject.device == descriptorSetObject.device)
3814    }
3815
3816    dynamicOffsets := pDynamicOffsets[0:dynamicOffsetCount]
3817    for i in (0 .. dynamicOffsetCount) {
3818        dynamicOffset := dynamicOffsets[i]
3819    }
3820
3821    queueFlags := cmdBufferObject.queueFlags | switch (pipelineBindPoint) {
3822        case VK_PIPELINE_BIND_POINT_COMPUTE:  VK_QUEUE_COMPUTE_BIT
3823        case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT
3824    }
3825    cmdBufferObject.queueFlags = queueFlags
3826}
3827
3828@threadSafety("app")
3829cmd void vkCmdBindIndexBuffer(
3830        VkCmdBuffer                                 cmdBuffer,
3831        VkBuffer                                    buffer,
3832        VkDeviceSize                                offset,
3833        VkIndexType                                 indexType) {
3834    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3835    bufferObject := GetBuffer(buffer)
3836    assert(cmdBufferObject.device == bufferObject.device)
3837
3838    bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem)
3839
3840    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3841    cmdBufferObject.queueFlags = queueFlags
3842}
3843
3844@threadSafety("app")
3845cmd void vkCmdBindVertexBuffers(
3846        VkCmdBuffer                                 cmdBuffer,
3847        u32                                         startBinding,
3848        u32                                         bindingCount,
3849        const VkBuffer*                             pBuffers,
3850        const VkDeviceSize*                         pOffsets) {
3851    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3852
3853    // TODO: check if not [startBinding:startBinding+bindingCount]
3854    buffers := pBuffers[0:bindingCount]
3855    offsets := pOffsets[0:bindingCount]
3856    for i in (0 .. bindingCount) {
3857        buffer := buffers[i]
3858        offset := offsets[i]
3859        bufferObject := GetBuffer(buffer)
3860        assert(cmdBufferObject.device == bufferObject.device)
3861
3862        bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem)
3863    }
3864
3865    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3866    cmdBufferObject.queueFlags = queueFlags
3867}
3868
3869@threadSafety("app")
3870cmd void vkCmdDraw(
3871        VkCmdBuffer                                 cmdBuffer,
3872        u32                                         vertexCount,
3873        u32                                         instanceCount,
3874        u32                                         firstVertex,
3875        u32                                         firstInstance) {
3876    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3877
3878    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3879    cmdBufferObject.queueFlags = queueFlags
3880}
3881
3882@threadSafety("app")
3883cmd void vkCmdDrawIndexed(
3884        VkCmdBuffer                                 cmdBuffer,
3885        u32                                         indexCount,
3886        u32                                         instanceCount,
3887        u32                                         firstIndex,
3888        s32                                         vertexOffset,
3889        u32                                         firstInstance) {
3890    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3891
3892    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3893    cmdBufferObject.queueFlags = queueFlags
3894}
3895
3896@threadSafety("app")
3897cmd void vkCmdDrawIndirect(
3898        VkCmdBuffer                                 cmdBuffer,
3899        VkBuffer                                    buffer,
3900        VkDeviceSize                                offset,
3901        u32                                         count,
3902        u32                                         stride) {
3903    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3904    bufferObject := GetBuffer(buffer)
3905    assert(cmdBufferObject.device == bufferObject.device)
3906
3907    bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem)
3908
3909    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3910    cmdBufferObject.queueFlags = queueFlags
3911}
3912
3913@threadSafety("app")
3914cmd void vkCmdDrawIndexedIndirect(
3915        VkCmdBuffer                                 cmdBuffer,
3916        VkBuffer                                    buffer,
3917        VkDeviceSize                                offset,
3918        u32                                         count,
3919        u32                                         stride) {
3920    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3921    bufferObject := GetBuffer(buffer)
3922    assert(cmdBufferObject.device == bufferObject.device)
3923
3924    bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem)
3925
3926    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
3927    cmdBufferObject.queueFlags = queueFlags
3928}
3929
3930@threadSafety("app")
3931cmd void vkCmdDispatch(
3932        VkCmdBuffer                                 cmdBuffer,
3933        u32                                         x,
3934        u32                                         y,
3935        u32                                         z) {
3936    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3937
3938    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_COMPUTE_BIT
3939    cmdBufferObject.queueFlags = queueFlags
3940}
3941
3942@threadSafety("app")
3943cmd void vkCmdDispatchIndirect(
3944        VkCmdBuffer                                 cmdBuffer,
3945        VkBuffer                                    buffer,
3946        VkDeviceSize                                offset) {
3947    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3948    bufferObject := GetBuffer(buffer)
3949    assert(cmdBufferObject.device == bufferObject.device)
3950
3951    bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem)
3952
3953    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_COMPUTE_BIT
3954    cmdBufferObject.queueFlags = queueFlags
3955}
3956
3957@threadSafety("app")
3958cmd void vkCmdCopyBuffer(
3959        VkCmdBuffer                                 cmdBuffer,
3960        VkBuffer                                    srcBuffer,
3961        VkBuffer                                    destBuffer,
3962        u32                                         regionCount,
3963        const VkBufferCopy*                         pRegions) {
3964    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3965    srcBufferObject := GetBuffer(srcBuffer)
3966    destBufferObject := GetBuffer(destBuffer)
3967    assert(cmdBufferObject.device == srcBufferObject.device)
3968    assert(cmdBufferObject.device == destBufferObject.device)
3969
3970    regions := pRegions[0:regionCount]
3971    for i in (0 .. regionCount) {
3972        region := regions[i]
3973    }
3974
3975    bindCmdBuffer(cmdBuffer, srcBuffer, srcBufferObject.mem)
3976    bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem)
3977
3978    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
3979    cmdBufferObject.queueFlags = queueFlags
3980}
3981
3982@threadSafety("app")
3983cmd void vkCmdCopyImage(
3984        VkCmdBuffer                                 cmdBuffer,
3985        VkImage                                     srcImage,
3986        VkImageLayout                               srcImageLayout,
3987        VkImage                                     destImage,
3988        VkImageLayout                               destImageLayout,
3989        u32                                         regionCount,
3990        const VkImageCopy*                          pRegions) {
3991    cmdBufferObject := GetCmdBuffer(cmdBuffer)
3992    srcImageObject := GetImage(srcImage)
3993    destImageObject := GetImage(destImage)
3994    assert(cmdBufferObject.device == srcImageObject.device)
3995    assert(cmdBufferObject.device == destImageObject.device)
3996
3997    regions := pRegions[0:regionCount]
3998    for i in (0 .. regionCount) {
3999        region := regions[i]
4000    }
4001
4002    bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem)
4003    bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem)
4004
4005    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
4006    cmdBufferObject.queueFlags = queueFlags
4007}
4008
4009@threadSafety("app")
4010cmd void vkCmdBlitImage(
4011        VkCmdBuffer                                 cmdBuffer,
4012        VkImage                                     srcImage,
4013        VkImageLayout                               srcImageLayout,
4014        VkImage                                     destImage,
4015        VkImageLayout                               destImageLayout,
4016        u32                                         regionCount,
4017        const VkImageBlit*                          pRegions,
4018        VkTexFilter                                 filter) {
4019    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4020    srcImageObject := GetImage(srcImage)
4021    destImageObject := GetImage(destImage)
4022    assert(cmdBufferObject.device == srcImageObject.device)
4023    assert(cmdBufferObject.device == destImageObject.device)
4024
4025    regions := pRegions[0:regionCount]
4026    for i in (0 .. regionCount) {
4027        region := regions[i]
4028    }
4029
4030    bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem)
4031    bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem)
4032
4033    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4034    cmdBufferObject.queueFlags = queueFlags
4035}
4036
4037@threadSafety("app")
4038cmd void vkCmdCopyBufferToImage(
4039        VkCmdBuffer                                 cmdBuffer,
4040        VkBuffer                                    srcBuffer,
4041        VkImage                                     destImage,
4042        VkImageLayout                               destImageLayout,
4043        u32                                         regionCount,
4044        const VkBufferImageCopy*                    pRegions) {
4045    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4046    srcBufferObject := GetBuffer(srcBuffer)
4047    destImageObject := GetImage(destImage)
4048    assert(cmdBufferObject.device == srcBufferObject.device)
4049    assert(cmdBufferObject.device == destImageObject.device)
4050
4051    regions := pRegions[0:regionCount]
4052    for i in (0 .. regionCount) {
4053        region := regions[i]
4054    }
4055
4056    bindCmdBuffer(cmdBuffer, srcBuffer, srcBufferObject.mem)
4057    bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem)
4058
4059    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
4060    cmdBufferObject.queueFlags = queueFlags
4061}
4062
4063@threadSafety("app")
4064cmd void vkCmdCopyImageToBuffer(
4065        VkCmdBuffer                                 cmdBuffer,
4066        VkImage                                     srcImage,
4067        VkImageLayout                               srcImageLayout,
4068        VkBuffer                                    destBuffer,
4069        u32                                         regionCount,
4070        const VkBufferImageCopy*                    pRegions) {
4071    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4072    srcImageObject := GetImage(srcImage)
4073    destBufferObject := GetBuffer(destBuffer)
4074    assert(cmdBufferObject.device == srcImageObject.device)
4075    assert(cmdBufferObject.device == destBufferObject.device)
4076
4077    regions := pRegions[0:regionCount]
4078    for i in (0 .. regionCount) {
4079        region := regions[i]
4080    }
4081
4082    bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem)
4083    bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem)
4084
4085    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
4086    cmdBufferObject.queueFlags = queueFlags
4087}
4088
4089@threadSafety("app")
4090cmd void vkCmdUpdateBuffer(
4091        VkCmdBuffer                                 cmdBuffer,
4092        VkBuffer                                    destBuffer,
4093        VkDeviceSize                                destOffset,
4094        VkDeviceSize                                dataSize,
4095        const u32*                                  pData) {
4096    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4097    destBufferObject := GetBuffer(destBuffer)
4098    assert(cmdBufferObject.device == destBufferObject.device)
4099
4100    data := pData[0:dataSize]
4101
4102    bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem)
4103
4104    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
4105    cmdBufferObject.queueFlags = queueFlags
4106}
4107
4108@threadSafety("app")
4109cmd void vkCmdFillBuffer(
4110        VkCmdBuffer                                 cmdBuffer,
4111        VkBuffer                                    destBuffer,
4112        VkDeviceSize                                destOffset,
4113        VkDeviceSize                                fillSize,
4114        u32                                         data) {
4115    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4116    destBufferObject := GetBuffer(destBuffer)
4117    assert(cmdBufferObject.device == destBufferObject.device)
4118
4119    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT
4120    cmdBufferObject.queueFlags = queueFlags
4121}
4122
4123@threadSafety("app")
4124cmd void vkCmdClearColorImage(
4125        VkCmdBuffer                                 cmdBuffer,
4126        VkImage                                     image,
4127        VkImageLayout                               imageLayout,
4128        const VkClearColorValue*                    pColor,
4129        u32                                         rangeCount,
4130        const VkImageSubresourceRange*              pRanges) {
4131    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4132    imageObject := GetImage(image)
4133    assert(cmdBufferObject.device == imageObject.device)
4134
4135    ranges := pRanges[0:rangeCount]
4136    for i in (0 .. rangeCount) {
4137        range := ranges[i]
4138    }
4139
4140    bindCmdBuffer(cmdBuffer, image, imageObject.mem)
4141
4142    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4143    cmdBufferObject.queueFlags = queueFlags
4144}
4145
4146@threadSafety("app")
4147cmd void vkCmdClearDepthStencilImage(
4148        VkCmdBuffer                                 cmdBuffer,
4149        VkImage                                     image,
4150        VkImageLayout                               imageLayout,
4151        const VkClearDepthStencilValue*             pDepthStencil,
4152        u32                                         rangeCount,
4153        const VkImageSubresourceRange*              pRanges) {
4154    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4155    imageObject := GetImage(image)
4156    assert(cmdBufferObject.device == imageObject.device)
4157
4158    ranges := pRanges[0:rangeCount]
4159    for i in (0 .. rangeCount) {
4160        range := ranges[i]
4161    }
4162
4163    bindCmdBuffer(cmdBuffer, image, imageObject.mem)
4164
4165    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4166    cmdBufferObject.queueFlags = queueFlags
4167}
4168
4169@threadSafety("app")
4170cmd void vkCmdClearAttachments(
4171        VkCmdBuffer                                 cmdBuffer,
4172        u32                                         attachmentCount,
4173        const VkClearAttachment*                    pAttachments,
4174        u32                                         rectCount,
4175        const VkClearRect*                          pRects) {
4176    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4177
4178    rects := pRects[0:rectCount]
4179    for i in (0 .. rectCount) {
4180        rect := rects[i]
4181    }
4182
4183    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4184    cmdBufferObject.queueFlags = queueFlags
4185}
4186
4187@threadSafety("app")
4188cmd void vkCmdResolveImage(
4189        VkCmdBuffer                                 cmdBuffer,
4190        VkImage                                     srcImage,
4191        VkImageLayout                               srcImageLayout,
4192        VkImage                                     destImage,
4193        VkImageLayout                               destImageLayout,
4194        u32                                         regionCount,
4195        const VkImageResolve*                       pRegions) {
4196    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4197    srcImageObject := GetImage(srcImage)
4198    destImageObject := GetImage(destImage)
4199    assert(cmdBufferObject.device == srcImageObject.device)
4200    assert(cmdBufferObject.device == destImageObject.device)
4201
4202    regions := pRegions[0:regionCount]
4203    for i in (0 .. regionCount) {
4204        region := regions[i]
4205    }
4206
4207    bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem)
4208    bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem)
4209
4210    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4211    cmdBufferObject.queueFlags = queueFlags
4212}
4213
4214@threadSafety("app")
4215cmd void vkCmdSetEvent(
4216        VkCmdBuffer                                 cmdBuffer,
4217        VkEvent                                     event,
4218        VkPipelineStageFlags                        stageMask) {
4219    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4220    eventObject := GetEvent(event)
4221    assert(cmdBufferObject.device == eventObject.device)
4222}
4223
4224@threadSafety("app")
4225cmd void vkCmdResetEvent(
4226        VkCmdBuffer                                 cmdBuffer,
4227        VkEvent                                     event,
4228        VkPipelineStageFlags                        stageMask) {
4229    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4230    eventObject := GetEvent(event)
4231    assert(cmdBufferObject.device == eventObject.device)
4232}
4233
4234@threadSafety("app")
4235cmd void vkCmdWaitEvents(
4236        VkCmdBuffer                                 cmdBuffer,
4237        u32                                         eventCount,
4238        const VkEvent*                              pEvents,
4239        VkPipelineStageFlags                        srcStageMask,
4240        VkPipelineStageFlags                        destStageMask,
4241        u32                                         memBarrierCount,
4242        const void* const*                          ppMemBarriers) {
4243    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4244
4245    events := pEvents[0:eventCount]
4246    for i in (0 .. eventCount) {
4247        event := events[i]
4248        eventObject := GetEvent(event)
4249        assert(cmdBufferObject.device == eventObject.device)
4250    }
4251
4252    pMemBarriers := ppMemBarriers[0:memBarrierCount]
4253    for i in (0 .. memBarrierCount) {
4254        switch as!VkMemoryBarrier const*(pMemBarriers[i])[0].sType {
4255            case VK_STRUCTURE_TYPE_MEMORY_BARRIER: {
4256                memBarrier := as!VkMemoryBarrier const*(pMemBarriers[i])[0]
4257            }
4258            case VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: {
4259                imageMemBarrier := as!VkImageMemoryBarrier const*(pMemBarriers[i])[0]
4260                imageObject := GetImage(imageMemBarrier.image)
4261                assert(imageObject.device == cmdBufferObject.device)
4262            }
4263            case VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: {
4264                bufferMemBarrier := as!VkBufferMemoryBarrier const*(pMemBarriers[i])[0]
4265                bufferObject := GetBuffer(bufferMemBarrier.buffer)
4266                assert(bufferObject.device == cmdBufferObject.device)
4267            }
4268        }
4269    }
4270}
4271
4272@threadSafety("app")
4273cmd void vkCmdPipelineBarrier(
4274        VkCmdBuffer                                 cmdBuffer,
4275        VkPipelineStageFlags                        srcStageMask,
4276        VkPipelineStageFlags                        destStageMask,
4277        VkBool32                                    byRegion,
4278        u32                                         memBarrierCount,
4279        const void* const*                          ppMemBarriers) {
4280    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4281
4282    pMemBarriers := ppMemBarriers[0:memBarrierCount]
4283    for i in (0 .. memBarrierCount) {
4284        switch as!VkMemoryBarrier const*(pMemBarriers[i])[0].sType {
4285            case VK_STRUCTURE_TYPE_MEMORY_BARRIER: {
4286                memBarrier := as!VkMemoryBarrier const*(pMemBarriers[i])[0]
4287            }
4288            case VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: {
4289                imageMemBarrier := as!VkImageMemoryBarrier const*(pMemBarriers[i])[0]
4290                imageObject := GetImage(imageMemBarrier.image)
4291                assert(imageObject.device == cmdBufferObject.device)
4292            }
4293            case VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: {
4294                bufferMemBarrier := as!VkBufferMemoryBarrier const*(pMemBarriers[i])[0]
4295                bufferObject := GetBuffer(bufferMemBarrier.buffer)
4296                assert(bufferObject.device == cmdBufferObject.device)
4297            }
4298        }
4299    }
4300}
4301
4302@threadSafety("app")
4303cmd void vkCmdBeginQuery(
4304        VkCmdBuffer                                 cmdBuffer,
4305        VkQueryPool                                 queryPool,
4306        u32                                         slot,
4307        VkQueryControlFlags                         flags) {
4308    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4309    queryPoolObject := GetQueryPool(queryPool)
4310    assert(cmdBufferObject.device == queryPoolObject.device)
4311}
4312
4313@threadSafety("app")
4314cmd void vkCmdEndQuery(
4315        VkCmdBuffer                                 cmdBuffer,
4316        VkQueryPool                                 queryPool,
4317        u32                                         slot) {
4318    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4319    queryPoolObject := GetQueryPool(queryPool)
4320    assert(cmdBufferObject.device == queryPoolObject.device)
4321}
4322
4323@threadSafety("app")
4324cmd void vkCmdResetQueryPool(
4325        VkCmdBuffer                                 cmdBuffer,
4326        VkQueryPool                                 queryPool,
4327        u32                                         startQuery,
4328        u32                                         queryCount) {
4329    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4330    queryPoolObject := GetQueryPool(queryPool)
4331    assert(cmdBufferObject.device == queryPoolObject.device)
4332}
4333
4334@threadSafety("app")
4335cmd void vkCmdWriteTimestamp(
4336        VkCmdBuffer                                 cmdBuffer,
4337        VkTimestampType                             timestampType,
4338        VkBuffer                                    destBuffer,
4339        VkDeviceSize                                destOffset) {
4340    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4341    destBufferObject := GetBuffer(destBuffer)
4342    assert(cmdBufferObject.device == destBufferObject.device)
4343}
4344
4345@threadSafety("app")
4346cmd void vkCmdCopyQueryPoolResults(
4347        VkCmdBuffer                                 cmdBuffer,
4348        VkQueryPool                                 queryPool,
4349        u32                                         startQuery,
4350        u32                                         queryCount,
4351        VkBuffer                                    destBuffer,
4352        VkDeviceSize                                destOffset,
4353        VkDeviceSize                                stride,
4354        VkQueryResultFlags                          flags) {
4355    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4356    queryPoolObject := GetQueryPool(queryPool)
4357    destBufferObject := GetBuffer(destBuffer)
4358    assert(cmdBufferObject.device == queryPoolObject.device)
4359    assert(cmdBufferObject.device == destBufferObject.device)
4360}
4361
4362cmd void vkCmdPushConstants(
4363        VkCmdBuffer                                 cmdBuffer,
4364        VkPipelineLayout                            layout,
4365        VkShaderStageFlags                          stageFlags,
4366        u32                                         start,
4367        u32                                         length,
4368        const void*                                 values) {
4369    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4370    layoutObject := GetPipelineLayout(layout)
4371    assert(cmdBufferObject.device == layoutObject.device)
4372}
4373
4374@threadSafety("app")
4375cmd void vkCmdBeginRenderPass(
4376        VkCmdBuffer                                 cmdBuffer,
4377        const VkRenderPassBeginInfo*                pRenderPassBegin,
4378        VkRenderPassContents                        contents) {
4379    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4380    renderPassObject := GetRenderPass(pRenderPassBegin.renderPass)
4381    framebufferObject := GetFramebuffer(pRenderPassBegin.framebuffer)
4382    assert(cmdBufferObject.device == renderPassObject.device)
4383    assert(cmdBufferObject.device == framebufferObject.device)
4384
4385    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4386    cmdBufferObject.queueFlags = queueFlags
4387}
4388
4389cmd void vkCmdNextSubpass(
4390        VkCmdBuffer                                 cmdBuffer,
4391        VkRenderPassContents                        contents) {
4392    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4393}
4394
4395@threadSafety("app")
4396cmd void vkCmdEndRenderPass(
4397        VkCmdBuffer                                 cmdBuffer) {
4398    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4399
4400    queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT
4401    cmdBufferObject.queueFlags = queueFlags
4402}
4403
4404cmd void vkCmdExecuteCommands(
4405        VkCmdBuffer                                 cmdBuffer,
4406        u32                                         cmdBuffersCount,
4407        const VkCmdBuffer*                          pCmdBuffers) {
4408    cmdBufferObject := GetCmdBuffer(cmdBuffer)
4409
4410    cmdBuffers := pCmdBuffers[0:cmdBuffersCount]
4411    for i in (0 .. cmdBuffersCount) {
4412        secondaryCmdBuffer := cmdBuffers[i]
4413        secondaryCmdBufferObject := GetCmdBuffer(secondaryCmdBuffer)
4414        assert(cmdBufferObject.device == secondaryCmdBufferObject.device)
4415    }
4416}
4417
4418@extension("VK_EXT_KHR_surface")
4419cmd void vkDestroySurfaceKHR(
4420        VkInstance                                  instance,
4421        VkSurfaceKHR                                surface) {
4422    instanceObject := GetInstance(instance)
4423    surfaceObject := GetSurface(surface)
4424    assert(surfaceObject.instance == instance)
4425
4426    State.Surfaces[surface] = null
4427}
4428
4429@extension("VK_EXT_KHR_surface")
4430cmd VkBool32 vkGetPhysicalDeviceSurfaceSupportKHR(
4431        VkPhysicalDevice                            physicalDevice,
4432        u32                                         queueFamilyIndex,
4433        VkSurfaceKHR                                surface) {
4434    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4435
4436    //supported := ?
4437
4438    return ?//supported
4439}
4440
4441@extension("VK_EXT_KHR_swapchain")
4442cmd VkResult vkGetSurfacePropertiesKHR(
4443        VkDevice                                    device,
4444        VkSurfaceKHR                                surface,
4445        VkSurfacePropertiesKHR*                     pSurfaceProperties) {
4446    deviceObject := GetDevice(device)
4447
4448    surfaceProperties := ?
4449    pSurfaceProperties[0] = surfaceProperties
4450
4451    return ?
4452}
4453
4454@extension("VK_EXT_KHR_swapchain")
4455cmd VkResult vkGetSurfaceFormatsKHR(
4456        VkDevice                                    device,
4457        VkSurfaceKHR                                surface,
4458        u32*                                        pCount,
4459        VkSurfaceFormatKHR*                         pSurfaceFormats) {
4460    deviceObject := GetDevice(device)
4461
4462    count := as!u32(?)
4463    pCount[0] = count
4464    surfaceFormats := pSurfaceFormats[0:count]
4465
4466    for i in (0 .. count) {
4467        surfaceFormat := ?
4468        surfaceFormats[i] = surfaceFormat
4469    }
4470
4471    return ?
4472}
4473
4474@extension("VK_EXT_KHR_swapchain")
4475cmd VkResult vkGetSurfacePresentModesKHR(
4476        VkDevice                                    device,
4477        VkSurfaceKHR                                surface,
4478        u32*                                        pCount,
4479        VkPresentModeKHR*                           pPresentModes) {
4480    deviceObject := GetDevice(device)
4481
4482    count := as!u32(?)
4483    pCount[0] = count
4484    presentModes := pPresentModes[0:count]
4485
4486    for i in (0 .. count) {
4487        presentMode := ?
4488        presentModes[i] = presentMode
4489    }
4490
4491    return ?
4492}
4493
4494@extension("VK_EXT_KHR_swapchain")
4495cmd VkResult vkCreateSwapchainKHR(
4496        VkDevice                                 device,
4497        const VkSwapchainCreateInfoKHR*          pCreateInfo,
4498        VkSwapchainKHR*                          pSwapchain) {
4499    assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR)
4500    deviceObject := GetDevice(device)
4501
4502    swapchain := ?
4503    pSwapchain[0] = swapchain
4504    State.Swapchains[swapchain] = new!SwapchainObject(device: device)
4505
4506    return ?
4507}
4508
4509@extension("VK_EXT_KHR_swapchain")
4510cmd void vkDestroySwapchainKHR(
4511        VkDevice                                 device,
4512        VkSwapchainKHR                           swapchain) {
4513    deviceObject := GetDevice(device)
4514    swapchainObject := GetSwapchain(swapchain)
4515    assert(swapchainObject.device == device)
4516
4517    State.Swapchains[swapchain] = null
4518}
4519
4520@extension("VK_EXT_KHR_swapchain")
4521cmd VkResult vkGetSwapchainImagesKHR(
4522        VkDevice                                 device,
4523        VkSwapchainKHR                           swapchain,
4524        u32*                                     pCount,
4525        VkImage*                                 pSwapchainImages) {
4526    deviceObject := GetDevice(device)
4527
4528    count := as!u32(?)
4529    pCount[0] = count
4530    swapchainImages := pSwapchainImages[0:count]
4531
4532    for i in (0 .. count) {
4533        swapchainImage := ?
4534        swapchainImages[i] = swapchainImage
4535        State.Images[swapchainImage] = new!ImageObject(device: device)
4536    }
4537
4538    return ?
4539}
4540
4541@extension("VK_EXT_KHR_swapchain")
4542cmd VkResult vkAcquireNextImageKHR(
4543        VkDevice                                 device,
4544        VkSwapchainKHR                           swapchain,
4545        u64                                      timeout,
4546        VkSemaphore                              semaphore,
4547        VkFence                                  fence,
4548        u32*                                     pImageIndex) {
4549    deviceObject := GetDevice(device)
4550    swapchainObject := GetSwapchain(swapchain)
4551
4552    imageIndex := ?
4553    pImageIndex[0] = imageIndex
4554
4555    return ?
4556}
4557
4558@extension("VK_EXT_KHR_swapchain")
4559cmd VkResult vkQueuePresentKHR(
4560        VkQueue                                  queue,
4561        VkPresentInfoKHR*                        pPresentInfo) {
4562    queueObject := GetQueue(queue)
4563
4564    presentInfo := ?
4565    pPresentInfo[0] = presentInfo
4566
4567    return ?
4568}
4569
4570@extension("VK_EXT_KHR_display")
4571cmd VkResult vkGetPhysicalDeviceDisplayPropertiesKHR(
4572        VkPhysicalDevice                        physicalDevice,
4573        u32*                                    count,
4574        VkDisplayPropertiesKHR*                 pProperties) {
4575    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4576    return ?
4577}
4578
4579@extension("VK_EXT_KHR_display")
4580cmd VkResult vkGetDisplayModePropertiesKHR(
4581        VkPhysicalDevice                        physicalDevice,
4582        VkDisplayKHR                            display,
4583        u32*                                    pCount,
4584        VkDisplayModePropertiesKHR*             pModeProperties) {
4585    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4586    return ?
4587}
4588
4589@extension("VK_EXT_KHR_display")
4590cmd VkResult vkCreateDisplayModeKHR(
4591        VkPhysicalDevice                        physicalDevice,
4592        VkDisplayKHR                            display,
4593        const VkDisplayModeCreateInfoKHR*       pCreateInfo,
4594        VkDisplayModeKHR*                       pMode) {
4595    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4596    return ?
4597}
4598
4599@extension("VK_EXT_KHR_display")
4600cmd VkResult vkGetDisplayPlanePropertiesKHR(
4601        VkPhysicalDevice                        physicalDevice,
4602        VkDisplayKHR                            display,
4603        VkDisplayModeKHR                        mode,
4604        u32                                     planeIndex,
4605        VkDisplayPlanePropertiesKHR*            pProperties) {
4606    physicalDeviceObject := GetPhysicalDevice(physicalDevice)
4607    return ?
4608}
4609
4610@extension("VK_EXT_KHR_x11_surface")
4611cmd VkResult vkCreateX11SurfaceKHR(
4612        VkInstance                              instance,
4613        platform.Display*                       dpy,
4614        platform.Window                         root,
4615        platform.Window                         window,
4616        VkSurfaceKHR*                           pSurface) {
4617    instanceObject := GetInstance(instance)
4618    return ?
4619}
4620
4621@extension("VK_EXT_KHR_xcb_surface")
4622cmd VkResult vkCreateXCBSurfaceKHR(
4623        VkInstance                              instance,
4624        platform.xcb_connection_t*              connection,
4625        platform.xcb_window_t                   root,
4626        platform.xcb_window_t                   window,
4627        VkSurfaceKHR*                           pSurface) {
4628    instanceObject := GetInstance(instance)
4629    return ?
4630}
4631
4632@extension("VK_EXT_KHR_wayland_surface")
4633cmd VkResult vkCreateWaylandSurfaceKHR(
4634        VkInstance                              instance,
4635        platform.wl_display*                    display,
4636        platform.wl_surface*                    surface,
4637        VkSurfaceKHR*                           pSurface) {
4638    instanceObject := GetInstance(instance)
4639    return ?
4640}
4641
4642@extension("VK_EXT_KHR_mir_surface")
4643cmd VkResult vkCreateMirSurfaceKHR(
4644        VkInstance                              instance,
4645        platform.MirConnection*                 connection,
4646        platform.MirSurface*                    mirSurface,
4647        VkSurfaceKHR*                           pSurface) {
4648    instanceObject := GetInstance(instance)
4649    return ?
4650}
4651
4652@extension("VK_EXT_KHR_android_surface")
4653cmd VkResult vkCreateAndroidSurfaceKHR(
4654        VkInstance                              instance,
4655        platform.ANativeWindow*                 window
4656        VkSurfaceKHR*                           pSurface) {
4657    instanceObject := GetInstance(instance)
4658    return ?
4659}
4660
4661@extension("VK_EXT_KHR_win32_surface")
4662cmd VkResult vkCreateWin32SurfaceKHR(
4663        VkInstance                              instance,
4664        platform.HINSTANCE                      hinstance,
4665        platform.HWND                           hwnd,
4666        VkSurfaceKHR*                           pSurface) {
4667    instanceObject := GetInstance(instance)
4668    return ?
4669}
4670
4671
4672////////////////
4673// Validation //
4674////////////////
4675
4676extern void validate(string layerName, bool condition, string message)
4677
4678
4679/////////////////////////////
4680// Internal State Tracking //
4681/////////////////////////////
4682
4683StateObject State
4684
4685@internal class StateObject {
4686    // Dispatchable objects.
4687    map!(VkInstance,       ref!InstanceObject)       Instances
4688    map!(VkPhysicalDevice, ref!PhysicalDeviceObject) PhysicalDevices
4689    map!(VkDevice,         ref!DeviceObject)         Devices
4690    map!(VkQueue,          ref!QueueObject)          Queues
4691    map!(VkCmdBuffer,      ref!CmdBufferObject)      CmdBuffers
4692
4693    // Non-dispatchable objects.
4694    map!(VkDeviceMemory,             ref!DeviceMemoryObject)             DeviceMemories
4695    map!(VkBuffer,                   ref!BufferObject)                   Buffers
4696    map!(VkBufferView,               ref!BufferViewObject)               BufferViews
4697    map!(VkImage,                    ref!ImageObject)                    Images
4698    map!(VkImageView,                ref!ImageViewObject)                ImageViews
4699    map!(VkShaderModule,             ref!ShaderModuleObject)             ShaderModules
4700    map!(VkShader,                   ref!ShaderObject)                   Shaders
4701    map!(VkPipeline,                 ref!PipelineObject)                 Pipelines
4702    map!(VkPipelineLayout,           ref!PipelineLayoutObject)           PipelineLayouts
4703    map!(VkSampler,                  ref!SamplerObject)                  Samplers
4704    map!(VkDescriptorSet,            ref!DescriptorSetObject)            DescriptorSets
4705    map!(VkDescriptorSetLayout,      ref!DescriptorSetLayoutObject)      DescriptorSetLayouts
4706    map!(VkDescriptorPool,           ref!DescriptorPoolObject)           DescriptorPools
4707    map!(VkFence,                    ref!FenceObject)                    Fences
4708    map!(VkSemaphore,                ref!SemaphoreObject)                Semaphores
4709    map!(VkEvent,                    ref!EventObject)                    Events
4710    map!(VkQueryPool,                ref!QueryPoolObject)                QueryPools
4711    map!(VkFramebuffer,              ref!FramebufferObject)              Framebuffers
4712    map!(VkRenderPass,               ref!RenderPassObject)               RenderPasses
4713    map!(VkPipelineCache,            ref!PipelineCacheObject)            PipelineCaches
4714    map!(VkCmdPool,                  ref!CmdPoolObject)                  CmdPools
4715    map!(VkSurfaceKHR,               ref!SurfaceObject)                  Surfaces
4716    map!(VkSwapchainKHR,             ref!SwapchainObject)                Swapchains
4717}
4718
4719@internal class InstanceObject {
4720}
4721
4722@internal class PhysicalDeviceObject {
4723    VkInstance instance
4724}
4725
4726@internal class DeviceObject {
4727    VkPhysicalDevice physicalDevice
4728}
4729
4730@internal class QueueObject {
4731    VkDevice      device
4732    VkQueueFlags  flags
4733}
4734
4735@internal class CmdBufferObject {
4736    VkDevice                  device
4737    map!(u64, VkDeviceMemory) boundObjects
4738    VkQueueFlags              queueFlags
4739}
4740
4741@internal class DeviceMemoryObject {
4742    VkDevice                         device
4743    VkDeviceSize                     allocationSize
4744    map!(u64, VkDeviceSize         ) boundObjects
4745    map!(VkCmdBuffer, VkCmdBuffer)   boundCommandBuffers
4746}
4747
4748@internal class BufferObject {
4749    VkDevice              device
4750    VkDeviceMemory        mem
4751    VkDeviceSize          memOffset
4752}
4753
4754@internal class BufferViewObject {
4755    VkDevice      device
4756    VkBuffer      buffer
4757}
4758
4759@internal class ImageObject {
4760    VkDevice              device
4761    VkDeviceMemory        mem
4762    VkDeviceSize          memOffset
4763}
4764
4765@internal class ImageViewObject {
4766    VkDevice      device
4767    VkImage       image
4768}
4769
4770@internal class ShaderObject {
4771    VkDevice      device
4772}
4773
4774@internal class ShaderModuleObject {
4775    VkDevice      device
4776}
4777
4778@internal class PipelineObject {
4779    VkDevice      device
4780}
4781
4782@internal class PipelineLayoutObject {
4783    VkDevice      device
4784}
4785
4786@internal class SamplerObject {
4787    VkDevice      device
4788}
4789
4790@internal class DescriptorSetObject {
4791    VkDevice      device
4792}
4793
4794@internal class DescriptorSetLayoutObject {
4795    VkDevice      device
4796}
4797
4798@internal class DescriptorPoolObject {
4799    VkDevice      device
4800}
4801
4802@internal class FenceObject {
4803    VkDevice      device
4804    bool          signaled
4805}
4806
4807@internal class SemaphoreObject {
4808    VkDevice      device
4809}
4810
4811@internal class EventObject {
4812    VkDevice      device
4813}
4814
4815@internal class QueryPoolObject {
4816    VkDevice      device
4817}
4818
4819@internal class FramebufferObject {
4820    VkDevice      device
4821}
4822
4823@internal class RenderPassObject {
4824    VkDevice      device
4825}
4826
4827@internal class PipelineCacheObject {
4828    VkDevice      device
4829}
4830
4831@internal class CmdPoolObject {
4832    VkDevice      device
4833}
4834
4835@internal class SurfaceObject {
4836    VkInstance    instance
4837}
4838
4839@internal class SwapchainObject {
4840    VkDevice      device
4841}
4842
4843macro ref!InstanceObject GetInstance(VkInstance instance) {
4844    assert(instance in State.Instances)
4845    return State.Instances[instance]
4846}
4847
4848macro ref!PhysicalDeviceObject GetPhysicalDevice(VkPhysicalDevice physicalDevice) {
4849    assert(physicalDevice in State.PhysicalDevices)
4850    return State.PhysicalDevices[physicalDevice]
4851}
4852
4853macro ref!DeviceObject GetDevice(VkDevice device) {
4854    assert(device in State.Devices)
4855    return State.Devices[device]
4856}
4857
4858macro ref!QueueObject GetQueue(VkQueue queue) {
4859    assert(queue in State.Queues)
4860    return State.Queues[queue]
4861}
4862
4863macro ref!CmdBufferObject GetCmdBuffer(VkCmdBuffer cmdBuffer) {
4864    assert(cmdBuffer in State.CmdBuffers)
4865    return State.CmdBuffers[cmdBuffer]
4866}
4867
4868macro ref!DeviceMemoryObject GetDeviceMemory(VkDeviceMemory mem) {
4869    assert(mem in State.DeviceMemories)
4870    return State.DeviceMemories[mem]
4871}
4872
4873macro ref!BufferObject GetBuffer(VkBuffer buffer) {
4874    assert(buffer in State.Buffers)
4875    return State.Buffers[buffer]
4876}
4877
4878macro ref!BufferViewObject GetBufferView(VkBufferView bufferView) {
4879    assert(bufferView in State.BufferViews)
4880    return State.BufferViews[bufferView]
4881}
4882
4883macro ref!ImageObject GetImage(VkImage image) {
4884    assert(image in State.Images)
4885    return State.Images[image]
4886}
4887
4888macro ref!ImageViewObject GetImageView(VkImageView imageView) {
4889    assert(imageView in State.ImageViews)
4890    return State.ImageViews[imageView]
4891}
4892
4893macro ref!ShaderObject GetShader(VkShader shader) {
4894    assert(shader in State.Shaders)
4895    return State.Shaders[shader]
4896}
4897
4898macro ref!ShaderModuleObject GetShaderModule(VkShaderModule shaderModule) {
4899    assert(shaderModule in State.ShaderModules)
4900    return State.ShaderModules[shaderModule]
4901}
4902
4903macro ref!PipelineObject GetPipeline(VkPipeline pipeline) {
4904    assert(pipeline in State.Pipelines)
4905    return State.Pipelines[pipeline]
4906}
4907
4908macro ref!PipelineLayoutObject GetPipelineLayout(VkPipelineLayout pipelineLayout) {
4909    assert(pipelineLayout in State.PipelineLayouts)
4910    return State.PipelineLayouts[pipelineLayout]
4911}
4912
4913macro ref!SamplerObject GetSampler(VkSampler sampler) {
4914    assert(sampler in State.Samplers)
4915    return State.Samplers[sampler]
4916}
4917
4918macro ref!DescriptorSetObject GetDescriptorSet(VkDescriptorSet descriptorSet) {
4919    assert(descriptorSet in State.DescriptorSets)
4920    return State.DescriptorSets[descriptorSet]
4921}
4922
4923macro ref!DescriptorSetLayoutObject GetDescriptorSetLayout(VkDescriptorSetLayout descriptorSetLayout) {
4924    assert(descriptorSetLayout in State.DescriptorSetLayouts)
4925    return State.DescriptorSetLayouts[descriptorSetLayout]
4926}
4927
4928macro ref!DescriptorPoolObject GetDescriptorPool(VkDescriptorPool descriptorPool) {
4929    assert(descriptorPool in State.DescriptorPools)
4930    return State.DescriptorPools[descriptorPool]
4931}
4932
4933macro ref!FenceObject GetFence(VkFence fence) {
4934    assert(fence in State.Fences)
4935    return State.Fences[fence]
4936}
4937
4938macro ref!SemaphoreObject GetSemaphore(VkSemaphore semaphore) {
4939    assert(semaphore in State.Semaphores)
4940    return State.Semaphores[semaphore]
4941}
4942
4943macro ref!EventObject GetEvent(VkEvent event) {
4944    assert(event in State.Events)
4945    return State.Events[event]
4946}
4947
4948macro ref!QueryPoolObject GetQueryPool(VkQueryPool queryPool) {
4949    assert(queryPool in State.QueryPools)
4950    return State.QueryPools[queryPool]
4951}
4952
4953macro ref!FramebufferObject GetFramebuffer(VkFramebuffer framebuffer) {
4954    assert(framebuffer in State.Framebuffers)
4955    return State.Framebuffers[framebuffer]
4956}
4957
4958macro ref!RenderPassObject GetRenderPass(VkRenderPass renderPass) {
4959    assert(renderPass in State.RenderPasses)
4960    return State.RenderPasses[renderPass]
4961}
4962
4963macro ref!PipelineCacheObject GetPipelineCache(VkPipelineCache pipelineCache) {
4964    assert(pipelineCache in State.PipelineCaches)
4965    return State.PipelineCaches[pipelineCache]
4966}
4967
4968macro ref!CmdPoolObject GetCmdPool(VkCmdPool cmdPool) {
4969    assert(cmdPool in State.CmdPools)
4970    return State.CmdPools[cmdPool]
4971}
4972
4973macro ref!SurfaceObject GetSurface(VkSurfaceKHR surface) {
4974    assert(surface in State.Surfaces)
4975    return State.Surfaces[surface]
4976}
4977
4978macro ref!SwapchainObject GetSwapchain(VkSwapchainKHR swapchain) {
4979    assert(swapchain in State.Swapchains)
4980    return State.Swapchains[swapchain]
4981}
4982