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