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