vulkan.api revision 88594d744093a8429030cf4f4a9ec22f25dfd500
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 170 31define VERSION_PATCH 2 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_TESS_CONTROL = 0x00000001, 542 VK_SHADER_STAGE_TESS_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_HOST_WRITE_COMBINED_BIT = 0x00000008, /// Memory should support host write combining 699 VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010, /// Memory may be allocated by the driver when it is required 700} 701 702/// Memory heap flags 703bitfield VkMemoryHeapFlags { 704 VK_MEMORY_HEAP_HOST_LOCAL_BIT = 0x00000001, /// If set, heap represents host memory 705} 706 707/// Memory output flags passed to resource transition commands 708bitfield VkMemoryOutputFlags { 709 VK_MEMORY_OUTPUT_HOST_WRITE_BIT = 0x00000001, /// Controls output coherency of host writes 710 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT = 0x00000002, /// Controls output coherency of generic shader writes 711 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT = 0x00000004, /// Controls output coherency of color attachment writes 712 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000008, /// Controls output coherency of depth/stencil attachment writes 713 VK_MEMORY_OUTPUT_TRANSFER_BIT = 0x00000010, /// Controls output coherency of transfer operations 714} 715 716/// Memory input flags passed to resource transition commands 717bitfield VkMemoryInputFlags { 718 VK_MEMORY_INPUT_HOST_READ_BIT = 0x00000001, /// Controls input coherency of host reads 719 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT = 0x00000002, /// Controls input coherency of indirect command reads 720 VK_MEMORY_INPUT_INDEX_FETCH_BIT = 0x00000004, /// Controls input coherency of index fetches 721 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT = 0x00000008, /// Controls input coherency of vertex attribute fetches 722 VK_MEMORY_INPUT_UNIFORM_READ_BIT = 0x00000010, /// Controls input coherency of uniform buffer reads 723 VK_MEMORY_INPUT_SHADER_READ_BIT = 0x00000020, /// Controls input coherency of generic shader reads 724 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT = 0x00000040, /// Controls input coherency of color attachment reads 725 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000080, /// Controls input coherency of depth/stencil attachment reads 726 VK_MEMORY_INPUT_INPUT_ATTACHMENT_BIT = 0x00000100, /// Controls input coherency of input attachment reads 727 VK_MEMORY_INPUT_TRANSFER_BIT = 0x00000200, /// Controls input coherency of transfer operations 728} 729 730/// Buffer usage flags 731bitfield VkBufferUsageFlags { 732 VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT = 0x00000001, /// Can be used as a source of transfer operations 733 VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT = 0x00000002, /// Can be used as a destination of transfer operations 734 VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, /// Can be used as TBO 735 VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x00000008, /// Can be used as IBO 736 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x00000010, /// Can be used as UBO 737 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020, /// Can be used as SSBO 738 VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040, /// Can be used as source of fixed function index fetch (index buffer) 739 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, /// Can be used as source of fixed function vertex fetch (VBO) 740 VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, /// Can be the source of indirect parameters (e.g. indirect buffer, parameter buffer) 741} 742 743/// Buffer creation flags 744bitfield VkBufferCreateFlags { 745 VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, /// Buffer should support sparse backing 746 VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, /// Buffer should support sparse backing with partial residency 747 VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, /// Buffer should support constent data access to physical memory blocks mapped into multiple locations of sparse buffers 748} 749 750/// Shader stage flags 751bitfield VkShaderStageFlags { 752 VK_SHADER_STAGE_VERTEX_BIT = 0x00000001, 753 VK_SHADER_STAGE_TESS_CONTROL_BIT = 0x00000002, 754 VK_SHADER_STAGE_TESS_EVALUATION_BIT = 0x00000004, 755 VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008, 756 VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010, 757 VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020, 758 759 VK_SHADER_STAGE_ALL = 0x7FFFFFFF, 760} 761 762/// Image usage flags 763bitfield VkImageUsageFlags { 764 VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT = 0x00000001, /// Can be used as a source of transfer operations 765 VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT = 0x00000002, /// Can be used as a destination of transfer operations 766 VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, /// Can be sampled from (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types) 767 VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, /// Can be used as storage image (STORAGE_IMAGE descriptor type) 768 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, /// Can be used as framebuffer color attachment 769 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, /// Can be used as framebuffer depth/stencil attachment 770 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, /// Image data not needed outside of rendering 771 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, /// Can be used as framebuffer input attachment 772} 773 774/// Image creation flags 775bitfield VkImageCreateFlags { 776 VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, /// Image should support sparse backing 777 VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, /// Image should support sparse backing with partial residency 778 VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, /// Image should support constent data access to physical memory blocks mapped into multiple locations of sparse images 779 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, /// Allows image views to have different format than the base image 780 VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, /// Allows creating image views with cube type from the created image 781} 782 783/// Framebuffer attachment view creation flags 784bitfield VkImageViewCreateFlags { 785 VK_IMAGE_VIEW_CREATE_READ_ONLY_DEPTH_BIT = 0x00000001, 786 VK_IMAGE_VIEW_CREATE_READ_ONLY_STENCIL_BIT = 0x00000002, 787} 788 789/// Pipeline creation flags 790bitfield VkPipelineCreateFlags { 791 VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, 792 VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002, 793 VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004, 794} 795 796/// Channel flags 797bitfield VkChannelFlags { 798 VK_CHANNEL_R_BIT = 0x00000001, 799 VK_CHANNEL_G_BIT = 0x00000002, 800 VK_CHANNEL_B_BIT = 0x00000004, 801 VK_CHANNEL_A_BIT = 0x00000008, 802} 803 804/// Fence creation flags 805bitfield VkFenceCreateFlags { 806 VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001, 807} 808 809/// Semaphore creation flags 810bitfield VkSemaphoreCreateFlags { 811} 812 813/// Format capability flags 814bitfield VkFormatFeatureFlags { 815 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001, /// Format can be used for sampled images (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types) 816 VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002, /// Format can be used for storage images (STORAGE_IMAGE descriptor type) 817 VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004, /// Format supports atomic operations in case it's used for storage images 818 VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008, /// Format can be used for uniform texel buffers (TBOs) 819 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 0x00000010, /// Format can be used for storage texel buffers (IBOs) 820 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020, /// Format supports atomic operations in case it's used for storage texel buffers 821 VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 0x00000040, /// Format can be used for vertex buffers (VBOs) 822 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080, /// Format can be used for color attachment images 823 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100, /// Format supports blending in case it's used for color attachment images 824 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200, /// Format can be used for depth/stencil attachment images 825 VK_FORMAT_FEATURE_BLIT_SOURCE_BIT = 0x00000400, /// Format can be used as the source image of blits with vkCmdBlitImage 826 VK_FORMAT_FEATURE_BLIT_DESTINATION_BIT = 0x00000800, /// Format can be used as the destination image of blits with vkCmdBlitImage 827} 828 829/// Query control flags 830bitfield VkQueryControlFlags { 831 VK_QUERY_CONTROL_CONSERVATIVE_BIT = 0x00000001, /// Allow conservative results to be collected by the query 832} 833 834/// Query result flags 835bitfield VkQueryResultFlags { 836 VK_QUERY_RESULT_DEFAULT = 0x00000000, /// Results of the queries are immediately written to the destination buffer as 32-bit values 837 VK_QUERY_RESULT_64_BIT = 0x00000001, /// Results of the queries are written to the destination buffer as 64-bit values 838 VK_QUERY_RESULT_WAIT_BIT = 0x00000002, /// Results of the queries are waited on before proceeding with the result copy 839 VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, /// Besides the results of the query, the availability of the results is also written 840 VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, /// Copy the partial results of the query even if the final results aren't available 841} 842 843/// Shader module creation flags 844bitfield VkShaderModuleCreateFlags { 845} 846 847/// Shader creation flags 848bitfield VkShaderCreateFlags { 849} 850 851/// Event creation flags 852bitfield VkEventCreateFlags { 853} 854 855/// Command buffer creation flags 856bitfield VkCmdBufferCreateFlags { 857} 858 859/// Command buffer optimization flags 860bitfield VkCmdBufferOptimizeFlags { 861 VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT = 0x00000001, 862 VK_CMD_BUFFER_OPTIMIZE_PIPELINE_SWITCH_BIT = 0x00000002, 863 VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT = 0x00000004, 864 VK_CMD_BUFFER_OPTIMIZE_DESCRIPTOR_SET_SWITCH_BIT = 0x00000008, 865 VK_CMD_BUFFER_OPTIMIZE_NO_SIMULTANEOUS_USE_BIT = 0x00000010, /// Only one call to the secondary command buffer will exist at any given time 866} 867 868/// Pipeline statistics flags 869bitfield VkQueryPipelineStatisticFlags { 870 VK_QUERY_PIPELINE_STATISTIC_IA_VERTICES_BIT = 0x00000001, /// Optional 871 VK_QUERY_PIPELINE_STATISTIC_IA_PRIMITIVES_BIT = 0x00000002, /// Optional 872 VK_QUERY_PIPELINE_STATISTIC_VS_INVOCATIONS_BIT = 0x00000004, /// Optional 873 VK_QUERY_PIPELINE_STATISTIC_GS_INVOCATIONS_BIT = 0x00000008, /// Optional 874 VK_QUERY_PIPELINE_STATISTIC_GS_PRIMITIVES_BIT = 0x00000010, /// Optional 875 VK_QUERY_PIPELINE_STATISTIC_C_INVOCATIONS_BIT = 0x00000020, /// Optional 876 VK_QUERY_PIPELINE_STATISTIC_C_PRIMITIVES_BIT = 0x00000040, /// Optional 877 VK_QUERY_PIPELINE_STATISTIC_FS_INVOCATIONS_BIT = 0x00000080, /// Optional 878 VK_QUERY_PIPELINE_STATISTIC_TCS_PATCHES_BIT = 0x00000100, /// Optional 879 VK_QUERY_PIPELINE_STATISTIC_TES_INVOCATIONS_BIT = 0x00000200, /// Optional 880 VK_QUERY_PIPELINE_STATISTIC_CS_INVOCATIONS_BIT = 0x00000400, /// Optional 881} 882 883/// Memory mapping flags 884bitfield VkMemoryMapFlags { 885} 886 887/// Bitfield of image aspects 888bitfield VkImageAspectFlags { 889 VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, 890 VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, 891 VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, 892 VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, 893} 894 895/// Sparse memory bind flags 896bitfield VkSparseMemoryBindFlags { 897 VK_SPARSE_MEMORY_BIND_REPLICATE_64KIB_BLOCK_BIT = 0x00000001, /// Replicate the first 64 KiB memory block to the entire bind rage 898} 899 900/// Sparse image memory requirements flags 901bitfield VkSparseImageFormatFlags { 902 VK_SPARSE_IMAGE_FMT_SINGLE_MIPTAIL_BIT = 0x00000001, /// Image uses a single miptail region for all array slices 903 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. 904 VK_SPARSE_IMAGE_FMT_NONSTD_BLOCK_SIZE_BIT = 0x00000004, /// Image uses a non-standard sparse block size 905} 906 907/// Pipeline stages 908bitfield VkPipelineStageFlags { 909 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, /// Before subsequent commands are processed 910 VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, /// Draw/DispatchIndirect command fetch 911 VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, /// Vertex/index fetch 912 VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008, /// Vertex shading 913 VK_PIPELINE_STAGE_TESS_CONTROL_SHADER_BIT = 0x00000010, /// Tessellation control shading 914 VK_PIPELINE_STAGE_TESS_EVALUATION_SHADER_BIT = 0x00000020, /// Tessellation evaluation shading 915 VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040, /// Geometry shading 916 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080, /// Fragment shading 917 VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100, /// Early fragment (depth/stencil) tests 918 VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200, /// Late fragment (depth/stencil) tests 919 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, /// Color attachment writes 920 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, /// Compute shading 921 VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, /// Transfer/copy operations 922 VK_PIPELINE_STAGE_HOST_BIT = 0x00002000, /// Indicates host (CPU) is a source/sink of the dependency 923 924 VK_PIPELINE_STAGE_ALL_GRAPHICS = 0x000007FF, /// All stages of the graphics pipeline 925 VK_PIPELINE_STAGE_ALL_GPU_COMMANDS = 0x00001FFF, /// All graphics, compute, copy, and transition commands 926} 927 928/// Render pass attachment description flags 929bitfield VkAttachmentDescriptionFlags { 930 VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, /// The attachment may alias physical memory of another attachment in the same renderpass 931} 932 933/// Subpass description flags 934bitfield VkSubpassDescriptionFlags { 935 VK_SUBPASS_DESCRIPTION_NO_OVERDRAW_BIT = 0x00000001, 936} 937 938/// Command pool creation flags 939bitfield VkCmdPoolCreateFlags { 940 VK_CMD_POOL_CREATE_TRANSIENT_BIT = 0x00000001, /// Command buffers have a short lifetime 941 VK_CMD_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002, /// Command buffers may release their memory individually 942} 943 944/// Command pool reset flags 945bitfield VkCmdPoolResetFlags { 946 VK_CMD_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, /// Release resources owned by the pool 947} 948 949bitfield VkCmdBufferResetFlags { 950 VK_CMD_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, /// Release resources owned by the buffer 951} 952 953bitfield VkSampleCountFlags { 954 VK_SAMPLE_COUNT_1_BIT = 0x00000001, 955 VK_SAMPLE_COUNT_2_BIT = 0x00000002, 956 VK_SAMPLE_COUNT_4_BIT = 0x00000004, 957 VK_SAMPLE_COUNT_8_BIT = 0x00000008, 958 VK_SAMPLE_COUNT_16_BIT = 0x00000010, 959 VK_SAMPLE_COUNT_32_BIT = 0x00000020, 960 VK_SAMPLE_COUNT_64_BIT = 0x00000040, 961} 962 963bitfield VkStencilFaceFlags { 964 VK_STENCIL_FACE_NONE = 0x00000000, /// No faces 965 VK_STENCIL_FACE_FRONT_BIT = 0x00000001, /// Front face 966 VK_STENCIL_FACE_BACK_BIT = 0x00000002, /// Back face 967} 968 969////////////////// 970// Extensions // 971////////////////// 972 973@extension("VK_EXT_KHR_swapchain") 974bitfield VkSurfaceTransformFlagsKHR { 975 VK_SURFACE_TRANSFORM_NONE_BIT_KHR = 0x00000001, 976 VK_SURFACE_TRANSFORM_ROT90_BIT_KHR = 0x00000002, 977 VK_SURFACE_TRANSFORM_ROT180_BIT_KHR = 0x00000004, 978 VK_SURFACE_TRANSFORM_ROT270_BIT_KHR = 0x00000008, 979 VK_SURFACE_TRANSFORM_HMIRROR_BIT_KHR = 0x00000010, 980 VK_SURFACE_TRANSFORM_HMIRROR_ROT90_BIT_KHR = 0x00000020, 981 VK_SURFACE_TRANSFORM_HMIRROR_ROT180_BIT_KHR = 0x00000040, 982 VK_SURFACE_TRANSFORM_HMIRROR_ROT270_BIT_KHR = 0x00000080, 983 VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, 984} 985 986////////////////// 987// Structures // 988////////////////// 989 990class VkOffset2D { 991 s32 x 992 s32 y 993} 994 995class VkOffset3D { 996 s32 x 997 s32 y 998 s32 z 999} 1000 1001class VkExtent2D { 1002 s32 width 1003 s32 height 1004} 1005 1006class VkExtent3D { 1007 s32 width 1008 s32 height 1009 s32 depth 1010} 1011 1012class VkViewport { 1013 f32 originX 1014 f32 originY 1015 f32 width 1016 f32 height 1017 f32 minDepth 1018 f32 maxDepth 1019} 1020 1021class VkRect2D { 1022 VkOffset2D offset 1023 VkExtent2D extent 1024} 1025 1026class VkRect3D { 1027 VkOffset3D offset 1028 VkExtent3D extent 1029} 1030 1031class VkChannelMapping { 1032 VkChannelSwizzle r 1033 VkChannelSwizzle g 1034 VkChannelSwizzle b 1035 VkChannelSwizzle a 1036} 1037 1038class VkPhysicalDeviceProperties { 1039 u32 apiVersion 1040 u32 driverVersion 1041 u32 vendorId 1042 u32 deviceId 1043 VkPhysicalDeviceType deviceType 1044 char[VK_MAX_PHYSICAL_DEVICE_NAME] deviceName 1045 u8[VK_UUID_LENGTH] pipelineCacheUUID 1046 VkPhysicalDeviceLimits limits 1047 VkPhysicalDeviceSparseProperties sparseProperties 1048} 1049 1050class VkExtensionProperties { 1051 char[VK_MAX_EXTENSION_NAME] extName /// extension name 1052 u32 specVersion /// version of the extension specification implemented 1053} 1054 1055class VkLayerProperties { 1056 char[VK_MAX_EXTENSION_NAME] layerName /// layer name 1057 u32 specVersion /// version of the layer specification implemented 1058 u32 implVersion /// build or release version of the layer's library 1059 char[VK_MAX_DESCRIPTION] description /// Free-form description of the layer 1060} 1061 1062class VkApplicationInfo { 1063 VkStructureType sType /// Type of structure. Should be VK_STRUCTURE_TYPE_APPLICATION_INFO 1064 const void* pNext /// Next structure in chain 1065 const char* pAppName 1066 u32 appVersion 1067 const char* pEngineName 1068 u32 engineVersion 1069 u32 apiVersion 1070} 1071 1072class VkAllocCallbacks { 1073 void* pUserData 1074 PFN_vkAllocFunction pfnAlloc 1075 PFN_vkFreeFunction pfnFree 1076} 1077 1078class VkDeviceQueueCreateInfo { 1079 VkStructureType sStype /// Should be VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO 1080 const void* pNext /// Pointer to next structure 1081 u32 queueFamilyIndex 1082 u32 queueCount 1083} 1084 1085class VkDeviceCreateInfo { 1086 VkStructureType sType /// Should be VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO 1087 const void* pNext /// Pointer to next structure 1088 u32 queueRecordCount 1089 const VkDeviceQueueCreateInfo* pRequestedQueues 1090 u32 layerCount 1091 const char* const* ppEnabledLayerNames /// Ordered list of layer names to be enabled 1092 u32 extensionCount 1093 const char* const* ppEnabledExtensionNames 1094 const VkPhysicalDeviceFeatures* pEnabledFeatures 1095} 1096 1097class VkInstanceCreateInfo { 1098 VkStructureType sType /// Should be VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO 1099 const void* pNext /// Pointer to next structure 1100 const VkApplicationInfo* pAppInfo 1101 const VkAllocCallbacks* pAllocCb 1102 u32 layerCount 1103 const char* const* ppEnabledLayerNames /// Ordered list of layer names to be enabled 1104 u32 extensionCount 1105 const char* const* ppEnabledExtensionNames /// Extension names to be enabled 1106} 1107 1108class VkQueueFamilyProperties { 1109 VkQueueFlags queueFlags /// Queue flags 1110 u32 queueCount 1111 VkBool32 supportsTimestamps 1112} 1113 1114class VkPhysicalDeviceMemoryProperties { 1115 u32 memoryTypeCount 1116 VkMemoryType[VK_MAX_MEMORY_TYPES] memoryTypes 1117 u32 memoryHeapCount 1118 VkMemoryHeap[VK_MAX_MEMORY_HEAPS] memoryHeaps 1119} 1120 1121class VkMemoryAllocInfo { 1122 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO 1123 const void* pNext /// Pointer to next structure 1124 VkDeviceSize allocationSize /// Size of memory allocation 1125 u32 memoryTypeIndex /// Index of the of the memory type to allocate from 1126} 1127 1128class VkMemoryRequirements { 1129 VkDeviceSize size /// Specified in bytes 1130 VkDeviceSize alignment /// Specified in bytes 1131 u32 memoryTypeBits /// Bitfield of the allowed memory type indices into memoryTypes[] for this object 1132} 1133 1134class VkSparseImageFormatProperties { 1135 VkImageAspect aspect 1136 VkExtent3D imageGranularity 1137 VkSparseImageFormatFlags flags 1138} 1139 1140class VkSparseImageMemoryRequirements { 1141 VkSparseImageFormatProperties formatProps 1142 u32 imageMipTailStartLOD 1143 VkDeviceSize imageMipTailSize /// Specified in bytes, must be a multiple of image block size / alignment 1144 VkDeviceSize imageMipTailOffset /// Specified in bytes, must be a multiple of image block size / alignment 1145 VkDeviceSize imageMipTailStride /// Specified in bytes, must be a multiple of image block size / alignment 1146} 1147 1148class VkMemoryType { 1149 VkMemoryPropertyFlags propertyFlags /// Memory properties of this memory type 1150 u32 heapIndex /// Index of the memory heap allocations of this memory type are taken from 1151} 1152 1153class VkMemoryHeap { 1154 VkDeviceSize size /// Available memory in the heap 1155 VkMemoryHeapFlags flags /// Flags for the heap 1156} 1157 1158class VkMappedMemoryRange { 1159 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE 1160 const void* pNext /// Pointer to next structure 1161 VkDeviceMemory mem /// Mapped memory object 1162 VkDeviceSize offset /// Offset within the mapped memory the range starts from 1163 VkDeviceSize size /// Size of the range within the mapped memory 1164} 1165 1166class VkFormatProperties { 1167 VkFormatFeatureFlags linearTilingFeatures /// Format features in case of linear tiling 1168 VkFormatFeatureFlags optimalTilingFeatures /// Format features in case of optimal tiling 1169 VkFormatFeatureFlags bufferFeatures /// Format features supported by buffers 1170} 1171 1172class VkImageFormatProperties { 1173 VkExtent3D maxExtent /// max image dimensions for this resource type 1174 u32 maxMipLevels /// max number of mipmap levels for this resource type 1175 u32 maxArraySize /// max array size for this resource type 1176 VkSampleCountFlags sampleCounts /// supported sample counts for this resource type 1177 VkDeviceSize maxResourceSize /// max size (in bytes) of this resource type 1178} 1179 1180class VkDescriptorBufferInfo { 1181 VkBuffer buffer /// Buffer used for this descriptor when the descriptor is UNIFORM_BUFFER[_DYNAMIC] 1182 VkDeviceSize offset /// Base offset from buffer start in bytes to update in the descriptor set. 1183 VkDeviceSize range /// Size in bytes of the buffer resource for this descriptor update. 1184} 1185 1186class VkDescriptorInfo { 1187 VkBufferView bufferView /// Buffer view to write to the descriptor (in case it's a buffer descriptor, otherwise should be VK_NULL_HANDLE) 1188 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) 1189 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) 1190 VkImageLayout imageLayout /// Layout the image is expected to be in when accessed using this descriptor (only used if imageView is not VK_NULL_HANDLE) 1191 VkDescriptorBufferInfo bufferInfo /// Raw buffer, size and offset for UNIFORM_BUFFER[_DYNAMIC] or STORAGE_BUFFER[_DYNAMIC] descriptor types. Ignored otherwise. 1192} 1193 1194class VkWriteDescriptorSet { 1195 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET 1196 const void* pNext /// Pointer to next structure 1197 VkDescriptorSet destSet /// Destination descriptor set 1198 u32 destBinding /// Binding within the destination descriptor set to write 1199 u32 destArrayElement /// Array element within the destination binding to write 1200 u32 count /// Number of descriptors to write (determines the size of the array pointed by <pDescriptors>) 1201 VkDescriptorType descriptorType /// Descriptor type to write (determines which fields of the array pointed by <pDescriptors> are going to be used) 1202 const VkDescriptorInfo* pDescriptors /// Array of info structures describing the descriptors to write 1203} 1204 1205class VkCopyDescriptorSet { 1206 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET 1207 const void* pNext /// Pointer to next structure 1208 VkDescriptorSet srcSet /// Source descriptor set 1209 u32 srcBinding /// Binding within the source descriptor set to copy from 1210 u32 srcArrayElement /// Array element within the source binding to copy from 1211 VkDescriptorSet destSet /// Destination descriptor set 1212 u32 destBinding /// Binding within the destination descriptor set to copy to 1213 u32 destArrayElement /// Array element within the destination binding to copy to 1214 u32 count /// Number of descriptors to copy 1215} 1216 1217class VkBufferCreateInfo { 1218 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO 1219 const void* pNext /// Pointer to next structure. 1220 VkDeviceSize size /// Specified in bytes 1221 VkBufferUsageFlags usage /// Buffer usage flags 1222 VkBufferCreateFlags flags /// Buffer creation flags 1223 VkSharingMode sharingMode 1224 u32 queueFamilyCount 1225 const u32* pQueueFamilyIndices 1226} 1227 1228class VkBufferViewCreateInfo { 1229 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO 1230 const void* pNext /// Pointer to next structure. 1231 VkBuffer buffer 1232 VkFormat format /// Optionally specifies format of elements 1233 VkDeviceSize offset /// Specified in bytes 1234 VkDeviceSize range /// View size specified in bytes 1235} 1236 1237class VkImageSubresource { 1238 VkImageAspect aspect 1239 u32 mipLevel 1240 u32 arrayLayer 1241} 1242 1243class VkImageSubresourceRange { 1244 VkImageAspectFlags aspectMask 1245 u32 baseMipLevel 1246 u32 mipLevels 1247 u32 baseArrayLayer 1248 u32 arraySize 1249} 1250 1251class VkMemoryBarrier { 1252 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_MEMORY_BARRIER 1253 const void* pNext /// Pointer to next structure. 1254 VkMemoryOutputFlags outputMask /// Outputs the barrier should sync 1255 VkMemoryInputFlags inputMask /// Inputs the barrier should sync to 1256} 1257 1258class VkBufferMemoryBarrier { 1259 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER 1260 const void* pNext /// Pointer to next structure. 1261 VkMemoryOutputFlags outputMask /// Outputs the barrier should sync 1262 VkMemoryInputFlags inputMask /// Inputs the barrier should sync to 1263 u32 srcQueueFamilyIndex /// Queue family to transition ownership from 1264 u32 destQueueFamilyIndex /// Queue family to transition ownership to 1265 VkBuffer buffer /// Buffer to sync 1266 VkDeviceSize offset /// Offset within the buffer to sync 1267 VkDeviceSize size /// Amount of bytes to sync 1268} 1269 1270class VkImageMemoryBarrier { 1271 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER 1272 const void* pNext /// Pointer to next structure. 1273 VkMemoryOutputFlags outputMask /// Outputs the barrier should sync 1274 VkMemoryInputFlags inputMask /// Inputs the barrier should sync to 1275 VkImageLayout oldLayout /// Current layout of the image 1276 VkImageLayout newLayout /// New layout to transition the image to 1277 u32 srcQueueFamilyIndex /// Queue family to transition ownership from 1278 u32 destQueueFamilyIndex /// Queue family to transition ownership to 1279 VkImage image /// Image to sync 1280 VkImageSubresourceRange subresourceRange /// Subresource range to sync 1281} 1282 1283class VkImageCreateInfo { 1284 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO 1285 const void* pNext /// Pointer to next structure. 1286 VkImageType imageType 1287 VkFormat format 1288 VkExtent3D extent 1289 u32 mipLevels 1290 u32 arraySize 1291 u32 samples 1292 VkImageTiling tiling 1293 VkImageUsageFlags usage /// Image usage flags 1294 VkImageCreateFlags flags /// Image creation flags 1295 VkSharingMode sharingMode /// Cross-queue-family sharing mode 1296 u32 queueFamilyCount /// Number of queue families to share across 1297 const u32* pQueueFamilyIndices /// Array of queue family indices to share across 1298 VkImageLayout initialLayout /// Initial image layout for all subresources 1299} 1300 1301class VkSubresourceLayout { 1302 VkDeviceSize offset /// Specified in bytes 1303 VkDeviceSize size /// Specified in bytes 1304 VkDeviceSize rowPitch /// Specified in bytes 1305 VkDeviceSize depthPitch /// Specified in bytes 1306} 1307 1308class VkImageViewCreateInfo { 1309 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO 1310 const void* pNext /// Pointer to next structure 1311 VkImage image 1312 VkImageViewType viewType 1313 VkFormat format 1314 VkChannelMapping channels 1315 VkImageSubresourceRange subresourceRange 1316 VkImageViewCreateFlags flags 1317} 1318 1319class VkBufferCopy { 1320 VkDeviceSize srcOffset /// Specified in bytes 1321 VkDeviceSize destOffset /// Specified in bytes 1322 VkDeviceSize copySize /// Specified in bytes 1323} 1324 1325class VkSparseMemoryBindInfo { 1326 VkDeviceSize rangeOffset /// Specified in bytes 1327 VkDeviceSize rangeSize /// Specified in bytes 1328 VkDeviceSize memOffset /// Specified in bytes 1329 VkDeviceMemory mem 1330 VkSparseMemoryBindFlags flags 1331} 1332 1333class VkSparseImageMemoryBindInfo { 1334 VkImageSubresource subresource 1335 VkOffset3D offset 1336 VkExtent3D extent 1337 VkDeviceSize memOffset /// Specified in bytes 1338 VkDeviceMemory mem 1339 VkSparseMemoryBindFlags flags 1340} 1341 1342class VkImageSubresourceCopy { 1343 VkImageAspect aspect 1344 u32 mipLevel 1345 u32 arrayLayer 1346 u32 arraySize 1347} 1348 1349class VkImageCopy { 1350 VkImageSubresourceCopy srcSubresource 1351 VkOffset3D srcOffset /// Specified in pixels for both compressed and uncompressed images 1352 VkImageSubresourceCopy destSubresource 1353 VkOffset3D destOffset /// Specified in pixels for both compressed and uncompressed images 1354 VkExtent3D extent /// Specified in pixels for both compressed and uncompressed images 1355} 1356 1357class VkImageBlit { 1358 VkImageSubresourceCopy srcSubresource 1359 VkOffset3D srcOffset /// Specified in pixels for both compressed and uncompressed images 1360 VkExtent3D srcExtent /// Specified in pixels for both compressed and uncompressed images 1361 VkImageSubresourceCopy destSubresource 1362 VkOffset3D destOffset /// Specified in pixels for both compressed and uncompressed images 1363 VkExtent3D destExtent /// Specified in pixels for both compressed and uncompressed images 1364} 1365 1366class VkBufferImageCopy { 1367 VkDeviceSize bufferOffset /// Specified in bytes 1368 u32 bufferRowLength /// Specified in texels 1369 u32 bufferImageHeight 1370 VkImageSubresourceCopy imageSubresource 1371 VkOffset3D imageOffset /// Specified in pixels for both compressed and uncompressed images 1372 VkExtent3D imageExtent /// Specified in pixels for both compressed and uncompressed images 1373} 1374 1375class VkImageResolve { 1376 VkImageSubresourceCopy srcSubresource 1377 VkOffset3D srcOffset 1378 VkImageSubresourceCopy destSubresource 1379 VkOffset3D destOffset 1380 VkExtent3D extent 1381} 1382 1383class VkShaderModuleCreateInfo { 1384 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO 1385 const void* pNext /// Pointer to next structure 1386 platform.size_t codeSize /// Specified in bytes 1387 const void* pCode /// Binary code of size codeSize 1388 VkShaderModuleCreateFlags flags /// Reserved 1389} 1390 1391class VkShaderCreateInfo { 1392 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_SHADER_CREATE_INFO 1393 const void* pNext /// Pointer to next structure 1394 VkShaderModule module /// Module containing entry point 1395 const char* pName /// Null-terminated entry point name 1396 VkShaderCreateFlags flags /// Reserved 1397 VkShaderStage stage 1398} 1399 1400class VkDescriptorSetLayoutBinding { 1401 VkDescriptorType descriptorType /// Type of the descriptors in this binding 1402 u32 arraySize /// Number of descriptors in this binding 1403 VkShaderStageFlags stageFlags /// Shader stages this binding is visible to 1404 const VkSampler* pImmutableSamplers /// Immutable samplers (used if descriptor type is SAMPLER or COMBINED_IMAGE_SAMPLER, is either NULL or contains <count> number of elements) 1405} 1406 1407class VkDescriptorSetLayoutCreateInfo { 1408 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO 1409 const void* pNext /// Pointer to next structure 1410 u32 count /// Number of bindings in the descriptor set layout 1411 const VkDescriptorSetLayoutBinding* pBinding /// Array of descriptor set layout bindings 1412} 1413 1414class VkDescriptorTypeCount { 1415 VkDescriptorType type 1416 u32 count 1417} 1418 1419class VkDescriptorPoolCreateInfo { 1420 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO 1421 const void* pNext /// Pointer to next structure 1422 VkDescriptorPoolUsage poolUsage 1423 u32 maxSets 1424 u32 count 1425 const VkDescriptorTypeCount* pTypeCount 1426} 1427 1428class VkSpecializationMapEntry { 1429 u32 constantId /// The SpecConstant ID specified in the BIL 1430 platform.size_t size /// Size in bytes of the SpecConstant 1431 u32 offset /// Offset of the value in the data block 1432} 1433 1434class VkSpecializationInfo { 1435 u32 mapEntryCount /// Number of entries in the map 1436 const VkSpecializationMapEntry* pMap /// Array of map entries 1437 platform.size_t dataSize /// Size in bytes of pData 1438 const void* pData /// Pointer to SpecConstant data 1439} 1440 1441class VkPipelineShaderStageCreateInfo { 1442 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO 1443 const void* pNext /// Pointer to next structure 1444 VkShaderStage stage 1445 VkShader shader 1446 const VkSpecializationInfo* pSpecializationInfo 1447} 1448 1449class VkComputePipelineCreateInfo { 1450 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO 1451 const void* pNext /// Pointer to next structure 1452 VkPipelineShaderStageCreateInfo stage 1453 VkPipelineCreateFlags flags /// Pipeline creation flags 1454 VkPipelineLayout layout /// Interface layout of the pipeline 1455 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 1456 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 1457} 1458 1459class VkVertexInputBindingDescription { 1460 u32 binding /// Vertex buffer binding id 1461 u32 strideInBytes /// Distance between vertices in bytes (0 = no advancement) 1462 VkVertexInputStepRate stepRate /// Rate at which binding is incremented 1463} 1464 1465class VkVertexInputAttributeDescription { 1466 u32 location /// location of the shader vertex attrib 1467 u32 binding /// Vertex buffer binding id 1468 VkFormat format /// format of source data 1469 u32 offsetInBytes /// Offset of first element in bytes from base of vertex 1470} 1471 1472class VkPipelineVertexInputStateCreateInfo { 1473 VkStructureType sType /// Should be VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO 1474 const void* pNext /// Pointer to next structure 1475 u32 bindingCount /// number of bindings 1476 const VkVertexInputBindingDescription* pVertexBindingDescriptions 1477 u32 attributeCount /// number of attributes 1478 const VkVertexInputAttributeDescription* pVertexAttributeDescriptions 1479} 1480 1481class VkPipelineInputAssemblyStateCreateInfo { 1482 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO 1483 const void* pNext /// Pointer to next structure 1484 VkPrimitiveTopology topology 1485 VkBool32 primitiveRestartEnable 1486} 1487 1488class VkPipelineTessellationStateCreateInfo { 1489 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO 1490 const void* pNext /// Pointer to next structure 1491 u32 patchControlPoints 1492} 1493 1494class VkPipelineViewportStateCreateInfo { 1495 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO 1496 const void* pNext /// Pointer to next structure 1497 u32 viewportCount 1498 const VkViewport* pViewports 1499 u32 scissorCount 1500 const VkRect2D* pScissors 1501} 1502 1503class VkPipelineRasterStateCreateInfo { 1504 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO 1505 const void* pNext /// Pointer to next structure 1506 VkBool32 depthClipEnable 1507 VkBool32 rasterizerDiscardEnable 1508 VkFillMode fillMode /// optional (GL45) 1509 VkCullMode cullMode 1510 VkFrontFace frontFace 1511 VkBool32 depthBiasEnable 1512 f32 depthBias 1513 f32 depthBiasClamp 1514 f32 slopeScaledDepthBias 1515 f32 lineWidth 1516} 1517 1518class VkPipelineMultisampleStateCreateInfo { 1519 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO 1520 const void* pNext /// Pointer to next structure 1521 u32 rasterSamples /// Number of samples used for rasterization 1522 VkBool32 sampleShadingEnable /// optional (GL45) 1523 f32 minSampleShading /// optional (GL45) 1524 const VkSampleMask* pSampleMask 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 alphaToCoverageEnable 1542 VkBool32 alphaToOneEnable 1543 VkBool32 logicOpEnable 1544 VkLogicOp logicOp 1545 u32 attachmentCount /// # of pAttachments 1546 const VkPipelineColorBlendAttachmentState* pAttachments 1547 f32[4] blendConst 1548} 1549 1550class VkStencilOpState { 1551 VkStencilOp stencilFailOp 1552 VkStencilOp stencilPassOp 1553 VkStencilOp stencilDepthFailOp 1554 VkCompareOp stencilCompareOp 1555 u32 stencilCompareMask 1556 u32 stencilWriteMask 1557 u32 stencilReference 1558} 1559 1560class VkPipelineDepthStencilStateCreateInfo { 1561 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO 1562 const void* pNext /// Pointer to next structure 1563 VkBool32 depthTestEnable 1564 VkBool32 depthWriteEnable 1565 VkCompareOp depthCompareOp 1566 VkBool32 depthBoundsTestEnable /// optional (depth_bounds_test) 1567 VkBool32 stencilTestEnable 1568 VkStencilOpState front 1569 VkStencilOpState back 1570 f32 minDepthBounds 1571 f32 maxDepthBounds 1572} 1573 1574class VkPipelineDynamicStateCreateInfo { 1575 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO 1576 const void* pNext /// Pointer to next structure 1577 u32 dynamicStateCount 1578 const VkDynamicState* pDynamicStates 1579} 1580 1581class VkGraphicsPipelineCreateInfo { 1582 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO 1583 const void* pNext /// Pointer to next structure 1584 u32 stageCount 1585 const VkPipelineShaderStageCreateInfo* pStages /// One entry for each active shader stage 1586 const VkPipelineVertexInputStateCreateInfo* pVertexInputState 1587 const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState 1588 const VkPipelineTessellationStateCreateInfo* pTessellationState 1589 const VkPipelineViewportStateCreateInfo* pViewportState 1590 const VkPipelineRasterStateCreateInfo* pRasterState 1591 const VkPipelineMultisampleStateCreateInfo* pMultisampleState 1592 const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState 1593 const VkPipelineColorBlendStateCreateInfo* pColorBlendState 1594 const VkPipelineDynamicStateCreateInfo* pDynamicState 1595 VkPipelineCreateFlags flags /// Pipeline creation flags 1596 VkPipelineLayout layout /// Interface layout of the pipeline 1597 VkRenderPass renderPass 1598 u32 subpass 1599 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 1600 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 1601} 1602 1603class VkPipelineCacheCreateInfo { 1604 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO 1605 const void* pNext /// Pointer to next structure 1606 platform.size_t initialSize /// Size of initial data to populate cache, in bytes 1607 const void* initialData /// Initial data to populate cache 1608 platform.size_t maxSize /// Maximum size cache can grow to, in bytes. If zero, then the cache may grow without bound. 1609} 1610 1611class VkPushConstantRange { 1612 VkShaderStageFlags stageFlags /// Which stages use the range 1613 u32 start /// Start of the range, in bytes 1614 u32 length /// Length of the range, in bytes 1615} 1616 1617class VkPipelineLayoutCreateInfo { 1618 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO 1619 const void* pNext /// Pointer to next structure 1620 u32 descriptorSetCount /// Number of descriptor sets interfaced by the pipeline 1621 const VkDescriptorSetLayout* pSetLayouts /// Array of <setCount> number of descriptor set layout objects defining the layout of the 1622 u32 pushConstantRangeCount /// Number of push-constant ranges used by the pipeline 1623 const VkPushConstantRange* pPushConstantRanges /// Array of pushConstantRangeCount number of ranges used by various shader stages 1624} 1625 1626class VkSamplerCreateInfo { 1627 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO 1628 const void* pNext /// Pointer to next structure 1629 VkTexFilter magFilter /// Filter mode for magnification 1630 VkTexFilter minFilter /// Filter mode for minifiation 1631 VkTexMipmapMode mipMode /// Mipmap selection mode 1632 VkTexAddressMode addressModeU 1633 VkTexAddressMode addressModeV 1634 VkTexAddressMode addressModeW 1635 f32 mipLodBias 1636 f32 maxAnisotropy 1637 VkBool32 compareEnable 1638 VkCompareOp compareOp 1639 f32 minLod 1640 f32 maxLod 1641 VkBorderColor borderColor 1642 VkBool32 unnormalizedCoordinates 1643} 1644 1645class VkCmdPoolCreateInfo { 1646 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO 1647 const void* pNext /// Pointer to next structure 1648 u32 queueFamilyIndex 1649 VkCmdPoolCreateFlags flags /// Command pool creation flags 1650} 1651 1652class VkCmdBufferCreateInfo { 1653 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO 1654 const void* pNext /// Pointer to next structure 1655 VkCmdPool cmdPool 1656 VkCmdBufferLevel level 1657 VkCmdBufferCreateFlags flags /// Command buffer creation flags 1658} 1659 1660class VkCmdBufferBeginInfo { 1661 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO 1662 const void* pNext /// Pointer to next structure 1663 VkCmdBufferOptimizeFlags flags /// Command buffer optimization flags 1664 VkRenderPass renderPass /// Render pass for secondary command buffers 1665 u32 subpass 1666 VkFramebuffer framebuffer /// Framebuffer for secondary command buffers 1667} 1668 1669class VkRenderPassBeginInfo { 1670 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO 1671 const void* pNext /// Pointer to next structure 1672 VkRenderPass renderPass 1673 VkFramebuffer framebuffer 1674 VkRect2D renderArea 1675 u32 clearValueCount 1676 const VkClearValue* pClearValues 1677} 1678 1679@union 1680/// Union allowing specification of floating point, integer, or unsigned integer color data. Actual value selected is based on image/attachment being cleared. 1681class VkClearColorValue { 1682 f32[4] float32 1683 s32[4] int32 1684 u32[4] uint32 1685} 1686 1687class VkClearDepthStencilValue { 1688 f32 depth 1689 u32 stencil 1690} 1691 1692@union 1693/// Union allowing specification of color, depth, and stencil color values. Actual value selected is based on attachment being cleared. 1694class VkClearValue { 1695 VkClearColorValue color 1696 VkClearDepthStencilValue depthStencil 1697} 1698 1699class VkAttachmentDescription { 1700 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION 1701 const void* pNext /// Pointer to next structure 1702 VkFormat format 1703 u32 samples 1704 VkAttachmentLoadOp loadOp /// Load op for color or depth data 1705 VkAttachmentStoreOp storeOp /// Store op for color or depth data 1706 VkAttachmentLoadOp stencilLoadOp /// Load op for stencil data 1707 VkAttachmentStoreOp stencilStoreOp /// Store op for stencil data 1708 VkImageLayout initialLayout 1709 VkImageLayout finalLayout 1710 VkAttachmentDescriptionFlags flags 1711} 1712 1713class VkAttachmentReference { 1714 u32 attachment 1715 VkImageLayout layout 1716} 1717 1718class VkSubpassDescription { 1719 VkStructureType sType /// Must be VK_STRUCTURE_SUBPASS_DESCRIPTION 1720 const void* pNext /// Pointer to next structure 1721 VkPipelineBindPoint pipelineBindPoint /// Must be VK_PIPELINE_BIND_POINT_GRAPHICS for now 1722 VkSubpassDescriptionFlags flags 1723 u32 inputCount 1724 const VkAttachmentReference* pInputAttachments 1725 u32 colorCount 1726 const VkAttachmentReference* pColorAttachments 1727 const VkAttachmentReference* pResolveAttachments 1728 VkAttachmentReference depthStencilAttachment 1729 u32 preserveCount 1730 const VkAttachmentReference* pPreserveAttachments 1731} 1732 1733class VkSubpassDependency { 1734 VkStructureType sType /// Must be VK_STRUCTURE_SUBPASS_DEPENDENCY 1735 const void* pNext /// Pointer to next structure 1736 u32 srcSubpass 1737 u32 destSubpass 1738 VkPipelineStageFlags srcStageMask 1739 VkPipelineStageFlags destStageMask 1740 VkMemoryOutputFlags outputMask 1741 VkMemoryInputFlags inputMask 1742 VkBool32 byRegion 1743} 1744 1745class VkRenderPassCreateInfo { 1746 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO 1747 const void* pNext /// Pointer to next structure 1748 u32 attachmentCount 1749 const VkAttachmentDescription* pAttachments 1750 u32 subpassCount 1751 const VkSubpassDescription* pSubpasses 1752 u32 dependencyCount 1753 const VkSubpassDependency* pDependencies 1754} 1755 1756class VkEventCreateInfo { 1757 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_EVENT_CREATE_INFO 1758 const void* pNext /// Pointer to next structure 1759 VkEventCreateFlags flags /// Event creation flags 1760} 1761 1762class VkFenceCreateInfo { 1763 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_FENCE_CREATE_INFO 1764 const void* pNext /// Pointer to next structure 1765 VkFenceCreateFlags flags /// Fence creation flags 1766} 1767 1768class VkPhysicalDeviceFeatures { 1769 VkBool32 robustBufferAccess /// out of bounds buffer accesses are well defined 1770 VkBool32 fullDrawIndexUint32 /// full 32-bit range of indices for indexed draw calls 1771 VkBool32 imageCubeArray /// image views which are arrays of cube maps 1772 VkBool32 independentBlend /// blending operations are controlled per-attachment 1773 VkBool32 geometryShader /// geometry stage 1774 VkBool32 tessellationShader /// tessellation control and evaluation stage 1775 VkBool32 sampleRateShading /// per-sample shading and interpolation 1776 VkBool32 dualSourceBlend /// blend operations which take two sources 1777 VkBool32 logicOp /// logic operations 1778 VkBool32 multiDrawIndirect /// multi draw indirect 1779 VkBool32 depthClip /// depth clipping 1780 VkBool32 depthBiasClamp /// depth bias clamping 1781 VkBool32 fillModeNonSolid /// point and wireframe fill modes 1782 VkBool32 depthBounds /// depth bounds test 1783 VkBool32 wideLines /// lines with width greater than 1 1784 VkBool32 largePoints /// points with size greater than 1 1785 VkBool32 textureCompressionETC2 /// ETC texture compression formats 1786 VkBool32 textureCompressionASTC_LDR /// ASTC LDR texture compression formats 1787 VkBool32 textureCompressionBC /// BC1-7 texture compressed formats 1788 VkBool32 occlusionQueryNonConservative /// non-conservative (exact) occlusion queries 1789 VkBool32 pipelineStatisticsQuery /// pipeline statistics query 1790 VkBool32 vertexSideEffects /// storage buffers and images in vertex stage 1791 VkBool32 tessellationSideEffects /// storage buffers and images in tessellation stage 1792 VkBool32 geometrySideEffects /// storage buffers and images in geometry stage 1793 VkBool32 fragmentSideEffects /// storage buffers and images in fragment stage 1794 VkBool32 shaderTessellationPointSize /// tessellation stage can export point size 1795 VkBool32 shaderGeometryPointSize /// geometry stage can export point size 1796 VkBool32 shaderImageGatherExtended /// texture gather with run-time values and independent offsets 1797 VkBool32 shaderStorageImageExtendedFormats /// the extended set of formats can be used for storage images 1798 VkBool32 shaderStorageImageMultisample /// multisample images can be used for storage images 1799 VkBool32 shaderUniformBufferArrayDynamicIndexing /// arrays of uniform buffers can be accessed with dynamically uniform indices 1800 VkBool32 shaderSampledImageArrayDynamicIndexing /// arrays of sampled images can be accessed with dynamically uniform indices 1801 VkBool32 shaderStorageBufferArrayDynamicIndexing /// arrays of storage buffers can be accessed with dynamically uniform indices 1802 VkBool32 shaderStorageImageArrayDynamicIndexing /// arrays of storage images can be accessed with dynamically uniform indices 1803 VkBool32 shaderClipDistance /// clip distance in shaders 1804 VkBool32 shaderCullDistance /// cull distance in shaders 1805 VkBool32 shaderFloat64 /// 64-bit floats (doubles) in shaders 1806 VkBool32 shaderInt64 /// 64-bit integers in shaders 1807 VkBool32 shaderInt16 /// 16-bit integers in shaders 1808 VkBool32 shaderResourceResidency /// shader can use texture operations that return resource residency information (requires sparseNonResident support) 1809 VkBool32 shaderResourceMinLOD /// shader can use texture operations that specify minimum resource LOD 1810 VkBool32 alphaToOne /// The fragment alpha channel can be forced to maximum representable alpha value 1811 VkBool32 sparseBinding /// Sparse resources support: Resource memory can be managed at opaque page level rather than object level 1812 VkBool32 sparseResidencyBuffer /// Sparse resources support: GPU can access partially resident buffers 1813 VkBool32 sparseResidencyImage2D /// Sparse resources support: GPU can access partially resident 2D (non-MSAA non-DepthStencil) images 1814 VkBool32 sparseResidencyImage3D /// Sparse resources support: GPU can access partially resident 3D images 1815 VkBool32 sparseResidency2Samples /// Sparse resources support: GPU can access partially resident MSAA 2D images with 2 samples 1816 VkBool32 sparseResidency4Samples /// Sparse resources support: GPU can access partially resident MSAA 2D images with 4 samples 1817 VkBool32 sparseResidency8Samples /// Sparse resources support: GPU can access partially resident MSAA 2D images with 8 samples 1818 VkBool32 sparseResidency16Samples /// Sparse resources support: GPU can access partially resident MSAA 2D images with 16 samples 1819 VkBool32 sparseResidencyAliased /// Sparse resources support: GPU can correctly access data aliased into multiple locations (opt-in) 1820} 1821 1822class VkPhysicalDeviceLimits { 1823 /// resource maximum sizes 1824 u32 maxImageDimension1D /// max 1D image dimension 1825 u32 maxImageDimension2D /// max 2D image dimension 1826 u32 maxImageDimension3D /// max 3D image dimension 1827 u32 maxImageDimensionCube /// max cubemap image dimension 1828 u32 maxImageArrayLayers /// max layers for image arrays 1829 VkSampleCountFlags sampleCounts /// sample counts supported for all images supporting rendering and sampling 1830 u32 maxTexelBufferSize /// max texel buffer size (bytes) 1831 u32 maxUniformBufferSize /// max uniform buffer size (bytes) 1832 u32 maxStorageBufferSize /// max storage buffer size (bytes) 1833 u32 maxPushConstantsSize /// max size of the push constants pool (bytes) 1834 /// memory limits 1835 u32 maxMemoryAllocationCount /// max number of device memory allocations supported 1836 VkDeviceSize bufferImageGranularity /// Granularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage 1837 VkDeviceSize sparseAddressSpaceSize /// Total address space available for sparse allocations (bytes) 1838 /// descriptor set limits 1839 u32 maxBoundDescriptorSets /// max number of descriptors sets that can be bound to a pipeline 1840 u32 maxDescriptorSets /// max number of allocated descriptor sets 1841 u32 maxPerStageDescriptorSamplers /// max num of samplers allowed per-stage in a descriptor set 1842 u32 maxPerStageDescriptorUniformBuffers /// max num of uniform buffers allowed per-stage in a descriptor set 1843 u32 maxPerStageDescriptorStorageBuffers /// max num of storage buffers allowed per-stage in a descriptor set 1844 u32 maxPerStageDescriptorSampledImages /// max num of sampled images allowed per-stage in a descriptor set 1845 u32 maxPerStageDescriptorStorageImages /// max num of storage images allowed per-stage in a descriptor set 1846 u32 maxDescriptorSetSamplers /// max num of samplers allowed in all stages in a descriptor set 1847 u32 maxDescriptorSetUniformBuffers /// max num of uniform buffers allowed in all stages in a descriptor set 1848 u32 maxDescriptorSetUniformBuffersDynamic /// max num of dynamic uniform buffers allowed in all stages in a descriptor set 1849 u32 maxDescriptorSetStorageBuffers /// max num of storage buffers allowed in all stages in a descriptor set 1850 u32 maxDescriptorSetStorageBuffersDynamic /// max num of dynamic storage buffers allowed in all stages in a descriptor set 1851 u32 maxDescriptorSetSampledImages /// max num of sampled images allowed in all stages in a descriptor set 1852 u32 maxDescriptorSetStorageImages /// max num of storage images allowed in all stages in a descriptor set 1853 /// vertex stage limits 1854 u32 maxVertexInputAttributes /// max num of vertex input attribute slots 1855 u32 maxVertexInputBindings /// max num of vertex input binding slots 1856 u32 maxVertexInputAttributeOffset /// max vertex input attribute offset added to vertex buffer offset 1857 u32 maxVertexInputBindingStride /// max vertex input binding stride 1858 u32 maxVertexOutputComponents /// max num of output components written by vertex shader 1859 /// tessellation control stage limits 1860 u32 maxTessGenLevel /// max level supported by tess primitive generator 1861 u32 maxTessPatchSize /// max patch size (vertices) 1862 u32 maxTessControlPerVertexInputComponents /// max num of input components per-vertex in TCS 1863 u32 maxTessControlPerVertexOutputComponents /// max num of output components per-vertex in TCS 1864 u32 maxTessControlPerPatchOutputComponents /// max num of output components per-patch in TCS 1865 u32 maxTessControlTotalOutputComponents /// max total num of per-vertex and per-patch output components in TCS 1866 u32 maxTessEvaluationInputComponents /// max num of input components per vertex in TES 1867 u32 maxTessEvaluationOutputComponents /// max num of output components per vertex in TES 1868 /// geometry stage limits 1869 u32 maxGeometryShaderInvocations /// max invocation count supported in geometry shader 1870 u32 maxGeometryInputComponents /// max num of input components read in geometry stage 1871 u32 maxGeometryOutputComponents /// max num of output components written in geometry stage 1872 u32 maxGeometryOutputVertices /// max num of vertices that can be emitted in geometry stage 1873 u32 maxGeometryTotalOutputComponents /// max total num of components (all vertices) written in geometry stage 1874 /// fragment stage limits 1875 u32 maxFragmentInputComponents /// max num of input compontents read in fragment stage 1876 u32 maxFragmentOutputBuffers /// max num of output buffers written in fragment stage 1877 u32 maxFragmentDualSourceBuffers /// max num of output buffers written when using dual source blending 1878 u32 maxFragmentCombinedOutputResources /// max total num of storage buffers, storage images and output buffers 1879 /// compute stage limits 1880 u32 maxComputeSharedMemorySize /// max total storage size of work group local storage (bytes) 1881 u32[3] maxComputeWorkGroupCount /// max num of compute work groups that may be dispatched by a single command (x,y,z) 1882 u32 maxComputeWorkGroupInvocations /// max total compute invocations in a single local work group 1883 u32[3] maxComputeWorkGroupSize /// max local size of a compute work group (x,y,z) 1884 1885 u32 subPixelPrecisionBits /// num bits of subpixel precision in screen x and y 1886 u32 subTexelPrecisionBits /// num bits of subtexel precision 1887 u32 mipmapPrecisionBits /// num bits of mipmap precision 1888 1889 u32 maxDrawIndexedIndexValue /// max index value for indexed draw calls (for 32-bit indices) 1890 u32 maxDrawIndirectInstanceCount /// max instance count for indirect draw calls 1891 VkBool32 primitiveRestartForPatches /// is primitive restart supported for PATCHES 1892 1893 f32 maxSamplerLodBias /// max absolute sampler level of detail bias 1894 f32 maxSamplerAnisotropy /// max degree of sampler anisotropy 1895 1896 u32 maxViewports /// max number of active viewports 1897 u32[2] maxViewportDimensions /// max viewport dimensions (x,y) 1898 f32[2] viewportBoundsRange /// viewport bounds range (min,max) 1899 u32 viewportSubPixelBits /// num bits of subpixel precision for viewport 1900 1901 u32 minMemoryMapAlignment /// min required alignment of pointers returned by MapMemory (bytes) 1902 u32 minTexelBufferOffsetAlignment /// min required alignment for texel buffer offsets (bytes) 1903 u32 minUniformBufferOffsetAlignment /// min required alignment for uniform buffer sizes and offsets (bytes) 1904 u32 minStorageBufferOffsetAlignment /// min required alignment for storage buffer offsets (bytes) 1905 1906 u32 minTexelOffset /// min texel offset for OpTextureSampleOffset 1907 u32 maxTexelOffset /// max texel offset for OpTextureSampleOffset 1908 u32 minTexelGatherOffset /// min texel offset for OpTextureGatherOffset 1909 u32 maxTexelGatherOffset /// max texel offset for OpTextureGatherOffset 1910 f32 minInterpolationOffset /// furthest negative offset for interpolateAtOffset 1911 f32 maxInterpolationOffset /// furthest positive offset for interpolateAtOffset 1912 u32 subPixelInterpolationOffsetBits /// num of subpixel bits for interpolateAtOffset 1913 1914 u32 maxFramebufferWidth /// max width for a framebuffer 1915 u32 maxFramebufferHeight /// max height for a framebuffer 1916 u32 maxFramebufferLayers /// max layer count for a layered framebuffer 1917 u32 maxFramebufferColorSamples /// max color sample count for a framebuffer 1918 u32 maxFramebufferDepthSamples /// max depth sample count for a framebuffer 1919 u32 maxFramebufferStencilSamples /// max stencil sample count for a framebuffer 1920 u32 maxColorAttachments /// max num of framebuffer color attachments 1921 1922 u32 maxSampledImageColorSamples /// max num of color samples for a non-integer sampled image 1923 u32 maxSampledImageDepthSamples /// max num of depth/stencil samples for a sampled image 1924 u32 maxSampledImageIntegerSamples /// max num of samples supported for an integer image 1925 u32 maxStorageImageSamples /// max num of samples for a storage image 1926 u32 maxSampleMaskWords /// max num of sample mask words 1927 1928 u64 timestampFrequency /// 1/clock_tick_granularity for timestamp queries 1929 1930 u32 maxClipDistances /// max number of clip distances 1931 u32 maxCullDistances /// max number of cull distances 1932 u32 maxCombinedClipAndCullDistances /// max combined number of user clipping 1933 1934 f32[2] pointSizeRange /// range (min,max) of supported point sizes 1935 f32[2] lineWidthRange /// range (min,max) of supported line widths 1936 f32 pointSizeGranularity /// granularity of supported point sizes 1937 f32 lineWidthGranularity /// granularity of supported line widths 1938} 1939 1940class VkPhysicalDeviceSparseProperties { 1941 VkBool32 residencyStandard2DBlockShape /// Sparse resources support: GPU will access all 2D (single sample) sparse resources using the standard block shapes (based on pixel format) 1942 VkBool32 residencyStandard2DMSBlockShape /// Sparse resources support: GPU will access all 2D (multisample) sparse resources using the standard block shapes (based on pixel format) 1943 VkBool32 residencyStandard3DBlockShape /// Sparse resources support: GPU will access all 3D sparse resources using the standard block shapes (based on pixel format) 1944 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 1945 VkBool32 residencyNonResident /// Sparse resources support: GPU can safely access non-resident regions of a resource, read values from read-write resources are undefined 1946 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 1947} 1948 1949class VkSemaphoreCreateInfo { 1950 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO 1951 const void* pNext /// Pointer to next structure 1952 VkSemaphoreCreateFlags flags /// Semaphore creation flags 1953} 1954 1955class VkQueryPoolCreateInfo { 1956 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO 1957 const void* pNext /// Pointer to next structure 1958 VkQueryType queryType 1959 u32 slots 1960 VkQueryPipelineStatisticFlags pipelineStatistics /// Optional 1961} 1962 1963class VkFramebufferCreateInfo { 1964 VkStructureType sType /// Must be VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO 1965 const void* pNext /// Pointer to next structure 1966 VkRenderPass renderPass 1967 u32 attachmentCount 1968 const VkImageView* pAttachments 1969 u32 width 1970 u32 height 1971 u32 layers 1972} 1973 1974class VkDrawIndirectCmd { 1975 u32 vertexCount 1976 u32 instanceCount 1977 u32 firstVertex 1978 u32 firstInstance 1979} 1980 1981class VkDrawIndexedIndirectCmd { 1982 u32 indexCount 1983 u32 instanceCount 1984 u32 firstIndex 1985 s32 vertexOffset 1986 u32 firstInstance 1987} 1988 1989class VkDispatchIndirectCmd { 1990 u32 x 1991 u32 y 1992 u32 z 1993} 1994 1995////////////////// 1996// Extensions // 1997////////////////// 1998 1999@extension("VK_EXT_KHR_device_swapchain") 2000class VkSurfacePropertiesKHR { 2001 u32 minImageCount 2002 u32 maxImageCount 2003 VkExtent2D currentExtent 2004 VkExtent2D minImageExtent 2005 VkExtent2D maxImageExtent 2006 VkSurfaceTransformFlagsKHR supportedTransforms 2007 VkSurfaceTransformKHR currentTransform 2008 u32 maxImageArraySize 2009 VkImageUsageFlags supportedUsageFlags 2010} 2011 2012@extension("VK_EXT_KHR_device_swapchain") 2013class VkSurfaceFormatKHR { 2014 VkFormat format 2015 VkColorSpaceKHR colorSpace 2016} 2017 2018@extension("VK_EXT_KHR_device_swapchain") 2019class VkSwapchainCreateInfoKHR { 2020 VkStructureType sType 2021 const void* pNext 2022 const VkSurfaceDescriptionKHR* pSurfaceDescription 2023 u32 minImageCount 2024 VkFormat imageFormat 2025 VkColorSpaceKHR imageColorSpace 2026 VkExtent2D imageExtent 2027 VkImageUsageFlags imageUsageFlags 2028 VkSurfaceTransformKHR preTransform 2029 u32 imageArraySize 2030 VkSharingMode sharingMode 2031 u32 queueFamilyCount 2032 const u32* pQueueFamilyIndices 2033 VkPresentModeKHR presentMode 2034 VkSwapchainKHR oldSwapchain 2035 VkBool32 clipped 2036} 2037 2038@extension("VK_EXT_KHR_device_swapchain") 2039class VkPresentInfoKHR { 2040 VkStructureType sType 2041 const void* pNext 2042 u32 swapchainCount 2043 const VkSwapchainKHR* swapchains 2044 const u32* imageIndices 2045} 2046 2047@extension("VK_EXT_KHR_swapchain") 2048class VkSurfaceDescriptionKHR { 2049 VkStructureType sType 2050 const void* pNext 2051} 2052 2053@extension("VK_EXT_KHR_swapchain") 2054class VkSurfaceDescriptionWindowKHR { 2055 VkStructureType sType 2056 const void* pNext 2057 VkPlatformKHR platform 2058 void* pPlatformHandle 2059 void* pPlatformWindow 2060} 2061 2062//////////////// 2063// Commands // 2064//////////////// 2065 2066// Function pointers. TODO: add support for function pointers. 2067 2068@external type void* PFN_vkVoidFunction 2069@pfn cmd void vkVoidFunction() { 2070} 2071 2072@external type void* PFN_vkAllocFunction 2073@pfn cmd void* vkAllocFunction( 2074 void* pUserData, 2075 platform.size_t size, 2076 platform.size_t alignment, 2077 VkSystemAllocType allocType) { 2078 return ? 2079} 2080 2081@external type void* PFN_vkFreeFunction 2082@pfn cmd void vkFreeFunction( 2083 void* pUserData, 2084 void* pMem) { 2085} 2086 2087 2088// Global functions 2089 2090@threadSafety("system") 2091cmd VkResult vkCreateInstance( 2092 const VkInstanceCreateInfo* pCreateInfo, 2093 VkInstance* pInstance) { 2094 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) 2095 2096 instance := ? 2097 pInstance[0] = instance 2098 State.Instances[instance] = new!InstanceObject() 2099 2100 layers := pCreateInfo.ppEnabledLayerNames[0:pCreateInfo.layerCount] 2101 extensions := pCreateInfo.ppEnabledExtensionNames[0:pCreateInfo.extensionCount] 2102 2103 return ? 2104} 2105 2106@threadSafety("system") 2107cmd void vkDestroyInstance( 2108 VkInstance instance) { 2109 instanceObject := GetInstance(instance) 2110 2111 State.Instances[instance] = null 2112} 2113 2114@threadSafety("system") 2115cmd VkResult vkEnumeratePhysicalDevices( 2116 VkInstance instance, 2117 u32* pPhysicalDeviceCount, 2118 VkPhysicalDevice* pPhysicalDevices) { 2119 instanceObject := GetInstance(instance) 2120 2121 physicalDeviceCount := as!u32(?) 2122 pPhysicalDeviceCount[0] = physicalDeviceCount 2123 physicalDevices := pPhysicalDevices[0:physicalDeviceCount] 2124 2125 for i in (0 .. physicalDeviceCount) { 2126 physicalDevice := ? 2127 physicalDevices[i] = physicalDevice 2128 if !(physicalDevice in State.PhysicalDevices) { 2129 State.PhysicalDevices[physicalDevice] = new!PhysicalDeviceObject(instance: instance) 2130 } 2131 } 2132 2133 return ? 2134} 2135 2136cmd PFN_vkVoidFunction vkGetDeviceProcAddr( 2137 VkDevice device, 2138 const char* pName) { 2139 if device != NULL_HANDLE { 2140 device := GetDevice(device) 2141 } 2142 2143 return ? 2144} 2145 2146cmd PFN_vkVoidFunction vkGetInstanceProcAddr( 2147 VkInstance instance, 2148 const char* pName) { 2149 if instance != NULL_HANDLE { 2150 instanceObject := GetInstance(instance) 2151 } 2152 2153 return ? 2154} 2155 2156cmd VkResult vkGetPhysicalDeviceProperties( 2157 VkPhysicalDevice physicalDevice, 2158 VkPhysicalDeviceProperties* pProperties) { 2159 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2160 2161 properties := ? 2162 pProperties[0] = properties 2163 2164 return ? 2165} 2166 2167cmd VkResult vkGetPhysicalDeviceQueueFamilyProperties( 2168 VkPhysicalDevice physicalDevice, 2169 u32* pCount, 2170 VkQueueFamilyProperties* pQueueFamilyProperties) { 2171 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2172 // TODO: Figure out how to express fetch-count-or-properties 2173 // This version fails 'apic validate' with 'fence not allowed in 2174 // *semantic.Branch'. Other attempts have failed with the same or other 2175 // errors. 2176 // if pQueueFamilyProperties != null { 2177 // queuesProperties := pQueueFamilyProperties[0:pCount[0]] 2178 // for i in (0 .. pCount[0]) { 2179 // queueProperties := as!VkQueueFamilyProperties(?) 2180 // queuesProperties[i] = queueProperties 2181 // } 2182 // } else { 2183 // count := ? 2184 // pCount[0] = count 2185 // } 2186 return ? 2187} 2188 2189cmd VkResult vkGetPhysicalDeviceMemoryProperties( 2190 VkPhysicalDevice physicalDevice, 2191 VkPhysicalDeviceMemoryProperties* pMemoryProperties) { 2192 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2193 2194 memoryProperties := ? 2195 pMemoryProperties[0] = memoryProperties 2196 2197 return ? 2198} 2199 2200cmd VkResult vkGetPhysicalDeviceFeatures( 2201 VkPhysicalDevice physicalDevice, 2202 VkPhysicalDeviceFeatures* pFeatures) { 2203 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2204 2205 features := ? 2206 pFeatures[0] = features 2207 2208 return ? 2209} 2210 2211cmd VkResult vkGetPhysicalDeviceFormatProperties( 2212 VkPhysicalDevice physicalDevice, 2213 VkFormat format, 2214 VkFormatProperties* pFormatProperties) { 2215 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2216 2217 formatProperties := ? 2218 pFormatProperties[0] = formatProperties 2219 2220 return ? 2221} 2222 2223cmd VkResult vkGetPhysicalDeviceImageFormatProperties( 2224 VkPhysicalDevice physicalDevice, 2225 VkFormat format, 2226 VkImageType type, 2227 VkImageTiling tiling, 2228 VkImageUsageFlags usage, 2229 VkImageCreateFlags flags, 2230 VkImageFormatProperties* pImageFormatProperties) { 2231 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2232 2233 imageFormatProperties := ? 2234 pImageFormatProperties[0] = imageFormatProperties 2235 2236 return ? 2237} 2238 2239 2240// Device functions 2241 2242@threadSafety("system") 2243cmd VkResult vkCreateDevice( 2244 VkPhysicalDevice physicalDevice, 2245 const VkDeviceCreateInfo* pCreateInfo, 2246 VkDevice* pDevice) { 2247 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO) 2248 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2249 2250 device := ? 2251 pDevice[0] = device 2252 State.Devices[device] = new!DeviceObject(physicalDevice: physicalDevice) 2253 2254 return ? 2255} 2256 2257@threadSafety("system") 2258cmd void vkDestroyDevice( 2259 VkDevice device) { 2260 deviceObject := GetDevice(device) 2261 2262 State.Devices[device] = null 2263} 2264 2265 2266// Extension discovery functions 2267 2268cmd VkResult vkEnumerateInstanceLayerProperties( 2269 u32* pCount, 2270 VkLayerProperties* pProperties) { 2271 count := as!u32(?) 2272 pCount[0] = count 2273 2274 properties := pProperties[0:count] 2275 for i in (0 .. count) { 2276 property := ? 2277 properties[i] = property 2278 } 2279 2280 return ? 2281} 2282 2283cmd VkResult vkEnumerateInstanceExtensionProperties( 2284 const char* pLayerName, 2285 u32* pCount, 2286 VkExtensionProperties* pProperties) { 2287 count := as!u32(?) 2288 pCount[0] = count 2289 2290 properties := pProperties[0:count] 2291 for i in (0 .. count) { 2292 property := ? 2293 properties[i] = property 2294 } 2295 2296 return ? 2297} 2298 2299cmd VkResult vkEnumerateDeviceLayerProperties( 2300 VkPhysicalDevice physicalDevice, 2301 u32* pCount, 2302 VkLayerProperties* pProperties) { 2303 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2304 count := as!u32(?) 2305 pCount[0] = count 2306 2307 properties := pProperties[0:count] 2308 for i in (0 .. count) { 2309 property := ? 2310 properties[i] = property 2311 } 2312 2313 return ? 2314} 2315 2316cmd VkResult vkEnumerateDeviceExtensionProperties( 2317 VkPhysicalDevice physicalDevice, 2318 const char* pLayerName, 2319 u32* pCount, 2320 VkExtensionProperties* pProperties) { 2321 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2322 2323 count := as!u32(?) 2324 pCount[0] = count 2325 2326 properties := pProperties[0:count] 2327 for i in (0 .. count) { 2328 property := ? 2329 properties[i] = property 2330 } 2331 2332 return ? 2333} 2334 2335 2336// Queue functions 2337 2338@threadSafety("system") 2339cmd VkResult vkGetDeviceQueue( 2340 VkDevice device, 2341 u32 queueFamilyIndex, 2342 u32 queueIndex, 2343 VkQueue* pQueue) { 2344 deviceObject := GetDevice(device) 2345 2346 queue := ? 2347 pQueue[0] = queue 2348 2349 if !(queue in State.Queues) { 2350 State.Queues[queue] = new!QueueObject(device: device) 2351 } 2352 2353 return ? 2354} 2355 2356@threadSafety("app") 2357cmd VkResult vkQueueSubmit( 2358 VkQueue queue, 2359 u32 cmdBufferCount, 2360 const VkCmdBuffer* pCmdBuffers, 2361 VkFence fence) { 2362 queueObject := GetQueue(queue) 2363 2364 if fence != NULL_HANDLE { 2365 fenceObject := GetFence(fence) 2366 assert(fenceObject.device == queueObject.device) 2367 } 2368 2369 cmdBuffers := pCmdBuffers[0:cmdBufferCount] 2370 for i in (0 .. cmdBufferCount) { 2371 cmdBuffer := cmdBuffers[i] 2372 cmdBufferObject := GetCmdBuffer(cmdBuffer) 2373 assert(cmdBufferObject.device == queueObject.device) 2374 2375 validate("QueueCheck", cmdBufferObject.queueFlags in queueObject.flags, 2376 "vkQueueSubmit: enqueued cmdBuffer requires missing queue capabilities.") 2377 } 2378 2379 return ? 2380} 2381 2382@threadSafety("system") 2383cmd VkResult vkQueueWaitIdle( 2384 VkQueue queue) { 2385 queueObject := GetQueue(queue) 2386 2387 return ? 2388} 2389 2390@threadSafety("system") 2391cmd VkResult vkDeviceWaitIdle( 2392 VkDevice device) { 2393 deviceObject := GetDevice(device) 2394 2395 return ? 2396} 2397 2398 2399// Memory functions 2400 2401@threadSafety("system") 2402cmd VkResult vkAllocMemory( 2403 VkDevice device, 2404 const VkMemoryAllocInfo* pAllocInfo, 2405 VkDeviceMemory* pMem) { 2406 assert(pAllocInfo.sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO) 2407 deviceObject := GetDevice(device) 2408 2409 mem := ? 2410 pMem[0] = mem 2411 State.DeviceMemories[mem] = new!DeviceMemoryObject( 2412 device: device, 2413 allocationSize: pAllocInfo[0].allocationSize) 2414 2415 return ? 2416} 2417 2418@threadSafety("system") 2419cmd void vkFreeMemory( 2420 VkDevice device, 2421 VkDeviceMemory mem) { 2422 deviceObject := GetDevice(device) 2423 memObject := GetDeviceMemory(mem) 2424 assert(memObject.device == device) 2425 2426 // Check that no objects are still bound before freeing. 2427 validate("MemoryCheck", len(memObject.boundObjects) == 0, 2428 "vkFreeMemory: objects still bound") 2429 validate("MemoryCheck", len(memObject.boundCommandBuffers) == 0, 2430 "vkFreeMemory: cmdBuffers still bound") 2431 State.DeviceMemories[mem] = null 2432} 2433 2434@threadSafety("app") 2435cmd VkResult vkMapMemory( 2436 VkDevice device, 2437 VkDeviceMemory mem, 2438 VkDeviceSize offset, 2439 VkDeviceSize size, 2440 VkMemoryMapFlags flags, 2441 void** ppData) { 2442 deviceObject := GetDevice(device) 2443 memObject := GetDeviceMemory(mem) 2444 assert(memObject.device == device) 2445 2446 assert(flags == as!VkMemoryMapFlags(0)) 2447 assert((offset + size) <= memObject.allocationSize) 2448 2449 return ? 2450} 2451 2452@threadSafety("app") 2453cmd void vkUnmapMemory( 2454 VkDevice device, 2455 VkDeviceMemory mem) { 2456 deviceObject := GetDevice(device) 2457 memObject := GetDeviceMemory(mem) 2458 assert(memObject.device == device) 2459} 2460 2461cmd VkResult vkFlushMappedMemoryRanges( 2462 VkDevice device, 2463 u32 memRangeCount 2464 const VkMappedMemoryRange* pMemRanges) { 2465 deviceObject := GetDevice(device) 2466 2467 memRanges := pMemRanges[0:memRangeCount] 2468 for i in (0 .. memRangeCount) { 2469 memRange := memRanges[i] 2470 memObject := GetDeviceMemory(memRange.mem) 2471 assert(memObject.device == device) 2472 assert((memRange.offset + memRange.size) <= memObject.allocationSize) 2473 } 2474 2475 return ? 2476} 2477 2478cmd VkResult vkInvalidateMappedMemoryRanges( 2479 VkDevice device, 2480 u32 memRangeCount, 2481 const VkMappedMemoryRange* pMemRanges) { 2482 deviceObject := GetDevice(device) 2483 2484 memRanges := pMemRanges[0:memRangeCount] 2485 for i in (0 .. memRangeCount) { 2486 memRange := memRanges[i] 2487 memObject := GetDeviceMemory(memRange.mem) 2488 assert(memObject.device == device) 2489 assert((memRange.offset + memRange.size) <= memObject.allocationSize) 2490 } 2491 2492 return ? 2493} 2494 2495 2496// Memory management API functions 2497 2498cmd VkResult vkGetDeviceMemoryCommitment( 2499 VkDevice device, 2500 VkDeviceMemory memory, 2501 VkDeviceSize* pCommittedMemoryInBytes) { 2502 deviceObject := GetDevice(device) 2503 2504 if memory != NULL_HANDLE { 2505 memoryObject := GetDeviceMemory(memory) 2506 assert(memoryObject.device == device) 2507 } 2508 2509 committedMemoryInBytes := ? 2510 pCommittedMemoryInBytes[0] = committedMemoryInBytes 2511 2512 return ? 2513} 2514 2515cmd VkResult vkGetBufferMemoryRequirements( 2516 VkDevice device, 2517 VkBuffer buffer, 2518 VkMemoryRequirements* pMemoryRequirements) { 2519 deviceObject := GetDevice(device) 2520 bufferObject := GetBuffer(buffer) 2521 assert(bufferObject.device == device) 2522 2523 return ? 2524} 2525 2526cmd VkResult vkBindBufferMemory( 2527 VkDevice device, 2528 VkBuffer buffer, 2529 VkDeviceMemory mem, 2530 VkDeviceSize memOffset) { 2531 deviceObject := GetDevice(device) 2532 bufferObject := GetBuffer(buffer) 2533 assert(bufferObject.device == device) 2534 2535 // Unbind buffer from previous memory object, if not VK_NULL_HANDLE. 2536 if bufferObject.mem != NULL_HANDLE { 2537 memObject := GetDeviceMemory(bufferObject.mem) 2538 memObject.boundObjects[as!u64(buffer)] = null 2539 } 2540 2541 // Bind buffer to given memory object, if not VK_NULL_HANDLE. 2542 if mem != NULL_HANDLE { 2543 memObject := GetDeviceMemory(mem) 2544 assert(memObject.device == device) 2545 memObject.boundObjects[as!u64(buffer)] = memOffset 2546 } 2547 bufferObject.mem = mem 2548 bufferObject.memOffset = memOffset 2549 2550 return ? 2551} 2552 2553cmd VkResult vkGetImageMemoryRequirements( 2554 VkDevice device, 2555 VkImage image, 2556 VkMemoryRequirements* pMemoryRequirements) { 2557 deviceObject := GetDevice(device) 2558 imageObject := GetImage(image) 2559 assert(imageObject.device == device) 2560 2561 return ? 2562} 2563 2564cmd VkResult vkBindImageMemory( 2565 VkDevice device, 2566 VkImage image, 2567 VkDeviceMemory mem, 2568 VkDeviceSize memOffset) { 2569 deviceObject := GetDevice(device) 2570 imageObject := GetImage(image) 2571 assert(imageObject.device == device) 2572 2573 // Unbind image from previous memory object, if not VK_NULL_HANDLE. 2574 if imageObject.mem != NULL_HANDLE { 2575 memObject := GetDeviceMemory(imageObject.mem) 2576 memObject.boundObjects[as!u64(image)] = null 2577 } 2578 2579 // Bind image to given memory object, if not VK_NULL_HANDLE. 2580 if mem != NULL_HANDLE { 2581 memObject := GetDeviceMemory(mem) 2582 assert(memObject.device == device) 2583 memObject.boundObjects[as!u64(image)] = memOffset 2584 } 2585 imageObject.mem = mem 2586 imageObject.memOffset = memOffset 2587 2588 return ? 2589} 2590 2591cmd VkResult vkGetImageSparseMemoryRequirements( 2592 VkDevice device, 2593 VkImage image, 2594 u32* pNumRequirements, 2595 VkSparseImageMemoryRequirements* pSparseMemoryRequirements) { 2596 deviceObject := GetDevice(device) 2597 imageObject := GetImage(image) 2598 assert(imageObject.device == device) 2599 2600 return ? 2601} 2602 2603cmd VkResult vkGetPhysicalDeviceSparseImageFormatProperties( 2604 VkPhysicalDevice physicalDevice, 2605 VkFormat format, 2606 VkImageType type, 2607 u32 samples, 2608 VkImageUsageFlags usage, 2609 VkImageTiling tiling, 2610 u32* pNumProperties, 2611 VkSparseImageFormatProperties* pProperties) { 2612 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 2613 2614 return ? 2615} 2616 2617cmd VkResult vkQueueBindSparseBufferMemory( 2618 VkQueue queue, 2619 VkBuffer buffer, 2620 u32 numBindings, 2621 const VkSparseMemoryBindInfo* pBindInfo) { 2622 queueObject := GetQueue(queue) 2623 bufferObject := GetBuffer(buffer) 2624 assert(bufferObject.device == queueObject.device) 2625 2626 return ? 2627} 2628 2629cmd VkResult vkQueueBindSparseImageOpaqueMemory( 2630 VkQueue queue, 2631 VkImage image, 2632 u32 numBindings, 2633 const VkSparseMemoryBindInfo* pBindInfo) { 2634 queueObject := GetQueue(queue) 2635 imageObject := GetImage(image) 2636 assert(imageObject.device == queueObject.device) 2637 2638 return ? 2639} 2640 2641 2642cmd VkResult vkQueueBindSparseImageMemory( 2643 VkQueue queue, 2644 VkImage image, 2645 u32 numBindings, 2646 const VkSparseImageMemoryBindInfo* pBindInfo) { 2647 queueObject := GetQueue(queue) 2648 imageObject := GetImage(image) 2649 2650 return ? 2651} 2652 2653 2654// Fence functions 2655 2656@threadSafety("system") 2657cmd VkResult vkCreateFence( 2658 VkDevice device, 2659 const VkFenceCreateInfo* pCreateInfo, 2660 VkFence* pFence) { 2661 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO) 2662 deviceObject := GetDevice(device) 2663 2664 fence := ? 2665 pFence[0] = fence 2666 State.Fences[fence] = new!FenceObject( 2667 device: device, signaled: (pCreateInfo.flags == VK_FENCE_CREATE_SIGNALED_BIT)) 2668 2669 return ? 2670} 2671 2672@threadSafety("system") 2673cmd void vkDestroyFence( 2674 VkDevice device, 2675 VkFence fence) { 2676 deviceObject := GetDevice(device) 2677 fenceObject := GetFence(fence) 2678 assert(fenceObject.device == device) 2679 2680 State.Fences[fence] = null 2681} 2682 2683@threadSafety("system") 2684cmd VkResult vkResetFences( 2685 VkDevice device, 2686 u32 fenceCount, 2687 const VkFence* pFences) { 2688 deviceObject := GetDevice(device) 2689 2690 fences := pFences[0:fenceCount] 2691 for i in (0 .. fenceCount) { 2692 fence := fences[i] 2693 fenceObject := GetFence(fence) 2694 assert(fenceObject.device == device) 2695 fenceObject.signaled = false 2696 } 2697 2698 return ? 2699} 2700 2701@threadSafety("system") 2702cmd VkResult vkGetFenceStatus( 2703 VkDevice device, 2704 VkFence fence) { 2705 deviceObject := GetDevice(device) 2706 fenceObject := GetFence(fence) 2707 assert(fenceObject.device == device) 2708 2709 return ? 2710} 2711 2712@threadSafety("system") 2713cmd VkResult vkWaitForFences( 2714 VkDevice device, 2715 u32 fenceCount, 2716 const VkFence* pFences, 2717 VkBool32 waitAll, 2718 u64 timeout) { /// timeout in nanoseconds 2719 deviceObject := GetDevice(device) 2720 2721 fences := pFences[0:fenceCount] 2722 for i in (0 .. fenceCount) { 2723 fence := fences[i] 2724 fenceObject := GetFence(fence) 2725 assert(fenceObject.device == device) 2726 } 2727 2728 return ? 2729} 2730 2731 2732// Queue semaphore functions 2733 2734@threadSafety("system") 2735cmd VkResult vkCreateSemaphore( 2736 VkDevice device, 2737 const VkSemaphoreCreateInfo* pCreateInfo, 2738 VkSemaphore* pSemaphore) { 2739 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO) 2740 deviceObject := GetDevice(device) 2741 2742 semaphore := ? 2743 pSemaphore[0] = semaphore 2744 State.Semaphores[semaphore] = new!SemaphoreObject(device: device) 2745 2746 return ? 2747} 2748 2749@threadSafety("system") 2750cmd void vkDestroySemaphore( 2751 VkDevice device, 2752 VkSemaphore semaphore) { 2753 deviceObject := GetDevice(device) 2754 semaphoreObject := GetSemaphore(semaphore) 2755 assert(semaphoreObject.device == device) 2756 2757 State.Semaphores[semaphore] = null 2758} 2759 2760@threadSafety("app") 2761cmd VkResult vkQueueSignalSemaphore( 2762 VkQueue queue, 2763 VkSemaphore semaphore) { 2764 queueObject := GetQueue(queue) 2765 semaphoreObject := GetSemaphore(semaphore) 2766 assert(queueObject.device == semaphoreObject.device) 2767 2768 return ? 2769} 2770 2771@threadSafety("system") 2772cmd VkResult vkQueueWaitSemaphore( 2773 VkQueue queue, 2774 VkSemaphore semaphore) { 2775 queueObject := GetQueue(queue) 2776 semaphoreObject := GetSemaphore(semaphore) 2777 assert(queueObject.device == semaphoreObject.device) 2778 2779 return ? 2780} 2781 2782 2783// Event functions 2784 2785@threadSafety("system") 2786cmd VkResult vkCreateEvent( 2787 VkDevice device, 2788 const VkEventCreateInfo* pCreateInfo, 2789 VkEvent* pEvent) { 2790 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO) 2791 deviceObject := GetDevice(device) 2792 2793 event := ? 2794 pEvent[0] = event 2795 State.Events[event] = new!EventObject(device: device) 2796 2797 return ? 2798} 2799 2800@threadSafety("system") 2801cmd void vkDestroyEvent( 2802 VkDevice device, 2803 VkEvent event) { 2804 deviceObject := GetDevice(device) 2805 eventObject := GetEvent(event) 2806 assert(eventObject.device == device) 2807 2808 State.Events[event] = null 2809} 2810 2811@threadSafety("system") 2812cmd VkResult vkGetEventStatus( 2813 VkDevice device, 2814 VkEvent event) { 2815 deviceObject := GetDevice(device) 2816 eventObject := GetEvent(event) 2817 assert(eventObject.device == device) 2818 2819 return ? 2820} 2821 2822@threadSafety("system") 2823cmd VkResult vkSetEvent( 2824 VkDevice device, 2825 VkEvent event) { 2826 deviceObject := GetDevice(device) 2827 eventObject := GetEvent(event) 2828 assert(eventObject.device == device) 2829 2830 return ? 2831} 2832 2833@threadSafety("system") 2834cmd VkResult vkResetEvent( 2835 VkDevice device, 2836 VkEvent event) { 2837 deviceObject := GetDevice(device) 2838 eventObject := GetEvent(event) 2839 assert(eventObject.device == device) 2840 2841 return ? 2842} 2843 2844 2845// Query functions 2846 2847@threadSafety("system") 2848cmd VkResult vkCreateQueryPool( 2849 VkDevice device, 2850 const VkQueryPoolCreateInfo* pCreateInfo, 2851 VkQueryPool* pQueryPool) { 2852 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO) 2853 deviceObject := GetDevice(device) 2854 2855 queryPool := ? 2856 pQueryPool[0] = queryPool 2857 State.QueryPools[queryPool] = new!QueryPoolObject(device: device) 2858 2859 return ? 2860} 2861 2862@threadSafety("system") 2863cmd void vkDestroyQueryPool( 2864 VkDevice device, 2865 VkQueryPool queryPool) { 2866 deviceObject := GetDevice(device) 2867 queryPoolObject := GetQueryPool(queryPool) 2868 assert(queryPoolObject.device == device) 2869 2870 State.QueryPools[queryPool] = null 2871} 2872 2873@threadSafety("system") 2874cmd VkResult vkGetQueryPoolResults( 2875 VkDevice device, 2876 VkQueryPool queryPool, 2877 u32 startQuery, 2878 u32 queryCount, 2879 platform.size_t* pDataSize, 2880 void* pData, 2881 VkQueryResultFlags flags) { 2882 deviceObject := GetDevice(device) 2883 queryPoolObject := GetQueryPool(queryPool) 2884 assert(queryPoolObject.device == device) 2885 2886 dataSize := ? 2887 pDataSize[0] = dataSize 2888 data := pData[0:dataSize] 2889 2890 return ? 2891} 2892 2893// Buffer functions 2894 2895@threadSafety("system") 2896cmd VkResult vkCreateBuffer( 2897 VkDevice device, 2898 const VkBufferCreateInfo* pCreateInfo, 2899 VkBuffer* pBuffer) { 2900 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO) 2901 deviceObject := GetDevice(device) 2902 2903 buffer := ? 2904 pBuffer[0] = buffer 2905 State.Buffers[buffer] = new!BufferObject(device: device) 2906 2907 return ? 2908} 2909 2910@threadSafety("system") 2911cmd void vkDestroyBuffer( 2912 VkDevice device, 2913 VkBuffer buffer) { 2914 deviceObject := GetDevice(device) 2915 bufferObject := GetBuffer(buffer) 2916 assert(bufferObject.device == device) 2917 2918 assert(bufferObject.mem == 0) 2919 State.Buffers[buffer] = null 2920} 2921 2922 2923// Buffer view functions 2924 2925@threadSafety("system") 2926cmd VkResult vkCreateBufferView( 2927 VkDevice device, 2928 const VkBufferViewCreateInfo* pCreateInfo, 2929 VkBufferView* pView) { 2930 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO) 2931 deviceObject := GetDevice(device) 2932 2933 bufferObject := GetBuffer(pCreateInfo.buffer) 2934 assert(bufferObject.device == device) 2935 2936 view := ? 2937 pView[0] = view 2938 State.BufferViews[view] = new!BufferViewObject(device: device, buffer: pCreateInfo.buffer) 2939 2940 return ? 2941} 2942 2943@threadSafety("system") 2944cmd void vkDestroyBufferView( 2945 VkDevice device, 2946 VkBufferView bufferView) { 2947 deviceObject := GetDevice(device) 2948 bufferViewObject := GetBufferView(bufferView) 2949 assert(bufferViewObject.device == device) 2950 2951 State.BufferViews[bufferView] = null 2952} 2953 2954 2955// Image functions 2956 2957@threadSafety("system") 2958cmd VkResult vkCreateImage( 2959 VkDevice device, 2960 const VkImageCreateInfo* pCreateInfo, 2961 VkImage* pImage) { 2962 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO) 2963 deviceObject := GetDevice(device) 2964 2965 image := ? 2966 pImage[0] = image 2967 State.Images[image] = new!ImageObject(device: device) 2968 2969 return ? 2970} 2971 2972@threadSafety("system") 2973cmd void vkDestroyImage( 2974 VkDevice device, 2975 VkImage image) { 2976 deviceObject := GetDevice(device) 2977 imageObject := GetImage(image) 2978 assert(imageObject.device == device) 2979 2980 assert(imageObject.mem == 0) 2981 State.Images[image] = null 2982} 2983 2984cmd VkResult vkGetImageSubresourceLayout( 2985 VkDevice device, 2986 VkImage image, 2987 const VkImageSubresource* pSubresource, 2988 VkSubresourceLayout* pLayout) { 2989 deviceObject := GetDevice(device) 2990 imageObject := GetImage(image) 2991 assert(imageObject.device == device) 2992 2993 return ? 2994} 2995 2996 2997// Image view functions 2998 2999@threadSafety("system") 3000cmd VkResult vkCreateImageView( 3001 VkDevice device, 3002 const VkImageViewCreateInfo* pCreateInfo, 3003 VkImageView* pView) { 3004 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO) 3005 deviceObject := GetDevice(device) 3006 3007 imageObject := GetImage(pCreateInfo.image) 3008 assert(imageObject.device == device) 3009 3010 view := ? 3011 pView[0] = view 3012 State.ImageViews[view] = new!ImageViewObject(device: device, image: pCreateInfo.image) 3013 3014 return ? 3015} 3016 3017@threadSafety("system") 3018cmd void vkDestroyImageView( 3019 VkDevice device, 3020 VkImageView imageView) { 3021 deviceObject := GetDevice(device) 3022 imageViewObject := GetImageView(imageView) 3023 assert(imageViewObject.device == device) 3024 3025 State.ImageViews[imageView] = null 3026} 3027 3028 3029// Shader functions 3030 3031cmd VkResult vkCreateShaderModule( 3032 VkDevice device, 3033 const VkShaderModuleCreateInfo* pCreateInfo, 3034 VkShaderModule* pShaderModule) { 3035 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO) 3036 deviceObject := GetDevice(device) 3037 3038 shaderModule := ? 3039 pShaderModule[0] = shaderModule 3040 State.ShaderModules[shaderModule] = new!ShaderModuleObject(device: device) 3041 3042 return ? 3043} 3044 3045cmd void vkDestroyShaderModule( 3046 VkDevice device, 3047 VkShaderModule shaderModule) { 3048 deviceObject := GetDevice(device) 3049 shaderModuleObject := GetShaderModule(shaderModule) 3050 assert(shaderModuleObject.device == device) 3051 3052 State.ShaderModules[shaderModule] = null 3053} 3054 3055@threadSafety("system") 3056cmd VkResult vkCreateShader( 3057 VkDevice device, 3058 const VkShaderCreateInfo* pCreateInfo, 3059 VkShader* pShader) { 3060 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO) 3061 deviceObject := GetDevice(device) 3062 3063 shader := ? 3064 pShader[0] = shader 3065 State.Shaders[shader] = new!ShaderObject(device: device) 3066 3067 return ? 3068} 3069 3070@threadSafety("system") 3071cmd void vkDestroyShader( 3072 VkDevice device, 3073 VkShader shader) { 3074 deviceObject := GetDevice(device) 3075 shaderObject := GetShader(shader) 3076 assert(shaderObject.device == device) 3077 3078 State.Shaders[shader] = null 3079} 3080 3081 3082// Pipeline functions 3083 3084cmd VkResult vkCreatePipelineCache( 3085 VkDevice device, 3086 const VkPipelineCacheCreateInfo* pCreateInfo, 3087 VkPipelineCache* pPipelineCache) { 3088 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO) 3089 deviceObject := GetDevice(device) 3090 3091 pipelineCache := ? 3092 pPipelineCache[0] = pipelineCache 3093 State.PipelineCaches[pipelineCache] = new!PipelineCacheObject(device: device) 3094 3095 return ? 3096} 3097 3098cmd void vkDestroyPipelineCache( 3099 VkDevice device, 3100 VkPipelineCache pipelineCache) { 3101 deviceObject := GetDevice(device) 3102 pipelineCacheObject := GetPipelineCache(pipelineCache) 3103 assert(pipelineCacheObject.device == device) 3104 3105 State.PipelineCaches[pipelineCache] = null 3106} 3107 3108cmd platform.size_t vkGetPipelineCacheSize( 3109 VkDevice device, 3110 VkPipelineCache pipelineCache) { 3111 deviceObject := GetDevice(device) 3112 pipelineCacheObject := GetPipelineCache(pipelineCache) 3113 assert(pipelineCacheObject.device == device) 3114 3115 return ? 3116} 3117 3118cmd VkResult vkGetPipelineCacheData( 3119 VkDevice device, 3120 VkPipelineCache pipelineCache, 3121 void* pData) { 3122 deviceObject := GetDevice(device) 3123 pipelineCacheObject := GetPipelineCache(pipelineCache) 3124 assert(pipelineCacheObject.device == device) 3125 3126 return ? 3127} 3128 3129cmd VkResult vkMergePipelineCaches( 3130 VkDevice device, 3131 VkPipelineCache destCache, 3132 u32 srcCacheCount, 3133 const VkPipelineCache* pSrcCaches) { 3134 deviceObject := GetDevice(device) 3135 destCacheObject := GetPipelineCache(destCache) 3136 assert(destCacheObject.device == device) 3137 3138 srcCaches := pSrcCaches[0:srcCacheCount] 3139 for i in (0 .. srcCacheCount) { 3140 srcCache := srcCaches[i] 3141 srcCacheObject := GetPipelineCache(srcCache) 3142 assert(srcCacheObject.device == device) 3143 } 3144 3145 return ? 3146} 3147 3148cmd VkResult vkCreateGraphicsPipelines( 3149 VkDevice device, 3150 VkPipelineCache pipelineCache, 3151 u32 count, 3152 const VkGraphicsPipelineCreateInfo* pCreateInfos, 3153 VkPipeline* pPipelines) { 3154 deviceObject := GetDevice(device) 3155 if pipelineCache != NULL_HANDLE { 3156 pipelineCacheObject := GetPipelineCache(pipelineCache) 3157 assert(pipelineCacheObject.device == device) 3158 } 3159 3160 createInfos := pCreateInfos[0:count] 3161 pipelines := pPipelines[0:count] 3162 for i in (0 .. count) { 3163 pipeline := ? 3164 pipelines[i] = pipeline 3165 State.Pipelines[pipeline] = new!PipelineObject(device: device) 3166 } 3167 3168 return ? 3169} 3170 3171cmd VkResult vkCreateComputePipelines( 3172 VkDevice device, 3173 VkPipelineCache pipelineCache, 3174 u32 count, 3175 const VkComputePipelineCreateInfo* pCreateInfos, 3176 VkPipeline* pPipelines) { 3177 deviceObject := GetDevice(device) 3178 if pipelineCache != NULL_HANDLE { 3179 pipelineCacheObject := GetPipelineCache(pipelineCache) 3180 assert(pipelineCacheObject.device == device) 3181 } 3182 3183 createInfos := pCreateInfos[0:count] 3184 pipelines := pPipelines[0:count] 3185 for i in (0 .. count) { 3186 pipeline := ? 3187 pipelines[i] = pipeline 3188 State.Pipelines[pipeline] = new!PipelineObject(device: device) 3189 } 3190 3191 return ? 3192} 3193 3194@threadSafety("system") 3195cmd void vkDestroyPipeline( 3196 VkDevice device, 3197 VkPipeline pipeline) { 3198 deviceObject := GetDevice(device) 3199 pipelineObjects := GetPipeline(pipeline) 3200 assert(pipelineObjects.device == device) 3201 3202 State.Pipelines[pipeline] = null 3203} 3204 3205 3206// Pipeline layout functions 3207 3208@threadSafety("system") 3209cmd VkResult vkCreatePipelineLayout( 3210 VkDevice device, 3211 const VkPipelineLayoutCreateInfo* pCreateInfo, 3212 VkPipelineLayout* pPipelineLayout) { 3213 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO) 3214 deviceObject := GetDevice(device) 3215 3216 pipelineLayout := ? 3217 pPipelineLayout[0] = pipelineLayout 3218 State.PipelineLayouts[pipelineLayout] = new!PipelineLayoutObject(device: device) 3219 3220 return ? 3221} 3222 3223@threadSafety("system") 3224cmd void vkDestroyPipelineLayout( 3225 VkDevice device, 3226 VkPipelineLayout pipelineLayout) { 3227 deviceObject := GetDevice(device) 3228 pipelineLayoutObjects := GetPipelineLayout(pipelineLayout) 3229 assert(pipelineLayoutObjects.device == device) 3230 3231 State.PipelineLayouts[pipelineLayout] = null 3232} 3233 3234 3235// Sampler functions 3236 3237@threadSafety("system") 3238cmd VkResult vkCreateSampler( 3239 VkDevice device, 3240 const VkSamplerCreateInfo* pCreateInfo, 3241 VkSampler* pSampler) { 3242 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO) 3243 deviceObject := GetDevice(device) 3244 3245 sampler := ? 3246 pSampler[0] = sampler 3247 State.Samplers[sampler] = new!SamplerObject(device: device) 3248 3249 return ? 3250} 3251 3252@threadSafety("system") 3253cmd void vkDestroySampler( 3254 VkDevice device, 3255 VkSampler sampler) { 3256 deviceObject := GetDevice(device) 3257 samplerObject := GetSampler(sampler) 3258 assert(samplerObject.device == device) 3259 3260 State.Samplers[sampler] = null 3261} 3262 3263 3264// Descriptor set functions 3265 3266@threadSafety("system") 3267cmd VkResult vkCreateDescriptorSetLayout( 3268 VkDevice device, 3269 const VkDescriptorSetLayoutCreateInfo* pCreateInfo, 3270 VkDescriptorSetLayout* pSetLayout) { 3271 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO) 3272 deviceObject := GetDevice(device) 3273 3274 setLayout := ? 3275 pSetLayout[0] = setLayout 3276 State.DescriptorSetLayouts[setLayout] = new!DescriptorSetLayoutObject(device: device) 3277 3278 return ? 3279} 3280 3281@threadSafety("system") 3282cmd void vkDestroyDescriptorSetLayout( 3283 VkDevice device, 3284 VkDescriptorSetLayout descriptorSetLayout) { 3285 deviceObject := GetDevice(device) 3286 descriptorSetLayoutObject := GetDescriptorSetLayout(descriptorSetLayout) 3287 assert(descriptorSetLayoutObject.device == device) 3288 3289 State.DescriptorSetLayouts[descriptorSetLayout] = null 3290} 3291 3292@threadSafety("system") 3293cmd VkResult vkCreateDescriptorPool( 3294 VkDevice device, 3295 const VkDescriptorPoolCreateInfo* pCreateInfo 3296 VkDescriptorPool* pDescriptorPool) { 3297 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO) 3298 deviceObject := GetDevice(device) 3299 3300 descriptorPool := ? 3301 pDescriptorPool[0] = descriptorPool 3302 State.DescriptorPools[descriptorPool] = new!DescriptorPoolObject(device: device) 3303 3304 return ? 3305} 3306 3307@threadSafety("system") 3308cmd void vkDestroyDescriptorPool( 3309 VkDevice device, 3310 VkDescriptorPool descriptorPool) { 3311 deviceObject := GetDevice(device) 3312 descriptorPoolObject := GetDescriptorPool(descriptorPool) 3313 assert(descriptorPoolObject.device == device) 3314 3315 State.DescriptorPools[descriptorPool] = null 3316} 3317 3318@threadSafety("app") 3319cmd VkResult vkResetDescriptorPool( 3320 VkDevice device, 3321 VkDescriptorPool descriptorPool) { 3322 deviceObject := GetDevice(device) 3323 descriptorPoolObject := GetDescriptorPool(descriptorPool) 3324 assert(descriptorPoolObject.device == device) 3325 3326 return ? 3327} 3328 3329@threadSafety("app") 3330cmd VkResult vkAllocDescriptorSets( 3331 VkDevice device, 3332 VkDescriptorPool descriptorPool, 3333 VkDescriptorSetUsage setUsage, 3334 u32 count, 3335 const VkDescriptorSetLayout* pSetLayouts, 3336 VkDescriptorSet* pDescriptorSets) { 3337 deviceObject := GetDevice(device) 3338 descriptorPoolObject := GetDescriptorPool(descriptorPool) 3339 3340 setLayouts := pSetLayouts[0:count] 3341 for i in (0 .. count) { 3342 setLayout := setLayouts[i] 3343 setLayoutObject := GetDescriptorSetLayout(setLayout) 3344 assert(setLayoutObject.device == device) 3345 } 3346 3347 descriptorSets := pDescriptorSets[0:count] 3348 for i in (0 .. count) { 3349 descriptorSet := ? 3350 descriptorSets[i] = descriptorSet 3351 State.DescriptorSets[descriptorSet] = new!DescriptorSetObject(device: device) 3352 } 3353 3354 return ? 3355} 3356 3357cmd VkResult vkFreeDescriptorSets( 3358 VkDevice device, 3359 VkDescriptorPool descriptorPool, 3360 u32 count, 3361 const VkDescriptorSet* pDescriptorSets) { 3362 deviceObject := GetDevice(device) 3363 descriptorPoolObject := GetDescriptorPool(descriptorPool) 3364 3365 descriptorSets := pDescriptorSets[0:count] 3366 for i in (0 .. count) { 3367 descriptorSet := descriptorSets[i] 3368 descriptorSetObject := GetDescriptorSet(descriptorSet) 3369 assert(descriptorSetObject.device == device) 3370 State.DescriptorSets[descriptorSet] = null 3371 } 3372 3373 return ? 3374} 3375 3376cmd void vkUpdateDescriptorSets( 3377 VkDevice device, 3378 u32 writeCount, 3379 const VkWriteDescriptorSet* pDescriptorWrites, 3380 u32 copyCount, 3381 const VkCopyDescriptorSet* pDescriptorCopies) { 3382 deviceObject := GetDevice(device) 3383 3384 descriptorWrites := pDescriptorWrites[0:writeCount] 3385 for i in (0 .. writeCount) { 3386 descriptorWrite := descriptorWrites[i] 3387 descriptorWriteObject := GetDescriptorSet(descriptorWrite.destSet) 3388 assert(descriptorWriteObject.device == device) 3389 } 3390 3391 descriptorCopies := pDescriptorCopies[0:copyCount] 3392 for i in (0 .. copyCount) { 3393 descriptorCopy := descriptorCopies[i] 3394 descriptorCopyObject := GetDescriptorSet(descriptorCopy.destSet) 3395 assert(descriptorCopyObject.device == device) 3396 } 3397} 3398 3399 3400// Framebuffer functions 3401 3402@threadSafety("system") 3403cmd VkResult vkCreateFramebuffer( 3404 VkDevice device, 3405 const VkFramebufferCreateInfo* pCreateInfo, 3406 VkFramebuffer* pFramebuffer) { 3407 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO) 3408 deviceObject := GetDevice(device) 3409 3410 framebuffer := ? 3411 pFramebuffer[0] = framebuffer 3412 State.Framebuffers[framebuffer] = new!FramebufferObject(device: device) 3413 3414 return ? 3415} 3416 3417@threadSafety("system") 3418cmd void vkDestroyFramebuffer( 3419 VkDevice device, 3420 VkFramebuffer framebuffer) { 3421 deviceObject := GetDevice(device) 3422 framebufferObject := GetFramebuffer(framebuffer) 3423 assert(framebufferObject.device == device) 3424 3425 State.Framebuffers[framebuffer] = null 3426} 3427 3428 3429// Renderpass functions 3430 3431@threadSafety("system") 3432cmd VkResult vkCreateRenderPass( 3433 VkDevice device, 3434 const VkRenderPassCreateInfo* pCreateInfo, 3435 VkRenderPass* pRenderPass) { 3436 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO) 3437 deviceObject := GetDevice(device) 3438 3439 renderpass := ? 3440 pRenderPass[0] = renderpass 3441 State.RenderPasses[renderpass] = new!RenderPassObject(device: device) 3442 3443 return ? 3444} 3445 3446@threadSafety("system") 3447cmd void vkDestroyRenderPass( 3448 VkDevice device, 3449 VkRenderPass renderPass) { 3450 deviceObject := GetDevice(device) 3451 renderPassObject := GetRenderPass(renderPass) 3452 assert(renderPassObject.device == device) 3453 3454 State.RenderPasses[renderPass] = null 3455} 3456 3457cmd VkResult vkGetRenderAreaGranularity( 3458 VkDevice device, 3459 VkRenderPass renderPass, 3460 VkExtent2D* pGranularity) { 3461 deviceObject := GetDevice(device) 3462 renderPassObject := GetRenderPass(renderPass) 3463 3464 granularity := ? 3465 pGranularity[0] = granularity 3466 3467 return ? 3468} 3469 3470// Command pool functions 3471 3472cmd VkResult vkCreateCommandPool( 3473 VkDevice device, 3474 const VkCmdPoolCreateInfo* pCreateInfo, 3475 VkCmdPool* pCmdPool) { 3476 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO) 3477 deviceObject := GetDevice(device) 3478 3479 cmdPool := ? 3480 pCmdPool[0] = cmdPool 3481 State.CmdPools[cmdPool] = new!CmdPoolObject(device: device) 3482 3483 return ? 3484} 3485 3486cmd void vkDestroyCommandPool( 3487 VkDevice device, 3488 VkCmdPool cmdPool) { 3489 deviceObject := GetDevice(device) 3490 cmdPoolObject := GetCmdPool(cmdPool) 3491 assert(cmdPoolObject.device == device) 3492 3493 State.CmdPools[cmdPool] = null 3494} 3495 3496cmd VkResult vkResetCommandPool( 3497 VkDevice device, 3498 VkCmdPool cmdPool, 3499 VkCmdPoolResetFlags flags) { 3500 deviceObject := GetDevice(device) 3501 cmdPoolObject := GetCmdPool(cmdPool) 3502 assert(cmdPoolObject.device == device) 3503 3504 return ? 3505} 3506 3507// Command buffer functions 3508 3509macro void bindCmdBuffer(VkCmdBuffer cmdBuffer, any obj, VkDeviceMemory mem) { 3510 memoryObject := GetDeviceMemory(mem) 3511 memoryObject.boundCommandBuffers[cmdBuffer] = cmdBuffer 3512 3513 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3514 cmdBufferObject.boundObjects[as!u64(obj)] = mem 3515} 3516 3517macro void unbindCmdBuffer(VkCmdBuffer cmdBuffer, any obj, VkDeviceMemory mem) { 3518 memoryObject := GetDeviceMemory(mem) 3519 memoryObject.boundCommandBuffers[cmdBuffer] = null 3520 3521 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3522 cmdBufferObject.boundObjects[as!u64(obj)] = null 3523} 3524 3525@threadSafety("system") 3526cmd VkResult vkCreateCommandBuffer( 3527 VkDevice device, 3528 const VkCmdBufferCreateInfo* pCreateInfo, 3529 VkCmdBuffer* pCmdBuffer) { 3530 assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO) 3531 3532 cmdBuffer := ? 3533 pCmdBuffer[0] = cmdBuffer 3534 State.CmdBuffers[cmdBuffer] = new!CmdBufferObject(device: device) 3535 3536 return ? 3537} 3538 3539@threadSafety("system") 3540cmd void vkDestroyCommandBuffer( 3541 VkDevice device, 3542 VkCmdBuffer commandBuffer) { 3543 deviceObject := GetDevice(device) 3544 cmdBufferObject := GetCmdBuffer(commandBuffer) 3545 assert(cmdBufferObject.device == device) 3546 3547 // TODO: iterate over boundObjects and clear memory bindings 3548 State.CmdBuffers[commandBuffer] = null 3549} 3550 3551@threadSafety("app") 3552cmd VkResult vkBeginCommandBuffer( 3553 VkCmdBuffer cmdBuffer, 3554 const VkCmdBufferBeginInfo* pBeginInfo) { 3555 assert(pBeginInfo.sType == VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO) 3556 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3557 3558 // TODO: iterate over boundObjects and clear memory bindings 3559 3560 return ? 3561} 3562 3563@threadSafety("app") 3564cmd VkResult vkEndCommandBuffer( 3565 VkCmdBuffer cmdBuffer) { 3566 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3567 3568 return ? 3569} 3570 3571@threadSafety("app") 3572cmd VkResult vkResetCommandBuffer( 3573 VkCmdBuffer cmdBuffer, 3574 VkCmdBufferResetFlags flags) { 3575 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3576 3577 // TODO: iterate over boundObjects and clear memory bindings 3578 3579 return ? 3580} 3581 3582 3583// Command buffer building functions 3584 3585@threadSafety("app") 3586cmd void vkCmdBindPipeline( 3587 VkCmdBuffer cmdBuffer, 3588 VkPipelineBindPoint pipelineBindPoint, 3589 VkPipeline pipeline) { 3590 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3591 pipelineObject := GetPipeline(pipeline) 3592 assert(cmdBufferObject.device == pipelineObject.device) 3593 3594 queueFlags := cmdBufferObject.queueFlags | switch (pipelineBindPoint) { 3595 case VK_PIPELINE_BIND_POINT_COMPUTE: VK_QUEUE_COMPUTE_BIT 3596 case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT 3597 } 3598 cmdBufferObject.queueFlags = queueFlags 3599} 3600 3601@threadSafety("app") 3602cmd void vkCmdSetViewport( 3603 VkCmdBuffer cmdBuffer, 3604 u32 viewportCount, 3605 const VkViewport* pViewports) { 3606 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3607 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3608 cmdBufferObject.queueFlags = queueFlags 3609} 3610 3611@threadSafety("app") 3612cmd void vkCmdSetScissor( 3613 VkCmdBuffer cmdBuffer, 3614 u32 scissorCount, 3615 const VkRect2D* pScissors) { 3616 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3617 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3618 cmdBufferObject.queueFlags = queueFlags 3619} 3620 3621@threadSafety("app") 3622cmd void vkCmdSetLineWidth( 3623 VkCmdBuffer cmdBuffer, 3624 f32 lineWidth) { 3625 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3626 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3627 cmdBufferObject.queueFlags = queueFlags 3628} 3629 3630@threadSafety("app") 3631cmd void vkCmdSetDepthBias( 3632 VkCmdBuffer cmdBuffer, 3633 f32 depthBias, 3634 f32 depthBiasClamp, 3635 f32 slopeScaledDepthBias) { 3636 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3637 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3638 cmdBufferObject.queueFlags = queueFlags 3639} 3640 3641@threadSafety("app") 3642cmd void vkCmdSetBlendConstants( 3643 VkCmdBuffer cmdBuffer, 3644 // TODO(jessehall): apic only supports 'const' on pointer types. Using 3645 // an annotation as a quick hack to pass this to the template without 3646 // having to modify the AST and semantic model. 3647 @readonly f32[4] blendConst) { 3648 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3649 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3650 cmdBufferObject.queueFlags = queueFlags 3651} 3652 3653@threadSafety("app") 3654cmd void vkCmdSetDepthBounds( 3655 VkCmdBuffer cmdBuffer, 3656 f32 minDepthBounds, 3657 f32 maxDepthBounds) { 3658 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3659 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3660 cmdBufferObject.queueFlags = queueFlags 3661} 3662 3663@threadSafety("app") 3664cmd void vkCmdSetStencilCompareMask( 3665 VkCmdBuffer cmdBuffer, 3666 VkStencilFaceFlags faceMask, 3667 u32 stencilCompareMask) { 3668 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3669 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3670 cmdBufferObject.queueFlags = queueFlags 3671} 3672 3673@threadSafety("app") 3674cmd void vkCmdSetStencilWriteMask( 3675 VkCmdBuffer cmdBuffer, 3676 VkStencilFaceFlags faceMask, 3677 u32 stencilWriteMask) { 3678 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3679 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3680 cmdBufferObject.queueFlags = queueFlags 3681} 3682 3683@threadSafety("app") 3684cmd void vkCmdSetStencilReference( 3685 VkCmdBuffer cmdBuffer, 3686 VkStencilFaceFlags faceMask, 3687 u32 stencilReference) { 3688 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3689 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3690 cmdBufferObject.queueFlags = queueFlags 3691} 3692 3693@threadSafety("app") 3694cmd void vkCmdBindDescriptorSets( 3695 VkCmdBuffer cmdBuffer, 3696 VkPipelineBindPoint pipelineBindPoint, 3697 VkPipelineLayout layout, 3698 u32 firstSet, 3699 u32 setCount, 3700 const VkDescriptorSet* pDescriptorSets, 3701 u32 dynamicOffsetCount, 3702 const u32* pDynamicOffsets) { 3703 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3704 3705 descriptorSets := pDescriptorSets[0:setCount] 3706 for i in (0 .. setCount) { 3707 descriptorSet := descriptorSets[i] 3708 descriptorSetObject := GetDescriptorSet(descriptorSet) 3709 assert(cmdBufferObject.device == descriptorSetObject.device) 3710 } 3711 3712 dynamicOffsets := pDynamicOffsets[0:dynamicOffsetCount] 3713 for i in (0 .. dynamicOffsetCount) { 3714 dynamicOffset := dynamicOffsets[i] 3715 } 3716 3717 queueFlags := cmdBufferObject.queueFlags | switch (pipelineBindPoint) { 3718 case VK_PIPELINE_BIND_POINT_COMPUTE: VK_QUEUE_COMPUTE_BIT 3719 case VK_PIPELINE_BIND_POINT_GRAPHICS: VK_QUEUE_GRAPHICS_BIT 3720 } 3721 cmdBufferObject.queueFlags = queueFlags 3722} 3723 3724@threadSafety("app") 3725cmd void vkCmdBindIndexBuffer( 3726 VkCmdBuffer cmdBuffer, 3727 VkBuffer buffer, 3728 VkDeviceSize offset, 3729 VkIndexType indexType) { 3730 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3731 bufferObject := GetBuffer(buffer) 3732 assert(cmdBufferObject.device == bufferObject.device) 3733 3734 bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem) 3735 3736 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3737 cmdBufferObject.queueFlags = queueFlags 3738} 3739 3740@threadSafety("app") 3741cmd void vkCmdBindVertexBuffers( 3742 VkCmdBuffer cmdBuffer, 3743 u32 startBinding, 3744 u32 bindingCount, 3745 const VkBuffer* pBuffers, 3746 const VkDeviceSize* pOffsets) { 3747 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3748 3749 // TODO: check if not [startBinding:startBinding+bindingCount] 3750 buffers := pBuffers[0:bindingCount] 3751 offsets := pOffsets[0:bindingCount] 3752 for i in (0 .. bindingCount) { 3753 buffer := buffers[i] 3754 offset := offsets[i] 3755 bufferObject := GetBuffer(buffer) 3756 assert(cmdBufferObject.device == bufferObject.device) 3757 3758 bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem) 3759 } 3760 3761 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3762 cmdBufferObject.queueFlags = queueFlags 3763} 3764 3765@threadSafety("app") 3766cmd void vkCmdDraw( 3767 VkCmdBuffer cmdBuffer, 3768 u32 vertexCount, 3769 u32 instanceCount, 3770 u32 firstVertex, 3771 u32 firstInstance) { 3772 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3773 3774 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3775 cmdBufferObject.queueFlags = queueFlags 3776} 3777 3778@threadSafety("app") 3779cmd void vkCmdDrawIndexed( 3780 VkCmdBuffer cmdBuffer, 3781 u32 indexCount, 3782 u32 instanceCount, 3783 u32 firstIndex, 3784 s32 vertexOffset, 3785 u32 firstInstance) { 3786 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3787 3788 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3789 cmdBufferObject.queueFlags = queueFlags 3790} 3791 3792@threadSafety("app") 3793cmd void vkCmdDrawIndirect( 3794 VkCmdBuffer cmdBuffer, 3795 VkBuffer buffer, 3796 VkDeviceSize offset, 3797 u32 count, 3798 u32 stride) { 3799 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3800 bufferObject := GetBuffer(buffer) 3801 assert(cmdBufferObject.device == bufferObject.device) 3802 3803 bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem) 3804 3805 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3806 cmdBufferObject.queueFlags = queueFlags 3807} 3808 3809@threadSafety("app") 3810cmd void vkCmdDrawIndexedIndirect( 3811 VkCmdBuffer cmdBuffer, 3812 VkBuffer buffer, 3813 VkDeviceSize offset, 3814 u32 count, 3815 u32 stride) { 3816 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3817 bufferObject := GetBuffer(buffer) 3818 assert(cmdBufferObject.device == bufferObject.device) 3819 3820 bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem) 3821 3822 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3823 cmdBufferObject.queueFlags = queueFlags 3824} 3825 3826@threadSafety("app") 3827cmd void vkCmdDispatch( 3828 VkCmdBuffer cmdBuffer, 3829 u32 x, 3830 u32 y, 3831 u32 z) { 3832 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3833 3834 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_COMPUTE_BIT 3835 cmdBufferObject.queueFlags = queueFlags 3836} 3837 3838@threadSafety("app") 3839cmd void vkCmdDispatchIndirect( 3840 VkCmdBuffer cmdBuffer, 3841 VkBuffer buffer, 3842 VkDeviceSize offset) { 3843 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3844 bufferObject := GetBuffer(buffer) 3845 assert(cmdBufferObject.device == bufferObject.device) 3846 3847 bindCmdBuffer(cmdBuffer, buffer, bufferObject.mem) 3848 3849 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_COMPUTE_BIT 3850 cmdBufferObject.queueFlags = queueFlags 3851} 3852 3853@threadSafety("app") 3854cmd void vkCmdCopyBuffer( 3855 VkCmdBuffer cmdBuffer, 3856 VkBuffer srcBuffer, 3857 VkBuffer destBuffer, 3858 u32 regionCount, 3859 const VkBufferCopy* pRegions) { 3860 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3861 srcBufferObject := GetBuffer(srcBuffer) 3862 destBufferObject := GetBuffer(destBuffer) 3863 assert(cmdBufferObject.device == srcBufferObject.device) 3864 assert(cmdBufferObject.device == destBufferObject.device) 3865 3866 regions := pRegions[0:regionCount] 3867 for i in (0 .. regionCount) { 3868 region := regions[i] 3869 } 3870 3871 bindCmdBuffer(cmdBuffer, srcBuffer, srcBufferObject.mem) 3872 bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem) 3873 3874 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 3875 cmdBufferObject.queueFlags = queueFlags 3876} 3877 3878@threadSafety("app") 3879cmd void vkCmdCopyImage( 3880 VkCmdBuffer cmdBuffer, 3881 VkImage srcImage, 3882 VkImageLayout srcImageLayout, 3883 VkImage destImage, 3884 VkImageLayout destImageLayout, 3885 u32 regionCount, 3886 const VkImageCopy* pRegions) { 3887 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3888 srcImageObject := GetImage(srcImage) 3889 destImageObject := GetImage(destImage) 3890 assert(cmdBufferObject.device == srcImageObject.device) 3891 assert(cmdBufferObject.device == destImageObject.device) 3892 3893 regions := pRegions[0:regionCount] 3894 for i in (0 .. regionCount) { 3895 region := regions[i] 3896 } 3897 3898 bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem) 3899 bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem) 3900 3901 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 3902 cmdBufferObject.queueFlags = queueFlags 3903} 3904 3905@threadSafety("app") 3906cmd void vkCmdBlitImage( 3907 VkCmdBuffer cmdBuffer, 3908 VkImage srcImage, 3909 VkImageLayout srcImageLayout, 3910 VkImage destImage, 3911 VkImageLayout destImageLayout, 3912 u32 regionCount, 3913 const VkImageBlit* pRegions, 3914 VkTexFilter filter) { 3915 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3916 srcImageObject := GetImage(srcImage) 3917 destImageObject := GetImage(destImage) 3918 assert(cmdBufferObject.device == srcImageObject.device) 3919 assert(cmdBufferObject.device == destImageObject.device) 3920 3921 regions := pRegions[0:regionCount] 3922 for i in (0 .. regionCount) { 3923 region := regions[i] 3924 } 3925 3926 bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem) 3927 bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem) 3928 3929 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 3930 cmdBufferObject.queueFlags = queueFlags 3931} 3932 3933@threadSafety("app") 3934cmd void vkCmdCopyBufferToImage( 3935 VkCmdBuffer cmdBuffer, 3936 VkBuffer srcBuffer, 3937 VkImage destImage, 3938 VkImageLayout destImageLayout, 3939 u32 regionCount, 3940 const VkBufferImageCopy* pRegions) { 3941 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3942 srcBufferObject := GetBuffer(srcBuffer) 3943 destImageObject := GetImage(destImage) 3944 assert(cmdBufferObject.device == srcBufferObject.device) 3945 assert(cmdBufferObject.device == destImageObject.device) 3946 3947 regions := pRegions[0:regionCount] 3948 for i in (0 .. regionCount) { 3949 region := regions[i] 3950 } 3951 3952 bindCmdBuffer(cmdBuffer, srcBuffer, srcBufferObject.mem) 3953 bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem) 3954 3955 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 3956 cmdBufferObject.queueFlags = queueFlags 3957} 3958 3959@threadSafety("app") 3960cmd void vkCmdCopyImageToBuffer( 3961 VkCmdBuffer cmdBuffer, 3962 VkImage srcImage, 3963 VkImageLayout srcImageLayout, 3964 VkBuffer destBuffer, 3965 u32 regionCount, 3966 const VkBufferImageCopy* pRegions) { 3967 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3968 srcImageObject := GetImage(srcImage) 3969 destBufferObject := GetBuffer(destBuffer) 3970 assert(cmdBufferObject.device == srcImageObject.device) 3971 assert(cmdBufferObject.device == destBufferObject.device) 3972 3973 regions := pRegions[0:regionCount] 3974 for i in (0 .. regionCount) { 3975 region := regions[i] 3976 } 3977 3978 bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem) 3979 bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem) 3980 3981 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 3982 cmdBufferObject.queueFlags = queueFlags 3983} 3984 3985@threadSafety("app") 3986cmd void vkCmdUpdateBuffer( 3987 VkCmdBuffer cmdBuffer, 3988 VkBuffer destBuffer, 3989 VkDeviceSize destOffset, 3990 VkDeviceSize dataSize, 3991 const u32* pData) { 3992 cmdBufferObject := GetCmdBuffer(cmdBuffer) 3993 destBufferObject := GetBuffer(destBuffer) 3994 assert(cmdBufferObject.device == destBufferObject.device) 3995 3996 data := pData[0:dataSize] 3997 3998 bindCmdBuffer(cmdBuffer, destBuffer, destBufferObject.mem) 3999 4000 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 4001 cmdBufferObject.queueFlags = queueFlags 4002} 4003 4004@threadSafety("app") 4005cmd void vkCmdFillBuffer( 4006 VkCmdBuffer cmdBuffer, 4007 VkBuffer destBuffer, 4008 VkDeviceSize destOffset, 4009 VkDeviceSize fillSize, 4010 u32 data) { 4011 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4012 destBufferObject := GetBuffer(destBuffer) 4013 assert(cmdBufferObject.device == destBufferObject.device) 4014 4015 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_DMA_BIT 4016 cmdBufferObject.queueFlags = queueFlags 4017} 4018 4019@threadSafety("app") 4020cmd void vkCmdClearColorImage( 4021 VkCmdBuffer cmdBuffer, 4022 VkImage image, 4023 VkImageLayout imageLayout, 4024 const VkClearColorValue* pColor, 4025 u32 rangeCount, 4026 const VkImageSubresourceRange* pRanges) { 4027 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4028 imageObject := GetImage(image) 4029 assert(cmdBufferObject.device == imageObject.device) 4030 4031 ranges := pRanges[0:rangeCount] 4032 for i in (0 .. rangeCount) { 4033 range := ranges[i] 4034 } 4035 4036 bindCmdBuffer(cmdBuffer, image, imageObject.mem) 4037 4038 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4039 cmdBufferObject.queueFlags = queueFlags 4040} 4041 4042@threadSafety("app") 4043cmd void vkCmdClearDepthStencilImage( 4044 VkCmdBuffer cmdBuffer, 4045 VkImage image, 4046 VkImageLayout imageLayout, 4047 const VkClearDepthStencilValue* pDepthStencil, 4048 u32 rangeCount, 4049 const VkImageSubresourceRange* pRanges) { 4050 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4051 imageObject := GetImage(image) 4052 assert(cmdBufferObject.device == imageObject.device) 4053 4054 ranges := pRanges[0:rangeCount] 4055 for i in (0 .. rangeCount) { 4056 range := ranges[i] 4057 } 4058 4059 bindCmdBuffer(cmdBuffer, image, imageObject.mem) 4060 4061 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4062 cmdBufferObject.queueFlags = queueFlags 4063} 4064 4065@threadSafety("app") 4066cmd void vkCmdClearColorAttachment( 4067 VkCmdBuffer cmdBuffer, 4068 u32 colorAttachment, 4069 VkImageLayout imageLayout, 4070 const VkClearColorValue* pColor, 4071 u32 rectCount, 4072 const VkRect3D* pRects) { 4073 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4074 4075 rects := pRects[0:rectCount] 4076 for i in (0 .. rectCount) { 4077 rect := rects[i] 4078 } 4079 4080 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4081 cmdBufferObject.queueFlags = queueFlags 4082} 4083 4084@threadSafety("app") 4085cmd void vkCmdClearDepthStencilAttachment( 4086 VkCmdBuffer cmdBuffer, 4087 VkImageAspectFlags aspectMask, 4088 VkImageLayout imageLayout, 4089 const VkClearDepthStencilValue* pDepthStencil, 4090 u32 rectCount, 4091 const VkRect3D* pRects) { 4092 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4093 4094 rects := pRects[0:rectCount] 4095 for i in (0 .. rectCount) { 4096 rect := rects[i] 4097 } 4098 4099 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4100 cmdBufferObject.queueFlags = queueFlags 4101} 4102 4103@threadSafety("app") 4104cmd void vkCmdResolveImage( 4105 VkCmdBuffer cmdBuffer, 4106 VkImage srcImage, 4107 VkImageLayout srcImageLayout, 4108 VkImage destImage, 4109 VkImageLayout destImageLayout, 4110 u32 regionCount, 4111 const VkImageResolve* pRegions) { 4112 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4113 srcImageObject := GetImage(srcImage) 4114 destImageObject := GetImage(destImage) 4115 assert(cmdBufferObject.device == srcImageObject.device) 4116 assert(cmdBufferObject.device == destImageObject.device) 4117 4118 regions := pRegions[0:regionCount] 4119 for i in (0 .. regionCount) { 4120 region := regions[i] 4121 } 4122 4123 bindCmdBuffer(cmdBuffer, srcImage, srcImageObject.mem) 4124 bindCmdBuffer(cmdBuffer, destImage, destImageObject.mem) 4125 4126 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4127 cmdBufferObject.queueFlags = queueFlags 4128} 4129 4130@threadSafety("app") 4131cmd void vkCmdSetEvent( 4132 VkCmdBuffer cmdBuffer, 4133 VkEvent event, 4134 VkPipelineStageFlags stageMask) { 4135 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4136 eventObject := GetEvent(event) 4137 assert(cmdBufferObject.device == eventObject.device) 4138} 4139 4140@threadSafety("app") 4141cmd void vkCmdResetEvent( 4142 VkCmdBuffer cmdBuffer, 4143 VkEvent event, 4144 VkPipelineStageFlags stageMask) { 4145 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4146 eventObject := GetEvent(event) 4147 assert(cmdBufferObject.device == eventObject.device) 4148} 4149 4150@threadSafety("app") 4151cmd void vkCmdWaitEvents( 4152 VkCmdBuffer cmdBuffer, 4153 u32 eventCount, 4154 const VkEvent* pEvents, 4155 VkPipelineStageFlags srcStageMask, 4156 VkPipelineStageFlags destStageMask, 4157 u32 memBarrierCount, 4158 const void* const* ppMemBarriers) { 4159 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4160 4161 events := pEvents[0:eventCount] 4162 for i in (0 .. eventCount) { 4163 event := events[i] 4164 eventObject := GetEvent(event) 4165 assert(cmdBufferObject.device == eventObject.device) 4166 } 4167 4168 pMemBarriers := ppMemBarriers[0:memBarrierCount] 4169 for i in (0 .. memBarrierCount) { 4170 switch as!VkMemoryBarrier const*(pMemBarriers[i])[0].sType { 4171 case VK_STRUCTURE_TYPE_MEMORY_BARRIER: { 4172 memBarrier := as!VkMemoryBarrier const*(pMemBarriers[i])[0] 4173 } 4174 case VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: { 4175 imageMemBarrier := as!VkImageMemoryBarrier const*(pMemBarriers[i])[0] 4176 imageObject := GetImage(imageMemBarrier.image) 4177 assert(imageObject.device == cmdBufferObject.device) 4178 } 4179 case VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: { 4180 bufferMemBarrier := as!VkBufferMemoryBarrier const*(pMemBarriers[i])[0] 4181 bufferObject := GetBuffer(bufferMemBarrier.buffer) 4182 assert(bufferObject.device == cmdBufferObject.device) 4183 } 4184 } 4185 } 4186} 4187 4188@threadSafety("app") 4189cmd void vkCmdPipelineBarrier( 4190 VkCmdBuffer cmdBuffer, 4191 VkPipelineStageFlags srcStageMask, 4192 VkPipelineStageFlags destStageMask, 4193 VkBool32 byRegion, 4194 u32 memBarrierCount, 4195 const void* const* ppMemBarriers) { 4196 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4197 4198 pMemBarriers := ppMemBarriers[0:memBarrierCount] 4199 for i in (0 .. memBarrierCount) { 4200 switch as!VkMemoryBarrier const*(pMemBarriers[i])[0].sType { 4201 case VK_STRUCTURE_TYPE_MEMORY_BARRIER: { 4202 memBarrier := as!VkMemoryBarrier const*(pMemBarriers[i])[0] 4203 } 4204 case VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: { 4205 imageMemBarrier := as!VkImageMemoryBarrier const*(pMemBarriers[i])[0] 4206 imageObject := GetImage(imageMemBarrier.image) 4207 assert(imageObject.device == cmdBufferObject.device) 4208 } 4209 case VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: { 4210 bufferMemBarrier := as!VkBufferMemoryBarrier const*(pMemBarriers[i])[0] 4211 bufferObject := GetBuffer(bufferMemBarrier.buffer) 4212 assert(bufferObject.device == cmdBufferObject.device) 4213 } 4214 } 4215 } 4216} 4217 4218@threadSafety("app") 4219cmd void vkCmdBeginQuery( 4220 VkCmdBuffer cmdBuffer, 4221 VkQueryPool queryPool, 4222 u32 slot, 4223 VkQueryControlFlags flags) { 4224 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4225 queryPoolObject := GetQueryPool(queryPool) 4226 assert(cmdBufferObject.device == queryPoolObject.device) 4227} 4228 4229@threadSafety("app") 4230cmd void vkCmdEndQuery( 4231 VkCmdBuffer cmdBuffer, 4232 VkQueryPool queryPool, 4233 u32 slot) { 4234 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4235 queryPoolObject := GetQueryPool(queryPool) 4236 assert(cmdBufferObject.device == queryPoolObject.device) 4237} 4238 4239@threadSafety("app") 4240cmd void vkCmdResetQueryPool( 4241 VkCmdBuffer cmdBuffer, 4242 VkQueryPool queryPool, 4243 u32 startQuery, 4244 u32 queryCount) { 4245 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4246 queryPoolObject := GetQueryPool(queryPool) 4247 assert(cmdBufferObject.device == queryPoolObject.device) 4248} 4249 4250@threadSafety("app") 4251cmd void vkCmdWriteTimestamp( 4252 VkCmdBuffer cmdBuffer, 4253 VkTimestampType timestampType, 4254 VkBuffer destBuffer, 4255 VkDeviceSize destOffset) { 4256 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4257 destBufferObject := GetBuffer(destBuffer) 4258 assert(cmdBufferObject.device == destBufferObject.device) 4259} 4260 4261@threadSafety("app") 4262cmd void vkCmdCopyQueryPoolResults( 4263 VkCmdBuffer cmdBuffer, 4264 VkQueryPool queryPool, 4265 u32 startQuery, 4266 u32 queryCount, 4267 VkBuffer destBuffer, 4268 VkDeviceSize destOffset, 4269 VkDeviceSize destStride, 4270 VkQueryResultFlags flags) { 4271 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4272 queryPoolObject := GetQueryPool(queryPool) 4273 destBufferObject := GetBuffer(destBuffer) 4274 assert(cmdBufferObject.device == queryPoolObject.device) 4275 assert(cmdBufferObject.device == destBufferObject.device) 4276} 4277 4278cmd void vkCmdPushConstants( 4279 VkCmdBuffer cmdBuffer, 4280 VkPipelineLayout layout, 4281 VkShaderStageFlags stageFlags, 4282 u32 start, 4283 u32 length, 4284 const void* values) { 4285 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4286 layoutObject := GetPipelineLayout(layout) 4287 assert(cmdBufferObject.device == layoutObject.device) 4288} 4289 4290@threadSafety("app") 4291cmd void vkCmdBeginRenderPass( 4292 VkCmdBuffer cmdBuffer, 4293 const VkRenderPassBeginInfo* pRenderPassBegin, 4294 VkRenderPassContents contents) { 4295 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4296 renderPassObject := GetRenderPass(pRenderPassBegin.renderPass) 4297 framebufferObject := GetFramebuffer(pRenderPassBegin.framebuffer) 4298 assert(cmdBufferObject.device == renderPassObject.device) 4299 assert(cmdBufferObject.device == framebufferObject.device) 4300 4301 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4302 cmdBufferObject.queueFlags = queueFlags 4303} 4304 4305cmd void vkCmdNextSubpass( 4306 VkCmdBuffer cmdBuffer, 4307 VkRenderPassContents contents) { 4308 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4309} 4310 4311@threadSafety("app") 4312cmd void vkCmdEndRenderPass( 4313 VkCmdBuffer cmdBuffer) { 4314 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4315 4316 queueFlags := cmdBufferObject.queueFlags | VK_QUEUE_GRAPHICS_BIT 4317 cmdBufferObject.queueFlags = queueFlags 4318} 4319 4320cmd void vkCmdExecuteCommands( 4321 VkCmdBuffer cmdBuffer, 4322 u32 cmdBuffersCount, 4323 const VkCmdBuffer* pCmdBuffers) { 4324 cmdBufferObject := GetCmdBuffer(cmdBuffer) 4325 4326 cmdBuffers := pCmdBuffers[0:cmdBuffersCount] 4327 for i in (0 .. cmdBuffersCount) { 4328 secondaryCmdBuffer := cmdBuffers[i] 4329 secondaryCmdBufferObject := GetCmdBuffer(secondaryCmdBuffer) 4330 assert(cmdBufferObject.device == secondaryCmdBufferObject.device) 4331 } 4332} 4333 4334//////////////// 4335// Extensions // 4336//////////////// 4337 4338@extension("VK_EXT_KHR_device_swapchain") 4339cmd VkResult vkGetSurfacePropertiesKHR( 4340 VkDevice device, 4341 const VkSurfaceDescriptionKHR* pSurfaceDescription, 4342 VkSurfacePropertiesKHR* pSurfaceProperties) { 4343 deviceObject := GetDevice(device) 4344 4345 surfaceProperties := ? 4346 pSurfaceProperties[0] = surfaceProperties 4347 4348 return ? 4349} 4350 4351@extension("VK_EXT_KHR_device_swapchain") 4352cmd VkResult vkGetSurfaceFormatsKHR( 4353 VkDevice device, 4354 const VkSurfaceDescriptionKHR* pSurfaceDescription, 4355 u32* pCount, 4356 VkSurfaceFormatKHR* pSurfaceFormats) { 4357 deviceObject := GetDevice(device) 4358 4359 count := as!u32(?) 4360 pCount[0] = count 4361 surfaceFormats := pSurfaceFormats[0:count] 4362 4363 for i in (0 .. count) { 4364 surfaceFormat := ? 4365 surfaceFormats[i] = surfaceFormat 4366 } 4367 4368 return ? 4369} 4370 4371@extension("VK_EXT_KHR_device_swapchain") 4372cmd VkResult vkGetSurfacePresentModesKHR( 4373 VkDevice device, 4374 const VkSurfaceDescriptionKHR* pSurfaceDescription, 4375 u32* pCount, 4376 VkPresentModeKHR* pPresentModes) { 4377 deviceObject := GetDevice(device) 4378 4379 count := as!u32(?) 4380 pCount[0] = count 4381 presentModes := pPresentModes[0:count] 4382 4383 for i in (0 .. count) { 4384 presentMode := ? 4385 presentModes[i] = presentMode 4386 } 4387 4388 return ? 4389} 4390 4391@extension("VK_EXT_KHR_device_swapchain") 4392cmd VkResult vkCreateSwapchainKHR( 4393 VkDevice device, 4394 const VkSwapchainCreateInfoKHR* pCreateInfo, 4395 VkSwapchainKHR* pSwapchain) { 4396 //assert(pCreateInfo.sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR) 4397 deviceObject := GetDevice(device) 4398 4399 swapchain := ? 4400 pSwapchain[0] = swapchain 4401 State.Swapchains[swapchain] = new!SwapchainObject(device: device) 4402 4403 return ? 4404} 4405 4406@extension("VK_EXT_KHR_device_swapchain") 4407cmd VkResult vkDestroySwapchainKHR( 4408 VkDevice device, 4409 VkSwapchainKHR swapchain) { 4410 deviceObject := GetDevice(device) 4411 swapchainObject := GetSwapchain(swapchain) 4412 assert(swapchainObject.device == device) 4413 4414 State.Swapchains[swapchain] = null 4415 4416 return ? 4417} 4418 4419@extension("VK_EXT_KHR_device_swapchain") 4420cmd VkResult vkGetSwapchainImagesKHR( 4421 VkDevice device, 4422 VkSwapchainKHR swapchain, 4423 u32* pCount, 4424 VkImage* pSwapchainImages) { 4425 deviceObject := GetDevice(device) 4426 4427 count := as!u32(?) 4428 pCount[0] = count 4429 swapchainImages := pSwapchainImages[0:count] 4430 4431 for i in (0 .. count) { 4432 swapchainImage := ? 4433 swapchainImages[i] = swapchainImage 4434 if !(swapchainImage in State.Images) { 4435 State.Images[swapchainImage] = new!ImageObject(device: device) 4436 } 4437 } 4438 4439 return ? 4440} 4441 4442@extension("VK_EXT_KHR_device_swapchain") 4443cmd VkResult vkAcquireNextImageKHR( 4444 VkDevice device, 4445 VkSwapchainKHR swapchain, 4446 u64 timeout, 4447 VkSemaphore semaphore, 4448 u32* pImageIndex) { 4449 deviceObject := GetDevice(device) 4450 swapchainObject := GetSwapchain(swapchain) 4451 4452 imageIndex := ? 4453 pImageIndex[0] = imageIndex 4454 4455 return ? 4456} 4457 4458@extension("VK_EXT_KHR_device_swapchain") 4459cmd VkResult vkQueuePresentKHR( 4460 VkQueue queue, 4461 VkPresentInfoKHR* pPresentInfo) { 4462 queueObject := GetQueue(queue) 4463 4464 presentInfo := ? 4465 pPresentInfo[0] = presentInfo 4466 4467 return ? 4468} 4469 4470@extension("VK_EXT_KHR_swapchain") 4471cmd VkResult vkGetPhysicalDeviceSurfaceSupportKHR( 4472 VkPhysicalDevice physicalDevice, 4473 u32 queueFamilyIndex, 4474 const VkSurfaceDescriptionKHR* pSurfaceDescription, 4475 VkBool32* pSupported) { 4476 physicalDeviceObject := GetPhysicalDevice(physicalDevice) 4477 4478 supported := ? 4479 pSupported[0] = supported 4480 4481 return ? 4482} 4483 4484//////////////// 4485// Validation // 4486//////////////// 4487 4488extern void validate(string layerName, bool condition, string message) 4489 4490 4491///////////////////////////// 4492// Internal State Tracking // 4493///////////////////////////// 4494 4495StateObject State 4496 4497@internal class StateObject { 4498 // Dispatchable objects. 4499 map!(VkInstance, ref!InstanceObject) Instances 4500 map!(VkPhysicalDevice, ref!PhysicalDeviceObject) PhysicalDevices 4501 map!(VkDevice, ref!DeviceObject) Devices 4502 map!(VkQueue, ref!QueueObject) Queues 4503 map!(VkCmdBuffer, ref!CmdBufferObject) CmdBuffers 4504 4505 // Non-dispatchable objects. 4506 map!(VkDeviceMemory, ref!DeviceMemoryObject) DeviceMemories 4507 map!(VkBuffer, ref!BufferObject) Buffers 4508 map!(VkBufferView, ref!BufferViewObject) BufferViews 4509 map!(VkImage, ref!ImageObject) Images 4510 map!(VkImageView, ref!ImageViewObject) ImageViews 4511 map!(VkShaderModule, ref!ShaderModuleObject) ShaderModules 4512 map!(VkShader, ref!ShaderObject) Shaders 4513 map!(VkPipeline, ref!PipelineObject) Pipelines 4514 map!(VkPipelineLayout, ref!PipelineLayoutObject) PipelineLayouts 4515 map!(VkSampler, ref!SamplerObject) Samplers 4516 map!(VkDescriptorSet, ref!DescriptorSetObject) DescriptorSets 4517 map!(VkDescriptorSetLayout, ref!DescriptorSetLayoutObject) DescriptorSetLayouts 4518 map!(VkDescriptorPool, ref!DescriptorPoolObject) DescriptorPools 4519 map!(VkFence, ref!FenceObject) Fences 4520 map!(VkSemaphore, ref!SemaphoreObject) Semaphores 4521 map!(VkEvent, ref!EventObject) Events 4522 map!(VkQueryPool, ref!QueryPoolObject) QueryPools 4523 map!(VkFramebuffer, ref!FramebufferObject) Framebuffers 4524 map!(VkRenderPass, ref!RenderPassObject) RenderPasses 4525 map!(VkPipelineCache, ref!PipelineCacheObject) PipelineCaches 4526 map!(VkCmdPool, ref!CmdPoolObject) CmdPools 4527 map!(VkSwapchainKHR, ref!SwapchainObject) Swapchains 4528} 4529 4530@internal class InstanceObject { 4531} 4532 4533@internal class PhysicalDeviceObject { 4534 VkInstance instance 4535} 4536 4537@internal class DeviceObject { 4538 VkPhysicalDevice physicalDevice 4539} 4540 4541@internal class QueueObject { 4542 VkDevice device 4543 VkQueueFlags flags 4544} 4545 4546@internal class CmdBufferObject { 4547 VkDevice device 4548 map!(u64, VkDeviceMemory) boundObjects 4549 VkQueueFlags queueFlags 4550} 4551 4552@internal class DeviceMemoryObject { 4553 VkDevice device 4554 VkDeviceSize allocationSize 4555 map!(u64, VkDeviceSize ) boundObjects 4556 map!(VkCmdBuffer, VkCmdBuffer) boundCommandBuffers 4557} 4558 4559@internal class BufferObject { 4560 VkDevice device 4561 VkDeviceMemory mem 4562 VkDeviceSize memOffset 4563} 4564 4565@internal class BufferViewObject { 4566 VkDevice device 4567 VkBuffer buffer 4568} 4569 4570@internal class ImageObject { 4571 VkDevice device 4572 VkDeviceMemory mem 4573 VkDeviceSize memOffset 4574} 4575 4576@internal class ImageViewObject { 4577 VkDevice device 4578 VkImage image 4579} 4580 4581@internal class ShaderObject { 4582 VkDevice device 4583} 4584 4585@internal class ShaderModuleObject { 4586 VkDevice device 4587} 4588 4589@internal class PipelineObject { 4590 VkDevice device 4591} 4592 4593@internal class PipelineLayoutObject { 4594 VkDevice device 4595} 4596 4597@internal class SamplerObject { 4598 VkDevice device 4599} 4600 4601@internal class DescriptorSetObject { 4602 VkDevice device 4603} 4604 4605@internal class DescriptorSetLayoutObject { 4606 VkDevice device 4607} 4608 4609@internal class DescriptorPoolObject { 4610 VkDevice device 4611} 4612 4613@internal class FenceObject { 4614 VkDevice device 4615 bool signaled 4616} 4617 4618@internal class SemaphoreObject { 4619 VkDevice device 4620} 4621 4622@internal class EventObject { 4623 VkDevice device 4624} 4625 4626@internal class QueryPoolObject { 4627 VkDevice device 4628} 4629 4630@internal class FramebufferObject { 4631 VkDevice device 4632} 4633 4634@internal class RenderPassObject { 4635 VkDevice device 4636} 4637 4638@internal class PipelineCacheObject { 4639 VkDevice device 4640} 4641 4642@internal class CmdPoolObject { 4643 VkDevice device 4644} 4645 4646@internal class SwapchainObject { 4647 VkDevice device 4648} 4649 4650macro ref!InstanceObject GetInstance(VkInstance instance) { 4651 assert(instance in State.Instances) 4652 return State.Instances[instance] 4653} 4654 4655macro ref!PhysicalDeviceObject GetPhysicalDevice(VkPhysicalDevice physicalDevice) { 4656 assert(physicalDevice in State.PhysicalDevices) 4657 return State.PhysicalDevices[physicalDevice] 4658} 4659 4660macro ref!DeviceObject GetDevice(VkDevice device) { 4661 assert(device in State.Devices) 4662 return State.Devices[device] 4663} 4664 4665macro ref!QueueObject GetQueue(VkQueue queue) { 4666 assert(queue in State.Queues) 4667 return State.Queues[queue] 4668} 4669 4670macro ref!CmdBufferObject GetCmdBuffer(VkCmdBuffer cmdBuffer) { 4671 assert(cmdBuffer in State.CmdBuffers) 4672 return State.CmdBuffers[cmdBuffer] 4673} 4674 4675macro ref!DeviceMemoryObject GetDeviceMemory(VkDeviceMemory mem) { 4676 assert(mem in State.DeviceMemories) 4677 return State.DeviceMemories[mem] 4678} 4679 4680macro ref!BufferObject GetBuffer(VkBuffer buffer) { 4681 assert(buffer in State.Buffers) 4682 return State.Buffers[buffer] 4683} 4684 4685macro ref!BufferViewObject GetBufferView(VkBufferView bufferView) { 4686 assert(bufferView in State.BufferViews) 4687 return State.BufferViews[bufferView] 4688} 4689 4690macro ref!ImageObject GetImage(VkImage image) { 4691 assert(image in State.Images) 4692 return State.Images[image] 4693} 4694 4695macro ref!ImageViewObject GetImageView(VkImageView imageView) { 4696 assert(imageView in State.ImageViews) 4697 return State.ImageViews[imageView] 4698} 4699 4700macro ref!ShaderObject GetShader(VkShader shader) { 4701 assert(shader in State.Shaders) 4702 return State.Shaders[shader] 4703} 4704 4705macro ref!ShaderModuleObject GetShaderModule(VkShaderModule shaderModule) { 4706 assert(shaderModule in State.ShaderModules) 4707 return State.ShaderModules[shaderModule] 4708} 4709 4710macro ref!PipelineObject GetPipeline(VkPipeline pipeline) { 4711 assert(pipeline in State.Pipelines) 4712 return State.Pipelines[pipeline] 4713} 4714 4715macro ref!PipelineLayoutObject GetPipelineLayout(VkPipelineLayout pipelineLayout) { 4716 assert(pipelineLayout in State.PipelineLayouts) 4717 return State.PipelineLayouts[pipelineLayout] 4718} 4719 4720macro ref!SamplerObject GetSampler(VkSampler sampler) { 4721 assert(sampler in State.Samplers) 4722 return State.Samplers[sampler] 4723} 4724 4725macro ref!DescriptorSetObject GetDescriptorSet(VkDescriptorSet descriptorSet) { 4726 assert(descriptorSet in State.DescriptorSets) 4727 return State.DescriptorSets[descriptorSet] 4728} 4729 4730macro ref!DescriptorSetLayoutObject GetDescriptorSetLayout(VkDescriptorSetLayout descriptorSetLayout) { 4731 assert(descriptorSetLayout in State.DescriptorSetLayouts) 4732 return State.DescriptorSetLayouts[descriptorSetLayout] 4733} 4734 4735macro ref!DescriptorPoolObject GetDescriptorPool(VkDescriptorPool descriptorPool) { 4736 assert(descriptorPool in State.DescriptorPools) 4737 return State.DescriptorPools[descriptorPool] 4738} 4739 4740macro ref!FenceObject GetFence(VkFence fence) { 4741 assert(fence in State.Fences) 4742 return State.Fences[fence] 4743} 4744 4745macro ref!SemaphoreObject GetSemaphore(VkSemaphore semaphore) { 4746 assert(semaphore in State.Semaphores) 4747 return State.Semaphores[semaphore] 4748} 4749 4750macro ref!EventObject GetEvent(VkEvent event) { 4751 assert(event in State.Events) 4752 return State.Events[event] 4753} 4754 4755macro ref!QueryPoolObject GetQueryPool(VkQueryPool queryPool) { 4756 assert(queryPool in State.QueryPools) 4757 return State.QueryPools[queryPool] 4758} 4759 4760macro ref!FramebufferObject GetFramebuffer(VkFramebuffer framebuffer) { 4761 assert(framebuffer in State.Framebuffers) 4762 return State.Framebuffers[framebuffer] 4763} 4764 4765macro ref!RenderPassObject GetRenderPass(VkRenderPass renderPass) { 4766 assert(renderPass in State.RenderPasses) 4767 return State.RenderPasses[renderPass] 4768} 4769 4770macro ref!PipelineCacheObject GetPipelineCache(VkPipelineCache pipelineCache) { 4771 assert(pipelineCache in State.PipelineCaches) 4772 return State.PipelineCaches[pipelineCache] 4773} 4774 4775macro ref!CmdPoolObject GetCmdPool(VkCmdPool cmdPool) { 4776 assert(cmdPool in State.CmdPools) 4777 return State.CmdPools[cmdPool] 4778} 4779 4780macro ref!SwapchainObject GetSwapchain(VkSwapchainKHR swapchain) { 4781 assert(swapchain in State.Swapchains) 4782 return State.Swapchains[swapchain] 4783} 4784