1// Copyright 2015-2024 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[synchronization]] 6= Synchronization and Cache Control 7 8Synchronization of access to resources is primarily the responsibility of 9the application in Vulkan. 10The order of execution of commands with respect to the host and other 11commands on the device has few implicit guarantees, and needs to be 12explicitly specified. 13Memory caches and other optimizations are also explicitly managed, requiring 14that the flow of data through the system is largely under application 15control. 16 17Whilst some implicit guarantees exist between commands, five explicit 18synchronization mechanisms are exposed by Vulkan: 19 20<<synchronization-fences,Fences>>:: 21 Fences can: be used to communicate to the host that execution of some 22 task on the device has completed, controlling resource access between 23 host and device. 24 25<<synchronization-semaphores,Semaphores>>:: 26 Semaphores can: be used to control resource access across multiple 27 queues. 28 29<<synchronization-events,Events>>:: 30 Events provide a fine-grained synchronization primitive which can: be 31 signaled either within a command buffer or by the host, and can: be 32 waited upon within a command buffer or queried on the host. 33 Events can: be used to control resource access within a single queue. 34 35<<synchronization-pipeline-barriers,Pipeline Barriers>>:: 36 Pipeline barriers also provide synchronization control within a command 37 buffer, but at a single point, rather than with separate signal and wait 38 operations. 39 Pipeline barriers can: be used to control resource access within a 40 single queue. 41 42<<renderpass,Render Passes>>:: 43 Render passes provide a useful synchronization framework for most 44 rendering tasks, built upon the concepts in this chapter. 45 Many cases that would otherwise need an application to use other 46 synchronization primitives can: be expressed more efficiently as part of 47 a render pass. 48 Render pass objects can: be used to control resource access within a 49 single queue. 50 51 52[[synchronization-dependencies]] 53== Execution and Memory Dependencies 54 55An _operation_ is an arbitrary amount of work to be executed on the host, a 56device, or an external entity such as a presentation engine. 57Synchronization commands introduce explicit _execution dependencies_, and 58_memory dependencies_ between two sets of operations defined by the 59command's two _synchronization scopes_. 60 61[[synchronization-dependencies-scopes]] 62The synchronization scopes define which other operations a synchronization 63command is able to create execution dependencies with. 64Any type of operation that is not in a synchronization command's 65synchronization scopes will not be included in the resulting dependency. 66For example, for many synchronization commands, the synchronization scopes 67can: be limited to just operations executing in specific 68<<synchronization-pipeline-stages,pipeline stages>>, which allows other 69pipeline stages to be excluded from a dependency. 70Other scoping options are possible, depending on the particular command. 71 72[[synchronization-dependencies-execution]] 73An _execution dependency_ is a guarantee that for two sets of operations, 74the first set must: _happen-before_ the second set. 75If an operation happens-before another operation, then the first operation 76must: complete before the second operation is initiated. 77More precisely: 78 79 * Let *Ops~1~* and *Ops~2~* be separate sets of operations. 80 * Let *Sync* be a synchronization command. 81 * Let *Scope~1st~* and *Scope~2nd~* be the synchronization scopes of 82 *Sync*. 83 * Let *ScopedOps~1~* be the intersection of sets *Ops~1~* and 84 *Scope~1st~*. 85 * Let *ScopedOps~2~* be the intersection of sets *Ops~2~* and 86 *Scope~2nd~*. 87 * Submitting *Ops~1~*, *Sync* and *Ops~2~* for execution, in that order, 88 will result in execution dependency *ExeDep* between *ScopedOps~1~* and 89 *ScopedOps~2~*. 90 * Execution dependency *ExeDep* guarantees that *ScopedOps~1~* 91 happen-before *ScopedOps~2~*. 92 93[[synchronization-dependencies-chains]] 94An _execution dependency chain_ is a sequence of execution dependencies that 95form a happens-before relation between the first dependency's *ScopedOps~1~* 96and the final dependency's *ScopedOps~2~*. 97For each consecutive pair of execution dependencies, a chain exists if the 98intersection of *Scope~2nd~* in the first dependency and *Scope~1st~* in the 99second dependency is not an empty set. 100The formation of a single execution dependency from an execution dependency 101chain can be described by substituting the following in the description of 102execution dependencies: 103 104 * Let *Sync* be a set of synchronization commands that generate an 105 execution dependency chain. 106 * Let *Scope~1st~* be the first synchronization scope of the first command 107 in *Sync*. 108 * Let *Scope~2nd~* be the second synchronization scope of the last command 109 in *Sync*. 110 111Execution dependencies alone are not sufficient to guarantee that values 112resulting from writes in one set of operations can: be read from another set 113of operations. 114 115[[synchronization-dependencies-available-and-visible]] 116Three additional types of operations are used to control memory access. 117_Availability operations_ cause the values generated by specified memory 118write accesses to become _available_ to a memory domain for future access. 119Any available value remains available until a subsequent write to the same 120memory location occurs (whether it is made available or not) or the memory 121is freed. 122_Memory domain operations_ cause writes that are available to a source 123memory domain to become available to a destination memory domain (an example 124of this is making writes available to the host domain available to the 125device domain). 126_Visibility operations_ cause values available to a memory domain to become 127_visible_ to specified memory accesses. 128 129ifdef::VK_VERSION_1_2,VK_KHR_vulkan_memory_model[] 130Availability, visibility, memory domains, and memory domain operations are 131formally defined in the <<memory-model-availability-visibility,Availability 132and Visibility>> section of the <<memory-model,Memory Model>> chapter. 133Which API operations perform each of these operations is defined in 134<<memory-model-vulkan-availability-visibility,Availability, Visibility, and 135Domain Operations>>. 136endif::VK_VERSION_1_2,VK_KHR_vulkan_memory_model[] 137 138[[synchronization-dependencies-memory]] 139A _memory dependency_ is an execution dependency which includes availability 140and visibility operations such that: 141 142 * The first set of operations happens-before the availability operation. 143 * The availability operation happens-before the visibility operation. 144 * The visibility operation happens-before the second set of operations. 145 146Once written values are made visible to a particular type of memory access, 147they can: be read or written by that type of memory access. 148Most synchronization commands in Vulkan define a memory dependency. 149 150[[synchronization-dependencies-access-scopes]] 151The specific memory accesses that are made available and visible are defined 152by the _access scopes_ of a memory dependency. 153Any type of access that is in a memory dependency's first access scope and 154occurs in *ScopedOps~1~* is made available. 155Any type of access that is in a memory dependency's second access scope and 156occurs in *ScopedOps~2~* has any available writes made visible to it. 157Any type of operation that is not in a synchronization command's access 158scopes will not be included in the resulting dependency. 159 160A memory dependency enforces availability and visibility of memory accesses 161and execution order between two sets of operations. 162Adding to the description of <<synchronization-dependencies-chains, 163execution dependency chains>>: 164 165 * Let *MemOps~1~* be the set of memory accesses performed by 166 *ScopedOps~1~*. 167 * Let *MemOps~2~* be the set of memory accesses performed by 168 *ScopedOps~2~*. 169 * Let *AccessScope~1st~* be the first access scope of the first command in 170 the *Sync* chain. 171 * Let *AccessScope~2nd~* be the second access scope of the last command in 172 the *Sync* chain. 173 * Let *ScopedMemOps~1~* be the intersection of sets *MemOps~1~* and 174 *AccessScope~1st~*. 175 * Let *ScopedMemOps~2~* be the intersection of sets *MemOps~2~* and 176 *AccessScope~2nd~*. 177 * Submitting *Ops~1~*, *Sync*, and *Ops~2~* for execution, in that order, 178 will result in a memory dependency *MemDep* between *ScopedOps~1~* and 179 *ScopedOps~2~*. 180 * Memory dependency *MemDep* guarantees that: 181 ** Memory writes in *ScopedMemOps~1~* are made available. 182 ** Available memory writes, including those from *ScopedMemOps~1~*, are 183 made visible to *ScopedMemOps~2~*. 184 185[NOTE] 186.Note 187==== 188Execution and memory dependencies are used to solve data hazards, i.e. to 189ensure that read and write operations occur in a well-defined order. 190Write-after-read hazards can be solved with just an execution dependency, 191but read-after-write and write-after-write hazards need appropriate memory 192dependencies to be included between them. 193If an application does not include dependencies to solve these hazards, the 194results and execution orders of memory accesses are undefined:. 195==== 196 197 198[[synchronization-image-layout-transitions]] 199=== Image Layout Transitions 200 201Image subresources can: be transitioned from one <<resources-image-layouts, 202layout>> to another as part of a <<synchronization-dependencies-memory, 203memory dependency>> (e.g. by using an 204<<synchronization-image-memory-barriers,image memory barrier>>). 205When a layout transition is specified in a memory dependency, it 206happens-after the availability operations in the memory dependency, and 207happens-before the visibility operations. 208Image layout transitions may: perform read and write accesses on all memory 209bound to the image subresource range, so applications must: ensure that all 210memory writes have been made 211<<synchronization-dependencies-available-and-visible, available>> before a 212layout transition is executed. 213Available memory is automatically made visible to a layout transition, and 214writes performed by a layout transition are automatically made available. 215 216Layout transitions always apply to a particular image subresource range, and 217specify both an old layout and new layout. 218The old layout must: either be ename:VK_IMAGE_LAYOUT_UNDEFINED, or match the 219current layout of the image subresource range. 220If the old layout matches the current layout of the image subresource range, 221the transition preserves the contents of that range. 222If the old layout is ename:VK_IMAGE_LAYOUT_UNDEFINED, the contents of that 223range may: be discarded. 224 225[NOTE] 226.Note 227==== 228Image layout transitions with ename:VK_IMAGE_LAYOUT_UNDEFINED allow the 229implementation to discard the image subresource range, which can provide 230performance or power benefits. 231Tile-based architectures may be able to avoid flushing tile data to memory, 232and immediate style renderers may be able to achieve fast metadata clears to 233reinitialize frame buffer compression state, or similar. 234 235If the contents of an attachment are not needed after a render pass 236completes, then applications should: use 237ename:VK_ATTACHMENT_STORE_OP_DONT_CARE. 238==== 239 240ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 241As image layout transitions may: perform read and write accesses on the 242memory bound to the image, if the image subresource affected by the layout 243transition is bound to peer memory for any device in the current device mask 244then the memory heap the bound memory comes from must: support the 245ename:VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT and 246ename:VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT capabilities as returned by 247flink:vkGetDeviceGroupPeerMemoryFeatures. 248endif::VK_VERSION_1_1,VK_KHR_device_group[] 249 250[NOTE] 251.Note 252==== 253Applications must: ensure that layout transitions happen-after all 254operations accessing the image with the old layout, and happen-before any 255operations that will access the image with the new layout. 256Layout transitions are potentially read/write operations, so not defining 257appropriate memory dependencies to guarantee this will result in a data 258race. 259==== 260 261Image layout transitions interact with <<resources-memory-aliasing,memory 262aliasing>>. 263 264 265[[synchronization-image-barrier-layout-transition-order]] 266Layout transitions that are performed via image memory barriers execute in 267their entirety in <<synchronization-submission-order, submission order>>, 268relative to other image layout transitions submitted to the same queue, 269including those performed by <<renderpass, render passes>>. 270In effect there is an implicit execution dependency from each such layout 271transition to all layout transitions previously submitted to the same queue. 272 273ifdef::VK_EXT_sample_locations[] 274 275The image layout of each image subresource of a depth/stencil image created 276with ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT is 277dependent on the last sample locations used to render to the image 278subresource as a depth/stencil attachment, thus when the pname:image member 279of an <<synchronization-image-memory-barriers, image memory barrier>> is an 280image created with this flag the application can: chain a 281slink:VkSampleLocationsInfoEXT structure to the pname:pNext chain of 282ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 283slink:VkImageMemoryBarrier2 or 284endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 285slink:VkImageMemoryBarrier to specify the sample locations to use during any 286image layout transition. 287 288If the sname:VkSampleLocationsInfoEXT structure does not match the sample 289location state last used to render to the image subresource range specified 290by pname:subresourceRange, or if no sname:VkSampleLocationsInfoEXT structure 291is present, then the contents of the given image subresource range becomes 292undefined: as if pname:oldLayout would equal 293ename:VK_IMAGE_LAYOUT_UNDEFINED. 294 295endif::VK_EXT_sample_locations[] 296 297 298[[synchronization-pipeline-stages]] 299=== Pipeline Stages 300 301The work performed by an <<fundamentals-queueoperation-command-types, action 302command>> consists of multiple operations, which are performed as a sequence 303of logically independent steps known as _pipeline stages_. 304The exact pipeline stages executed depend on the particular command that is 305used, and current command buffer state when the command was recorded. 306 307[NOTE] 308.Note 309==== 310Operations performed by synchronization commands (e.g. 311<<synchronization-dependencies-available-and-visible, availability and 312visibility operations>>) are not executed by a defined pipeline stage. 313However other commands can still synchronize with them by using the 314<<synchronization-dependencies-scopes, synchronization scopes>> to create a 315<<synchronization-dependencies-chains, dependency chain>>. 316==== 317 318Execution of operations across pipeline stages must: adhere to 319<<synchronization-implicit, implicit ordering guarantees>>, particularly 320including <<synchronization-pipeline-stages-order, pipeline stage order>>. 321Otherwise, execution across pipeline stages may: overlap or execute out of 322order with regards to other stages, unless otherwise enforced by an 323execution dependency. 324 325Several of the synchronization commands include pipeline stage parameters, 326restricting the <<synchronization-dependencies-scopes, synchronization 327scopes>> for that command to just those stages. 328This allows fine grained control over the exact execution dependencies and 329accesses performed by action commands. 330Implementations should: use these pipeline stages to avoid unnecessary 331stalls or cache flushing. 332 333ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 334[open,refpage='VkPipelineStageFlagBits2',desc='Pipeline stage flags for VkPipelineStageFlags2',type='enums',alias='VkPipelineStageFlagBits2KHR'] 335-- 336Bits which can: be set in a tlink:VkPipelineStageFlags2 mask, specifying 337stages of execution, are: 338 339ifdef::editing-notes[] 340[NOTE] 341.editing-note 342==== 343The many places pipeline stage flags are used are not currently listed here. 344==== 345endif::editing-notes[] 346 347include::{generated}/api/enums/VkPipelineStageFlagBits2.adoc[] 348 349ifdef::VK_KHR_synchronization2[] 350or the equivalent 351 352include::{generated}/api/enums/VkPipelineStageFlagBits2KHR.adoc[] 353endif::VK_KHR_synchronization2[] 354 355 * ename:VK_PIPELINE_STAGE_2_NONE specifies no stages of execution. 356 * ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT specifies the stage of the 357 pipeline where indirect command parameters are consumed. 358ifdef::VK_NV_device_generated_commands[] 359 This stage also includes reading commands written by 360 flink:vkCmdPreprocessGeneratedCommandsNV. 361endif::VK_NV_device_generated_commands[] 362ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 363 * ename:VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_EXT specifies the task shader 364 stage. 365 * ename:VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_EXT specifies the mesh shader 366 stage. 367endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 368 * ename:VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT specifies the stage of the 369 pipeline where index buffers are consumed. 370 * ename:VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT specifies the stage 371 of the pipeline where vertex buffers are consumed. 372 * ename:VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT is equivalent to the logical 373 OR of: 374include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT.adoc[] 375 * ename:VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT specifies the vertex shader 376 stage. 377 * ename:VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT specifies the 378 tessellation control shader stage. 379 * ename:VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT specifies 380 the tessellation evaluation shader stage. 381 * ename:VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT specifies the geometry 382 shader stage. 383 * ename:VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT is equivalent to 384 specifying all supported 385 <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 386 stages>>: 387include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT.adoc[] 388 * ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT specifies the fragment 389 shader stage. 390 * ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT specifies the stage 391 of the pipeline where early fragment tests (depth and stencil tests 392 before fragment shading) are performed. 393 This stage also includes <<renderpass-load-operations, render pass load 394 operations>> for framebuffer attachments with a depth/stencil format. 395 * ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT specifies the stage of 396 the pipeline where late fragment tests (depth and stencil tests after 397 fragment shading) are performed. 398 This stage also includes <<renderpass-store-operations, render pass 399 store operations>> for framebuffer attachments with a depth/stencil 400 format. 401 * ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT specifies the 402 stage of the pipeline where final color values are output from the 403 pipeline. 404 This stage includes <<framebuffer-blending, blending>>, 405 <<framebuffer-logicop, logic operations>>, render pass 406 <<renderpass-load-operations, load>> and <<renderpass-store-operations, 407 store>> operations for color attachments, 408 <<renderpass-resolve-operations, render pass multisample resolve 409 operations>>, and flink:vkCmdClearAttachments. 410 * ename:VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT specifies the compute 411 shader stage. 412 * ename:VK_PIPELINE_STAGE_2_HOST_BIT specifies a pseudo-stage indicating 413 execution on the host of reads/writes of device memory. 414 This stage is not invoked by any commands recorded in a command buffer. 415 * ename:VK_PIPELINE_STAGE_2_COPY_BIT specifies the execution of all 416 <<copies,copy commands>>, including flink:vkCmdCopyQueryPoolResults. 417 * ename:VK_PIPELINE_STAGE_2_BLIT_BIT specifies the execution of 418 flink:vkCmdBlitImage. 419 * ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT specifies the execution of 420 flink:vkCmdResolveImage. 421 * ename:VK_PIPELINE_STAGE_2_CLEAR_BIT specifies the execution of 422 <<clears,clear commands>>, with the exception of 423 flink:vkCmdClearAttachments. 424 * ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT is equivalent to specifying 425 all of: 426include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT.adoc[] 427ifdef::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[] 428 * ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR specifies the 429 execution of the ray tracing shader stages. 430endif::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[] 431ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 432 * ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR specifies 433 the execution of <<acceleration-structure, acceleration structure 434 commands>> or <<acceleration-structure-copying, acceleration structure 435 copy commands>>. 436ifdef::VK_KHR_ray_tracing_maintenance1[] 437 * ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR specifies 438 the execution of <<acceleration-structure-copying, acceleration 439 structure copy commands>>. 440endif::VK_KHR_ray_tracing_maintenance1[] 441endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 442 * ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT specifies the execution of 443 all graphics pipeline stages, and is equivalent to the logical OR of: 444include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT.adoc[] 445 * ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT specifies all operations 446 performed by all commands supported on the queue it is used with. 447ifdef::VK_EXT_conditional_rendering[] 448 * ename:VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT specifies the 449 stage of the pipeline where the predicate of conditional rendering is 450 consumed. 451endif::VK_EXT_conditional_rendering[] 452ifdef::VK_EXT_transform_feedback[] 453 * ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT specifies the stage 454 of the pipeline where vertex attribute output values are written to the 455 transform feedback buffers. 456endif::VK_EXT_transform_feedback[] 457ifdef::VK_NV_device_generated_commands[] 458 * ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV specifies the stage 459 of the pipeline where device-side generation of commands via 460 flink:vkCmdPreprocessGeneratedCommandsNV is handled. 461endif::VK_NV_device_generated_commands[] 462ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 463 * ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR 464 specifies the stage of the pipeline where the 465ifdef::VK_KHR_fragment_shading_rate[] 466 <<primsrast-fragment-shading-rate-attachment, fragment shading rate 467 attachment>> 468endif::VK_KHR_fragment_shading_rate[] 469ifdef::VK_KHR_fragment_shading_rate+VK_NV_shading_rate_image[or] 470ifdef::VK_NV_shading_rate_image[] 471 <<primsrast-shading-rate-image, shading rate image>> 472endif::VK_NV_shading_rate_image[] 473 is read to determine the fragment shading rate for portions of a 474 rasterized primitive. 475endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 476ifdef::VK_EXT_fragment_density_map[] 477 * ename:VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT specifies the 478 stage of the pipeline where the fragment density map is read to 479 <<fragmentdensitymapops,generate the fragment areas>>. 480endif::VK_EXT_fragment_density_map[] 481ifdef::VK_HUAWEI_invocation_mask[] 482 * ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI specifies the stage 483 of the pipeline where the invocation mask image is read by the 484 implementation to optimize the ray dispatch. 485endif::VK_HUAWEI_invocation_mask[] 486ifdef::VK_KHR_video_decode_queue[] 487 * ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR specifies the execution 488 of <<video-decode-operations, video decode operations>>. 489endif::VK_KHR_video_decode_queue[] 490ifdef::VK_KHR_video_encode_queue[] 491 * ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR specifies the execution 492 of <<video-encode-operations, video encode operations>>. 493endif::VK_KHR_video_encode_queue[] 494ifdef::VK_NV_optical_flow[] 495 * ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV specifies the stage of the 496 pipeline where <<opticalflow-operations, optical flow operation>> are 497 performed. 498endif::VK_NV_optical_flow[] 499ifdef::VK_HUAWEI_subpass_shading[] 500 * ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI specifies the 501 subpass shading shader stage. 502endif::VK_HUAWEI_subpass_shading[] 503ifdef::VK_EXT_opacity_micromap[] 504 * ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT specifies the execution 505 of <<micromap, micromap commands>>. 506endif::VK_EXT_opacity_micromap[] 507ifdef::VK_HUAWEI_cluster_culling_shader[] 508 * ename:VK_PIPELINE_STAGE_2_CLUSTER_CULLING_SHADER_BIT_HUAWEI specifies 509 the cluster culling shader stage. 510endif::VK_HUAWEI_cluster_culling_shader[] 511 * ename:VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT is equivalent to 512 ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT with tlink:VkAccessFlags2 set 513 to `0` when specified in the second synchronization scope, but 514 equivalent to ename:VK_PIPELINE_STAGE_2_NONE in the first scope. 515 * ename:VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT is equivalent to 516 ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT with tlink:VkAccessFlags2 set 517 to `0` when specified in the first synchronization scope, but equivalent 518 to ename:VK_PIPELINE_STAGE_2_NONE in the second scope. 519 520[NOTE] 521.Note 522==== 523The etext:TOP and etext:BOTTOM pipeline stages are deprecated, and 524applications should prefer ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT and 525ename:VK_PIPELINE_STAGE_2_NONE. 526==== 527 528[NOTE] 529.Note 530==== 531The tname:VkPipelineStageFlags2 bitmask goes beyond the 31 individual bit 532flags allowable within a C99 enum, which is how 533elink:VkPipelineStageFlagBits is defined. 534The first 31 values are common to both, and are interchangeable. 535==== 536-- 537 538[open,refpage='VkPipelineStageFlags2',desc='64-bit mask of pipeline stage flags',type='flags',alias='VkPipelineStageFlags2KHR'] 539-- 540tname:VkPipelineStageFlags2 is a bitmask type for setting a mask of zero or 541more elink:VkPipelineStageFlagBits2 flags: 542 543include::{generated}/api/flags/VkPipelineStageFlags2.adoc[] 544 545ifdef::VK_KHR_synchronization2[] 546or the equivalent 547 548include::{generated}/api/flags/VkPipelineStageFlags2KHR.adoc[] 549endif::VK_KHR_synchronization2[] 550-- 551endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 552 553[open,refpage='VkPipelineStageFlagBits',desc='Bitmask specifying pipeline stages',type='enums'] 554-- 555Bits which can: be set in a tlink:VkPipelineStageFlags mask, specifying 556stages of execution, are: 557 558include::{generated}/api/enums/VkPipelineStageFlagBits.adoc[] 559 560ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 561These values all have the same meaning as the equivalently named values for 562tlink:VkPipelineStageFlags2. 563endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 564 565ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 566 * ename:VK_PIPELINE_STAGE_NONE specifies no stages of execution. 567endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 568 * ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT specifies the stage of the 569 pipeline where stext:VkDrawIndirect* / stext:VkDispatchIndirect* / 570 stext:VkTraceRaysIndirect* data structures are consumed. 571ifdef::VK_NV_device_generated_commands[] 572 This stage also includes reading commands written by 573 flink:vkCmdExecuteGeneratedCommandsNV. 574endif::VK_NV_device_generated_commands[] 575ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 576 * ename:VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT specifies the task shader 577 stage. 578 * ename:VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT specifies the mesh shader 579 stage. 580endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 581 * ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT specifies the stage of the 582 pipeline where vertex and index buffers are consumed. 583 * ename:VK_PIPELINE_STAGE_VERTEX_SHADER_BIT specifies the vertex shader 584 stage. 585 * ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT specifies the 586 tessellation control shader stage. 587 * ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT specifies the 588 tessellation evaluation shader stage. 589 * ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT specifies the geometry 590 shader stage. 591 * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT specifies the fragment 592 shader stage. 593 * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT specifies the stage of 594 the pipeline where early fragment tests (depth and stencil tests before 595 fragment shading) are performed. 596 This stage also includes <<renderpass-load-operations, render pass load 597 operations>> for framebuffer attachments with a depth/stencil format. 598 * ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT specifies the stage of 599 the pipeline where late fragment tests (depth and stencil tests after 600 fragment shading) are performed. 601 This stage also includes <<renderpass-store-operations, render pass 602 store operations>> for framebuffer attachments with a depth/stencil 603 format. 604 * ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT specifies the stage 605 of the pipeline after blending where the final color values are output 606 from the pipeline. 607 This stage includes <<framebuffer-blending, blending>>, 608 <<framebuffer-logicop, logic operations>>, render pass 609 <<renderpass-load-operations, load>> and <<renderpass-store-operations, 610 store>> operations for color attachments, 611 <<renderpass-resolve-operations, render pass multisample resolve 612 operations>>, and flink:vkCmdClearAttachments. 613 * ename:VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT specifies the execution of a 614 compute shader. 615 * [[synchronization-pipeline-stages-transfer]] 616 ename:VK_PIPELINE_STAGE_TRANSFER_BIT specifies the following commands: 617 ** All <<copies,copy commands>>, including flink:vkCmdCopyQueryPoolResults 618ifndef::VK_VERSION_1_3,VK_KHR_copy_commands2[] 619 ** flink:vkCmdBlitImage 620 ** flink:vkCmdResolveImage 621endif::VK_VERSION_1_3,VK_KHR_copy_commands2[] 622ifdef::VK_VERSION_1_3,VK_KHR_copy_commands2[] 623 ** flink:vkCmdBlitImage2 and flink:vkCmdBlitImage 624 ** flink:vkCmdResolveImage2 and flink:vkCmdResolveImage 625endif::VK_VERSION_1_3,VK_KHR_copy_commands2[] 626 ** All <<clears,clear commands>>, with the exception of 627 flink:vkCmdClearAttachments 628 * ename:VK_PIPELINE_STAGE_HOST_BIT specifies a pseudo-stage indicating 629 execution on the host of reads/writes of device memory. 630 This stage is not invoked by any commands recorded in a command buffer. 631ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 632 * ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR specifies 633 the execution of 634ifdef::VK_NV_ray_tracing[] 635 flink:vkCmdBuildAccelerationStructureNV, 636 flink:vkCmdCopyAccelerationStructureNV, 637 flink:vkCmdWriteAccelerationStructuresPropertiesNV 638endif::VK_NV_ray_tracing[] 639ifdef::VK_NV_ray_tracing+VK_KHR_acceleration_structure[,] 640ifdef::VK_KHR_acceleration_structure[] 641 flink:vkCmdBuildAccelerationStructuresKHR, 642 flink:vkCmdBuildAccelerationStructuresIndirectKHR, 643 flink:vkCmdCopyAccelerationStructureKHR, 644 flink:vkCmdCopyAccelerationStructureToMemoryKHR, 645 flink:vkCmdCopyMemoryToAccelerationStructureKHR, and 646 flink:vkCmdWriteAccelerationStructuresPropertiesKHR. 647endif::VK_KHR_acceleration_structure[] 648endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 649ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 650 * ename:VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR specifies the 651 execution of the ray tracing shader stages, via 652ifdef::VK_NV_ray_tracing[flink:vkCmdTraceRaysNV] 653ifdef::VK_NV_ray_tracing+VK_KHR_ray_tracing_pipeline[,] 654ifdef::VK_KHR_ray_tracing_pipeline[flink:vkCmdTraceRaysKHR, or flink:vkCmdTraceRaysIndirectKHR] 655endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 656 * ename:VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT specifies the execution of all 657 graphics pipeline stages, and is equivalent to the logical OR of: 658 ** ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT 659ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 660 ** ename:VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT 661 ** ename:VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT 662endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 663 ** ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT 664 ** ename:VK_PIPELINE_STAGE_VERTEX_SHADER_BIT 665 ** ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT 666 ** ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT 667 ** ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT 668 ** ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT 669 ** ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT 670 ** ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT 671 ** ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 672ifdef::VK_EXT_conditional_rendering[] 673 ** ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT 674endif::VK_EXT_conditional_rendering[] 675ifdef::VK_EXT_transform_feedback[] 676 ** ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT 677endif::VK_EXT_transform_feedback[] 678ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 679 ** ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR 680endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 681ifdef::VK_EXT_fragment_density_map[] 682 ** ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT 683endif::VK_EXT_fragment_density_map[] 684 * ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT specifies all operations 685 performed by all commands supported on the queue it is used with. 686ifdef::VK_EXT_conditional_rendering[] 687 * ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT specifies the 688 stage of the pipeline where the predicate of conditional rendering is 689 consumed. 690endif::VK_EXT_conditional_rendering[] 691ifdef::VK_EXT_transform_feedback[] 692 * ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT specifies the stage 693 of the pipeline where vertex attribute output values are written to the 694 transform feedback buffers. 695endif::VK_EXT_transform_feedback[] 696ifdef::VK_NV_device_generated_commands[] 697 * ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV specifies the stage of 698 the pipeline where device-side preprocessing for generated commands via 699 flink:vkCmdPreprocessGeneratedCommandsNV is handled. 700endif::VK_NV_device_generated_commands[] 701ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 702 * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR 703 specifies the stage of the pipeline where the 704ifdef::VK_KHR_fragment_shading_rate[] 705 <<primsrast-fragment-shading-rate-attachment, fragment shading rate 706 attachment>> 707endif::VK_KHR_fragment_shading_rate[] 708ifdef::VK_KHR_fragment_shading_rate+VK_NV_shading_rate_image[or] 709ifdef::VK_NV_shading_rate_image[] 710 <<primsrast-shading-rate-image, shading rate image>> 711endif::VK_NV_shading_rate_image[] 712 is read to determine the fragment shading rate for portions of a 713 rasterized primitive. 714endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] 715ifdef::VK_EXT_fragment_density_map[] 716 * ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT specifies the 717 stage of the pipeline where the fragment density map is read to 718 <<fragmentdensitymapops,generate the fragment areas>>. 719endif::VK_EXT_fragment_density_map[] 720 * ename:VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT is equivalent to 721 ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT with tlink:VkAccessFlags set to 722 `0` when specified in the second synchronization scope, but specifies no 723 stage of execution when specified in the first scope. 724 * ename:VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT is equivalent to 725 ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT with tlink:VkAccessFlags set to 726 `0` when specified in the first synchronization scope, but specifies no 727 stage of execution when specified in the second scope. 728-- 729 730[open,refpage='VkPipelineStageFlags',desc='Bitmask of VkPipelineStageFlagBits',type='flags'] 731-- 732include::{generated}/api/flags/VkPipelineStageFlags.adoc[] 733 734tname:VkPipelineStageFlags is a bitmask type for setting a mask of zero or 735more elink:VkPipelineStageFlagBits. 736-- 737 738[[synchronization-pipeline-stages-masks]] 739If a synchronization command includes a source stage mask, its first 740<<synchronization-dependencies-scopes, synchronization scope>> only includes 741execution of the pipeline stages specified in that mask and any 742<<synchronization-pipeline-stages-order, logically earlier>> stages. 743Its first <<synchronization-dependencies-access-scopes, access scope>> only 744includes memory accesses performed by pipeline stages explicitly specified 745in the source stage mask. 746 747If a synchronization command includes a destination stage mask, its second 748<<synchronization-dependencies-scopes, synchronization scope>> only includes 749execution of the pipeline stages specified in that mask and any 750<<synchronization-pipeline-stages-order, logically later>> stages. 751Its second <<synchronization-dependencies-access-scopes, access scope>> only 752includes memory accesses performed by pipeline stages explicitly specified 753in the destination stage mask. 754 755[NOTE] 756.Note 757==== 758Note that <<synchronization-dependencies-access-scopes, access scopes>> do 759not interact with the logically earlier or later stages for either scope - 760only the stages the app specifies are considered part of each access scope. 761==== 762 763Certain pipeline stages are only available on queues that support a 764particular set of operations. 765The following table lists, for each pipeline stage flag, which queue 766capability flag must: be supported by the queue. 767When multiple flags are enumerated in the second column of the table, it 768means that the pipeline stage is supported on the queue if it supports any 769of the listed capability flags. 770For further details on queue capabilities see 771<<devsandqueues-physical-device-enumeration,Physical Device Enumeration>> 772and <<devsandqueues-queues,Queues>>. 773 774[[synchronization-pipeline-stages-supported]] 775.Supported pipeline stage flags 776[cols="70%,30%",options="header"] 777|==== 778|Pipeline stage flag | Required queue capability flag 779include::{generated}/sync/supportedPipelineStages.adoc[] 780|==== 781 782[[synchronization-pipeline-stages-order]] 783Pipeline stages that execute as a result of a command logically complete 784execution in a specific order, such that completion of a logically later 785pipeline stage must: not happen-before completion of a logically earlier 786stage. 787This means that including any stage in the source stage mask for a 788particular synchronization command also implies that any logically earlier 789stages are included in *Scope~1st~* for that command. 790 791Similarly, initiation of a logically earlier pipeline stage must: not 792happen-after initiation of a logically later pipeline stage. 793Including any given stage in the destination stage mask for a particular 794synchronization command also implies that any logically later stages are 795included in *Scope~2nd~* for that command. 796 797[NOTE] 798.Note 799==== 800Implementations may: not support synchronization at every pipeline stage for 801every synchronization operation. 802If a pipeline stage that an implementation does not support synchronization 803for appears in a source stage mask, it may: substitute any logically later 804stage in its place for the first synchronization scope. 805If a pipeline stage that an implementation does not support synchronization 806for appears in a destination stage mask, it may: substitute any logically 807earlier stage in its place for the second synchronization scope. 808 809For example, if an implementation is unable to signal an event immediately 810after vertex shader execution is complete, it may: instead signal the event 811after color attachment output has completed. 812 813If an implementation makes such a substitution, it must: not affect the 814semantics of execution or memory dependencies or image and buffer memory 815barriers. 816==== 817 818[[synchronization-pipeline-stages-types]][[synchronization-pipeline-graphics]] 819<<pipelines-graphics, Graphics pipelines>> are executable on queues 820supporting ename:VK_QUEUE_GRAPHICS_BIT. 821Stages executed by graphics pipelines can: only be specified in commands 822recorded for queues supporting ename:VK_QUEUE_GRAPHICS_BIT. 823 824The graphics 825ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 826primitive 827endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 828pipeline executes the following stages, with the logical ordering of the 829stages matching the order specified here: 830 831include::{generated}/sync/pipelineOrders/graphics_primitive.adoc[] 832 833ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 834The graphics mesh pipeline executes the following stages, with the logical 835ordering of the stages matching the order specified here: 836 837include::{generated}/sync/pipelineOrders/graphics_mesh.adoc[] 838endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 839 840For the compute pipeline, the following stages occur in this order: 841 842include::{generated}/sync/pipelineOrders/compute.adoc[] 843 844ifdef::VK_HUAWEI_subpass_shading[] 845For the subpass shading pipeline, the following stages occur in this order: 846 847include::{generated}/sync/pipelineOrders/subpass_shading.adoc[] 848endif::VK_HUAWEI_subpass_shading[] 849 850ifdef::VK_EXT_fragment_density_map[] 851For graphics pipeline commands executing in a render pass with a fragment 852density map attachment, the following pipeline stage where the fragment 853density map read happens has no particular order relative to the other 854stages, except that it is logically earlier than 855ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT: 856 857 * ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT 858 * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT 859endif::VK_EXT_fragment_density_map[] 860 861ifdef::VK_EXT_conditional_rendering[] 862The conditional rendering stage is formally part of both the graphics, and 863the compute pipeline. 864The pipeline stage where the predicate read happens has unspecified order 865relative to other stages of these pipelines: 866 867 * ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT 868endif::VK_EXT_conditional_rendering[] 869 870For the transfer pipeline, the following stages occur in this order: 871 872include::{generated}/sync/pipelineOrders/transfer.adoc[] 873 874For host operations, only one pipeline stage occurs, so no order is 875guaranteed: 876 877include::{generated}/sync/pipelineOrders/host.adoc[] 878 879ifdef::VK_NV_device_generated_commands[] 880For the command preprocessing pipeline, the following stages occur in this 881order: 882 883include::{generated}/sync/pipelineOrders/command_preprocessing.adoc[] 884endif::VK_NV_device_generated_commands[] 885 886ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 887For acceleration structure build operations, only one pipeline stage occurs, 888so no order is guaranteed: 889 890include::{generated}/sync/pipelineOrders/acceleration_structure_build.adoc[] 891 892For acceleration structure copy operations, only one pipeline stage occurs, 893so no order is guaranteed: 894 895include::{generated}/sync/pipelineOrders/acceleration_structure_copy.adoc[] 896endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 897 898ifdef::VK_EXT_opacity_micromap[] 899For opacity micromap build operations, only one pipeline stage occurs, so no 900order is guaranteed: 901 902include::{generated}/sync/pipelineOrders/opacity_micromap.adoc[] 903endif::VK_EXT_opacity_micromap[] 904 905ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 906For the ray tracing pipeline, the following stages occur in this order: 907 908include::{generated}/sync/pipelineOrders/ray_tracing.adoc[] 909endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 910 911ifdef::VK_KHR_video_decode_queue[] 912For the video decode pipeline, the following stages occur in this order: 913 914include::{generated}/sync/pipelineOrders/video_decode.adoc[] 915endif::VK_KHR_video_decode_queue[] 916 917ifdef::VK_KHR_video_encode_queue[] 918For the video encode pipeline, the following stages occur in this order: 919 920include::{generated}/sync/pipelineOrders/video_encode.adoc[] 921endif::VK_KHR_video_encode_queue[] 922 923[[synchronization-access-types]] 924=== Access Types 925 926Memory in Vulkan can: be accessed from within shader invocations and via 927some fixed-function stages of the pipeline. 928The _access type_ is a function of the <<descriptorsets, descriptor type>> 929used, or how a fixed-function stage accesses memory. 930 931[[synchronization-access-masks]] 932Some synchronization commands take sets of access types as parameters to 933define the <<synchronization-dependencies-access-scopes, access scopes>> of 934a memory dependency. 935If a synchronization command includes a _source access mask_, its first 936<<synchronization-dependencies-access-scopes, access scope>> only includes 937accesses via the access types specified in that mask. 938Similarly, if a synchronization command includes a _destination access 939mask_, its second <<synchronization-dependencies-access-scopes, access 940scope>> only includes accesses via the access types specified in that mask. 941 942ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 943[open,refpage='VkAccessFlagBits2',desc='Access flags for VkAccessFlags2',type='enums',alias='VkAccessFlagBits2KHR'] 944-- 945Bits which can: be set in the pname:srcAccessMask and pname:dstAccessMask 946members of slink:VkMemoryBarrier2KHR, slink:VkImageMemoryBarrier2KHR, and 947slink:VkBufferMemoryBarrier2KHR, specifying access behavior, are: 948 949include::{generated}/api/enums/VkAccessFlagBits2.adoc[] 950 951ifdef::VK_KHR_synchronization2[] 952or the equivalent 953 954include::{generated}/api/enums/VkAccessFlagBits2KHR.adoc[] 955endif::VK_KHR_synchronization2[] 956 957 * ename:VK_ACCESS_2_NONE specifies no accesses. 958 * ename:VK_ACCESS_2_MEMORY_READ_BIT specifies all read accesses. 959 It is always valid in any access mask, and is treated as equivalent to 960 setting all etext:READ access flags that are valid where it is used. 961 * ename:VK_ACCESS_2_MEMORY_WRITE_BIT specifies all write accesses. 962 It is always valid in any access mask, and is treated as equivalent to 963 setting all etext:WRITE access flags that are valid where it is used. 964 * ename:VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT specifies read access to 965 command data read from indirect buffers as part of an indirect 966ifdef::VK_KHR_acceleration_structure[build,] 967ifdef::VK_KHR_ray_tracing_pipeline[trace,] 968 drawing or dispatch command. 969 Such access occurs in the ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT 970 pipeline stage. 971 * ename:VK_ACCESS_2_INDEX_READ_BIT specifies read access to an index 972 buffer as part of an indexed drawing command, bound by 973ifdef::VK_KHR_maintenance5[flink:vkCmdBindIndexBuffer2KHR and] 974 flink:vkCmdBindIndexBuffer. 975 Such access occurs in the ename:VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT 976 pipeline stage. 977 * ename:VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT specifies read access to a 978 vertex buffer as part of a drawing command, bound by 979 flink:vkCmdBindVertexBuffers. 980 Such access occurs in the 981 ename:VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT pipeline stage. 982 * ename:VK_ACCESS_2_UNIFORM_READ_BIT specifies read access to a 983 <<descriptorsets-uniformbuffer, uniform buffer>> in any shader pipeline 984 stage. 985 * ename:VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT specifies read access to an 986 <<renderpass, input attachment>> within a render pass during 987ifdef::VK_HUAWEI_subpass_shading[] 988 subpass shading or 989endif::VK_HUAWEI_subpass_shading[] 990 fragment shading. 991 Such access occurs in the 992ifdef::VK_HUAWEI_subpass_shading[] 993 ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI or 994endif::VK_HUAWEI_subpass_shading[] 995 ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. 996 * ename:VK_ACCESS_2_SHADER_SAMPLED_READ_BIT specifies read access to a 997 <<descriptorsets-uniformtexelbuffer, uniform texel buffer>> or 998 <<descriptorsets-sampledimage, sampled image>> in any shader pipeline 999 stage. 1000 * ename:VK_ACCESS_2_SHADER_STORAGE_READ_BIT specifies read access to a 1001 <<descriptorsets-storagebuffer, storage buffer>>, 1002ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] 1003 <<descriptorsets-physical-storage-buffer, physical storage buffer>>, 1004endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] 1005 <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or 1006 <<descriptorsets-storageimage, storage image>> in any shader pipeline 1007 stage. 1008ifdef::VK_KHR_ray_tracing_maintenance1+VK_KHR_ray_tracing_pipeline[] 1009 * ename:VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR specifies read 1010 access to a <<shader-binding-table, shader binding table>> in any shader 1011 pipeline stage. 1012endif::VK_KHR_ray_tracing_maintenance1+VK_KHR_ray_tracing_pipeline[] 1013 * ename:VK_ACCESS_2_SHADER_READ_BIT 1014ifndef::VK_KHR_ray_tracing_maintenance1[] 1015ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 1016 specifies read access to a <<shader-binding-table, shader binding 1017 table>> in any shader pipeline. 1018 In addition, it 1019endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 1020endif::VK_KHR_ray_tracing_maintenance1[] 1021 is equivalent to the logical OR of: 1022include::{generated}/sync/flagDefinitions/VK_ACCESS_2_SHADER_READ_BIT.adoc[] 1023 * ename:VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT specifies write access to a 1024 <<descriptorsets-storagebuffer, storage buffer>>, 1025ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] 1026 <<descriptorsets-physical-storage-buffer, physical storage buffer>>, 1027endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] 1028 <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or 1029 <<descriptorsets-storageimage, storage image>> in any shader pipeline 1030 stage. 1031 * ename:VK_ACCESS_2_SHADER_WRITE_BIT is equivalent to 1032 ename:VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT. 1033 * ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT specifies read access to a 1034 <<renderpass, color attachment>>, such as via 1035ifndef::VK_EXT_blend_operation_advanced[<<framebuffer-blending, blending>>,] 1036ifdef::VK_EXT_blend_operation_advanced[] 1037 <<framebuffer-blending, blending>> (other than 1038 <<framebuffer-blend-advanced, advanced blend operations>>), 1039endif::VK_EXT_blend_operation_advanced[] 1040 <<framebuffer-logicop, logic operations>> or certain 1041ifndef::VK_EXT_shader_tile_image[] 1042 <<renderpass-load-operations, render pass load operations>>. 1043 Such access occurs in the 1044 ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1045endif::VK_EXT_shader_tile_image[] 1046ifdef::VK_EXT_shader_tile_image[] 1047 <<renderpass-load-operations, render pass load operations>> in the 1048 ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage or 1049 via <<fragops-shader-tileimage-reads, fragment shader tile image reads>> 1050 in the ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. 1051endif::VK_EXT_shader_tile_image[] 1052 * ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT specifies write access to a 1053 <<renderpass, color attachment>> during a <<renderpass, render pass>> or 1054 via certain render pass <<renderpass-load-operations, load>>, 1055 <<renderpass-store-operations, store>>, and 1056 <<renderpass-resolve-operations, multisample resolve>> operations. 1057 Such access occurs in the 1058 ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1059 * ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT specifies read 1060 access to a <<renderpass, depth/stencil attachment>>, via 1061 <<fragops-ds-state, depth or stencil operations>> or certain 1062ifndef::VK_EXT_shader_tile_image[] 1063 <<renderpass-load-operations, render pass load operations>>. 1064 Such access occurs in the 1065 ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or 1066 ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages. 1067endif::VK_EXT_shader_tile_image[] 1068ifdef::VK_EXT_shader_tile_image[] 1069 <<renderpass-load-operations, render pass load operations>> in the 1070 ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or 1071 ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages or via 1072 <<fragops-shader-tileimage-reads, fragment shader tile image reads>> in 1073 the ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. 1074endif::VK_EXT_shader_tile_image[] 1075 * ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT specifies write 1076 access to a <<renderpass, depth/stencil attachment>>, via 1077 <<fragops-ds-state, depth or stencil operations>> or certain render pass 1078 <<renderpass-load-operations, load>> and <<renderpass-store-operations, 1079 store>> operations. 1080 Such access occurs in the 1081 ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or 1082 ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages. 1083 * ename:VK_ACCESS_2_TRANSFER_READ_BIT specifies read access to an image or 1084 buffer in a <<copies, copy>> operation. 1085 Such access occurs in the ename:VK_PIPELINE_STAGE_2_COPY_BIT, 1086 ename:VK_PIPELINE_STAGE_2_BLIT_BIT, or 1087 ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT pipeline stages. 1088 * ename:VK_ACCESS_2_TRANSFER_WRITE_BIT specifies write access to an image 1089 or buffer in a <<clears, clear>> or <<copies, copy>> operation. 1090 Such access occurs in the ename:VK_PIPELINE_STAGE_2_COPY_BIT, 1091 ename:VK_PIPELINE_STAGE_2_BLIT_BIT, ename:VK_PIPELINE_STAGE_2_CLEAR_BIT, 1092 or ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT pipeline stages. 1093 * ename:VK_ACCESS_2_HOST_READ_BIT specifies read access by a host 1094 operation. 1095 Accesses of this type are not performed through a resource, but directly 1096 on memory. 1097 Such access occurs in the ename:VK_PIPELINE_STAGE_2_HOST_BIT pipeline 1098 stage. 1099 * ename:VK_ACCESS_2_HOST_WRITE_BIT specifies write access by a host 1100 operation. 1101 Accesses of this type are not performed through a resource, but directly 1102 on memory. 1103 Such access occurs in the ename:VK_PIPELINE_STAGE_2_HOST_BIT pipeline 1104 stage. 1105ifdef::VK_EXT_conditional_rendering[] 1106 * ename:VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT specifies read 1107 access to a predicate as part of conditional rendering. 1108 Such access occurs in the 1109 ename:VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT pipeline stage. 1110endif::VK_EXT_conditional_rendering[] 1111ifdef::VK_EXT_transform_feedback[] 1112 * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT specifies write 1113 access to a transform feedback buffer made when transform feedback is 1114 active. 1115 Such access occurs in the 1116 ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1117 * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT specifies read 1118 access to a transform feedback counter buffer which is read when 1119 flink:vkCmdBeginTransformFeedbackEXT executes. 1120 Such access occurs in the 1121 ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1122 * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT specifies 1123 write access to a transform feedback counter buffer which is written 1124 when flink:vkCmdEndTransformFeedbackEXT executes. 1125 Such access occurs in the 1126 ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1127endif::VK_EXT_transform_feedback[] 1128ifdef::VK_NV_device_generated_commands[] 1129 * ename:VK_ACCESS_2_COMMAND_PREPROCESS_READ_BIT_NV specifies reads from 1130 buffer inputs to flink:vkCmdPreprocessGeneratedCommandsNV. 1131 Such access occurs in the 1132 ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV pipeline stage. 1133 * ename:VK_ACCESS_2_COMMAND_PREPROCESS_WRITE_BIT_NV specifies writes to 1134 the target command buffer preprocess outputs. 1135 Such access occurs in the 1136 ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV pipeline stage. 1137endif::VK_NV_device_generated_commands[] 1138ifdef::VK_EXT_blend_operation_advanced[] 1139 * ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT specifies 1140 read access to <<renderpass, color attachments>>, including 1141 <<framebuffer-blend-advanced,advanced blend operations>>. 1142 Such access occurs in the 1143 ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1144endif::VK_EXT_blend_operation_advanced[] 1145ifdef::VK_HUAWEI_invocation_mask[] 1146 * ename:VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI specifies read access 1147 to a invocation mask image in the 1148 ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI pipeline stage. 1149endif::VK_HUAWEI_invocation_mask[] 1150ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 1151 * ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR specifies read 1152 access to an acceleration structure as part of a trace, build, or copy 1153 command, or to an <<acceleration-structure-scratch, acceleration 1154 structure scratch buffer>> as part of a build command. 1155 Such access occurs in the 1156ifdef::VK_KHR_ray_tracing_pipeline[] 1157 ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR pipeline stage or 1158endif::VK_KHR_ray_tracing_pipeline[] 1159 ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline 1160 stage. 1161 * ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR specifies write 1162 access to an acceleration structure or <<acceleration-structure-scratch, 1163 acceleration structure scratch buffer>> as part of a build or copy 1164 command. 1165 Such access occurs in the 1166 ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline 1167 stage. 1168endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 1169ifdef::VK_EXT_fragment_density_map[] 1170 * ename:VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT specifies read 1171 access to a <<renderpass-fragmentdensitymapattachment, fragment density 1172 map attachment>> during dynamic <<fragmentdensitymapops, fragment 1173 density map operations>>. 1174 Such access occurs in the 1175 ename:VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT pipeline 1176 stage. 1177endif::VK_EXT_fragment_density_map[] 1178ifdef::VK_KHR_fragment_shading_rate[] 1179 * ename:VK_ACCESS_2_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR 1180 specifies read access to a fragment shading rate attachment during 1181 rasterization. 1182 Such access occurs in the 1183 ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR 1184 pipeline stage. 1185endif::VK_KHR_fragment_shading_rate[] 1186ifdef::VK_NV_shading_rate_image[] 1187 * ename:VK_ACCESS_2_SHADING_RATE_IMAGE_READ_BIT_NV specifies read access 1188 to a shading rate image during rasterization. 1189 Such access occurs in the 1190 ename:VK_PIPELINE_STAGE_2_SHADING_RATE_IMAGE_BIT_NV pipeline stage. 1191ifdef::VK_KHR_fragment_shading_rate[] 1192 It is equivalent to 1193 ename:VK_ACCESS_2_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR. 1194endif::VK_KHR_fragment_shading_rate[] 1195endif::VK_NV_shading_rate_image[] 1196ifdef::VK_KHR_video_decode_queue[] 1197 * ename:VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR specifies read access to an 1198 image or buffer resource in a <<video-decode-operations, video decode 1199 operation>>. 1200 Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR 1201 pipeline stage. 1202 * ename:VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR specifies write access to 1203 an image or buffer resource in a <<video-decode-operations, video decode 1204 operation>>. 1205 Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR 1206 pipeline stage. 1207endif::VK_KHR_video_decode_queue[] 1208ifdef::VK_KHR_video_encode_queue[] 1209 * ename:VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR specifies read access to an 1210 image or buffer resource in a <<video-encode-operations, video encode 1211 operation>>. 1212 Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR 1213 pipeline stage. 1214 * ename:VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR specifies write access to 1215 an image or buffer resource in a <<video-encode-operations, video encode 1216 operation>>. 1217 Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR 1218 pipeline stage. 1219endif::VK_KHR_video_encode_queue[] 1220ifdef::VK_EXT_descriptor_buffer[] 1221 * ename:VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT specifies read access 1222 to a <<descriptorbuffers, descriptor buffer>> in any shader pipeline 1223 stage. 1224endif::VK_EXT_descriptor_buffer[] 1225ifdef::VK_NV_optical_flow[] 1226 * ename:VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV specifies read access to an 1227 image or buffer resource as part of a <<opticalflow-operations, optical 1228 flow operation>>. 1229 Such access occurs in the ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV 1230 pipeline stage. 1231 * ename:VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV specifies write access to an 1232 image or buffer resource as part of a <<opticalflow-operations, optical 1233 flow operation>>. 1234 Such access occurs in the ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV 1235 pipeline stage. 1236endif::VK_NV_optical_flow[] 1237ifdef::VK_EXT_opacity_micromap[] 1238 * ename:VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT specifies write access to a 1239 micromap object. 1240 Such access occurs in the 1241 ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT pipeline stage. 1242 * ename:VK_ACCESS_2_MICROMAP_READ_BIT_EXT specifies read access to a 1243 micromap object. 1244 Such access occurs in the 1245 ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT and 1246 ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline 1247 stages. 1248endif::VK_EXT_opacity_micromap[] 1249 1250[NOTE] 1251.Note 1252==== 1253In situations where an application wishes to select all access types for a 1254given set of pipeline stages, ename:VK_ACCESS_2_MEMORY_READ_BIT or 1255ename:VK_ACCESS_2_MEMORY_WRITE_BIT can be used. 1256This is particularly useful when specifying stages that only have a single 1257access type. 1258==== 1259 1260[NOTE] 1261.Note 1262==== 1263The tname:VkAccessFlags2 bitmask goes beyond the 31 individual bit flags 1264allowable within a C99 enum, which is how elink:VkAccessFlagBits is defined. 1265The first 31 values are common to both, and are interchangeable. 1266==== 1267-- 1268 1269[open,refpage='VkAccessFlags2',desc='64-bit mask of access flags',type='flags',alias='VkAccessFlags2KHR'] 1270-- 1271tname:VkAccessFlags2 is a bitmask type for setting a mask of zero or more 1272elink:VkAccessFlagBits2: 1273 1274include::{generated}/api/flags/VkAccessFlags2.adoc[] 1275 1276ifdef::VK_KHR_synchronization2[] 1277or the equivalent 1278 1279include::{generated}/api/flags/VkAccessFlags2KHR.adoc[] 1280endif::VK_KHR_synchronization2[] 1281-- 1282endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1283 1284[open,refpage='VkAccessFlagBits',desc='Bitmask specifying memory access types that will participate in a memory dependency',type='enums'] 1285-- 1286Bits which can: be set in the pname:srcAccessMask and pname:dstAccessMask 1287members of slink:VkSubpassDependency, 1288ifdef::VK_KHR_synchronization2[slink:VkSubpassDependency2,] 1289slink:VkMemoryBarrier, slink:VkBufferMemoryBarrier, and 1290slink:VkImageMemoryBarrier, specifying access behavior, are: 1291 1292include::{generated}/api/enums/VkAccessFlagBits.adoc[] 1293 1294ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1295These values all have the same meaning as the equivalently named values for 1296tlink:VkAccessFlags2. 1297 1298 * ename:VK_ACCESS_NONE specifies no accesses. 1299endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1300 * ename:VK_ACCESS_MEMORY_READ_BIT specifies all read accesses. 1301 It is always valid in any access mask, and is treated as equivalent to 1302 setting all etext:READ access flags that are valid where it is used. 1303 * ename:VK_ACCESS_MEMORY_WRITE_BIT specifies all write accesses. 1304 It is always valid in any access mask, and is treated as equivalent to 1305 setting all etext:WRITE access flags that are valid where it is used. 1306 * ename:VK_ACCESS_INDIRECT_COMMAND_READ_BIT specifies read access to 1307 indirect command data read as part of an indirect 1308ifdef::VK_KHR_acceleration_structure[build,] 1309ifdef::VK_KHR_ray_tracing_pipeline[trace,] 1310 drawing or dispatching command. 1311 Such access occurs in the ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT 1312 pipeline stage. 1313 * ename:VK_ACCESS_INDEX_READ_BIT specifies read access to an index buffer 1314 as part of an indexed drawing command, bound by 1315ifdef::VK_KHR_maintenance5[flink:vkCmdBindIndexBuffer2KHR and] 1316 flink:vkCmdBindIndexBuffer. 1317 Such access occurs in the ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT 1318 pipeline stage. 1319 * ename:VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT specifies read access to a 1320 vertex buffer as part of a drawing command, bound by 1321 flink:vkCmdBindVertexBuffers. 1322 Such access occurs in the ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT 1323 pipeline stage. 1324 * ename:VK_ACCESS_UNIFORM_READ_BIT specifies read access to a 1325 <<descriptorsets-uniformbuffer, uniform buffer>> in any shader pipeline 1326 stage. 1327 * ename:VK_ACCESS_INPUT_ATTACHMENT_READ_BIT specifies read access to an 1328 <<renderpass, input attachment>> within a render pass during 1329ifdef::VK_HUAWEI_subpass_shading[] 1330 subpass shading or 1331endif::VK_HUAWEI_subpass_shading[] 1332 fragment shading. 1333 Such access occurs in the 1334ifdef::VK_HUAWEI_subpass_shading[] 1335 ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI or 1336endif::VK_HUAWEI_subpass_shading[] 1337 ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. 1338 * ename:VK_ACCESS_SHADER_READ_BIT specifies read access to a 1339 <<descriptorsets-uniformtexelbuffer, uniform texel buffer>>, 1340 <<descriptorsets-sampledimage, sampled image>>, 1341 <<descriptorsets-storagebuffer, storage buffer>>, 1342ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1343 <<descriptorsets-physical-storage-buffer, physical storage buffer>>, 1344endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1345ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 1346 <<shader-binding-table, shader binding table>>, 1347endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 1348 <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or 1349 <<descriptorsets-storageimage, storage image>> in any shader pipeline 1350 stage. 1351 * ename:VK_ACCESS_SHADER_WRITE_BIT specifies write access to a 1352 <<descriptorsets-storagebuffer, storage buffer>>, 1353ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1354 <<descriptorsets-physical-storage-buffer, physical storage buffer>>, 1355endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1356 <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or 1357 <<descriptorsets-storageimage, storage image>> in any shader pipeline 1358 stage. 1359 * ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT specifies read access to a 1360 <<renderpass, color attachment>>, such as via 1361ifndef::VK_EXT_blend_operation_advanced[<<framebuffer-blending, blending>>,] 1362ifdef::VK_EXT_blend_operation_advanced[] 1363 <<framebuffer-blending, blending>> (other than 1364 <<framebuffer-blend-advanced, advanced blend operations>>), 1365endif::VK_EXT_blend_operation_advanced[] 1366 <<framebuffer-logicop, logic operations>> or certain 1367ifndef::VK_EXT_shader_tile_image[] 1368 <<renderpass-load-operations, render pass load operations>>. 1369 Such access occurs in the 1370 ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1371endif::VK_EXT_shader_tile_image[] 1372ifdef::VK_EXT_shader_tile_image[] 1373 <<renderpass-load-operations, render pass load operations>> in the 1374 ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage or 1375 via <<fragops-shader-tileimage-reads, fragment shader tile image reads>> 1376 in the ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. 1377endif::VK_EXT_shader_tile_image[] 1378 * ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT specifies write access to a 1379ifndef::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] 1380 <<renderpass, color or resolve attachment>> 1381endif::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] 1382ifdef::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] 1383 <<renderpass, color, resolve, or depth/stencil resolve attachment>> 1384endif::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] 1385 during a <<renderpass, render pass>> or via certain render pass 1386 <<renderpass-load-operations, load>> and <<renderpass-store-operations, 1387 store>> operations. 1388 Such access occurs in the 1389 ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1390 * ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT specifies read access 1391 to a <<renderpass, depth/stencil attachment>>, via <<fragops-ds-state, 1392 depth or stencil operations>> or certain 1393ifndef::VK_EXT_shader_tile_image[] 1394 <<renderpass-load-operations, render pass load operations>>. 1395 Such access occurs in the 1396 ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or 1397 ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages. 1398endif::VK_EXT_shader_tile_image[] 1399ifdef::VK_EXT_shader_tile_image[] 1400 <<renderpass-load-operations, render pass load operations>> in the 1401 ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or 1402 ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages or via 1403 <<fragops-shader-tileimage-reads, fragment shader tile image reads>> in 1404 the ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. 1405endif::VK_EXT_shader_tile_image[] 1406 * ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT specifies write 1407 access to a <<renderpass, depth/stencil attachment>>, via 1408 <<fragops-ds-state, depth or stencil operations>> or certain render pass 1409 <<renderpass-load-operations, load>> and <<renderpass-store-operations, 1410 store>> operations. 1411 Such access occurs in the 1412 ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or 1413 ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages. 1414 * ename:VK_ACCESS_TRANSFER_READ_BIT specifies read access to an image or 1415 buffer in a <<copies, copy>> operation. 1416ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1417 Such access occurs in the ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT 1418 pipeline stage. 1419endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1420 * ename:VK_ACCESS_TRANSFER_WRITE_BIT specifies write access to an image or 1421 buffer in a <<clears, clear>> or <<copies, copy>> operation. 1422ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1423 Such access occurs in the ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT 1424 pipeline stage. 1425endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1426 * ename:VK_ACCESS_HOST_READ_BIT specifies read access by a host operation. 1427 Accesses of this type are not performed through a resource, but directly 1428 on memory. 1429 Such access occurs in the ename:VK_PIPELINE_STAGE_HOST_BIT pipeline 1430 stage. 1431 * ename:VK_ACCESS_HOST_WRITE_BIT specifies write access by a host 1432 operation. 1433 Accesses of this type are not performed through a resource, but directly 1434 on memory. 1435 Such access occurs in the ename:VK_PIPELINE_STAGE_HOST_BIT pipeline 1436 stage. 1437ifdef::VK_EXT_conditional_rendering[] 1438 * ename:VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT specifies read access 1439 to a predicate as part of conditional rendering. 1440 Such access occurs in the 1441 ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT pipeline stage. 1442endif::VK_EXT_conditional_rendering[] 1443ifdef::VK_EXT_transform_feedback[] 1444 * ename:VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT specifies write access 1445 to a transform feedback buffer made when transform feedback is active. 1446 Such access occurs in the 1447 ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1448 * ename:VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT specifies read 1449 access to a transform feedback counter buffer which is read when 1450 fname:vkCmdBeginTransformFeedbackEXT executes. 1451 Such access occurs in the 1452 ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1453 * ename:VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT specifies write 1454 access to a transform feedback counter buffer which is written when 1455 fname:vkCmdEndTransformFeedbackEXT executes. 1456 Such access occurs in the 1457 ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. 1458endif::VK_EXT_transform_feedback[] 1459ifdef::VK_NV_device_generated_commands[] 1460 * ename:VK_ACCESS_COMMAND_PREPROCESS_READ_BIT_NV specifies reads from 1461 buffer inputs to flink:vkCmdPreprocessGeneratedCommandsNV. 1462 Such access occurs in the 1463 ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV pipeline stage. 1464 * ename:VK_ACCESS_COMMAND_PREPROCESS_WRITE_BIT_NV specifies writes to the 1465 target command buffer preprocess outputs in 1466 flink:vkCmdPreprocessGeneratedCommandsNV. 1467 Such access occurs in the 1468 ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV pipeline stage. 1469endif::VK_NV_device_generated_commands[] 1470ifdef::VK_EXT_blend_operation_advanced[] 1471 * ename:VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT specifies read 1472 access to <<renderpass, color attachments>>, including 1473 <<framebuffer-blend-advanced,advanced blend operations>>. 1474 Such access occurs in the 1475 ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. 1476endif::VK_EXT_blend_operation_advanced[] 1477ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 1478ifdef::VK_HUAWEI_invocation_mask[] 1479 * ename:VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI specifies read access 1480 to a invocation mask image in the 1481 ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI pipeline stage. 1482endif::VK_HUAWEI_invocation_mask[] 1483 * ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR specifies read 1484 access to an acceleration structure as part of a trace, build, or copy 1485 command, or to an <<acceleration-structure-scratch, acceleration 1486 structure scratch buffer>> as part of a build command. 1487 Such access occurs in the 1488ifdef::VK_KHR_ray_tracing_pipeline[] 1489 ename:VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR pipeline stage or 1490endif::VK_KHR_ray_tracing_pipeline[] 1491 ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline 1492 stage. 1493 * ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR specifies write 1494 access to an acceleration structure or <<acceleration-structure-scratch, 1495 acceleration structure scratch buffer>> as part of a build or copy 1496 command. 1497 Such access occurs in the 1498 ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline 1499 stage. 1500endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 1501ifdef::VK_EXT_fragment_density_map[] 1502 * ename:VK_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT specifies read access 1503 to a <<renderpass-fragmentdensitymapattachment, fragment density map 1504 attachment>> during dynamic <<fragmentdensitymapops, fragment density 1505 map operations>> Such access occurs in the 1506 ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT pipeline stage. 1507endif::VK_EXT_fragment_density_map[] 1508ifdef::VK_KHR_fragment_shading_rate[] 1509 * ename:VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR specifies 1510 read access to a fragment shading rate attachment during rasterization. 1511 Such access occurs in the 1512 ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR 1513 pipeline stage. 1514endif::VK_KHR_fragment_shading_rate[] 1515ifdef::VK_NV_shading_rate_image[] 1516 * ename:VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV specifies read access to 1517 a shading rate image during rasterization. 1518 Such access occurs in the 1519 ename:VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV pipeline stage. 1520ifdef::VK_KHR_fragment_shading_rate[] 1521 It is equivalent to 1522 ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR. 1523endif::VK_KHR_fragment_shading_rate[] 1524endif::VK_NV_shading_rate_image[] 1525 1526Certain access types are only performed by a subset of pipeline stages. 1527Any synchronization command that takes both stage masks and access masks 1528uses both to define the <<synchronization-dependencies-access-scopes, access 1529scopes>> - only the specified access types performed by the specified stages 1530are included in the access scope. 1531An application must: not specify an access flag in a synchronization command 1532if it does not include a pipeline stage in the corresponding stage mask that 1533is able to perform accesses of that type. 1534The following table lists, for each access flag, which pipeline stages can: 1535perform that type of access. 1536 1537[[synchronization-access-types-supported]] 1538.Supported access types 1539[cols="50,50",options="header"] 1540|==== 1541|Access flag | Supported pipeline stages 1542include::{generated}/sync/supportedAccessTypes.adoc[] 1543|==== 1544-- 1545 1546[open,refpage='VkAccessFlags',desc='Bitmask of VkAccessFlagBits',type='flags'] 1547-- 1548include::{generated}/api/flags/VkAccessFlags.adoc[] 1549 1550tname:VkAccessFlags is a bitmask type for setting a mask of zero or more 1551elink:VkAccessFlagBits. 1552-- 1553 1554 1555[[synchronization-host-access-types]] 1556If a memory object does not have the 1557ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT property, then 1558flink:vkFlushMappedMemoryRanges must: be called in order to guarantee that 1559writes to the memory object from the host are made available to the host 1560domain, where they can: be further made available to the device domain via a 1561domain operation. 1562Similarly, flink:vkInvalidateMappedMemoryRanges must: be called to guarantee 1563that writes which are available to the host domain are made visible to host 1564operations. 1565 1566If the memory object does have the 1567ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT property flag, writes to the 1568memory object from the host are automatically made available to the host 1569domain. 1570Similarly, writes made available to the host domain are automatically made 1571visible to the host. 1572 1573[NOTE] 1574.Note 1575==== 1576<<devsandqueues-submission, Queue submission commands>> automatically 1577perform a <<synchronization-submission-host-writes,domain operation from 1578host to device>> for all writes performed before the command executes, so in 1579most cases an explicit memory barrier is not needed for this case. 1580In the few circumstances where a submit does not occur between the host 1581write and the device read access, writes can: be made available by using an 1582explicit memory barrier. 1583==== 1584 1585 1586[[synchronization-framebuffer-regions]] 1587=== Framebuffer Region Dependencies 1588 1589<<synchronization-pipeline-stages, Pipeline stages>> that operate on, or 1590with respect to, the framebuffer are collectively the _framebuffer-space_ 1591pipeline stages. 1592These stages are: 1593 1594 * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT 1595 * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT 1596 * ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT 1597 * ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 1598 1599For these pipeline stages, an execution or memory dependency from the first 1600set of operations to the second set can: either be a single 1601_framebuffer-global_ dependency, or split into multiple _framebuffer-local_ 1602dependencies. 1603A dependency with non-framebuffer-space pipeline stages is neither 1604framebuffer-global nor framebuffer-local. 1605 1606ifndef::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1607A _framebuffer region_ is a set of sample (x, y, layer, sample) coordinates 1608that is a subset of the entire framebuffer. 1609endif::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1610ifdef::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1611A _framebuffer region_ is a subset of the entire framebuffer, and can: 1612either be: 1613 1614 * A _sample region_, which is set of sample (x, y, layer, sample) 1615 coordinates that is a subset of the entire framebuffer, or 1616 * A _fragment region_, which is a set of fragment (x, y, layer) 1617 coordinates that is a subset of the entire framebuffer. 1618endif::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1619 1620Both <<synchronization-dependencies-scopes, synchronization scopes>> of a 1621framebuffer-local dependency include only the operations performed within 1622corresponding framebuffer regions (as defined below). 1623No ordering guarantees are made between different framebuffer regions for a 1624framebuffer-local dependency. 1625 1626Both <<synchronization-dependencies-scopes, synchronization scopes>> of a 1627framebuffer-global dependency include operations on all framebuffer-regions. 1628 1629If the first synchronization scope includes operations on pixels/fragments 1630with N samples and the second synchronization scope includes operations on 1631pixels/fragments with M samples, where N does not equal M, then a 1632framebuffer region containing all samples at a given (x, y, layer) 1633coordinate in the first synchronization scope corresponds to a region 1634containing all samples at the same coordinate in the second synchronization 1635scope. 1636ifndef::VK_QCOM_render_pass_shader_resolve[] 1637In other words, it is a pixel granularity dependency. 1638endif::VK_QCOM_render_pass_shader_resolve[] 1639ifdef::VK_QCOM_render_pass_shader_resolve[] 1640In other words, the framebuffer region is a fragment region and it is a 1641pixel granularity dependency. 1642endif::VK_QCOM_render_pass_shader_resolve[] 1643If N equals M, 1644ifdef::VK_QCOM_render_pass_shader_resolve[] 1645and if the sname:VkSubpassDescription::pname:flags does not specify the 1646ename:VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM flag, 1647endif::VK_QCOM_render_pass_shader_resolve[] 1648then a framebuffer region containing a single (x, y, layer, sample) 1649coordinate in the first synchronization scope corresponds to a region 1650containing the same sample at the same coordinate in the second 1651synchronization scope. 1652ifndef::VK_QCOM_render_pass_shader_resolve[] 1653In other words, it is a sample granularity dependency. 1654endif::VK_QCOM_render_pass_shader_resolve[] 1655ifdef::VK_QCOM_render_pass_shader_resolve[] 1656In other words, the framebuffer region is a sample region and it is a sample 1657granularity dependency. 1658endif::VK_QCOM_render_pass_shader_resolve[] 1659 1660ifdef::VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1661If the pipeline performing the operation was created with 1662ename:VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT, 1663ename:VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, 1664or 1665ename:VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, 1666the framebuffer region is a fragment region and it is a pixel granularity 1667dependency. 1668endif::VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] 1669 1670[NOTE] 1671.Note 1672==== 1673Since fragment shader invocations are not specified to run in any particular 1674groupings, the size of a framebuffer region is implementation-dependent, not 1675known to the application, and must: be assumed to be no larger than 1676specified above. 1677==== 1678 1679[NOTE] 1680.Note 1681==== 1682Practically, the pixel vs. sample granularity dependency means that if an 1683input attachment has a different number of samples than the pipeline's 1684pname:rasterizationSamples, then a fragment can: access any sample in the 1685input attachment's pixel even if it only uses framebuffer-local 1686dependencies. 1687If the input attachment has the same number of samples, then the fragment 1688can: only access the covered samples in its input code:SampleMask (i.e. the 1689fragment operations happen-after a framebuffer-local dependency for each 1690sample the fragment covers). 1691To access samples that are not covered, 1692ifdef::VK_QCOM_render_pass_shader_resolve[] 1693either the sname:VkSubpassDescription::pname:flags 1694ename:VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM flag is required, or 1695endif::VK_QCOM_render_pass_shader_resolve[] 1696a framebuffer-global dependency is required. 1697==== 1698 1699If a synchronization command includes a pname:dependencyFlags parameter, and 1700specifies the ename:VK_DEPENDENCY_BY_REGION_BIT flag, then it defines 1701framebuffer-local dependencies for the framebuffer-space pipeline stages in 1702that synchronization command, for all framebuffer regions. 1703If no pname:dependencyFlags parameter is included, or the 1704ename:VK_DEPENDENCY_BY_REGION_BIT flag is not specified, then a 1705framebuffer-global dependency is specified for those stages. 1706The ename:VK_DEPENDENCY_BY_REGION_BIT flag does not affect the dependencies 1707between non-framebuffer-space pipeline stages, nor does it affect the 1708dependencies between framebuffer-space and non-framebuffer-space pipeline 1709stages. 1710 1711[NOTE] 1712.Note 1713==== 1714Framebuffer-local dependencies are more efficient for most architectures; 1715particularly tile-based architectures - which can keep framebuffer-regions 1716entirely in on-chip registers and thus avoid external bandwidth across such 1717a dependency. 1718Including a framebuffer-global dependency in your rendering will usually 1719force all implementations to flush data to memory, or to a higher level 1720cache, breaking any potential locality optimizations. 1721==== 1722 1723 1724ifdef::VK_VERSION_1_1,VK_KHR_multiview[] 1725[[synchronization-view-local-dependencies]] 1726=== View-Local Dependencies 1727 1728In a render pass instance that has <<renderpass-multiview,multiview>> 1729enabled, dependencies can: be either view-local or view-global. 1730 1731A view-local dependency only includes operations from a single 1732<<renderpass-multiview-view-local,source view>> from the source subpass in 1733the first synchronization scope, and only includes operations from a single 1734<<renderpass-multiview-view-local,destination view>> from the destination 1735subpass in the second synchronization scope. 1736A view-global dependency includes all views in the view mask of the source 1737and destination subpasses in the corresponding synchronization scopes. 1738 1739If a synchronization command includes a pname:dependencyFlags parameter and 1740specifies the ename:VK_DEPENDENCY_VIEW_LOCAL_BIT flag, then it defines 1741view-local dependencies for that synchronization command, for all views. 1742If no pname:dependencyFlags parameter is included or the 1743ename:VK_DEPENDENCY_VIEW_LOCAL_BIT flag is not specified, then a view-global 1744dependency is specified. 1745endif::VK_VERSION_1_1,VK_KHR_multiview[] 1746 1747 1748ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 1749[[synchronization-device-local-dependencies]] 1750=== Device-Local Dependencies 1751 1752Dependencies can: be either device-local or non-device-local. 1753A device-local dependency acts as multiple separate dependencies, one for 1754each physical device that executes the synchronization command, where each 1755dependency only includes operations from that physical device in both 1756synchronization scopes. 1757A non-device-local dependency is a single dependency where both 1758synchronization scopes include operations from all physical devices that 1759participate in the synchronization command. 1760For subpass dependencies, all physical devices in the 1761slink:VkDeviceGroupRenderPassBeginInfo::pname:deviceMask participate in the 1762dependency, and for pipeline barriers all physical devices that are set in 1763the command buffer's current device mask participate in the dependency. 1764 1765If a synchronization command includes a pname:dependencyFlags parameter and 1766specifies the ename:VK_DEPENDENCY_DEVICE_GROUP_BIT flag, then it defines a 1767non-device-local dependency for that synchronization command. 1768If no pname:dependencyFlags parameter is included or the 1769ename:VK_DEPENDENCY_DEVICE_GROUP_BIT flag is not specified, then it defines 1770device-local dependencies for that synchronization command, for all 1771participating physical devices. 1772 1773Semaphore and event dependencies are device-local and only execute on the 1774one physical device that performs the dependency. 1775endif::VK_VERSION_1_1,VK_KHR_device_group[] 1776 1777 1778[[synchronization-implicit]] 1779== Implicit Synchronization Guarantees 1780 1781A small number of implicit ordering guarantees are provided by Vulkan, 1782ensuring that the order in which commands are submitted is meaningful, and 1783avoiding unnecessary complexity in common operations. 1784 1785[[synchronization-submission-order]] 1786_Submission order_ is a fundamental ordering in Vulkan, giving meaning to 1787the order in which <<fundamentals-queueoperation-command-types, action and 1788synchronization commands>> are recorded and submitted to a single queue. 1789Explicit and implicit ordering guarantees between commands in Vulkan all 1790work on the premise that this ordering is meaningful. 1791This order does not itself define any execution or memory dependencies; 1792synchronization commands and other orderings within the API use this 1793ordering to define their scopes. 1794 1795Submission order for any given set of commands is based on the order in 1796which they were recorded to command buffers and then submitted. 1797This order is determined as follows: 1798 1799 . The initial order is determined by the order in which 1800 flink:vkQueueSubmit 1801ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1802 and flink:vkQueueSubmit2 1803endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1804 commands are executed on the host, for a single queue, from first to 1805 last. 1806 . The order in which slink:VkSubmitInfo structures are specified in the 1807 pname:pSubmits parameter of flink:vkQueueSubmit, 1808ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1809 or in which slink:VkSubmitInfo2 structures are specified in the 1810 pname:pSubmits parameter of flink:vkQueueSubmit2, 1811endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1812 from lowest index to highest. 1813 . The order in which command buffers are specified in the 1814 pname:pCommandBuffers member of slink:VkSubmitInfo 1815ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1816 or slink:VkSubmitInfo2 1817endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1818 from lowest index to highest. 1819 . The order in which commands were recorded to a command buffer on the 1820 host, from first to last: 1821 ** For commands recorded outside a render pass, this includes all other 1822 commands recorded outside a render pass, including 1823 flink:vkCmdBeginRenderPass and flink:vkCmdEndRenderPass commands; it 1824 does not directly include commands inside a render pass. 1825 ** For commands recorded inside a render pass, this includes all other 1826 commands recorded inside the same subpass, including the 1827 flink:vkCmdBeginRenderPass and flink:vkCmdEndRenderPass commands that 1828 delimit the same render pass instance; it does not include commands 1829 recorded to other subpasses. 1830<<fundamentals-queueoperation-command-types, State commands>> do not execute 1831any operations on the device, instead they set the state of the command 1832buffer when they execute on the host, in the order that they are recorded. 1833<<fundamentals-queueoperation-command-types, Action commands>> consume the 1834current state of the command buffer when they are recorded, and will execute 1835state changes on the device as required to match the recorded state. 1836 1837<<drawing-primitive-order, The order of primitives passing through the 1838graphics pipeline>> and 1839<<synchronization-image-barrier-layout-transition-order, image layout 1840transitions as part of an image memory barrier>> provide additional 1841guarantees based on submission order. 1842 1843Execution of <<synchronization-pipeline-stages-order, pipeline stages>> 1844within a given command also has a loose ordering, dependent only on a single 1845command. 1846 1847[[synchronization-signal-operation-order]] 1848_Signal operation order_ is a fundamental ordering in Vulkan, giving meaning 1849to the order in which semaphore and fence signal operations occur when 1850submitted to a single queue. 1851The signal operation order for queue operations is determined as follows: 1852 1853 . The initial order is determined by the order in which 1854 flink:vkQueueSubmit 1855ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1856 and flink:vkQueueSubmit2 1857endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1858 commands are executed on the host, for a single queue, from first to 1859 last. 1860 . The order in which slink:VkSubmitInfo structures are specified in the 1861 pname:pSubmits parameter of flink:vkQueueSubmit, 1862ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 1863 or in which slink:VkSubmitInfo2 structures are specified in the 1864 pname:pSubmits parameter of flink:vkQueueSubmit2, 1865endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 1866 from lowest index to highest. 1867 . The fence signal operation defined by the pname:fence parameter of a 1868 flink:vkQueueSubmit 1869ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] 1870ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] 1871 command is ordered after all semaphore signal operations defined by that 1872 command. 1873 1874Semaphore signal operations defined by a single slink:VkSubmitInfo 1875ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or slink:VkSubmitInfo2] 1876ifndef::VKSC_VERSION_1_0[or slink:VkBindSparseInfo] 1877structure are unordered with respect to other semaphore signal operations 1878defined within the same structure. 1879 1880ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1881The flink:vkSignalSemaphore command does not execute on a queue but instead 1882performs the signal operation from the host. 1883The semaphore signal operation defined by executing a 1884flink:vkSignalSemaphore command happens-after the flink:vkSignalSemaphore 1885command is invoked and happens-before the command returns. 1886 1887[NOTE] 1888.Note 1889==== 1890When signaling timeline semaphores, it is the responsibility of the 1891application to ensure that they are ordered such that the semaphore value is 1892strictly increasing. 1893Because the first synchronization scope for a semaphore signal operation 1894contains all semaphore signal operations which occur earlier in submission 1895order, all semaphore signal operations contained in any given batch are 1896guaranteed to happen-after all semaphore signal operations contained in any 1897previous batches. 1898However, no ordering guarantee is provided between the semaphore signal 1899operations defined within a single batch. 1900This, combined with the requirement that timeline semaphore values strictly 1901increase, means that it is invalid to signal the same timeline semaphore 1902twice within a single batch. 1903 1904If an application wishes to ensure that some semaphore signal operation 1905happens-after some other semaphore signal operation, it can submit a 1906separate batch containing only semaphore signal operations, which will 1907happen-after the semaphore signal operations in any earlier batches. 1908 1909When signaling a semaphore from the host, the only ordering guarantee is 1910that the signal operation happens-after when flink:vkSignalSemaphore is 1911called and happens-before it returns. 1912Therefore, it is invalid to call fname:vkSignalSemaphore while there are any 1913outstanding signal operations on that semaphore from any queue submissions 1914unless those queue submissions have some dependency which ensures that they 1915happen-after the host signal operation. 1916One example of this would be if the pending signal operation is, itself, 1917waiting on the same semaphore at a lower value and the call to 1918fname:vkSignalSemaphore signals that lower value. 1919Furthermore, if there are two or more processes or threads signaling the 1920same timeline semaphore from the host, the application must ensure that the 1921fname:vkSignalSemaphore with the lower semaphore value returns before 1922fname:vkSignalSemaphore is called with the higher value. 1923==== 1924endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1925 1926 1927[[synchronization-fences]] 1928== Fences 1929 1930[open,refpage='VkFence',desc='Opaque handle to a fence object',type='handles'] 1931-- 1932Fences are a synchronization primitive that can: be used to insert a 1933dependency from a queue to the host. 1934Fences have two states - signaled and unsignaled. 1935A fence can: be signaled as part of the execution of a 1936<<devsandqueues-submission, queue submission>> command. 1937Fences can: be unsignaled on the host with flink:vkResetFences. 1938Fences can: be waited on by the host with the flink:vkWaitForFences command, 1939and the current state can: be queried with flink:vkGetFenceStatus. 1940 1941ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] 1942[[synchronization-fences-payloads]] 1943The internal data of a fence may: include a reference to any resources and 1944pending work associated with signal or unsignal operations performed on that 1945fence object, collectively referred to as the fence's _payload_. 1946Mechanisms to import and export that internal data to and from fences are 1947provided <<VkExportFenceCreateInfo, below>>. 1948These mechanisms indirectly enable applications to share fence state between 1949two or more fences and other synchronization primitives across process and 1950API boundaries. 1951 1952endif::VK_VERSION_1_1,VK_KHR_external_fence[] 1953 1954Fences are represented by sname:VkFence handles: 1955 1956include::{generated}/api/handles/VkFence.adoc[] 1957-- 1958 1959[open,refpage='vkCreateFence',desc='Create a new fence object',type='protos'] 1960-- 1961:refpage: vkCreateFence 1962:objectnameplural: fences 1963:objectnamecamelcase: fence 1964:objectcount: 1 1965 1966To create a fence, call: 1967 1968include::{generated}/api/protos/vkCreateFence.adoc[] 1969 1970 * pname:device is the logical device that creates the fence. 1971 * pname:pCreateInfo is a pointer to a slink:VkFenceCreateInfo structure 1972 containing information about how the fence is to be created. 1973 * pname:pAllocator controls host memory allocation as described in the 1974 <<memory-allocation, Memory Allocation>> chapter. 1975 * pname:pFence is a pointer to a handle in which the resulting fence 1976 object is returned. 1977 1978include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 1979 1980ifdef::VKSC_VERSION_1_0,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 1981.Valid Usage 1982**** 1983include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] 1984ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 1985 * [[VUID-vkCreateFence-pNext-05106]] 1986 If the pname:pNext chain of slink:VkFenceCreateInfo includes 1987 slink:VkExportFenceSciSyncInfoNV, then 1988 slink:VkFenceCreateInfo::pname:flags must: not include 1989 ename:VK_FENCE_CREATE_SIGNALED_BIT 1990endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 1991**** 1992endif::VKSC_VERSION_1_0,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 1993 1994include::{generated}/validity/protos/vkCreateFence.adoc[] 1995-- 1996 1997[open,refpage='VkFenceCreateInfo',desc='Structure specifying parameters of a newly created fence',type='structs'] 1998-- 1999The sname:VkFenceCreateInfo structure is defined as: 2000 2001include::{generated}/api/structs/VkFenceCreateInfo.adoc[] 2002 2003 * pname:sType is a elink:VkStructureType value identifying this structure. 2004 * pname:pNext is `NULL` or a pointer to a structure extending this 2005 structure. 2006 * pname:flags is a bitmask of elink:VkFenceCreateFlagBits specifying the 2007 initial state and behavior of the fence. 2008 2009include::{generated}/validity/structs/VkFenceCreateInfo.adoc[] 2010-- 2011 2012[open,refpage='VkFenceCreateFlagBits',desc='Bitmask specifying initial state and behavior of a fence',type='enums'] 2013-- 2014include::{generated}/api/enums/VkFenceCreateFlagBits.adoc[] 2015 2016 * ename:VK_FENCE_CREATE_SIGNALED_BIT specifies that the fence object is 2017 created in the signaled state. 2018 Otherwise, it is created in the unsignaled state. 2019-- 2020 2021[open,refpage='VkFenceCreateFlags',desc='Bitmask of VkFenceCreateFlagBits',type='flags'] 2022-- 2023include::{generated}/api/flags/VkFenceCreateFlags.adoc[] 2024 2025tname:VkFenceCreateFlags is a bitmask type for setting a mask of zero or 2026more elink:VkFenceCreateFlagBits. 2027-- 2028 2029ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] 2030[open,refpage='VkExportFenceCreateInfo',desc='Structure specifying handle types that can be exported from a fence',type='structs'] 2031-- 2032To create a fence whose payload can: be exported to external handles, add a 2033slink:VkExportFenceCreateInfo structure to the pname:pNext chain of the 2034slink:VkFenceCreateInfo structure. 2035The sname:VkExportFenceCreateInfo structure is defined as: 2036 2037include::{generated}/api/structs/VkExportFenceCreateInfo.adoc[] 2038 2039ifdef::VK_KHR_external_fence[] 2040or the equivalent 2041 2042include::{generated}/api/structs/VkExportFenceCreateInfoKHR.adoc[] 2043endif::VK_KHR_external_fence[] 2044 2045 * pname:sType is a elink:VkStructureType value identifying this structure. 2046 * pname:pNext is `NULL` or a pointer to a structure extending this 2047 structure. 2048 * pname:handleTypes is a bitmask of 2049 elink:VkExternalFenceHandleTypeFlagBits specifying one or more fence 2050 handle types the application can: export from the resulting fence. 2051 The application can: request multiple handle types for the same fence. 2052 2053.Valid Usage 2054**** 2055 * [[VUID-VkExportFenceCreateInfo-handleTypes-01446]] 2056 The bits in pname:handleTypes must: be supported and compatible, as 2057 reported by slink:VkExternalFenceProperties 2058ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 2059 * [[VUID-VkExportFenceCreateInfo-pNext-05107]] 2060 If the pname:pNext chain includes a slink:VkExportFenceSciSyncInfoNV 2061 structure, 2062 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence and 2063 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncExport, or 2064 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence and 2065 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncExport 2066 must: be enabled 2067endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 2068**** 2069 2070include::{generated}/validity/structs/VkExportFenceCreateInfo.adoc[] 2071-- 2072endif::VK_VERSION_1_1,VK_KHR_external_fence[] 2073 2074ifdef::VK_KHR_external_fence_win32[] 2075[open,refpage='VkExportFenceWin32HandleInfoKHR',desc='Structure specifying additional attributes of Windows handles exported from a fence',type='structs'] 2076-- 2077To specify additional attributes of NT handles exported from a fence, add a 2078slink:VkExportFenceWin32HandleInfoKHR structure to the pname:pNext chain of 2079the slink:VkFenceCreateInfo structure. 2080The sname:VkExportFenceWin32HandleInfoKHR structure is defined as: 2081 2082include::{generated}/api/structs/VkExportFenceWin32HandleInfoKHR.adoc[] 2083 2084 * pname:sType is a elink:VkStructureType value identifying this structure. 2085 * pname:pNext is `NULL` or a pointer to a structure extending this 2086 structure. 2087 * pname:pAttributes is a pointer to a Windows code:SECURITY_ATTRIBUTES 2088 structure specifying security attributes of the handle. 2089 * pname:dwAccess is a code:DWORD specifying access rights of the handle. 2090 * pname:name is a null-terminated UTF-16 string to associate with the 2091 underlying synchronization primitive referenced by NT handles exported 2092 from the created fence. 2093 2094If slink:VkExportFenceCreateInfo is not included in the same pname:pNext 2095chain, this structure is ignored. 2096 2097If slink:VkExportFenceCreateInfo is included in the pname:pNext chain of 2098slink:VkFenceCreateInfo with a Windows pname:handleType, but either 2099sname:VkExportFenceWin32HandleInfoKHR is not included in the pname:pNext 2100chain, or it is included but pname:pAttributes is set to `NULL`, default 2101security descriptor values will be used, and child processes created by the 2102application will not inherit the handle, as described in the MSDN 2103documentation for "`Synchronization Object Security and Access Rights`"^1^. 2104Further, if the structure is not present, the access rights will be 2105 2106code:DXGI_SHARED_RESOURCE_READ | code:DXGI_SHARED_RESOURCE_WRITE 2107 2108for handles of the following types: 2109 2110ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT 2111 21121:: 2113 https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights 2114 2115.Valid Usage 2116**** 2117 * [[VUID-VkExportFenceWin32HandleInfoKHR-handleTypes-01447]] 2118 If slink:VkExportFenceCreateInfo::pname:handleTypes does not include 2119 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, a 2120 sname:VkExportFenceWin32HandleInfoKHR structure must: not be included in 2121 the pname:pNext chain of slink:VkFenceCreateInfo 2122**** 2123 2124include::{generated}/validity/structs/VkExportFenceWin32HandleInfoKHR.adoc[] 2125-- 2126 2127[open,refpage='vkGetFenceWin32HandleKHR',desc='Get a Windows HANDLE for a fence',type='protos'] 2128-- 2129To export a Windows handle representing the state of a fence, call: 2130 2131include::{generated}/api/protos/vkGetFenceWin32HandleKHR.adoc[] 2132 2133 * pname:device is the logical device that created the fence being 2134 exported. 2135 * pname:pGetWin32HandleInfo is a pointer to a 2136 slink:VkFenceGetWin32HandleInfoKHR structure containing parameters of 2137 the export operation. 2138 * pname:pHandle will return the Windows handle representing the fence 2139 state. 2140 2141For handle types defined as NT handles, the handles returned by 2142fname:vkGetFenceWin32HandleKHR are owned by the application. 2143To avoid leaking resources, the application must: release ownership of them 2144using the code:CloseHandle system call when they are no longer needed. 2145 2146Exporting a Windows handle from a fence may: have side effects depending on 2147the transference of the specified handle type, as described in 2148<<synchronization-fences-importing,Importing Fence Payloads>>. 2149 2150include::{generated}/validity/protos/vkGetFenceWin32HandleKHR.adoc[] 2151-- 2152 2153[open,refpage='VkFenceGetWin32HandleInfoKHR',desc='Structure describing a Win32 handle fence export operation',type='structs'] 2154-- 2155The sname:VkFenceGetWin32HandleInfoKHR structure is defined as: 2156 2157include::{generated}/api/structs/VkFenceGetWin32HandleInfoKHR.adoc[] 2158 2159 * pname:sType is a elink:VkStructureType value identifying this structure. 2160 * pname:pNext is `NULL` or a pointer to a structure extending this 2161 structure. 2162 * pname:fence is the fence from which state will be exported. 2163 * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value 2164 specifying the type of handle requested. 2165 2166The properties of the handle returned depend on the value of 2167pname:handleType. 2168See elink:VkExternalFenceHandleTypeFlagBits for a description of the 2169properties of the defined external fence handle types. 2170 2171.Valid Usage 2172**** 2173 * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01448]] 2174 pname:handleType must: have been included in 2175 slink:VkExportFenceCreateInfo::pname:handleTypes when the pname:fence's 2176 current payload was created 2177 * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01449]] 2178 If pname:handleType is defined as an NT handle, 2179 flink:vkGetFenceWin32HandleKHR must: be called no more than once for 2180 each valid unique combination of pname:fence and pname:handleType 2181 * [[VUID-VkFenceGetWin32HandleInfoKHR-fence-01450]] 2182 pname:fence must: not currently have its payload replaced by an imported 2183 payload as described below in 2184 <<synchronization-fences-importing,Importing Fence Payloads>> unless 2185 that imported payload's handle type was included in 2186 slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes for 2187 pname:handleType 2188 * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01451]] 2189 If pname:handleType refers to a handle type with copy payload 2190 transference semantics, pname:fence must: be signaled, or have an 2191 associated <<synchronization-fences-signaling,fence signal operation>> 2192 pending execution 2193 * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01452]] 2194 pname:handleType must: be defined as an NT handle or a global share 2195 handle 2196**** 2197 2198include::{generated}/validity/structs/VkFenceGetWin32HandleInfoKHR.adoc[] 2199-- 2200endif::VK_KHR_external_fence_win32[] 2201 2202ifdef::VK_KHR_external_fence_fd[] 2203[open,refpage='vkGetFenceFdKHR',desc='Get a POSIX file descriptor handle for a fence',type='protos'] 2204-- 2205:refpage: vkGetFenceFdKHR 2206 2207To export a POSIX file descriptor representing the payload of a fence, call: 2208 2209include::{generated}/api/protos/vkGetFenceFdKHR.adoc[] 2210 2211 * pname:device is the logical device that created the fence being 2212 exported. 2213 * pname:pGetFdInfo is a pointer to a slink:VkFenceGetFdInfoKHR structure 2214 containing parameters of the export operation. 2215 * pname:pFd will return the file descriptor representing the fence 2216 payload. 2217 2218Each call to fname:vkGetFenceFdKHR must: create a new file descriptor and 2219transfer ownership of it to the application. 2220To avoid leaking resources, the application must: release ownership of the 2221file descriptor when it is no longer needed. 2222 2223[NOTE] 2224.Note 2225==== 2226Ownership can be released in many ways. 2227For example, the application can call code:close() on the file descriptor, 2228or transfer ownership back to Vulkan by using the file descriptor to import 2229a fence payload. 2230==== 2231 2232If pname:pGetFdInfo->handleType is 2233ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT and the fence is signaled at 2234the time fname:vkGetFenceFdKHR is called, pname:pFd may: return the value 2235`-1` instead of a valid file descriptor. 2236 2237Where supported by the operating system, the implementation must: set the 2238file descriptor to be closed automatically when an code:execve system call 2239is made. 2240 2241Exporting a file descriptor from a fence may: have side effects depending on 2242the transference of the specified handle type, as described in 2243<<synchronization-fences-importing,Importing Fence State>>. 2244 2245include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 2246 2247include::{generated}/validity/protos/vkGetFenceFdKHR.adoc[] 2248-- 2249 2250[open,refpage='VkFenceGetFdInfoKHR',desc='Structure describing a POSIX FD fence export operation',type='structs'] 2251-- 2252The sname:VkFenceGetFdInfoKHR structure is defined as: 2253 2254include::{generated}/api/structs/VkFenceGetFdInfoKHR.adoc[] 2255 2256 * pname:sType is a elink:VkStructureType value identifying this structure. 2257 * pname:pNext is `NULL` or a pointer to a structure extending this 2258 structure. 2259 * pname:fence is the fence from which state will be exported. 2260 * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value 2261 specifying the type of handle requested. 2262 2263The properties of the file descriptor returned depend on the value of 2264pname:handleType. 2265See elink:VkExternalFenceHandleTypeFlagBits for a description of the 2266properties of the defined external fence handle types. 2267 2268.Valid Usage 2269**** 2270 * [[VUID-VkFenceGetFdInfoKHR-handleType-01453]] 2271 pname:handleType must: have been included in 2272 slink:VkExportFenceCreateInfo::pname:handleTypes when pname:fence's 2273 current payload was created 2274 * [[VUID-VkFenceGetFdInfoKHR-handleType-01454]] 2275 If pname:handleType refers to a handle type with copy payload 2276 transference semantics, pname:fence must: be signaled, or have an 2277 associated <<synchronization-fences-signaling,fence signal operation>> 2278 pending execution 2279 * [[VUID-VkFenceGetFdInfoKHR-fence-01455]] 2280 pname:fence must: not currently have its payload replaced by an imported 2281 payload as described below in 2282 <<synchronization-fences-importing,Importing Fence Payloads>> unless 2283 that imported payload's handle type was included in 2284 slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes for 2285 pname:handleType 2286 * [[VUID-VkFenceGetFdInfoKHR-handleType-01456]] 2287 pname:handleType must: be defined as a POSIX file descriptor handle 2288**** 2289 2290include::{generated}/validity/structs/VkFenceGetFdInfoKHR.adoc[] 2291-- 2292endif::VK_KHR_external_fence_fd[] 2293 2294ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 2295[open,refpage='VkExportFenceSciSyncInfoNV',desc='Structure specifying additional attributes SciSync handles exported from a fence',type='structs'] 2296-- 2297To specify additional attributes of stext:NvSciSync handles exported from a 2298fence, add a slink:VkExportFenceSciSyncInfoNV structure to the pname:pNext 2299chain of the slink:VkFenceCreateInfo structure. 2300The sname:VkExportFenceSciSyncInfoNV structure is defined as: 2301 2302include::{generated}/api/structs/VkExportFenceSciSyncInfoNV.adoc[] 2303 2304 * pname:sType is a elink:VkStructureType value identifying this structure. 2305 * pname:pNext is `NULL` or a pointer to a structure extending this 2306 structure. 2307 * pname:pAttributes is an opaque sname:NvSciSyncAttrList describing the 2308 attributes of the NvSciSync object that will be exported. 2309 2310If slink:VkExportFenceCreateInfo is not present in the same pname:pNext 2311chain, this structure is ignored. 2312If the pname:pNext chain of slink:VkFenceCreateInfo includes a 2313slink:VkExportFenceCreateInfo structure with a NvSciSync pname:handleType, 2314but either slink:VkExportFenceSciSyncInfoNV is not included in the 2315pname:pNext chain, or it is included but pname:pAttributes is set to `NULL`, 2316flink:vkCreateFence will return ename:VK_ERROR_INITIALIZATION_FAILED. 2317 2318The pname:pAttributes must: be a reconciled sname:NvSciSyncAttrList. 2319Before exporting the NvSciSync handles, applications must: use the 2320flink:vkGetPhysicalDeviceSciSyncAttributesNV command to get the unreconciled 2321sname:NvSciSyncAttrList and then use the NvSciSync API to reconcile it. 2322 2323.Valid Usage 2324**** 2325 * [[VUID-VkExportFenceSciSyncInfoNV-pAttributes-05108]] 2326 pname:pAttributes must: be a reconciled stext:NvSciSyncAttrList 2327**** 2328 2329include::{generated}/validity/structs/VkExportFenceSciSyncInfoNV.adoc[] 2330-- 2331 2332[open,refpage='vkGetPhysicalDeviceSciSyncAttributesNV',desc='Get the implementation-specific NvSciSync attributes',type='protos'] 2333-- 2334 2335To obtain the implementation-specific NvSciSync attributes in an 2336unreconciled sname:NvSciSyncAttrList, call: 2337 2338include::{generated}/api/protos/vkGetPhysicalDeviceSciSyncAttributesNV.adoc[] 2339 2340 * pname:physicalDevice is the handle to the physical device that will be 2341 used to determine the attributes. 2342 * pname:pSciSyncAttributesInfo is a pointer to a 2343 slink:VkSciSyncAttributesInfoNV structure containing information about 2344 how the attributes are to be filled. 2345 * pname:pAttributes is an opaque stext:NvSciSyncAttrList in which the 2346 implementation will set the requested attributes. 2347 2348On success, pname:pAttributes will contain an unreconciled 2349stext:NvSciSyncAttrList whose private attributes and some public attributes 2350are filled in by the implementation. 2351If the attributes of pname:physicalDevice could not be obtained, 2352ename:VK_ERROR_INITIALIZATION_FAILED is returned. 2353 2354.Valid Usage 2355**** 2356 * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pSciSyncAttributesInfo-05109]] 2357 If pname:pSciSyncAttributesInfo->primitiveType is 2358 ename:VK_SCI_SYNC_PRIMITIVE_TYPE_FENCE_NV then 2359 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or 2360 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence 2361 must: be enabled 2362 * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pSciSyncAttributesInfo-05110]] 2363 If pname:pSciSyncAttributesInfo->primitiveType is 2364 ename:VK_SCI_SYNC_PRIMITIVE_TYPE_SEMAPHORE_NV then 2365 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore 2366 or 2367 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2 2368 must: be enabled 2369 * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pAttributes-05111]] 2370 pname:pAttributes must: be a valid stext:NvSciSyncAttrList and must: not 2371 be `NULL` 2372**** 2373 2374include::{generated}/validity/protos/vkGetPhysicalDeviceSciSyncAttributesNV.adoc[] 2375-- 2376 2377[open,refpage='VkSciSyncAttributesInfoNV',desc='Structure describing SciSync attribute information',type='structs'] 2378-- 2379The sname:VkSciSyncAttributesInfoNV structure is defined as: 2380 2381include::{generated}/api/structs/VkSciSyncAttributesInfoNV.adoc[] 2382 2383 * pname:sType is a elink:VkStructureType value identifying this structure. 2384 * pname:pNext is `NULL` or a pointer to a structure extending this 2385 structure. 2386 * pname:clientType is the permission type of client. 2387 * pname:primitiveType is the synchronization primitive type. 2388 2389NvSciSync disallows multi-signalers, therefore clients must: specify their 2390permission types as one of signaler, waiter or signaler_waiter. 2391In addition, NvSciSync requires clients to specify which primitive type is 2392to be used in synchronization, hence clients also need to provide the 2393primitive type (slink:VkFence or slink:VkSemaphore) that will be used. 2394 2395include::{generated}/validity/structs/VkSciSyncAttributesInfoNV.adoc[] 2396-- 2397 2398[open,refpage='VkSciSyncClientTypeNV',desc='Enums specifying client permission types',type='enums'] 2399-- 2400The ename:VkSciSyncClientTypeNV enum is defined as: 2401 2402include::{generated}/api/enums/VkSciSyncClientTypeNV.adoc[] 2403 2404 * ename:VK_SCI_SYNC_CLIENT_TYPE_SIGNALER_NV specifies the permission of 2405 the client as signaler. 2406 It indicates that the client can only signal the created fence or 2407 semaphore and disallows waiting on it. 2408 * ename:VK_SCI_SYNC_CLIENT_TYPE_WAITER_NV specifies the permission of the 2409 client as waiter. 2410 It indicates that the client can only wait on the imported fence or 2411 semaphore and disallows signalling it. 2412 This type of permission is only used when the client imports NvSciSync 2413 handles, and export is not allowed. 2414 * ename:VK_SCI_SYNC_CLIENT_TYPE_SIGNALER_WAITER_NV specifies the 2415 permission of client as both signaler and waiter. 2416 It indicates that the client can: signal and wait on the created fence 2417 or semaphore. 2418-- 2419 2420[open,refpage='VkSciSyncPrimitiveTypeNV',desc='Enums specifying the primitive types',type='enums'] 2421-- 2422The ename:VkSciSyncPrimitiveTypeNV enum is defined as: 2423 2424include::{generated}/api/enums/VkSciSyncPrimitiveTypeNV.adoc[] 2425 2426 * ename:VK_SCI_SYNC_PRIMITIVE_TYPE_FENCE_NV specifies that the 2427 synchronization primitive type the client will create is a 2428 slink:VkFence. 2429 * ename:VK_SCI_SYNC_PRIMITIVE_TYPE_SEMAPHORE_NV specifies that the 2430 synchronization primitive type the client will create is a 2431 slink:VkSemaphore. 2432-- 2433 2434[open,refpage='vkGetFenceSciSyncFenceNV',desc='Get a stext:NvSciSyncFence handle for a fence',type='protos'] 2435-- 2436To export a stext:NvSciSyncFence handle representing the payload of a fence, 2437call: 2438 2439include::{generated}/api/protos/vkGetFenceSciSyncFenceNV.adoc[] 2440 2441 * pname:device is the logical device that created the fence being 2442 exported. 2443 * pname:pGetSciSyncHandleInfo is a pointer to a 2444 slink:VkFenceGetSciSyncInfoNV structure containing parameters of the 2445 export operation. 2446 * pname:pHandle is a pointer to a stext:NvSciSyncFence which will contain 2447 the fence payload on return. 2448 2449Each call to fname:vkGetFenceSciSyncFenceNV will duplicate the underlying 2450stext:NvSciSyncFence handle and transfer the ownership of the 2451stext:NvSciSyncFence handle to the application. 2452To avoid leaking resources, the application must: release of the ownership 2453of the stext:NvSciSyncFence handle when it is no longer needed. 2454 2455.Valid Usage 2456**** 2457 * [[VUID-vkGetFenceSciSyncFenceNV-pGetSciSyncHandleInfo-05112]] 2458 pname:pGetSciSyncHandleInfo->handleType must: be 2459 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV 2460 * [[VUID-vkGetFenceSciSyncFenceNV-sciSyncFence-05113]] 2461 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or 2462 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence 2463 must: be enabled 2464**** 2465 2466include::{generated}/validity/protos/vkGetFenceSciSyncFenceNV.adoc[] 2467-- 2468 2469[open,refpage='vkGetFenceSciSyncObjNV',desc='Get a stext:NvSciSyncObj handle for a fence',type='protos'] 2470-- 2471To export a stext:NvSciSyncObj handle representing the payload of a fence, 2472call: 2473 2474include::{generated}/api/protos/vkGetFenceSciSyncObjNV.adoc[] 2475 2476 * pname:device is the logical device that created the fence being 2477 exported. 2478 * pname:pGetSciSyncHandleInfo is a pointer to a 2479 slink:VkFenceGetSciSyncInfoNV structure containing parameters of the 2480 export operation. 2481 * pname:pHandle will return the stext:NvSciSyncObj handle representing the 2482 fence payload. 2483 2484Each call to fname:vkGetFenceSciSyncObjNV will duplicate the underlying 2485stext:NvSciSyncObj handle and transfer the ownership of the 2486stext:NvSciSyncObj handle to the application. 2487To avoid leaking resources, the application must: release of the ownership 2488of the stext:NvSciSyncObj handle when it is no longer needed. 2489 2490.Valid Usage 2491**** 2492 * [[VUID-vkGetFenceSciSyncObjNV-pGetSciSyncHandleInfo-05114]] 2493 pname:pGetSciSyncHandleInfo->handleType must: be 2494 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV 2495 * [[VUID-vkGetFenceSciSyncObjNV-sciSyncFence-05115]] 2496 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or 2497 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence 2498 must: be enabled 2499**** 2500 2501include::{generated}/validity/protos/vkGetFenceSciSyncObjNV.adoc[] 2502-- 2503 2504[open,refpage='VkFenceGetSciSyncInfoNV',desc='Structure describing a slink:VkFence export operation to NvSciSync',type='structs'] 2505-- 2506The sname:VkFenceGetSciSyncInfoNV structure is defined as: 2507 2508include::{generated}/api/structs/VkFenceGetSciSyncInfoNV.adoc[] 2509 2510 * pname:sType is a elink:VkStructureType value identifying this structure. 2511 * pname:pNext is `NULL` or a pointer to a structure extending this 2512 structure. 2513 * pname:fence is the fence from which state will be exported. 2514 * pname:handleType is the type of NvSciSync handle (stext:NvSciSyncObj or 2515 stext:NvSciSyncFence) representing the fence payload that will be 2516 exported. 2517 2518If pname:handleType is 2519ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV, a 2520stext:NvSciSyncObj will be exported. 2521If pname:handleType is 2522ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV, a 2523stext:NvSciSyncFence will be exported. 2524 2525include::{generated}/validity/structs/VkFenceGetSciSyncInfoNV.adoc[] 2526-- 2527endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 2528 2529[open,refpage='vkDestroyFence',desc='Destroy a fence object',type='protos'] 2530-- 2531To destroy a fence, call: 2532 2533include::{generated}/api/protos/vkDestroyFence.adoc[] 2534 2535 * pname:device is the logical device that destroys the fence. 2536 * pname:fence is the handle of the fence to destroy. 2537 * pname:pAllocator controls host memory allocation as described in the 2538 <<memory-allocation, Memory Allocation>> chapter. 2539 2540.Valid Usage 2541**** 2542 * [[VUID-vkDestroyFence-fence-01120]] 2543 All <<devsandqueues-submission, queue submission>> commands that refer 2544 to pname:fence must: have completed execution 2545ifndef::VKSC_VERSION_1_0[] 2546 * [[VUID-vkDestroyFence-fence-01121]] 2547 If sname:VkAllocationCallbacks were provided when pname:fence was 2548 created, a compatible set of callbacks must: be provided here 2549 * [[VUID-vkDestroyFence-fence-01122]] 2550 If no sname:VkAllocationCallbacks were provided when pname:fence was 2551 created, pname:pAllocator must: be `NULL` 2552endif::VKSC_VERSION_1_0[] 2553**** 2554 2555include::{generated}/validity/protos/vkDestroyFence.adoc[] 2556-- 2557 2558[open,refpage='vkGetFenceStatus',desc='Return the status of a fence',type='protos'] 2559-- 2560:refpage: vkGetFenceStatus 2561 2562To query the status of a fence from the host, call: 2563 2564include::{generated}/api/protos/vkGetFenceStatus.adoc[] 2565 2566 * pname:device is the logical device that owns the fence. 2567 * pname:fence is the handle of the fence to query. 2568 2569Upon success, fname:vkGetFenceStatus returns the status of the fence object, 2570with the following return codes: 2571 2572.Fence Object Status Codes 2573[width="80%",options="header"] 2574|==== 2575| Status | Meaning 2576| ename:VK_SUCCESS | The fence specified by pname:fence is signaled. 2577| ename:VK_NOT_READY | The fence specified by pname:fence is unsignaled. 2578| ename:VK_ERROR_DEVICE_LOST | The device has been lost. See <<devsandqueues-lost-device,Lost Device>>. 2579|==== 2580 2581If a <<devsandqueues-submission, queue submission>> command is pending 2582execution, then the value returned by this command may: immediately be out 2583of date. 2584 2585If the device has been lost (see <<devsandqueues-lost-device,Lost Device>>), 2586fname:vkGetFenceStatus may: return any of the above status codes. 2587If the device has been lost and fname:vkGetFenceStatus is called repeatedly, 2588it will eventually return either ename:VK_SUCCESS or 2589ename:VK_ERROR_DEVICE_LOST. 2590 2591include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 2592 2593include::{generated}/validity/protos/vkGetFenceStatus.adoc[] 2594-- 2595 2596[[synchronization-fences-unsignaling]] 2597[open,refpage='vkResetFences',desc='Resets one or more fence objects',type='protos'] 2598-- 2599To set the state of fences to unsignaled from the host, call: 2600 2601include::{generated}/api/protos/vkResetFences.adoc[] 2602 2603 * pname:device is the logical device that owns the fences. 2604 * pname:fenceCount is the number of fences to reset. 2605 * pname:pFences is a pointer to an array of fence handles to reset. 2606 2607ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] 2608 2609If any member of pname:pFences currently has its 2610<<synchronization-fences-importing, payload imported>> with temporary 2611permanence, that fence's prior permanent payload is first restored. 2612The remaining operations described therefore operate on the restored 2613payload. 2614 2615endif::VK_VERSION_1_1,VK_KHR_external_fence[] 2616 2617When flink:vkResetFences is executed on the host, it defines a _fence 2618unsignal operation_ for each fence, which resets the fence to the unsignaled 2619state. 2620 2621If any member of pname:pFences is already in the unsignaled state when 2622flink:vkResetFences is executed, then flink:vkResetFences has no effect on 2623that fence. 2624 2625.Valid Usage 2626**** 2627 * [[VUID-vkResetFences-pFences-01123]] 2628 Each element of pname:pFences must: not be currently associated with any 2629 queue command that has not yet completed execution on that queue 2630**** 2631 2632include::{generated}/validity/protos/vkResetFences.adoc[] 2633-- 2634 2635[[synchronization-fences-signaling]] 2636When a fence is submitted to a queue as part of a 2637<<devsandqueues-submission, queue submission>> command, it defines a memory 2638dependency on the batches that were submitted as part of that command, and 2639defines a _fence signal operation_ which sets the fence to the signaled 2640state. 2641 2642The first <<synchronization-dependencies-scopes, synchronization scope>> 2643includes every batch submitted in the same <<devsandqueues-submission, queue 2644submission>> command. 2645Fence signal operations that are defined by flink:vkQueueSubmit 2646ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] 2647additionally include in the first synchronization scope all commands that 2648occur earlier in <<synchronization-submission-order,submission order>>. 2649Fence signal operations that are defined by flink:vkQueueSubmit 2650ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] 2651ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] 2652additionally include in the first synchronization scope any semaphore and 2653fence signal operations that occur earlier in 2654<<synchronization-signal-operation-order,signal operation order>>. 2655 2656The second <<synchronization-dependencies-scopes, synchronization scope>> 2657only includes the fence signal operation. 2658 2659The first <<synchronization-dependencies-access-scopes, access scope>> 2660includes all memory access performed by the device. 2661 2662The second <<synchronization-dependencies-access-scopes, access scope>> is 2663empty. 2664 2665[open,refpage='vkWaitForFences',desc='Wait for one or more fences to become signaled',type='protos'] 2666-- 2667:refpage: vkWaitForFences 2668 2669To wait for one or more fences to enter the signaled state on the host, 2670call: 2671 2672include::{generated}/api/protos/vkWaitForFences.adoc[] 2673 2674 * pname:device is the logical device that owns the fences. 2675 * pname:fenceCount is the number of fences to wait on. 2676 * pname:pFences is a pointer to an array of pname:fenceCount fence 2677 handles. 2678 * pname:waitAll is the condition that must: be satisfied to successfully 2679 unblock the wait. 2680 If pname:waitAll is ename:VK_TRUE, then the condition is that all fences 2681 in pname:pFences are signaled. 2682 Otherwise, the condition is that at least one fence in pname:pFences is 2683 signaled. 2684 * pname:timeout is the timeout period in units of nanoseconds. 2685 pname:timeout is adjusted to the closest value allowed by the 2686 implementation-dependent timeout accuracy, which may: be substantially 2687 longer than one nanosecond, and may: be longer than the requested 2688 period. 2689 2690If the condition is satisfied when fname:vkWaitForFences is called, then 2691fname:vkWaitForFences returns immediately. 2692If the condition is not satisfied at the time fname:vkWaitForFences is 2693called, then fname:vkWaitForFences will block and wait until the condition 2694is satisfied or the pname:timeout has expired, whichever is sooner. 2695 2696If pname:timeout is zero, then fname:vkWaitForFences does not wait, but 2697simply returns the current state of the fences. 2698ename:VK_TIMEOUT will be returned in this case if the condition is not 2699satisfied, even though no actual wait was performed. 2700 2701If the condition is satisfied before the pname:timeout has expired, 2702fname:vkWaitForFences returns ename:VK_SUCCESS. 2703Otherwise, fname:vkWaitForFences returns ename:VK_TIMEOUT after the 2704pname:timeout has expired. 2705 2706If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before 2707the timeout has expired, fname:vkWaitForFences must: return in finite time 2708with either ename:VK_SUCCESS or ename:VK_ERROR_DEVICE_LOST. 2709 2710[NOTE] 2711.Note 2712==== 2713While we guarantee that fname:vkWaitForFences must: return in finite time, 2714no guarantees are made that it returns immediately upon device loss. 2715However, the client can reasonably expect that the delay will be on the 2716order of seconds and that calling fname:vkWaitForFences will not result in a 2717permanently (or seemingly permanently) dead process. 2718==== 2719 2720include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 2721 2722include::{generated}/validity/protos/vkWaitForFences.adoc[] 2723-- 2724 2725[[synchronization-fences-waiting]] 2726An execution dependency is defined by waiting for a fence to become 2727signaled, either via flink:vkWaitForFences or by polling on 2728flink:vkGetFenceStatus. 2729 2730The first <<synchronization-dependencies-scopes, synchronization scope>> 2731includes only the fence signal operation. 2732 2733The second <<synchronization-dependencies-scopes, synchronization scope>> 2734includes the host operations of flink:vkWaitForFences or 2735flink:vkGetFenceStatus indicating that the fence has become signaled. 2736 2737[NOTE] 2738.Note 2739==== 2740Signaling a fence and waiting on the host does not guarantee that the 2741results of memory accesses will be visible to the host, as the access scope 2742of a memory dependency defined by a fence only includes device access. 2743A <<synchronization-memory-barriers, memory barrier>> or other memory 2744dependency must: be used to guarantee this. 2745See the description of <<synchronization-host-access-types, host access 2746types>> for more information. 2747==== 2748 2749ifdef::VK_EXT_display_control[] 2750include::{chapters}/VK_EXT_display_control/fence_events.adoc[] 2751endif::VK_EXT_display_control[] 2752 2753 2754ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] 2755[[synchronization-fences-importing]] 2756=== Importing Fence Payloads 2757 2758Applications can: import a fence payload into an existing fence using an 2759external fence handle. 2760The effects of the import operation will be either temporary or permanent, 2761as specified by the application. 2762If the import is temporary, the fence will be _restored_ to its permanent 2763state the next time that fence is passed to flink:vkResetFences. 2764 2765[NOTE] 2766.Note 2767==== 2768Restoring a fence to its prior permanent payload is a distinct operation 2769from resetting a fence payload. 2770See flink:vkResetFences for more detail. 2771==== 2772 2773Performing a subsequent temporary import on a fence before resetting it has 2774no effect on this requirement; the next unsignal of the fence must: still 2775restore its last permanent state. 2776A permanent payload import behaves as if the target fence was destroyed, and 2777a new fence was created with the same handle but the imported payload. 2778Because importing a fence payload temporarily or permanently detaches the 2779existing payload from a fence, similar usage restrictions to those applied 2780to fname:vkDestroyFence are applied to any command that imports a fence 2781payload. 2782Which of these import types is used is referred to as the import operation's 2783_permanence_. 2784Each handle type supports either one or both types of permanence. 2785 2786The implementation must: perform the import operation by either referencing 2787or copying the payload referred to by the specified external fence handle, 2788depending on the handle's type. 2789The import method used is referred to as the handle type's _transference_. 2790When using handle types with reference transference, importing a payload to 2791a fence adds the fence to the set of all fences sharing that payload. 2792This set includes the fence from which the payload was exported. 2793Fence signaling, waiting, and resetting operations performed on any fence in 2794the set must: behave as if the set were a single fence. 2795Importing a payload using handle types with copy transference creates a 2796duplicate copy of the payload at the time of import, but makes no further 2797reference to it. 2798Fence signaling, waiting, and resetting operations performed on the target 2799of copy imports must: not affect any other fence or payload. 2800 2801Export operations have the same transference as the specified handle type's 2802import operations. 2803Additionally, exporting a fence payload to a handle with copy transference 2804has the same side effects on the source fence's payload as executing a fence 2805reset operation. 2806If the fence was using a temporarily imported payload, the fence's prior 2807permanent payload will be restored. 2808 2809ifdef::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] 2810[NOTE] 2811.Note 2812==== 2813The 2814ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[tables] 2815ifndef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[table] 2816ifdef::VK_KHR_external_fence_win32[] 2817<<synchronization-fence-handletypes-win32,Handle Types Supported by 2818sname:VkImportFenceWin32HandleInfoKHR>> 2819endif::VK_KHR_external_fence_win32[] 2820ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[and] 2821ifdef::VK_KHR_external_fence_fd[] 2822<<synchronization-fence-handletypes-fd,Handle Types Supported by 2823sname:VkImportFenceFdInfoKHR>> 2824endif::VK_KHR_external_fence_fd[] 2825ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[define] 2826ifndef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[defines] 2827the permanence and transference of each handle type. 2828==== 2829endif::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] 2830 2831<<fundamentals-threadingbehavior,External synchronization>> allows 2832implementations to modify an object's internal state, i.e. payload, without 2833internal synchronization. 2834However, for fences sharing a payload across processes, satisfying the 2835external synchronization requirements of sname:VkFence parameters as if all 2836fences in the set were the same object is sometimes infeasible. 2837Satisfying valid usage constraints on the state of a fence would similarly 2838require impractical coordination or levels of trust between processes. 2839Therefore, these constraints only apply to a specific fence handle, not to 2840its payload. 2841For distinct fence objects which share a payload: 2842 2843 * If multiple commands which queue a signal operation, or which unsignal a 2844 fence, are called concurrently, behavior will be as if the commands were 2845 called in an arbitrary sequential order. 2846 * If a queue submission command is called with a fence that is sharing a 2847 payload, and the payload is already associated with another queue 2848 command that has not yet completed execution, either one or both of the 2849 commands will cause the fence to become signaled when they complete 2850 execution. 2851 * If a fence payload is reset while it is associated with a queue command 2852 that has not yet completed execution, the payload will become 2853 unsignaled, but may: become signaled again when the command completes 2854 execution. 2855 * In the preceding cases, any of the devices associated with the fences 2856 sharing the payload may: be lost, or any of the queue submission or 2857 fence reset commands may: return ename:VK_ERROR_INITIALIZATION_FAILED. 2858 2859Other than these non-deterministic results, behavior is well defined. 2860In particular: 2861 2862 * The implementation must: not crash or enter an internally inconsistent 2863 state where future valid Vulkan commands might cause undefined: results, 2864 * Timeouts on future wait commands on fences sharing the payload must: be 2865 effective. 2866 2867[NOTE] 2868.Note 2869==== 2870These rules allow processes to synchronize access to shared memory without 2871trusting each other. 2872However, such processes must still be cautious not to use the shared fence 2873for more than synchronizing access to the shared memory. 2874For example, a process should not use a fence with shared payload to tell 2875when commands it submitted to a queue have completed and objects used by 2876those commands may be destroyed, since the other process can accidentally or 2877maliciously cause the fence to signal before the commands actually complete. 2878==== 2879 2880When a fence is using an imported payload, its 2881slink:VkExportFenceCreateInfo::pname:handleTypes value is specified when 2882creating the fence from which the payload was exported, rather than 2883specified when creating the fence. 2884Additionally, 2885slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes 2886restricts which handle types can: be exported from such a fence based on the 2887specific handle type used to import the current payload. 2888ifdef::VK_KHR_swapchain[] 2889Passing a fence to flink:vkAcquireNextImageKHR is equivalent to temporarily 2890importing a fence payload to that fence. 2891 2892[NOTE] 2893.Note 2894==== 2895Because the exportable handle types of an imported fence correspond to its 2896current imported payload, and flink:vkAcquireNextImageKHR behaves the same 2897as a temporary import operation for which the source fence is opaque to the 2898application, applications have no way of determining whether any external 2899handle types can: be exported from a fence in this state. 2900Therefore, applications must: not attempt to export handles from fences 2901using a temporarily imported payload from flink:vkAcquireNextImageKHR. 2902==== 2903endif::VK_KHR_swapchain[] 2904 2905When importing a fence payload, it is the responsibility of the application 2906to ensure the external handles meet all valid usage requirements. 2907However, implementations must: perform sufficient validation of external 2908handles to ensure that the operation results in a valid fence which will not 2909cause program termination, device loss, queue stalls, host thread stalls, or 2910corruption of other resources when used as allowed according to its import 2911parameters. 2912If the external handle provided does not meet these requirements, the 2913implementation must: fail the fence payload import operation with the error 2914code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 2915endif::VK_VERSION_1_1,VK_KHR_external_fence[] 2916 2917ifdef::VK_KHR_external_fence_win32[] 2918[open,refpage='vkImportFenceWin32HandleKHR',desc='Import a fence from a Windows HANDLE',type='protos'] 2919-- 2920To import a fence payload from a Windows handle, call: 2921 2922include::{generated}/api/protos/vkImportFenceWin32HandleKHR.adoc[] 2923 2924 * pname:device is the logical device that created the fence. 2925 * pname:pImportFenceWin32HandleInfo is a pointer to a 2926 slink:VkImportFenceWin32HandleInfoKHR structure specifying the fence and 2927 import parameters. 2928 2929Importing a fence payload from Windows handles does not transfer ownership 2930of the handle to the Vulkan implementation. 2931For handle types defined as NT handles, the application must: release 2932ownership using the code:CloseHandle system call when the handle is no 2933longer needed. 2934 2935Applications can: import the same fence payload into multiple instances of 2936Vulkan, into the same instance from which it was exported, and multiple 2937times into a given Vulkan instance. 2938 2939.Valid Usage 2940**** 2941 * [[VUID-vkImportFenceWin32HandleKHR-fence-04448]] 2942 pname:fence must: not be associated with any queue command that has not 2943 yet completed execution on that queue 2944**** 2945 2946include::{generated}/validity/protos/vkImportFenceWin32HandleKHR.adoc[] 2947-- 2948 2949[open,refpage='VkImportFenceWin32HandleInfoKHR',desc='(None)',type='structs'] 2950-- 2951The sname:VkImportFenceWin32HandleInfoKHR structure is defined as: 2952 2953include::{generated}/api/structs/VkImportFenceWin32HandleInfoKHR.adoc[] 2954 2955 * pname:sType is a elink:VkStructureType value identifying this structure. 2956 * pname:pNext is `NULL` or a pointer to a structure extending this 2957 structure. 2958 * pname:fence is the fence into which the state will be imported. 2959 * pname:flags is a bitmask of elink:VkFenceImportFlagBits specifying 2960 additional parameters for the fence payload import operation. 2961 * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value 2962 specifying the type of pname:handle. 2963 * pname:handle is `NULL` or the external handle to import. 2964 * pname:name is `NULL` or a null-terminated UTF-16 string naming the 2965 underlying synchronization primitive to import. 2966 2967The handle types supported by pname:handleType are: 2968 2969[[synchronization-fence-handletypes-win32]] 2970.Handle Types Supported by sname:VkImportFenceWin32HandleInfoKHR 2971[width="80%",options="header"] 2972|==== 2973| Handle Type | Transference | Permanence Supported 2974| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT | Reference | Temporary,Permanent 2975| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | Reference | Temporary,Permanent 2976|==== 2977 2978.Valid Usage 2979**** 2980 * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457]] 2981 pname:handleType must: be a value included in the 2982 <<synchronization-fence-handletypes-win32, Handle Types Supported by 2983 sname:VkImportFenceWin32HandleInfoKHR>> table 2984 * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01459]] 2985 If pname:handleType is not 2986 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, pname:name must: 2987 be `NULL` 2988 * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01460]] 2989 If pname:handle is `NULL`, pname:name must: name a valid synchronization 2990 primitive of the type specified by pname:handleType 2991 * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01461]] 2992 If pname:name is `NULL`, pname:handle must: be a valid handle of the 2993 type specified by pname:handleType 2994 * [[VUID-VkImportFenceWin32HandleInfoKHR-handle-01462]] 2995 If pname:handle is not `NULL`, pname:name must: be `NULL` 2996 * [[VUID-VkImportFenceWin32HandleInfoKHR-handle-01539]] 2997 If pname:handle is not `NULL`, it must: obey any requirements listed for 2998 pname:handleType in <<external-fence-handle-types-compatibility,external 2999 fence handle types compatibility>> 3000 * [[VUID-VkImportFenceWin32HandleInfoKHR-name-01540]] 3001 If pname:name is not `NULL`, it must: obey any requirements listed for 3002 pname:handleType in <<external-fence-handle-types-compatibility,external 3003 fence handle types compatibility>> 3004**** 3005 3006include::{generated}/validity/structs/VkImportFenceWin32HandleInfoKHR.adoc[] 3007-- 3008endif::VK_KHR_external_fence_win32[] 3009 3010ifdef::VK_KHR_external_fence_fd[] 3011[open,refpage='vkImportFenceFdKHR',desc='Import a fence from a POSIX file descriptor',type='protos'] 3012-- 3013:refpage: vkImportFenceFdKHR 3014 3015To import a fence payload from a POSIX file descriptor, call: 3016 3017include::{generated}/api/protos/vkImportFenceFdKHR.adoc[] 3018 3019 * pname:device is the logical device that created the fence. 3020 * pname:pImportFenceFdInfo is a pointer to a slink:VkImportFenceFdInfoKHR 3021 structure specifying the fence and import parameters. 3022 3023Importing a fence payload from a file descriptor transfers ownership of the 3024file descriptor from the application to the Vulkan implementation. 3025The application must: not perform any operations on the file descriptor 3026after a successful import. 3027 3028Applications can: import the same fence payload into multiple instances of 3029Vulkan, into the same instance from which it was exported, and multiple 3030times into a given Vulkan instance. 3031 3032include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 3033 3034.Valid Usage 3035**** 3036 * [[VUID-vkImportFenceFdKHR-fence-01463]] 3037 pname:fence must: not be associated with any queue command that has not 3038 yet completed execution on that queue 3039**** 3040 3041include::{generated}/validity/protos/vkImportFenceFdKHR.adoc[] 3042-- 3043 3044[open,refpage='VkImportFenceFdInfoKHR',desc='(None)',type='structs'] 3045-- 3046The sname:VkImportFenceFdInfoKHR structure is defined as: 3047 3048include::{generated}/api/structs/VkImportFenceFdInfoKHR.adoc[] 3049 3050 * pname:sType is a elink:VkStructureType value identifying this structure. 3051 * pname:pNext is `NULL` or a pointer to a structure extending this 3052 structure. 3053 * pname:fence is the fence into which the payload will be imported. 3054 * pname:flags is a bitmask of elink:VkFenceImportFlagBits specifying 3055 additional parameters for the fence payload import operation. 3056 * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value 3057 specifying the type of pname:fd. 3058 * pname:fd is the external handle to import. 3059 3060The handle types supported by pname:handleType are: 3061 3062[[synchronization-fence-handletypes-fd]] 3063.Handle Types Supported by sname:VkImportFenceFdInfoKHR 3064[width="80%",options="header"] 3065|==== 3066| Handle Type | Transference | Permanence Supported 3067| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT | Reference | Temporary,Permanent 3068| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT | Copy | Temporary 3069|==== 3070 3071.Valid Usage 3072**** 3073 * [[VUID-VkImportFenceFdInfoKHR-handleType-01464]] 3074 pname:handleType must: be a value included in the 3075 <<synchronization-fence-handletypes-fd, Handle Types Supported by 3076 sname:VkImportFenceFdInfoKHR>> table 3077 * [[VUID-VkImportFenceFdInfoKHR-fd-01541]] 3078 pname:fd must: obey any requirements listed for pname:handleType in 3079 <<external-fence-handle-types-compatibility,external fence handle types 3080 compatibility>> 3081 * [[VUID-VkImportFenceFdInfoKHR-handleType-07306]] 3082 If pname:handleType refers to a handle type with copy payload 3083 transference semantics, pname:flags must: contain 3084 ename:VK_FENCE_IMPORT_TEMPORARY_BIT 3085**** 3086 3087If pname:handleType is ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT, the 3088special value `-1` for pname:fd is treated like a valid sync file descriptor 3089referring to an object that has already signaled. 3090The import operation will succeed and the sname:VkFence will have a 3091temporarily imported payload as if a valid file descriptor had been 3092provided. 3093 3094[NOTE] 3095.Note 3096==== 3097This special behavior for importing an invalid sync file descriptor allows 3098easier interoperability with other system APIs which use the convention that 3099an invalid sync file descriptor represents work that has already completed 3100and does not need to be waited for. 3101It is consistent with the option for implementations to return a `-1` file 3102descriptor when exporting a ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT 3103from a sname:VkFence which is signaled. 3104==== 3105 3106include::{generated}/validity/structs/VkImportFenceFdInfoKHR.adoc[] 3107-- 3108endif::VK_KHR_external_fence_fd[] 3109 3110ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 3111[open,refpage='vkImportFenceSciSyncFenceNV',desc='Import a fence from a stext:NvSciSyncFence handle',type='protos'] 3112-- 3113To import a fence payload from a stext:NvSciSyncFence handle, call: 3114 3115include::{generated}/api/protos/vkImportFenceSciSyncFenceNV.adoc[] 3116 3117 * pname:device is the logical device that created the fence. 3118 * pname:pImportFenceSciSyncInfo is a pointer to a 3119 slink:VkImportFenceSciSyncInfoNV structure containing parameters of the 3120 import operation 3121 3122Importing a fence payload from stext:NvSciSyncFence does not transfer 3123ownership of the handle to the Vulkan implementation. 3124Vulkan will make a copy of stext:NvSciSyncFence when importing it. 3125The application must: release ownership using the NvSciSync API when the 3126handle is no longer needed. 3127 3128.Valid Usage 3129**** 3130 * [[VUID-vkImportFenceSciSyncFenceNV-sciSyncImport-05140]] 3131 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and 3132 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence, or 3133 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncImport 3134 and slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence 3135 must: be enabled 3136 * [[VUID-vkImportFenceSciSyncFenceNV-fence-05141]] 3137 pname:fence must: not be associated with any queue command that has not 3138 yet completed execution on that queue 3139 * [[VUID-vkImportFenceSciSyncFenceNV-pImportFenceSciSyncInfo-05142]] 3140 pname:pImportFenceSciSyncInfo->handleType must: be 3141 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV 3142**** 3143 3144include::{generated}/validity/protos/vkImportFenceSciSyncFenceNV.adoc[] 3145-- 3146 3147[open,refpage='vkImportFenceSciSyncObjNV',desc='Import a fence from a stext:NvSciSyncObj handle',type='protos'] 3148-- 3149To import a fence payload from a stext:NvSciSyncObj handle, call: 3150 3151include::{generated}/api/protos/vkImportFenceSciSyncObjNV.adoc[] 3152 3153 * pname:device is the logical device that created the fence. 3154 * pname:pImportFenceSciSyncInfo is a pointer to a 3155 slink:VkImportFenceSciSyncInfoNV structure containing parameters of the 3156 import operation 3157 3158Importing a fence payload from a stext:NvSciSyncObj does not transfer 3159ownership of the handle to the Vulkan implementation. 3160Vulkan will make a new reference to the stext:NvSciSyncObj object when 3161importing it. 3162The application must: release ownership using the NvSciSync API when the 3163handle is no longer needed. 3164 3165The application must: not import the same stext:NvSciSyncObj with signaler 3166access permissions into multiple instances of slink:VkFence, and must: not 3167import into the same instance from which it was exported. 3168 3169.Valid Usage 3170**** 3171 * [[VUID-vkImportFenceSciSyncObjNV-sciSyncImport-05143]] 3172 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and 3173 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence, or 3174 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncImport 3175 and slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence 3176 must: be enabled 3177 * [[VUID-vkImportFenceSciSyncObjNV-fence-05144]] 3178 pname:fence must: not be associated with any queue command that has not 3179 yet completed execution on that queue 3180 * [[VUID-vkImportFenceSciSyncObjNV-pImportFenceSciSyncInfo-05145]] 3181 pname:pImportFenceSciSyncInfo->handleType must: be 3182 ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV 3183**** 3184 3185include::{generated}/validity/protos/vkImportFenceSciSyncObjNV.adoc[] 3186-- 3187 3188 3189[open,refpage='VkImportFenceSciSyncInfoNV',desc='Structure specifying attributes for importing a SciSync handle as a fence',type='structs'] 3190-- 3191The sname:VkImportFenceSciSyncInfoNV structure is defined as: 3192 3193include::{generated}/api/structs/VkImportFenceSciSyncInfoNV.adoc[] 3194 3195 * pname:sType is a elink:VkStructureType value identifying this structure. 3196 * pname:pNext is `NULL` or a pointer to a structure extending this 3197 structure. 3198 * pname:fence is the fence into which the state will be imported. 3199 * pname:handleType specifies the type of stext:handle. 3200 * pname:handle is the external handle to import. 3201 3202The handle types supported by pname:handleType are: 3203 3204[[synchronization-fence-handletypes-sci-sync]] 3205.Handle Types Supported by sname:VkImportFenceSciSyncInfoNV 3206[width="80%",options="header"] 3207|==== 3208| Handle Type | Transference | Permanence Supported 3209| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV | Reference | Permanent 3210| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV | Copy | Temporary 3211|==== 3212 3213include::{generated}/validity/structs/VkImportFenceSciSyncInfoNV.adoc[] 3214-- 3215endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 3216 3217ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] 3218ifdef::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] 3219[open,refpage='VkFenceImportFlagBits',desc='Bitmask specifying additional parameters of fence payload import',type='enums'] 3220-- 3221Bits which can: be set in 3222 3223ifdef::VK_KHR_external_fence_win32[] 3224 * slink:VkImportFenceWin32HandleInfoKHR::pname:flags 3225endif::VK_KHR_external_fence_win32[] 3226ifdef::VK_KHR_external_fence_fd[] 3227 * slink:VkImportFenceFdInfoKHR::pname:flags 3228endif::VK_KHR_external_fence_fd[] 3229 3230specifying additional parameters of a fence import operation are: 3231 3232include::{generated}/api/enums/VkFenceImportFlagBits.adoc[] 3233 3234ifdef::VK_KHR_external_fence[] 3235or the equivalent 3236 3237include::{generated}/api/enums/VkFenceImportFlagBitsKHR.adoc[] 3238endif::VK_KHR_external_fence[] 3239 3240 * ename:VK_FENCE_IMPORT_TEMPORARY_BIT specifies that the fence payload 3241 will be imported only temporarily, as described in 3242 <<synchronization-fences-importing,Importing Fence Payloads>>, 3243 regardless of the permanence of pname:handleType. 3244-- 3245 3246[open,refpage='VkFenceImportFlags',desc='Bitmask of VkFenceImportFlagBits',type='flags'] 3247-- 3248include::{generated}/api/flags/VkFenceImportFlags.adoc[] 3249 3250ifdef::VK_KHR_external_fence[] 3251or the equivalent 3252 3253include::{generated}/api/flags/VkFenceImportFlagsKHR.adoc[] 3254endif::VK_KHR_external_fence[] 3255 3256tname:VkFenceImportFlags is a bitmask type for setting a mask of zero or 3257more elink:VkFenceImportFlagBits. 3258-- 3259endif::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] 3260endif::VK_VERSION_1_1,VK_KHR_external_fence[] 3261 3262 3263[[synchronization-semaphores]] 3264== Semaphores 3265 3266[open,refpage='VkSemaphore',desc='Opaque handle to a semaphore object',type='handles'] 3267-- 3268Semaphores are a synchronization primitive that can: be used to insert a 3269dependency 3270ifndef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3271between queue operations. 3272Semaphores have two states - signaled and unsignaled. 3273endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3274ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3275between queue operations or between a queue operation and the host. 3276<<glossary, Binary semaphores>> have two states - signaled and unsignaled. 3277<<glossary, Timeline semaphores>> have a strictly increasing 64-bit unsigned 3278integer payload and are signaled with respect to a particular reference 3279value. 3280endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3281A semaphore can: be signaled after execution of a queue operation is 3282completed, and a queue operation can: wait for a semaphore to become 3283signaled before it begins execution. 3284ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3285A timeline semaphore can: additionally be signaled from the host with the 3286flink:vkSignalSemaphore command and waited on from the host with the 3287flink:vkWaitSemaphores command. 3288endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3289 3290ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 3291[[synchronization-semaphores-payloads]] 3292The internal data of a semaphore may: include a reference to any resources 3293and pending work associated with signal or unsignal operations performed on 3294that semaphore object, collectively referred to as the semaphore's 3295_payload_. 3296Mechanisms to import and export that internal data to and from semaphores 3297are provided <<VkExportSemaphoreCreateInfo, below>>. 3298These mechanisms indirectly enable applications to share semaphore state 3299between two or more semaphores and other synchronization primitives across 3300process and API boundaries. 3301 3302endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 3303 3304Semaphores are represented by sname:VkSemaphore handles: 3305 3306include::{generated}/api/handles/VkSemaphore.adoc[] 3307-- 3308 3309[open,refpage='vkCreateSemaphore',desc='Create a new queue semaphore object',type='protos'] 3310-- 3311:refpage: vkCreateSemaphore 3312:objectnameplural: semaphores 3313:objectnamecamelcase: semaphore 3314:objectcount: 1 3315 3316To create a semaphore, call: 3317 3318include::{generated}/api/protos/vkCreateSemaphore.adoc[] 3319 3320 * pname:device is the logical device that creates the semaphore. 3321 * pname:pCreateInfo is a pointer to a slink:VkSemaphoreCreateInfo 3322 structure containing information about how the semaphore is to be 3323 created. 3324 * pname:pAllocator controls host memory allocation as described in the 3325 <<memory-allocation, Memory Allocation>> chapter. 3326 * pname:pSemaphore is a pointer to a handle in which the resulting 3327 semaphore object is returned. 3328 3329ifndef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3330This command creates a _binary semaphore_ that has a boolean payload 3331indicating whether the semaphore is currently signaled or unsignaled. 3332When created, the semaphore is in the unsignaled state. 3333endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3334 3335include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 3336 3337ifdef::VKSC_VERSION_1_0[] 3338.Valid Usage 3339**** 3340include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] 3341**** 3342endif::VKSC_VERSION_1_0[] 3343 3344include::{generated}/validity/protos/vkCreateSemaphore.adoc[] 3345-- 3346 3347[open,refpage='VkSemaphoreCreateInfo',desc='Structure specifying parameters of a newly created semaphore',type='structs'] 3348-- 3349The sname:VkSemaphoreCreateInfo structure is defined as: 3350 3351include::{generated}/api/structs/VkSemaphoreCreateInfo.adoc[] 3352 3353 * pname:sType is a elink:VkStructureType value identifying this structure. 3354 * pname:pNext is `NULL` or a pointer to a structure extending this 3355 structure. 3356 * pname:flags is reserved for future use. 3357 3358ifdef::VK_EXT_metal_objects,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 3359.Valid Usage 3360**** 3361ifdef::VK_EXT_metal_objects[] 3362 * [[VUID-VkSemaphoreCreateInfo-pNext-06789]] 3363 If the pname:pNext chain includes a 3364 slink:VkExportMetalObjectCreateInfoEXT structure, its 3365 pname:exportObjectType member must: be 3366 ename:VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT 3367endif::VK_EXT_metal_objects[] 3368ifdef::VK_NV_external_sci_sync[] 3369 * [[VUID-VkSemaphoreCreateInfo-pNext-05118]] 3370 If the pname:pNext chain includes slink:VkExportSemaphoreSciSyncInfoNV, 3371 it must: also include slink:VkSemaphoreTypeCreateInfo with a 3372 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType of 3373 ename:VK_SEMAPHORE_TYPE_TIMELINE 3374endif::VK_NV_external_sci_sync[] 3375ifdef::VK_NV_external_sci_sync2[] 3376 * [[VUID-VkSemaphoreCreateInfo-pNext-05146]] 3377 If the pname:pNext chain includes slink:VkSemaphoreSciSyncCreateInfoNV, 3378 it must: also include slink:VkSemaphoreTypeCreateInfo with a 3379 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType of 3380 ename:VK_SEMAPHORE_TYPE_TIMELINE 3381endif::VK_NV_external_sci_sync2[] 3382**** 3383endif::VK_EXT_metal_objects,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 3384 3385include::{generated}/validity/structs/VkSemaphoreCreateInfo.adoc[] 3386-- 3387 3388[open,refpage='VkSemaphoreCreateFlags',desc='Reserved for future use',type='flags'] 3389-- 3390include::{generated}/api/flags/VkSemaphoreCreateFlags.adoc[] 3391 3392tname:VkSemaphoreCreateFlags is a bitmask type for setting a mask, but is 3393currently reserved for future use. 3394-- 3395 3396ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3397[open,refpage='VkSemaphoreTypeCreateInfo',desc='Structure specifying the type of a newly created semaphore',type='structs',alias='VkSemaphoreTypeCreateInfoKHR'] 3398-- 3399The sname:VkSemaphoreTypeCreateInfo structure is defined as: 3400 3401include::{generated}/api/structs/VkSemaphoreTypeCreateInfo.adoc[] 3402 3403ifdef::VK_KHR_timeline_semaphore[] 3404or the equivalent 3405 3406include::{generated}/api/structs/VkSemaphoreTypeCreateInfoKHR.adoc[] 3407endif::VK_KHR_timeline_semaphore[] 3408 3409 * pname:sType is a elink:VkStructureType value identifying this structure. 3410 * pname:pNext is `NULL` or a pointer to a structure extending this 3411 structure. 3412 * pname:semaphoreType is a elink:VkSemaphoreType value specifying the type 3413 of the semaphore. 3414 * pname:initialValue is the initial payload value if pname:semaphoreType 3415 is ename:VK_SEMAPHORE_TYPE_TIMELINE. 3416 3417To create a semaphore of a specific type, add a 3418sname:VkSemaphoreTypeCreateInfo structure to the 3419slink:VkSemaphoreCreateInfo::pname:pNext chain. 3420 3421If no sname:VkSemaphoreTypeCreateInfo structure is included in the 3422pname:pNext chain of slink:VkSemaphoreCreateInfo, then the created semaphore 3423will have a default elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY. 3424 3425ifdef::VK_NV_external_sci_sync2[] 3426If slink:VkSemaphoreSciSyncCreateInfoNV structure is included in the 3427pname:pNext chain of sname:VkSemaphoreTypeCreateInfo, pname:initialValue is 3428ignored. 3429endif::VK_NV_external_sci_sync2[] 3430 3431.Valid Usage 3432**** 3433 * [[VUID-VkSemaphoreTypeCreateInfo-timelineSemaphore-03252]] 3434 If the <<features-timelineSemaphore, pname:timelineSemaphore>> feature 3435 is not enabled, pname:semaphoreType must: not equal 3436 ename:VK_SEMAPHORE_TYPE_TIMELINE 3437 * [[VUID-VkSemaphoreTypeCreateInfo-semaphoreType-03279]] 3438 If pname:semaphoreType is ename:VK_SEMAPHORE_TYPE_BINARY, 3439 pname:initialValue must: be zero 3440ifdef::VK_NV_external_sci_sync[] 3441 * [[VUID-VkSemaphoreTypeCreateInfo-pNext-05119]] 3442 If the pname:pNext chain includes slink:VkExportSemaphoreSciSyncInfoNV, 3443 pname:initialValue must: be zero. 3444endif::VK_NV_external_sci_sync[] 3445**** 3446 3447include::{generated}/validity/structs/VkSemaphoreTypeCreateInfo.adoc[] 3448-- 3449 3450[open,refpage='VkSemaphoreType',desc='Specifies the type of a semaphore object',type='enums',alias='VkSemaphoreTypeKHR'] 3451-- 3452Possible values of slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType, 3453specifying the type of a semaphore, are: 3454 3455include::{generated}/api/enums/VkSemaphoreType.adoc[] 3456 3457ifdef::VK_KHR_timeline_semaphore[] 3458or the equivalent 3459 3460include::{generated}/api/enums/VkSemaphoreTypeKHR.adoc[] 3461endif::VK_KHR_timeline_semaphore[] 3462 3463 * ename:VK_SEMAPHORE_TYPE_BINARY specifies a _binary semaphore_ type that 3464 has a boolean payload indicating whether the semaphore is currently 3465 signaled or unsignaled. 3466 When created, the semaphore is in the unsignaled state. 3467 * ename:VK_SEMAPHORE_TYPE_TIMELINE specifies a _timeline semaphore_ type 3468 that has a strictly increasing 64-bit unsigned integer payload 3469 indicating whether the semaphore is signaled with respect to a 3470 particular reference value. 3471 When created, the semaphore payload has the value given by the 3472 pname:initialValue field of slink:VkSemaphoreTypeCreateInfo. 3473-- 3474endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3475 3476ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 3477[open,refpage='VkExportSemaphoreCreateInfo',desc='Structure specifying handle types that can be exported from a semaphore',type='structs'] 3478-- 3479To create a semaphore whose payload can: be exported to external handles, 3480add a slink:VkExportSemaphoreCreateInfo structure to the pname:pNext chain 3481of the slink:VkSemaphoreCreateInfo structure. 3482The sname:VkExportSemaphoreCreateInfo structure is defined as: 3483 3484include::{generated}/api/structs/VkExportSemaphoreCreateInfo.adoc[] 3485 3486ifdef::VK_KHR_external_semaphore[] 3487or the equivalent 3488 3489include::{generated}/api/structs/VkExportSemaphoreCreateInfoKHR.adoc[] 3490endif::VK_KHR_external_semaphore[] 3491 3492 * pname:sType is a elink:VkStructureType value identifying this structure. 3493 * pname:pNext is `NULL` or a pointer to a structure extending this 3494 structure. 3495 * pname:handleTypes is a bitmask of 3496 elink:VkExternalSemaphoreHandleTypeFlagBits specifying one or more 3497 semaphore handle types the application can: export from the resulting 3498 semaphore. 3499 The application can: request multiple handle types for the same 3500 semaphore. 3501 3502.Valid Usage 3503**** 3504 * [[VUID-VkExportSemaphoreCreateInfo-handleTypes-01124]] 3505 The bits in pname:handleTypes must: be supported and compatible, as 3506 reported by slink:VkExternalSemaphoreProperties 3507ifdef::VK_NV_external_sci_sync[] 3508 * [[VUID-VkExportSemaphoreCreateInfo-pNext-05120]] 3509 If the pname:pNext chain includes a sname:VkExportSemaphoreSciSyncInfoNV 3510 structure, 3511 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemapore 3512 and slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncExport 3513 must: be enabled 3514endif::VK_NV_external_sci_sync[] 3515**** 3516 3517include::{generated}/validity/structs/VkExportSemaphoreCreateInfo.adoc[] 3518-- 3519endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 3520 3521ifdef::VK_KHR_external_semaphore_win32[] 3522[open,refpage='VkExportSemaphoreWin32HandleInfoKHR',desc='Structure specifying additional attributes of Windows handles exported from a semaphore',type='structs'] 3523-- 3524To specify additional attributes of NT handles exported from a semaphore, 3525add a sname:VkExportSemaphoreWin32HandleInfoKHR structure to the pname:pNext 3526chain of the slink:VkSemaphoreCreateInfo structure. 3527The sname:VkExportSemaphoreWin32HandleInfoKHR structure is defined as: 3528 3529include::{generated}/api/structs/VkExportSemaphoreWin32HandleInfoKHR.adoc[] 3530 3531 * pname:sType is a elink:VkStructureType value identifying this structure. 3532 * pname:pNext is `NULL` or a pointer to a structure extending this 3533 structure. 3534 * pname:pAttributes is a pointer to a Windows code:SECURITY_ATTRIBUTES 3535 structure specifying security attributes of the handle. 3536 * pname:dwAccess is a code:DWORD specifying access rights of the handle. 3537 * pname:name is a null-terminated UTF-16 string to associate with the 3538 underlying synchronization primitive referenced by NT handles exported 3539 from the created semaphore. 3540 3541If slink:VkExportSemaphoreCreateInfo is not included in the same pname:pNext 3542chain, this structure is ignored. 3543 3544If slink:VkExportSemaphoreCreateInfo is included in the pname:pNext chain of 3545slink:VkSemaphoreCreateInfo with a Windows pname:handleType, but either 3546sname:VkExportSemaphoreWin32HandleInfoKHR is not included in the pname:pNext 3547chain, or it is included but pname:pAttributes is set to `NULL`, default 3548security descriptor values will be used, and child processes created by the 3549application will not inherit the handle, as described in the MSDN 3550documentation for "`Synchronization Object Security and Access Rights`"^1^. 3551Further, if the structure is not present, the access rights used depend on 3552the handle type. 3553 3554For handles of the following types: 3555 3556ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT 3557 3558The implementation must: ensure the access rights allow both signal and wait 3559operations on the semaphore. 3560 3561For handles of the following types: 3562 3563ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT 3564 3565The access rights must: be: 3566 3567code:GENERIC_ALL 3568 35691:: 3570 https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights 3571 3572.Valid Usage 3573**** 3574 * [[VUID-VkExportSemaphoreWin32HandleInfoKHR-handleTypes-01125]] 3575 If slink:VkExportSemaphoreCreateInfo::pname:handleTypes does not include 3576 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 3577 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, 3578 sname:VkExportSemaphoreWin32HandleInfoKHR must: not be included in the 3579 pname:pNext chain of slink:VkSemaphoreCreateInfo 3580**** 3581 3582include::{generated}/validity/structs/VkExportSemaphoreWin32HandleInfoKHR.adoc[] 3583-- 3584 3585[open,refpage='vkGetSemaphoreWin32HandleKHR',desc='Get a Windows HANDLE for a semaphore',type='protos'] 3586-- 3587To export a Windows handle representing the payload of a semaphore, call: 3588 3589include::{generated}/api/protos/vkGetSemaphoreWin32HandleKHR.adoc[] 3590 3591 * pname:device is the logical device that created the semaphore being 3592 exported. 3593 * pname:pGetWin32HandleInfo is a pointer to a 3594 slink:VkSemaphoreGetWin32HandleInfoKHR structure containing parameters 3595 of the export operation. 3596 * pname:pHandle will return the Windows handle representing the semaphore 3597 state. 3598 3599For handle types defined as NT handles, the handles returned by 3600fname:vkGetSemaphoreWin32HandleKHR are owned by the application. 3601To avoid leaking resources, the application must: release ownership of them 3602using the code:CloseHandle system call when they are no longer needed. 3603 3604Exporting a Windows handle from a semaphore may: have side effects depending 3605on the transference of the specified handle type, as described in 3606<<synchronization-semaphores-importing,Importing Semaphore Payloads>>. 3607 3608include::{generated}/validity/protos/vkGetSemaphoreWin32HandleKHR.adoc[] 3609-- 3610 3611[open,refpage='VkSemaphoreGetWin32HandleInfoKHR',desc='Structure describing a Win32 handle semaphore export operation',type='structs'] 3612-- 3613The sname:VkSemaphoreGetWin32HandleInfoKHR structure is defined as: 3614 3615include::{generated}/api/structs/VkSemaphoreGetWin32HandleInfoKHR.adoc[] 3616 3617 * pname:sType is a elink:VkStructureType value identifying this structure. 3618 * pname:pNext is `NULL` or a pointer to a structure extending this 3619 structure. 3620 * pname:semaphore is the semaphore from which state will be exported. 3621 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 3622 specifying the type of handle requested. 3623 3624The properties of the handle returned depend on the value of 3625pname:handleType. 3626See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the 3627properties of the defined external semaphore handle types. 3628 3629.Valid Usage 3630**** 3631 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01126]] 3632 pname:handleType must: have been included in 3633 slink:VkExportSemaphoreCreateInfo::pname:handleTypes when the 3634 pname:semaphore's current payload was created 3635 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01127]] 3636 If pname:handleType is defined as an NT handle, 3637 flink:vkGetSemaphoreWin32HandleKHR must: be called no more than once for 3638 each valid unique combination of pname:semaphore and pname:handleType 3639 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-semaphore-01128]] 3640 pname:semaphore must: not currently have its payload replaced by an 3641 imported payload as described below in 3642 <<synchronization-semaphores-importing,Importing Semaphore Payloads>> 3643 unless that imported payload's handle type was included in 3644 slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes 3645 for pname:handleType 3646 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01129]] 3647 If pname:handleType refers to a handle type with copy payload 3648 transference semantics, as defined below in 3649 <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, 3650 there must: be no queue waiting on pname:semaphore 3651 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01130]] 3652 If pname:handleType refers to a handle type with copy payload 3653 transference semantics, pname:semaphore must: be signaled, or have an 3654 associated <<synchronization-semaphores-signaling,semaphore signal 3655 operation>> pending execution 3656 * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01131]] 3657 pname:handleType must: be defined as an NT handle or a global share 3658 handle 3659**** 3660 3661include::{generated}/validity/structs/VkSemaphoreGetWin32HandleInfoKHR.adoc[] 3662-- 3663endif::VK_KHR_external_semaphore_win32[] 3664 3665 3666ifdef::VK_NV_low_latency[] 3667[open,refpage='VkQueryLowLatencySupportNV',desc='Structure used for NVIDIA Reflex Support',type='structs'] 3668-- 3669The sname:VkQueryLowLatencySupportNV structure is defined as: 3670 3671include::{generated}/api/structs/VkQueryLowLatencySupportNV.adoc[] 3672 3673This structure describes the following feature: 3674 3675 * pname:sType is a elink:VkStructureType value identifying this structure. 3676 * pname:pNext is `NULL` or a pointer to a structure extending this 3677 structure. 3678 * pname:pQueriedLowLatencyData is used for NVIDIA Reflex Support. 3679 3680include::{generated}/validity/structs/VkQueryLowLatencySupportNV.adoc[] 3681-- 3682endif::VK_NV_low_latency[] 3683 3684ifdef::VK_KHR_external_semaphore_fd[] 3685[open,refpage='vkGetSemaphoreFdKHR',desc='Get a POSIX file descriptor handle for a semaphore',type='protos'] 3686-- 3687:refpage: vkGetSemaphoreFdKHR 3688 3689To export a POSIX file descriptor representing the payload of a semaphore, 3690call: 3691 3692include::{generated}/api/protos/vkGetSemaphoreFdKHR.adoc[] 3693 3694 * pname:device is the logical device that created the semaphore being 3695 exported. 3696 * pname:pGetFdInfo is a pointer to a slink:VkSemaphoreGetFdInfoKHR 3697 structure containing parameters of the export operation. 3698 * pname:pFd will return the file descriptor representing the semaphore 3699 payload. 3700 3701Each call to fname:vkGetSemaphoreFdKHR must: create a new file descriptor 3702and transfer ownership of it to the application. 3703To avoid leaking resources, the application must: release ownership of the 3704file descriptor when it is no longer needed. 3705 3706[NOTE] 3707.Note 3708==== 3709Ownership can be released in many ways. 3710For example, the application can call code:close() on the file descriptor, 3711or transfer ownership back to Vulkan by using the file descriptor to import 3712a semaphore payload. 3713==== 3714Where supported by the operating system, the implementation must: set the 3715file descriptor to be closed automatically when an code:execve system call 3716is made. 3717 3718Exporting a file descriptor from a semaphore may: have side effects 3719depending on the transference of the specified handle type, as described in 3720<<synchronization-semaphores-importing,Importing Semaphore State>>. 3721 3722include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 3723 3724include::{generated}/validity/protos/vkGetSemaphoreFdKHR.adoc[] 3725-- 3726 3727[open,refpage='VkSemaphoreGetFdInfoKHR',desc='Structure describing a POSIX FD semaphore export operation',type='structs'] 3728-- 3729The sname:VkSemaphoreGetFdInfoKHR structure is defined as: 3730 3731include::{generated}/api/structs/VkSemaphoreGetFdInfoKHR.adoc[] 3732 3733 * pname:sType is a elink:VkStructureType value identifying this structure. 3734 * pname:pNext is `NULL` or a pointer to a structure extending this 3735 structure. 3736 * pname:semaphore is the semaphore from which state will be exported. 3737 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 3738 specifying the type of handle requested. 3739 3740The properties of the file descriptor returned depend on the value of 3741pname:handleType. 3742See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the 3743properties of the defined external semaphore handle types. 3744 3745.Valid Usage 3746**** 3747 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01132]] 3748 pname:handleType must: have been included in 3749 slink:VkExportSemaphoreCreateInfo::pname:handleTypes when 3750 pname:semaphore's current payload was created 3751 * [[VUID-VkSemaphoreGetFdInfoKHR-semaphore-01133]] 3752 pname:semaphore must: not currently have its payload replaced by an 3753 imported payload as described below in 3754 <<synchronization-semaphores-importing,Importing Semaphore Payloads>> 3755 unless that imported payload's handle type was included in 3756 slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes 3757 for pname:handleType 3758 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01134]] 3759 If pname:handleType refers to a handle type with copy payload 3760 transference semantics, as defined below in 3761 <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, 3762 there must: be no queue waiting on pname:semaphore 3763 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01135]] 3764 If pname:handleType refers to a handle type with copy payload 3765 transference semantics, pname:semaphore must: be signaled, or have an 3766 associated <<synchronization-semaphores-signaling,semaphore signal 3767 operation>> pending execution 3768 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01136]] 3769 pname:handleType must: be defined as a POSIX file descriptor handle 3770ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3771 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-03253]] 3772 If pname:handleType refers to a handle type with copy payload 3773 transference semantics, pname:semaphore must: have been created with a 3774 elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY 3775 * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-03254]] 3776 If pname:handleType refers to a handle type with copy payload 3777 transference semantics, pname:semaphore must: have an associated 3778 semaphore signal operation that has been submitted for execution and any 3779 semaphore signal operations on which it depends must: have also been 3780 submitted for execution 3781endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 3782**** 3783 3784include::{generated}/validity/structs/VkSemaphoreGetFdInfoKHR.adoc[] 3785-- 3786endif::VK_KHR_external_semaphore_fd[] 3787 3788ifdef::VK_FUCHSIA_external_semaphore[] 3789[open,refpage='vkGetSemaphoreZirconHandleFUCHSIA',desc='Get a Zircon event handle for a semaphore',type='protos'] 3790-- 3791To export a Zircon event handle representing the payload of a semaphore, 3792call: 3793 3794include::{generated}/api/protos/vkGetSemaphoreZirconHandleFUCHSIA.adoc[] 3795 3796 * pname:device is the logical device that created the semaphore being 3797 exported. 3798 * pname:pGetZirconHandleInfo is a pointer to a 3799 slink:VkSemaphoreGetZirconHandleInfoFUCHSIA structure containing 3800 parameters of the export operation. 3801 * pname:pZirconHandle will return the Zircon event handle representing the 3802 semaphore payload. 3803 3804Each call to fname:vkGetSemaphoreZirconHandleFUCHSIA must: create a Zircon 3805event handle and transfer ownership of it to the application. 3806To avoid leaking resources, the application must: release ownership of the 3807Zircon event handle when it is no longer needed. 3808 3809[NOTE] 3810.Note 3811==== 3812Ownership can be released in many ways. 3813For example, the application can call zx_handle_close() on the file 3814descriptor, or transfer ownership back to Vulkan by using the file 3815descriptor to import a semaphore payload. 3816==== 3817 3818Exporting a Zircon event handle from a semaphore may: have side effects 3819depending on the transference of the specified handle type, as described in 3820<<synchronization-semaphores-importing,Importing Semaphore State>>. 3821 3822include::{generated}/validity/protos/vkGetSemaphoreZirconHandleFUCHSIA.adoc[] 3823-- 3824 3825[open,refpage='VkSemaphoreGetZirconHandleInfoFUCHSIA',desc='Structure describing a Zircon event handle semaphore export operation',type='structs'] 3826-- 3827The sname:VkSemaphoreGetZirconHandleInfoFUCHSIA structure is defined as: 3828 3829include::{generated}/api/structs/VkSemaphoreGetZirconHandleInfoFUCHSIA.adoc[] 3830 3831 * pname:sType is a elink:VkStructureType value identifying this structure. 3832 * pname:pNext is `NULL` or a pointer to a structure extending this 3833 structure. 3834 * pname:semaphore is the semaphore from which state will be exported. 3835 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 3836 specifying the type of handle requested. 3837 3838The properties of the Zircon event handle returned depend on the value of 3839pname:handleType. 3840See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the 3841properties of the defined external semaphore handle types. 3842 3843.Valid Usage 3844**** 3845 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04758]] 3846 pname:handleType must: have been included in 3847 slink:VkExportSemaphoreCreateInfo::pname:handleTypes when 3848 pname:semaphore's current payload was created 3849 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-semaphore-04759]] 3850 pname:semaphore must: not currently have its payload replaced by an 3851 imported payload as described below in 3852 <<synchronization-semaphores-importing,Importing Semaphore Payloads>> 3853 unless that imported payload's handle type was included in 3854 slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes 3855 for pname:handleType 3856 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04760]] 3857 If pname:handleType refers to a handle type with copy payload 3858 transference semantics, as defined below in 3859 <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, 3860 there must: be no queue waiting on pname:semaphore 3861 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04761]] 3862 If pname:handleType refers to a handle type with copy payload 3863 transference semantics, pname:semaphore must: be signaled, or have an 3864 associated <<synchronization-semaphores-signaling,semaphore signal 3865 operation>> pending execution 3866 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04762]] 3867 pname:handleType must: be defined as a Zircon event handle 3868 * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-semaphore-04763]] 3869 pname:semaphore must: have been created with a elink:VkSemaphoreType of 3870 ename:VK_SEMAPHORE_TYPE_BINARY 3871**** 3872 3873include::{generated}/validity/structs/VkSemaphoreGetZirconHandleInfoFUCHSIA.adoc[] 3874-- 3875endif::VK_FUCHSIA_external_semaphore[] 3876 3877ifdef::VK_NV_external_sci_sync[] 3878[open,refpage='VkExportSemaphoreSciSyncInfoNV',desc='Structure specifying additional attributes of NvSciSync handles exported from a semaphore',type='structs'] 3879-- 3880To specify additional attributes of NvSciSync handles exported from a 3881semaphore, add a sname:VkExportSemaphoreSciSyncInfoNV structure to the 3882pname:pNext chain of the slink:VkSemaphoreCreateInfo structure. 3883The sname:VkExportSemaphoreSciSyncInfoNV structure is defined as: 3884 3885include::{generated}/api/structs/VkExportSemaphoreSciSyncInfoNV.adoc[] 3886 3887 * pname:sType is a elink:VkStructureType value identifying this structure. 3888 * pname:pNext is `NULL` or a pointer to a structure extending this 3889 structure. 3890 * pname:pAttributes is an opaque sname:NvSciSyncAttrList describing the 3891 attributes of the NvSciSync object that will be exported. 3892 3893If slink:VkExportSemaphoreCreateInfo is not present in the same pname:pNext 3894chain, this structure is ignored. 3895If the pname:pNext chain of slink:VkSemaphoreCreateInfo includes a 3896slink:VkExportSemaphoreCreateInfo structure with a NvSciSync 3897pname:handleType, but either slink:VkExportSemaphoreSciSyncInfoNV is not 3898included in the pname:pNext chain, or it is included but pname:pAttributes 3899is set to `NULL`, flink:vkCreateSemaphore will return 3900ename:VK_ERROR_INITIALIZATION_FAILED. 3901 3902The pname:pAttributes must: be a reconciled sname:NvSciSyncAttrList. 3903Before exporting a NvSciSync handle, the application must: use the 3904flink:vkGetPhysicalDeviceSciSyncAttributesNV command to obtain the 3905unreconciled sname:NvSciSyncAttrList and then use the NvSciSync API to 3906reconcile it. 3907 3908.Valid Usage 3909**** 3910 * [[VUID-VkExportSemaphoreSciSyncInfoNV-pAttributes-05121]] 3911 pname:pAttributes must: be a reconciled stext:NvSciSyncAttrList 3912**** 3913 3914include::{generated}/validity/structs/VkExportSemaphoreSciSyncInfoNV.adoc[] 3915-- 3916 3917[open,refpage='vkGetSemaphoreSciSyncObjNV',desc='Get a stext:NvSciSyncObj handle for a semaphore',type='protos'] 3918-- 3919 3920To export a stext:NvSciSyncObj handle representing the payload of a 3921semaphore, call: 3922 3923include::{generated}/api/protos/vkGetSemaphoreSciSyncObjNV.adoc[] 3924 3925 * pname:device is the logical device that created the semaphore being 3926 exported. 3927 * pname:pGetSciSyncInfo is a pointer to a 3928 slink:VkSemaphoreGetSciSyncInfoNV structure containing parameters of the 3929 export operation. 3930 * pname:pHandle will return the stext:NvSciSyncObj representing the 3931 semaphore payload. 3932 3933Each call to fname:vkGetSemaphoreSciSyncObjNV will duplicate the underlying 3934stext:NvSciSyncObj and transfer the ownership of the stext:NvSciSyncObj 3935handle to the application. 3936To avoid leaking resources, the application must: release ownership of the 3937stext:NvSciSyncObj when it is no longer needed. 3938 3939.Valid Usage 3940**** 3941 * [[VUID-vkGetSemaphoreSciSyncObjNV-sciSyncSemaphore-05147]] 3942 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore 3943 must: be enabled 3944**** 3945 3946include::{generated}/validity/protos/vkGetSemaphoreSciSyncObjNV.adoc[] 3947-- 3948 3949[open,refpage='VkSemaphoreGetSciSyncInfoNV',desc='Structure describing a slink:VkSemaphore export operation to NvSciSync',type='structs'] 3950-- 3951 3952The sname:VkSemaphoreGetSciSyncInfoNV structure is defined as: 3953 3954include::{generated}/api/structs/VkSemaphoreGetSciSyncInfoNV.adoc[] 3955 3956 * pname:sType is a elink:VkStructureType value identifying this structure. 3957 * pname:pNext is `NULL` or a pointer to a structure extending this 3958 structure. 3959 * pname:semaphore is the semaphore from which state will be exported. 3960 * pname:handleType is the type of NvSciSync handle (stext:NvSciSyncObj) 3961 representing the semaphore that will be exported. 3962 3963.Valid Usage 3964**** 3965 * [[VUID-VkSemaphoreGetSciSyncInfoNV-handleType-05122]] 3966 pname:handleType must: be 3967 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV 3968 * [[VUID-VkSemaphoreGetSciSyncInfoNV-semaphore-05123]] 3969 pname:semaphore must: have been created with a elink:VkSemaphoreType of 3970 ename:VK_SEMAPHORE_TYPE_TIMELINE 3971 * [[VUID-VkSemaphoreGetSciSyncInfoNV-semaphore-05129]] 3972 pname:semaphore must: have been created with 3973 slink:VkExportSemaphoreSciSyncInfoNV included pname:pNext chain of 3974 slink:VkSemaphoreCreateInfo, or previously imported by 3975 flink:vkImportSemaphoreSciSyncObjNV 3976**** 3977 3978include::{generated}/validity/structs/VkSemaphoreGetSciSyncInfoNV.adoc[] 3979-- 3980endif::VK_NV_external_sci_sync[] 3981 3982ifdef::VK_NV_external_sci_sync2[] 3983[open,refpage='VkSemaphoreSciSyncCreateInfoNV',desc='Structure to create a semaphore from a semaphore SciSync pool',type='structs'] 3984-- 3985The sname:VkSemaphoreSciSyncCreateInfoNV structure is defined as: 3986 3987include::{generated}/api/structs/VkSemaphoreSciSyncCreateInfoNV.adoc[] 3988 3989 * pname:sType is a elink:VkStructureType value identifying this structure. 3990 * pname:pNext is `NULL` or a pointer to a structure extending this 3991 structure. 3992 * pname:semaphorePool is a slink:VkSemaphoreSciSyncPoolNV handle. 3993 * pname:pFence is a pointer to a stext:NvSciSyncFence. 3994 3995When slink:VkSemaphoreSciSyncCreateInfoNV is included in 3996slink:VkSemaphoreCreateInfo::pname:pNext chain, the semaphore is created 3997from the slink:VkSemaphoreSciSyncPoolNV handle that represents a 3998stext:NvSciSyncObj with one or more primitives. 3999The slink:VkSemaphoreSciSyncCreateInfoNV::pname:pFence parameter provides 4000the information to select the corresponding primitive represented by this 4001semaphore. 4002When a stext:NvSciSyncObj with signaler permissions is imported to 4003slink:VkSemaphoreSciSyncPoolNV, it only supports one primitive and 4004slink:VkSemaphoreSciSyncCreateInfoNV::pname:pFence must: be in the cleared 4005state. 4006 4007.Valid Usage 4008**** 4009 * [[VUID-VkSemaphoreSciSyncCreateInfoNV-sciSyncSemaphore2-05148]] 4010 The <<features-sciSyncSemaphore2, 4011 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> 4012 feature must: be enabled 4013**** 4014 4015include::{generated}/validity/structs/VkSemaphoreSciSyncCreateInfoNV.adoc[] 4016-- 4017endif::VK_NV_external_sci_sync2[] 4018 4019 4020[open,refpage='vkDestroySemaphore',desc='Destroy a semaphore object',type='protos'] 4021-- 4022To destroy a semaphore, call: 4023 4024include::{generated}/api/protos/vkDestroySemaphore.adoc[] 4025 4026 * pname:device is the logical device that destroys the semaphore. 4027 * pname:semaphore is the handle of the semaphore to destroy. 4028 * pname:pAllocator controls host memory allocation as described in the 4029 <<memory-allocation, Memory Allocation>> chapter. 4030 4031ifdef::VK_NV_external_sci_sync2[] 4032If pname:semaphore was created with slink:VkSemaphoreSciSyncCreateInfoNV 4033present in the slink:VkSemaphoreCreateInfo::pname:pNext chain, 4034pname:semaphore can: be destroyed immediately after all batches that refer 4035to it are submitted. 4036Otherwise, all submitted batches that refer to pname:semaphore must: have 4037completed execution before it can be destroyed. 4038endif::VK_NV_external_sci_sync2[] 4039 4040.Valid Usage 4041**** 4042 * [[VUID-vkDestroySemaphore-semaphore-05149]] 4043ifdef::VK_NV_external_sci_sync2[] 4044 If pname:semaphore was not created with 4045 slink:VkSemaphoreSciSyncCreateInfoNV present in the 4046 slink:VkSemaphoreCreateInfo::pname:pNext chain when it was created, all 4047endif::VK_NV_external_sci_sync2[] 4048ifndef::VK_NV_external_sci_sync2[All] 4049 submitted batches that refer to pname:semaphore must: have completed 4050 execution 4051ifndef::VKSC_VERSION_1_0[] 4052 * [[VUID-vkDestroySemaphore-semaphore-01138]] 4053 If sname:VkAllocationCallbacks were provided when pname:semaphore was 4054 created, a compatible set of callbacks must: be provided here 4055 * [[VUID-vkDestroySemaphore-semaphore-01139]] 4056 If no sname:VkAllocationCallbacks were provided when pname:semaphore was 4057 created, pname:pAllocator must: be `NULL` 4058endif::VKSC_VERSION_1_0[] 4059**** 4060 4061include::{generated}/validity/protos/vkDestroySemaphore.adoc[] 4062-- 4063 4064ifdef::VK_NV_external_sci_sync2[] 4065=== Semaphore SciSync Pools 4066 4067A semaphore SciSync pool is used to represent a stext:NvSciSyncObj with one 4068or more primitives. 4069 4070[open,refpage='VkSemaphoreSciSyncPoolNV',desc='Opaque handle to a semaphore SciSync pool',type='handles'] 4071-- 4072Semaphore SciSync pools are represented by sname:VkSemaphoreSciSyncPoolNV 4073handles: 4074 4075include::{generated}/api/handles/VkSemaphoreSciSyncPoolNV.adoc[] 4076-- 4077 4078To import a stext:NvSciSyncObj with multiple primitives, use 4079flink:vkCreateSemaphoreSciSyncPoolNV to reserve a semaphore pool to map the 4080multiple semaphores allocated by stext:NvSciSyncObj. 4081Then create a slink:VkSemaphore from the semaphore pool using the index 4082provided by the stext:NvSciSyncFence when chaining the 4083slink:VkSemaphoreSciSyncCreateInfoNV structure to 4084slink:VkSemaphoreCreateInfo. 4085 4086[open,refpage='vkCreateSemaphoreSciSyncPoolNV',desc='Create a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] 4087-- 4088:refpage: vkCreateSemaphoreSciSyncPoolNV 4089 4090To create a sname:VkSemaphoreSciSyncPoolNV, call: 4091 4092include::{generated}/api/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] 4093 4094 * pname:device is the logical device that creates the semaphore pool. 4095 * pname:pCreateInfo is a pointer to a 4096 slink:VkSemaphoreSciSyncPoolCreateInfoNV structure containing 4097 information about the semaphore SciSync pool being created. 4098 * pname:pAllocator controls host memory allocation as described in the 4099 <<memory-allocation, Memory Allocation>> chapter. 4100 * pname:pSemaphorePool is a pointer to a handle in which the resulting 4101 semaphore pool object is returned. 4102 4103include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4104 4105.Valid Usage 4106**** 4107ifdef::VKSC_VERSION_1_0[] 4108 * [[VUID-vkCreateSemaphoreSciSyncPoolNV-device-05150]] 4109 The number of semaphore pools currently allocated from pname:device plus 4110 1 must: be less than or equal to the total number of semaphore pools 4111 requested via 4112 slink:VkDeviceSemaphoreSciSyncPoolReservationCreateInfoNV::pname:semaphoreSciSyncPoolRequestCount 4113 specified when pname:device was created 4114endif::VKSC_VERSION_1_0[] 4115 * [[VUID-vkCreateSemaphoreSciSyncPoolNV-sciSyncSemaphore2-05151]] 4116 The <<features-sciSyncSemaphore2, 4117 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> 4118 feature must: be enabled 4119**** 4120 4121include::{generated}/validity/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] 4122-- 4123 4124[open,refpage='VkSemaphoreSciSyncPoolCreateInfoNV',desc='Structure describing the creation parameters for a SciSync pool',type='structs'] 4125-- 4126The sname:VkSemaphoreSciSyncPoolCreateInfoNV structure is defined as: 4127 4128include::{generated}/api/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] 4129 4130 * pname:sType is a elink:VkStructureType value identifying this structure. 4131 * pname:pNext is `NULL` or a pointer to a structure extending this 4132 structure. 4133 * pname:handle is an external stext:NvSciSyncObj to import. 4134 4135During flink:vkCreateSemaphoreSciSyncPoolNV, the external stext:NvSciSyncObj 4136is imported to sname:VkSemaphoreSciSyncPoolNV. 4137The import does not transfer the ownership of the stext:NvSciSyncObj to the 4138implementation, but will increment the reference count of that object. 4139ifndef::VKSC_VERSION_1_0[] 4140flink:vkDestroySemaphoreSciSyncPoolNV will decrement the reference count of 4141that object. 4142endif::VKSC_VERSION_1_0[] 4143The application must: delete other references of the original 4144stext:NvSciSyncObj using <<NvSciSync2-extension-page, NvSciSync APIs>> when 4145it is no longer needed. 4146 4147Applications must: not import the same stext:NvSciSyncObj with signaler 4148access permissions to multiple instances of sname:VkSemaphoreSciSyncPoolNV. 4149 4150.Valid Usage 4151**** 4152 * [[VUID-VkSemaphoreSciSyncPoolCreateInfoNV-handle-05152]] 4153 pname:handle must: be a valid stext:NvSciSyncObj 4154**** 4155 4156include::{generated}/validity/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] 4157-- 4158 4159ifdef::VKSC_VERSION_1_0[] 4160ifdef::hidden[] 4161// tag::scremoved[] 4162ifdef::VK_NV_external_sci_sync2[] 4163 * fname:vkDestroySemaphoreSciSyncPoolNV <<SCID-4>> 4164endif::VK_NV_external_sci_sync2[] 4165// end::scremoved[] 4166endif::hidden[] 4167 4168Semaphore SciSync pools cannot: be freed <<SCID-4>>. 4169If 4170slink:VkPhysicalDeviceVulkanSC10Properties::<<limits-deviceDestroyFreesMemory,pname:deviceDestroyFreesMemory>> 4171is ename:VK_TRUE, the memory is returned to the system and the reference to 4172the stext:NvSciSyncObj that was imported is releasd when the device is 4173destroyed. 4174endif::VKSC_VERSION_1_0[] 4175 4176ifndef::VKSC_VERSION_1_0[] 4177[open,refpage='vkDestroySemaphoreSciSyncPoolNV',desc='Destroy a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] 4178-- 4179To destroy a slink:VkSemaphoreSciSyncPoolNV, call: 4180 4181include::{generated}/api/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] 4182 4183 * pname:device is the logical device that destroys the semaphore SciSync 4184 pool. 4185 * pname:semaphorePool is the handle of the semaphore SciSync pool to 4186 destroy. 4187 * pname:pAllocator controls host memory allocation as described in the 4188 <<memory-allocation, Memory Allocation>> chapter. 4189 4190.Valid Usage 4191**** 4192 * [[VUID-vkDestroySemaphoreSciSyncPoolNV-semaphorePool-05153]] 4193 All submitted batches that refer to a semaphore created from 4194 pname:semaphorePool must: have completed execution 4195 * [[VUID-vkDestroySemaphoreSciSyncPoolNV-sciSyncSemaphore2-05154]] 4196 The <<features-sciSyncSemaphore2, 4197 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> 4198 feature must: be enabled 4199**** 4200 4201include::{generated}/validity/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] 4202-- 4203endif::VKSC_VERSION_1_0[] 4204endif::VK_NV_external_sci_sync2[] 4205 4206 4207[[synchronization-semaphores-signaling]] 4208=== Semaphore Signaling 4209 4210When a batch is submitted to a queue via a <<devsandqueues-submission, queue 4211submission>>, and it includes semaphores to be signaled, it defines a memory 4212dependency on the batch, and defines _semaphore signal operations_ which set 4213the semaphores to the signaled state. 4214 4215ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4216In case of semaphores created with a elink:VkSemaphoreType of 4217ename:VK_SEMAPHORE_TYPE_TIMELINE the semaphore is considered signaled with 4218respect to the counter value set to be signaled as specified in 4219slink:VkTimelineSemaphoreSubmitInfo or slink:VkSemaphoreSignalInfo. 4220endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4221 4222The first <<synchronization-dependencies-scopes, synchronization scope>> 4223includes every command submitted in the same batch. 4224ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4225In the case of flink:vkQueueSubmit2, the first synchronization scope is 4226limited to the pipeline stage specified by 4227slink:VkSemaphoreSubmitInfo::pname:stageMask. 4228endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4229Semaphore signal operations that are defined by flink:vkQueueSubmit 4230ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4231or flink:vkQueueSubmit2 4232endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4233additionally include all commands that occur earlier in 4234<<synchronization-submission-order,submission order>>. 4235Semaphore signal operations that are defined by flink:vkQueueSubmit 4236ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] 4237ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] 4238additionally include in the first synchronization scope any semaphore and 4239fence signal operations that occur earlier in 4240<<synchronization-signal-operation-order,signal operation order>>. 4241 4242The second <<synchronization-dependencies-scopes, synchronization scope>> 4243includes only the semaphore signal operation. 4244 4245The first <<synchronization-dependencies-access-scopes, access scope>> 4246includes all memory access performed by the device. 4247 4248The second <<synchronization-dependencies-access-scopes, access scope>> is 4249empty. 4250 4251 4252[[synchronization-semaphores-waiting]] 4253=== Semaphore Waiting 4254 4255When a batch is submitted to a queue via a <<devsandqueues-submission, queue 4256submission>>, and it includes semaphores to be waited on, it defines a 4257memory dependency between prior semaphore signal operations and the batch, 4258and defines _semaphore wait operations_. 4259 4260Such semaphore wait operations set the semaphores 4261ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4262created with a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY 4263endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4264to the unsignaled state. 4265ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4266In case of semaphores created with a elink:VkSemaphoreType of 4267ename:VK_SEMAPHORE_TYPE_TIMELINE a prior semaphore signal operation defines 4268a memory dependency with a semaphore wait operation if the value the 4269semaphore is signaled with is greater than or equal to the value the 4270semaphore is waited with, thus the semaphore will continue to be considered 4271signaled with respect to the counter value waited on as specified in 4272slink:VkTimelineSemaphoreSubmitInfo. 4273endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4274 4275The first synchronization scope includes all semaphore signal operations 4276that operate on semaphores waited on in the same batch, and that 4277happen-before the wait completes. 4278 4279The second <<synchronization-dependencies-scopes, synchronization scope>> 4280includes every command submitted in the same batch. 4281In the case of flink:vkQueueSubmit, the second synchronization scope is 4282limited to operations on the pipeline stages determined by the 4283<<synchronization-pipeline-stages-masks, destination stage mask>> specified 4284by the corresponding element of pname:pWaitDstStageMask. 4285ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4286In the case of flink:vkQueueSubmit2, the second synchronization scope is 4287limited to the pipeline stage specified by 4288slink:VkSemaphoreSubmitInfo::pname:stageMask. 4289endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4290Also, in the case of 4291ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4292either flink:vkQueueSubmit2 or 4293endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4294flink:vkQueueSubmit, the second synchronization scope additionally includes 4295all commands that occur later in 4296<<synchronization-submission-order,submission order>>. 4297 4298The first <<synchronization-dependencies-access-scopes, access scope>> is 4299empty. 4300 4301The second <<synchronization-dependencies-access-scopes, access scope>> 4302includes all memory access performed by the device. 4303 4304The semaphore wait operation happens-after the first set of operations in 4305the execution dependency, and happens-before the second set of operations in 4306the execution dependency. 4307 4308[NOTE] 4309.Note 4310==== 4311Unlike 4312ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4313timeline semaphores, 4314endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4315fences or events, the act of waiting for a binary semaphore also unsignals 4316that semaphore. 4317Applications must: ensure that between two such wait operations, the 4318semaphore is signaled again, with execution dependencies used to ensure 4319these occur in order. 4320Binary semaphore waits and signals should thus occur in discrete 1:1 pairs. 4321==== 4322 4323ifdef::VK_KHR_swapchain[] 4324[NOTE] 4325.Note 4326==== 4327A common scenario for using pname:pWaitDstStageMask with values other than 4328ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT is when synchronizing a window 4329system presentation operation against subsequent command buffers which 4330render the next frame. 4331In this case, a presentation image must: not be overwritten until the 4332presentation operation completes, but other pipeline stages can: execute 4333without waiting. 4334A mask of ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT prevents 4335subsequent color attachment writes from executing until the semaphore 4336signals. 4337Some implementations may: be able to execute transfer operations and/or 4338pre-rasterization work before the semaphore is signaled. 4339 4340If an image layout transition needs to be performed on a presentable image 4341before it is used in a framebuffer, that can: be performed as the first 4342operation submitted to the queue after acquiring the image, and should: not 4343prevent other work from overlapping with the presentation operation. 4344For example, a sname:VkImageMemoryBarrier could use: 4345 4346 * pname:srcStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 4347 * pname:srcAccessMask = 0 4348 * pname:dstStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 4349 * pname:dstAccessMask = ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | 4350 ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. 4351 * pname:oldLayout = ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR 4352 * pname:newLayout = ename:VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL 4353 4354Alternatively, pname:oldLayout can: be ename:VK_IMAGE_LAYOUT_UNDEFINED, if 4355the image's contents need not be preserved. 4356 4357This barrier accomplishes a dependency chain between previous presentation 4358operations and subsequent color attachment output operations, with the 4359layout transition performed in between, and does not introduce a dependency 4360between previous work and any 4361<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4362stage>>s. 4363More precisely, the semaphore signals after the presentation operation 4364completes, the semaphore wait stalls the 4365ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage, and there is a 4366dependency from that same stage to itself with the layout transition 4367performed in between. 4368==== 4369endif::VK_KHR_swapchain[] 4370 4371 4372[[synchronization-semaphores-waiting-state]] 4373=== Semaphore State Requirements for Wait Operations 4374 4375Before waiting on a semaphore, the application must: ensure the semaphore is 4376in a valid state for a wait operation. 4377Specifically, when a <<synchronization-semaphores-waiting,semaphore wait 4378operation>> is submitted to a queue: 4379 4380 * A binary semaphore must: be signaled, or have an associated 4381 <<synchronization-semaphores-signaling,semaphore signal operation>> that 4382 is pending execution. 4383 * Any <<synchronization-semaphores-signaling,semaphore signal operations>> 4384 on which the pending binary semaphore signal operation depends must: 4385 also be completed or pending execution. 4386 * There must: be no other queue waiting on the same binary semaphore when 4387 the operation executes. 4388 4389 4390ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4391[[synchronization-semaphores-hostops]] 4392=== Host Operations on Semaphores 4393 4394In addition to <<synchronization-semaphores-signaling,semaphore signal 4395operations>> and <<synchronization-semaphores-waiting,semaphore wait 4396operations>> submitted to device queues, timeline semaphores support the 4397following host operations: 4398 4399 * Query the current counter value of the semaphore using the 4400 flink:vkGetSemaphoreCounterValue command. 4401 * Wait for a set of semaphores to reach particular counter values using 4402 the flink:vkWaitSemaphores command. 4403 * Signal the semaphore with a particular counter value from the host using 4404 the flink:vkSignalSemaphore command. 4405 4406[open,refpage='vkGetSemaphoreCounterValue',desc='Query the current state of a timeline semaphore',type='protos',alias='vkGetSemaphoreCounterValueKHR'] 4407-- 4408:refpage: vkGetSemaphoreCounterValue 4409 4410To query the current counter value of a semaphore created with a 4411elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE from the host, 4412call: 4413 4414ifdef::VK_VERSION_1_2[] 4415include::{generated}/api/protos/vkGetSemaphoreCounterValue.adoc[] 4416endif::VK_VERSION_1_2[] 4417 4418ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4419 4420ifdef::VK_KHR_timeline_semaphore[] 4421include::{generated}/api/protos/vkGetSemaphoreCounterValueKHR.adoc[] 4422endif::VK_KHR_timeline_semaphore[] 4423 4424 * pname:device is the logical device that owns the semaphore. 4425 * pname:semaphore is the handle of the semaphore to query. 4426 * pname:pValue is a pointer to a 64-bit integer value in which the current 4427 counter value of the semaphore is returned. 4428 4429[NOTE] 4430.Note 4431==== 4432If a <<devsandqueues-submission, queue submission>> command is pending 4433execution, then the value returned by this command may: immediately be out 4434of date. 4435==== 4436 4437include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4438 4439.Valid Usage 4440**** 4441 * [[VUID-vkGetSemaphoreCounterValue-semaphore-03255]] 4442 pname:semaphore must: have been created with a elink:VkSemaphoreType of 4443 ename:VK_SEMAPHORE_TYPE_TIMELINE 4444**** 4445 4446include::{generated}/validity/protos/vkGetSemaphoreCounterValue.adoc[] 4447-- 4448 4449[open,refpage='vkWaitSemaphores',desc='Wait for timeline semaphores on the host',type='protos',alias='vkWaitSemaphoresKHR'] 4450-- 4451:refpage: vkWaitSemaphores 4452 4453To wait for a set of semaphores created with a elink:VkSemaphoreType of 4454ename:VK_SEMAPHORE_TYPE_TIMELINE to reach particular counter values on the 4455host, call: 4456 4457ifdef::VK_VERSION_1_2[] 4458include::{generated}/api/protos/vkWaitSemaphores.adoc[] 4459endif::VK_VERSION_1_2[] 4460 4461ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4462 4463ifdef::VK_KHR_timeline_semaphore[] 4464include::{generated}/api/protos/vkWaitSemaphoresKHR.adoc[] 4465endif::VK_KHR_timeline_semaphore[] 4466 4467 * pname:device is the logical device that owns the semaphores. 4468 * pname:pWaitInfo is a pointer to a slink:VkSemaphoreWaitInfo structure 4469 containing information about the wait condition. 4470 * pname:timeout is the timeout period in units of nanoseconds. 4471 pname:timeout is adjusted to the closest value allowed by the 4472 implementation-dependent timeout accuracy, which may: be substantially 4473 longer than one nanosecond, and may: be longer than the requested 4474 period. 4475 4476If the condition is satisfied when fname:vkWaitSemaphores is called, then 4477fname:vkWaitSemaphores returns immediately. 4478If the condition is not satisfied at the time fname:vkWaitSemaphores is 4479called, then fname:vkWaitSemaphores will block and wait until the condition 4480is satisfied or the pname:timeout has expired, whichever is sooner. 4481 4482If pname:timeout is zero, then fname:vkWaitSemaphores does not wait, but 4483simply returns information about the current state of the semaphores. 4484ename:VK_TIMEOUT will be returned in this case if the condition is not 4485satisfied, even though no actual wait was performed. 4486 4487If the condition is satisfied before the pname:timeout has expired, 4488fname:vkWaitSemaphores returns ename:VK_SUCCESS. 4489Otherwise, fname:vkWaitSemaphores returns ename:VK_TIMEOUT after the 4490pname:timeout has expired. 4491 4492If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before 4493the timeout has expired, fname:vkWaitSemaphores must: return in finite time 4494with either ename:VK_SUCCESS or ename:VK_ERROR_DEVICE_LOST. 4495 4496include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4497 4498include::{generated}/validity/protos/vkWaitSemaphores.adoc[] 4499-- 4500 4501[open,refpage='VkSemaphoreWaitInfo',desc='Structure containing information about the semaphore wait condition',type='structs',alias='VkSemaphoreWaitInfoKHR'] 4502-- 4503The sname:VkSemaphoreWaitInfo structure is defined as: 4504 4505include::{generated}/api/structs/VkSemaphoreWaitInfo.adoc[] 4506 4507ifdef::VK_KHR_timeline_semaphore[] 4508or the equivalent 4509 4510include::{generated}/api/structs/VkSemaphoreWaitInfoKHR.adoc[] 4511endif::VK_KHR_timeline_semaphore[] 4512 4513 * pname:sType is a elink:VkStructureType value identifying this structure. 4514 * pname:pNext is `NULL` or a pointer to a structure extending this 4515 structure. 4516 * pname:flags is a bitmask of elink:VkSemaphoreWaitFlagBits specifying 4517 additional parameters for the semaphore wait operation. 4518 * pname:semaphoreCount is the number of semaphores to wait on. 4519 * pname:pSemaphores is a pointer to an array of pname:semaphoreCount 4520 semaphore handles to wait on. 4521 * pname:pValues is a pointer to an array of pname:semaphoreCount timeline 4522 semaphore values. 4523 4524.Valid Usage 4525**** 4526 * [[VUID-VkSemaphoreWaitInfo-pSemaphores-03256]] 4527 All of the elements of pname:pSemaphores must: reference a semaphore 4528 that was created with a elink:VkSemaphoreType of 4529 ename:VK_SEMAPHORE_TYPE_TIMELINE 4530ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4531 * [[VUID-VkSemaphoreWaitInfo-pSemaphores-05124]] 4532 If any of the semaphores in pname:pSemaphores have stext:NvSciSyncObj as 4533 payload, application must: calculate the corresponding timeline 4534 semaphore values in pname:pValues by calling 4535 <<NvSciSync2-extension-page, NvSciSync APIs>>. 4536endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4537**** 4538 4539include::{generated}/validity/structs/VkSemaphoreWaitInfo.adoc[] 4540-- 4541 4542[open,refpage='VkSemaphoreWaitFlagBits',desc='Bitmask specifying additional parameters of a semaphore wait operation',type='enums',alias='VkSemaphoreWaitFlagBitsKHR'] 4543-- 4544Bits which can: be set in slink:VkSemaphoreWaitInfo::pname:flags, specifying 4545additional parameters of a semaphore wait operation, are: 4546 4547include::{generated}/api/enums/VkSemaphoreWaitFlagBits.adoc[] 4548 4549ifdef::VK_KHR_timeline_semaphore[] 4550or the equivalent 4551 4552include::{generated}/api/enums/VkSemaphoreWaitFlagBitsKHR.adoc[] 4553endif::VK_KHR_timeline_semaphore[] 4554 4555 * ename:VK_SEMAPHORE_WAIT_ANY_BIT specifies that the semaphore wait 4556 condition is that at least one of the semaphores in 4557 sname:VkSemaphoreWaitInfo::pname:pSemaphores has reached the value 4558 specified by the corresponding element of 4559 sname:VkSemaphoreWaitInfo::pname:pValues. 4560 If ename:VK_SEMAPHORE_WAIT_ANY_BIT is not set, the semaphore wait 4561 condition is that all of the semaphores in 4562 sname:VkSemaphoreWaitInfo::pname:pSemaphores have reached the value 4563 specified by the corresponding element of 4564 sname:VkSemaphoreWaitInfo::pname:pValues. 4565-- 4566 4567[open,refpage='VkSemaphoreWaitFlags',desc='Bitmask of VkSemaphoreWaitFlagBits',type='flags',alias='VkSemaphoreWaitFlagsKHR'] 4568-- 4569include::{generated}/api/flags/VkSemaphoreWaitFlags.adoc[] 4570 4571ifdef::VK_KHR_timeline_semaphore[] 4572or the equivalent 4573 4574include::{generated}/api/flags/VkSemaphoreWaitFlagsKHR.adoc[] 4575endif::VK_KHR_timeline_semaphore[] 4576 4577tname:VkSemaphoreWaitFlags is a bitmask type for setting a mask of zero or 4578more elink:VkSemaphoreWaitFlagBits. 4579-- 4580 4581[open,refpage='vkSignalSemaphore',desc='Signal a timeline semaphore on the host',type='protos',alias='vkSignalSemaphoreKHR'] 4582-- 4583:refpage: vkSignalSemaphore 4584 4585To signal a semaphore created with a elink:VkSemaphoreType of 4586ename:VK_SEMAPHORE_TYPE_TIMELINE with a particular counter value, on the 4587host, call: 4588 4589ifdef::VK_VERSION_1_2[] 4590include::{generated}/api/protos/vkSignalSemaphore.adoc[] 4591endif::VK_VERSION_1_2[] 4592 4593ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4594 4595ifdef::VK_KHR_timeline_semaphore[] 4596include::{generated}/api/protos/vkSignalSemaphoreKHR.adoc[] 4597endif::VK_KHR_timeline_semaphore[] 4598 4599 * pname:device is the logical device that owns the semaphore. 4600 * pname:pSignalInfo is a pointer to a slink:VkSemaphoreSignalInfo 4601 structure containing information about the signal operation. 4602 4603When fname:vkSignalSemaphore is executed on the host, it defines and 4604immediately executes a <<synchronization-semaphores-signaling,_semaphore 4605signal operation_>> which sets the timeline semaphore to the given value. 4606 4607The first synchronization scope is defined by the host execution model, but 4608includes execution of fname:vkSignalSemaphore on the host and anything that 4609happened-before it. 4610 4611The second synchronization scope is empty. 4612 4613include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4614 4615include::{generated}/validity/protos/vkSignalSemaphore.adoc[] 4616-- 4617 4618[open,refpage='VkSemaphoreSignalInfo',desc='Structure containing information about a semaphore signal operation',type='structs',alias='VkSemaphoreSignalInfoKHR'] 4619-- 4620The sname:VkSemaphoreSignalInfo structure is defined as: 4621 4622include::{generated}/api/structs/VkSemaphoreSignalInfo.adoc[] 4623 4624ifdef::VK_KHR_timeline_semaphore[] 4625or the equivalent 4626 4627include::{generated}/api/structs/VkSemaphoreSignalInfoKHR.adoc[] 4628endif::VK_KHR_timeline_semaphore[] 4629 4630 * pname:sType is a elink:VkStructureType value identifying this structure. 4631 * pname:pNext is `NULL` or a pointer to a structure extending this 4632 structure. 4633 * pname:semaphore is the handle of the semaphore to signal. 4634 * pname:value is the value to signal. 4635 4636.Valid Usage 4637**** 4638 * [[VUID-VkSemaphoreSignalInfo-semaphore-03257]] 4639 pname:semaphore must: have been created with a elink:VkSemaphoreType of 4640 ename:VK_SEMAPHORE_TYPE_TIMELINE 4641 * [[VUID-VkSemaphoreSignalInfo-value-03258]] 4642 pname:value must: have a value greater than the current value of the 4643 semaphore 4644 * [[VUID-VkSemaphoreSignalInfo-value-03259]] 4645 pname:value must: be less than the value of any pending semaphore signal 4646 operations 4647 * [[VUID-VkSemaphoreSignalInfo-value-03260]] 4648 pname:value must: have a value which does not differ from the current 4649 value of the semaphore or the value of any outstanding semaphore wait or 4650 signal operation on pname:semaphore by more than 4651 <<limits-maxTimelineSemaphoreValueDifference, 4652 pname:maxTimelineSemaphoreValueDifference>> 4653ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4654 * [[VUID-VkSemaphoreSignalInfo-semaphores-05125]] 4655 If pname:semaphores has stext:NvSciSyncObj as payload, application must: 4656 calculate the corresponding timeline semaphore value in pname:value by 4657 calling <<NvSciSync2-extension-page, NvSciSync APIs>>. 4658endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4659**** 4660 4661include::{generated}/validity/structs/VkSemaphoreSignalInfo.adoc[] 4662-- 4663endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4664 4665 4666ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 4667[[synchronization-semaphores-importing]] 4668=== Importing Semaphore Payloads 4669 4670Applications can: import a semaphore payload into an existing semaphore 4671using an external semaphore handle. 4672The effects of the import operation will be either temporary or permanent, 4673as specified by the application. 4674If the import is temporary, the implementation must: restore the semaphore 4675to its prior permanent state after submitting the next semaphore wait 4676operation. 4677Performing a subsequent temporary import on a semaphore before performing a 4678semaphore wait has no effect on this requirement; the next wait submitted on 4679the semaphore must: still restore its last permanent state. 4680A permanent payload import behaves as if the target semaphore was destroyed, 4681and a new semaphore was created with the same handle but the imported 4682payload. 4683Because importing a semaphore payload temporarily or permanently detaches 4684the existing payload from a semaphore, similar usage restrictions to those 4685applied to fname:vkDestroySemaphore are applied to any command that imports 4686a semaphore payload. 4687Which of these import types is used is referred to as the import operation's 4688_permanence_. 4689Each handle type supports either one or both types of permanence. 4690 4691The implementation must: perform the import operation by either referencing 4692or copying the payload referred to by the specified external semaphore 4693handle, depending on the handle's type. 4694The import method used is referred to as the handle type's _transference_. 4695When using handle types with reference transference, importing a payload to 4696a semaphore adds the semaphore to the set of all semaphores sharing that 4697payload. 4698This set includes the semaphore from which the payload was exported. 4699Semaphore signaling and waiting operations performed on any semaphore in the 4700set must: behave as if the set were a single semaphore. 4701Importing a payload using handle types with copy transference creates a 4702duplicate copy of the payload at the time of import, but makes no further 4703reference to it. 4704Semaphore signaling and waiting operations performed on the target of copy 4705imports must: not affect any other semaphore or payload. 4706 4707Export operations have the same transference as the specified handle type's 4708import operations. 4709Additionally, exporting a semaphore payload to a handle with copy 4710transference has the same side effects on the source semaphore's payload as 4711executing a semaphore wait operation. 4712If the semaphore was using a temporarily imported payload, the semaphore's 4713prior permanent payload will be restored. 4714 4715ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 4716[NOTE] 4717.Note 4718==== 4719The permanence and transference of handle types can be found in: 4720 4721ifdef::VK_KHR_external_semaphore_win32[] 4722 * <<synchronization-semaphore-handletypes-win32,Handle Types Supported by 4723 sname:VkImportSemaphoreWin32HandleInfoKHR>> 4724endif::VK_KHR_external_semaphore_win32[] 4725ifdef::VK_KHR_external_semaphore_fd[] 4726 * <<synchronization-semaphore-handletypes-fd,Handle Types Supported by 4727 sname:VkImportSemaphoreFdInfoKHR>> 4728endif::VK_KHR_external_semaphore_fd[] 4729ifdef::VK_FUCHSIA_external_semaphore[] 4730 * <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported 4731 by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> 4732endif::VK_FUCHSIA_external_semaphore[] 4733==== 4734endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 4735 4736<<fundamentals-threadingbehavior,External synchronization>> allows 4737implementations to modify an object's internal state, i.e. payload, without 4738internal synchronization. 4739However, for semaphores sharing a payload across processes, satisfying the 4740external synchronization requirements of sname:VkSemaphore parameters as if 4741all semaphores in the set were the same object is sometimes infeasible. 4742Satisfying the <<synchronization-semaphores-waiting-state,wait operation 4743state requirements>> would similarly require impractical coordination or 4744levels of trust between processes. 4745Therefore, these constraints only apply to a specific semaphore handle, not 4746to its payload. 4747For distinct semaphore objects which share a payload, if the semaphores are 4748passed to separate queue submission commands concurrently, behavior will be 4749as if the commands were called in an arbitrary sequential order. 4750If the <<synchronization-semaphores-waiting-state,wait operation state 4751requirements>> are violated for the shared payload by a queue submission 4752command, or if a signal operation is queued for a shared payload that is 4753already signaled or has a pending signal operation, effects must: be limited 4754to one or more of the following: 4755 4756 * Returning ename:VK_ERROR_INITIALIZATION_FAILED from the command which 4757 resulted in the violation. 4758 * Losing the logical device on which the violation occurred immediately or 4759 at a future time, resulting in a ename:VK_ERROR_DEVICE_LOST error from 4760 subsequent commands, including the one causing the violation. 4761 * Continuing execution of the violating command or operation as if the 4762 semaphore wait completed successfully after an implementation-dependent 4763 timeout. 4764 In this case, the state of the payload becomes undefined:, and future 4765 operations on semaphores sharing the payload will be subject to these 4766 same rules. 4767 The semaphore must: be destroyed or have its payload replaced by an 4768 import operation to again have a well-defined state. 4769 4770[NOTE] 4771.Note 4772==== 4773These rules allow processes to synchronize access to shared memory without 4774trusting each other. 4775However, such processes must still be cautious not to use the shared 4776semaphore for more than synchronizing access to the shared memory. 4777For example, a process should not use a shared semaphore as part of an 4778execution dependency chain that, when complete, leads to objects being 4779destroyed, if it does not trust other processes sharing the semaphore 4780payload. 4781==== 4782 4783When a semaphore is using an imported payload, its 4784slink:VkExportSemaphoreCreateInfo::pname:handleTypes value is specified when 4785creating the semaphore from which the payload was exported, rather than 4786specified when creating the semaphore. 4787Additionally, 4788slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes 4789restricts which handle types can: be exported from such a semaphore based on 4790the specific handle type used to import the current payload. 4791ifdef::VK_KHR_swapchain[] 4792Passing a semaphore to flink:vkAcquireNextImageKHR is equivalent to 4793temporarily importing a semaphore payload to that semaphore. 4794 4795[NOTE] 4796.Note 4797==== 4798Because the exportable handle types of an imported semaphore correspond to 4799its current imported payload, and flink:vkAcquireNextImageKHR behaves the 4800same as a temporary import operation for which the source semaphore is 4801opaque to the application, applications have no way of determining whether 4802any external handle types can: be exported from a semaphore in this state. 4803Therefore, applications must: not attempt to export external handles from 4804semaphores using a temporarily imported payload from 4805flink:vkAcquireNextImageKHR. 4806==== 4807endif::VK_KHR_swapchain[] 4808 4809When importing a semaphore payload, it is the responsibility of the 4810application to ensure the external handles meet all valid usage 4811requirements. 4812However, implementations must: perform sufficient validation of external 4813handles to ensure that the operation results in a valid semaphore which will 4814not cause program termination, device loss, queue stalls, or corruption of 4815other resources when used as allowed according to its import parameters, and 4816excepting those side effects allowed for violations of the 4817<<synchronization-semaphores-waiting-state,valid semaphore state for wait 4818operations>> rules. 4819If the external handle provided does not meet these requirements, the 4820implementation must: fail the semaphore payload import operation with the 4821error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 4822 4823ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4824In addition, when importing a semaphore payload that is not compatible with 4825the payload type corresponding to the elink:VkSemaphoreType the semaphore 4826was created with, the implementation may: fail the semaphore payload import 4827operation with the error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 4828 4829[NOTE] 4830.Note 4831==== 4832As the introduction of the external semaphore handle type 4833ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT predates that of 4834timeline semaphores, support for importing semaphore payloads from external 4835handles of that type into semaphores created (implicitly or explicitly) with 4836a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY is preserved for 4837backwards compatibility. 4838However, applications should: prefer importing such handle types into 4839semaphores created with a elink:VkSemaphoreType of 4840ename:VK_SEMAPHORE_TYPE_TIMELINE. 4841==== 4842endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4843endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 4844 4845ifdef::VK_KHR_external_semaphore_win32[] 4846[open,refpage='vkImportSemaphoreWin32HandleKHR',desc='Import a semaphore from a Windows HANDLE',type='protos'] 4847-- 4848To import a semaphore payload from a Windows handle, call: 4849 4850include::{generated}/api/protos/vkImportSemaphoreWin32HandleKHR.adoc[] 4851 4852 * pname:device is the logical device that created the semaphore. 4853 * pname:pImportSemaphoreWin32HandleInfo is a pointer to a 4854 slink:VkImportSemaphoreWin32HandleInfoKHR structure specifying the 4855 semaphore and import parameters. 4856 4857Importing a semaphore payload from Windows handles does not transfer 4858ownership of the handle to the Vulkan implementation. 4859For handle types defined as NT handles, the application must: release 4860ownership using the code:CloseHandle system call when the handle is no 4861longer needed. 4862 4863Applications can: import the same semaphore payload into multiple instances 4864of Vulkan, into the same instance from which it was exported, and multiple 4865times into a given Vulkan instance. 4866 4867include::{generated}/validity/protos/vkImportSemaphoreWin32HandleKHR.adoc[] 4868-- 4869 4870[open,refpage='VkImportSemaphoreWin32HandleInfoKHR',desc='Structure specifying Windows handle to import to a semaphore',type='structs'] 4871-- 4872The sname:VkImportSemaphoreWin32HandleInfoKHR structure is defined as: 4873 4874include::{generated}/api/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] 4875 4876 * pname:sType is a elink:VkStructureType value identifying this structure. 4877 * pname:pNext is `NULL` or a pointer to a structure extending this 4878 structure. 4879 * pname:semaphore is the semaphore into which the payload will be 4880 imported. 4881 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 4882 additional parameters for the semaphore payload import operation. 4883 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 4884 specifying the type of pname:handle. 4885 * pname:handle is `NULL` or the external handle to import. 4886 * pname:name is `NULL` or a null-terminated UTF-16 string naming the 4887 underlying synchronization primitive to import. 4888 4889The handle types supported by pname:handleType are: 4890 4891[[synchronization-semaphore-handletypes-win32]] 4892.Handle Types Supported by sname:VkImportSemaphoreWin32HandleInfoKHR 4893[width="80%",options="header"] 4894|==== 4895| Handle Type | Transference | Permanence Supported 4896| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | Reference | Temporary,Permanent 4897| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | Reference | Temporary,Permanent 4898| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT | Reference | Temporary,Permanent 4899|==== 4900 4901.Valid Usage 4902**** 4903 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140]] 4904 pname:handleType must: be a value included in the 4905 <<synchronization-semaphore-handletypes-win32,Handle Types Supported by 4906 sname:VkImportSemaphoreWin32HandleInfoKHR>> table 4907 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01466]] 4908 If pname:handleType is not 4909 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4910 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, pname:name 4911 must: be `NULL` 4912 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01467]] 4913 If pname:handle is `NULL`, pname:name must: name a valid synchronization 4914 primitive of the type specified by pname:handleType 4915 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01468]] 4916 If pname:name is `NULL`, pname:handle must: be a valid handle of the 4917 type specified by pname:handleType 4918 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01469]] 4919 If pname:handle is not `NULL`, pname:name must: be `NULL` 4920 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01542]] 4921 If pname:handle is not `NULL`, it must: obey any requirements listed for 4922 pname:handleType in 4923 <<external-semaphore-handle-types-compatibility,external semaphore 4924 handle types compatibility>> 4925 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-name-01543]] 4926 If pname:name is not `NULL`, it must: obey any requirements listed for 4927 pname:handleType in 4928 <<external-semaphore-handle-types-compatibility,external semaphore 4929 handle types compatibility>> 4930 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03261]] 4931 If pname:handleType is 4932 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4933 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the 4934 slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the 4935 semaphore from which pname:handle or pname:name was exported 4936ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4937 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03262]] 4938 If pname:handleType is 4939 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4940 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the 4941 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match 4942 that of the semaphore from which pname:handle or pname:name was exported 4943 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-flags-03322]] 4944 If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the 4945 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the 4946 semaphore from which pname:handle or pname:name was exported must: not 4947 be ename:VK_SEMAPHORE_TYPE_TIMELINE 4948endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4949**** 4950 4951include::{generated}/validity/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] 4952-- 4953endif::VK_KHR_external_semaphore_win32[] 4954 4955ifdef::VK_KHR_external_semaphore_fd[] 4956[open,refpage='vkImportSemaphoreFdKHR',desc='Import a semaphore from a POSIX file descriptor',type='protos'] 4957-- 4958:refpage: vkImportSemaphoreFdKHR 4959 4960To import a semaphore payload from a POSIX file descriptor, call: 4961 4962include::{generated}/api/protos/vkImportSemaphoreFdKHR.adoc[] 4963 4964 * pname:device is the logical device that created the semaphore. 4965 * pname:pImportSemaphoreFdInfo is a pointer to a 4966 slink:VkImportSemaphoreFdInfoKHR structure specifying the semaphore and 4967 import parameters. 4968 4969Importing a semaphore payload from a file descriptor transfers ownership of 4970the file descriptor from the application to the Vulkan implementation. 4971The application must: not perform any operations on the file descriptor 4972after a successful import. 4973 4974Applications can: import the same semaphore payload into multiple instances 4975of Vulkan, into the same instance from which it was exported, and multiple 4976times into a given Vulkan instance. 4977 4978include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4979 4980.Valid Usage 4981**** 4982 * [[VUID-vkImportSemaphoreFdKHR-semaphore-01142]] 4983 pname:semaphore must: not be associated with any queue command that has 4984 not yet completed execution on that queue 4985**** 4986 4987include::{generated}/validity/protos/vkImportSemaphoreFdKHR.adoc[] 4988-- 4989 4990[open,refpage='VkImportSemaphoreFdInfoKHR',desc='Structure specifying POSIX file descriptor to import to a semaphore',type='structs'] 4991-- 4992The sname:VkImportSemaphoreFdInfoKHR structure is defined as: 4993 4994include::{generated}/api/structs/VkImportSemaphoreFdInfoKHR.adoc[] 4995 4996 * pname:sType is a elink:VkStructureType value identifying this structure. 4997 * pname:pNext is `NULL` or a pointer to a structure extending this 4998 structure. 4999 * pname:semaphore is the semaphore into which the payload will be 5000 imported. 5001 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 5002 additional parameters for the semaphore payload import operation. 5003 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 5004 specifying the type of pname:fd. 5005 * pname:fd is the external handle to import. 5006 5007The handle types supported by pname:handleType are: 5008 5009[[synchronization-semaphore-handletypes-fd]] 5010.Handle Types Supported by sname:VkImportSemaphoreFdInfoKHR 5011[width="80%",options="header"] 5012|==== 5013| Handle Type | Transference | Permanence Supported 5014| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | Reference | Temporary,Permanent 5015| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT | Copy | Temporary 5016|==== 5017 5018.Valid Usage 5019**** 5020 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-01143]] 5021 pname:handleType must: be a value included in the 5022 <<synchronization-semaphore-handletypes-fd,Handle Types Supported by 5023 sname:VkImportSemaphoreFdInfoKHR>> table 5024 * [[VUID-VkImportSemaphoreFdInfoKHR-fd-01544]] 5025 pname:fd must: obey any requirements listed for pname:handleType in 5026 <<external-semaphore-handle-types-compatibility,external semaphore 5027 handle types compatibility>> 5028 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03263]] 5029 If pname:handleType is 5030 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the 5031 slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the 5032 semaphore from which pname:fd was exported 5033 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-07307]] 5034 If pname:handleType refers to a handle type with copy payload 5035 transference semantics, pname:flags must: contain 5036 ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT 5037ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5038 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03264]] 5039 If pname:handleType is 5040 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the 5041 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match 5042 that of the semaphore from which pname:fd was exported 5043 * [[VUID-VkImportSemaphoreFdInfoKHR-flags-03323]] 5044 If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the 5045 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the 5046 semaphore from which pname:fd was exported must: not be 5047 ename:VK_SEMAPHORE_TYPE_TIMELINE 5048endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5049**** 5050 5051If pname:handleType is ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, 5052the special value `-1` for pname:fd is treated like a valid sync file 5053descriptor referring to an object that has already signaled. 5054The import operation will succeed and the sname:VkSemaphore will have a 5055temporarily imported payload as if a valid file descriptor had been 5056provided. 5057 5058[NOTE] 5059.Note 5060==== 5061This special behavior for importing an invalid sync file descriptor allows 5062easier interoperability with other system APIs which use the convention that 5063an invalid sync file descriptor represents work that has already completed 5064and does not need to be waited for. 5065It is consistent with the option for implementations to return a `-1` file 5066descriptor when exporting a 5067ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT from a sname:VkSemaphore 5068which is signaled. 5069==== 5070 5071include::{generated}/validity/structs/VkImportSemaphoreFdInfoKHR.adoc[] 5072-- 5073endif::VK_KHR_external_semaphore_fd[] 5074 5075ifdef::VK_FUCHSIA_external_semaphore[] 5076[open,refpage='vkImportSemaphoreZirconHandleFUCHSIA',desc='Import a semaphore from a Zircon event handle',type='protos'] 5077-- 5078To import a semaphore payload from a Zircon event handle, call: 5079 5080include::{generated}/api/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] 5081 5082 * pname:device is the logical device that created the semaphore. 5083 * pname:pImportSemaphoreZirconHandleInfo is a pointer to a 5084 slink:VkImportSemaphoreZirconHandleInfoFUCHSIA structure specifying the 5085 semaphore and import parameters. 5086 5087Importing a semaphore payload from a Zircon event handle transfers ownership 5088of the handle from the application to the Vulkan implementation. 5089The application must: not perform any operations on the handle after a 5090successful import. 5091 5092Applications can: import the same semaphore payload into multiple instances 5093of Vulkan, into the same instance from which it was exported, and multiple 5094times into a given Vulkan instance. 5095 5096.Valid Usage 5097**** 5098 * [[VUID-vkImportSemaphoreZirconHandleFUCHSIA-semaphore-04764]] 5099 pname:semaphore must: not be associated with any queue command that has 5100 not yet completed execution on that queue 5101**** 5102 5103include::{generated}/validity/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] 5104-- 5105 5106[open,refpage='VkImportSemaphoreZirconHandleInfoFUCHSIA',desc='Structure specifying Zircon event handle to import to a semaphore',type='structs'] 5107-- 5108The sname:VkImportSemaphoreZirconHandleInfoFUCHSIA structure is defined as: 5109 5110include::{generated}/api/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] 5111 5112 * pname:sType is a elink:VkStructureType value identifying this structure. 5113 * pname:pNext is `NULL` or a pointer to a structure extending this 5114 structure. 5115 * pname:semaphore is the semaphore into which the payload will be 5116 imported. 5117 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 5118 additional parameters for the semaphore payload import operation. 5119 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 5120 specifying the type of pname:zirconHandle. 5121 * pname:zirconHandle is the external handle to import. 5122 5123The handle types supported by pname:handleType are: 5124 5125[[synchronization-semaphore-handletypes-fuchsia]] 5126.Handle Types Supported by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA 5127[width="80%",options="header"] 5128|==== 5129| Handle Type | Transference | Permanence Supported 5130| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA | Reference | Temporary,Permanent 5131|==== 5132 5133.Valid Usage 5134**** 5135 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-handleType-04765]] 5136 pname:handleType must: be a value included in the 5137 <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported 5138 by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> table 5139 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04766]] 5140 pname:zirconHandle must: obey any requirements listed for 5141 pname:handleType in 5142 <<external-semaphore-handle-types-compatibility,external semaphore 5143 handle types compatibility>> 5144 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04767]] 5145 pname:zirconHandle must: have code:ZX_RIGHTS_BASIC and 5146 code:ZX_RIGHTS_SIGNAL rights 5147ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5148 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-semaphoreType-04768]] 5149 The slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: not 5150 be ename:VK_SEMAPHORE_TYPE_TIMELINE 5151endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5152**** 5153 5154include::{generated}/validity/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] 5155-- 5156endif::VK_FUCHSIA_external_semaphore[] 5157 5158ifdef::VK_NV_external_sci_sync[] 5159[open,refpage='vkImportSemaphoreSciSyncObjNV',desc='Import a semaphore from a SciSync handle',type='protos'] 5160-- 5161To import a semaphore payload from a stext:NvSciSyncObj, call: 5162 5163include::{generated}/api/protos/vkImportSemaphoreSciSyncObjNV.adoc[] 5164 5165 * pname:device is the logical device that created the semaphore. 5166 * pname:pImportSemaphoreSciSyncInfo is a pointer to a 5167 slink:VkImportSemaphoreSciSyncInfoNV structure containing parameters of 5168 the import operation 5169 5170Importing a semaphore payload from stext:NvSciSyncObj does not transfer 5171ownership of the handle to the Vulkan implementation. 5172When importing stext:NvSciSyncObj, Vulkan will make a new reference to that 5173object, the application must: release its ownership using 5174<<NvSciSync-extension-page, NvSciSync APIs>> when that ownership is no 5175longer needed. 5176 5177Application must: not import the same stext:NvSciSyncObj with signaler 5178access permissions into multiple instances of VkSemaphore, and must: not 5179import into the same instance from which it was exported. 5180 5181.Valid Usage 5182**** 5183 * [[VUID-vkImportSemaphoreSciSyncObjNV-sciSyncImport-05155]] 5184 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and 5185 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore 5186 must: be enabled 5187**** 5188 5189include::{generated}/validity/protos/vkImportSemaphoreSciSyncObjNV.adoc[] 5190-- 5191 5192[open,refpage='VkImportSemaphoreSciSyncInfoNV',desc='Structure specifying SciSync handle to import to a semaphore',type='structs'] 5193-- 5194The sname:VkImportSemaphoreSciSyncInfoNV structure is defined as: 5195 5196include::{generated}/api/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] 5197 5198 * pname:sType is a elink:VkStructureType value identifying this structure. 5199 * pname:pNext is `NULL` or a pointer to a structure extending this 5200 structure. 5201 * pname:semaphore is the semaphore into which the payload will be 5202 imported. 5203 * pname:handleType specifies the type of stext:handle. 5204 * pname:handle is the external handle to import. 5205 5206The handle types supported by pname:handleType are: 5207 5208[[synchronization-semaphore-handletypes-sci-sync]] 5209.Handle Types Supported by sname:VkImportSemaphoreSciSyncInfoNV 5210[width="80%",options="header"] 5211|==== 5212| Handle Type | Transference | Permanence Supported 5213| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV | Reference | Permanent 5214|==== 5215 5216.Valid Usage 5217**** 5218 * [[VUID-VkImportSemaphoreSciSyncInfoNV-handleType-05126]] 5219 pname:handleType must: be a value included in the 5220 <<synchronization-semaphore-handletypes-sci-sync, Handle Types Supported 5221 by sname:VkImportSemaphoreSciSyncInfoNV>> table 5222 * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05127]] 5223 pname:semaphore must: have been created with a elink:VkSemaphoreType of 5224 ename:VK_SEMAPHORE_TYPE_TIMELINE 5225 * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05128]] 5226 pname:semaphore must: not be associated with any queue command that has 5227 not yet completed execution on that queue 5228**** 5229 5230include::{generated}/validity/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] 5231-- 5232endif::VK_NV_external_sci_sync[] 5233 5234ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 5235ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 5236[open,refpage='VkSemaphoreImportFlagBits',desc='Bitmask specifying additional parameters of semaphore payload import',type='enums'] 5237-- 5238Bits which can: be set in 5239 5240ifdef::VK_KHR_external_semaphore_win32[] 5241 * slink:VkImportSemaphoreWin32HandleInfoKHR::pname:flags 5242endif::VK_KHR_external_semaphore_win32[] 5243ifdef::VK_KHR_external_semaphore_fd[] 5244 * slink:VkImportSemaphoreFdInfoKHR::pname:flags 5245endif::VK_KHR_external_semaphore_fd[] 5246ifdef::VK_FUCHSIA_external_semaphore[] 5247 * slink:VkImportSemaphoreZirconHandleInfoFUCHSIA::pname:flags 5248endif::VK_FUCHSIA_external_semaphore[] 5249 5250specifying additional parameters of a semaphore import operation are: 5251 5252include::{generated}/api/enums/VkSemaphoreImportFlagBits.adoc[] 5253 5254ifdef::VK_KHR_external_semaphore[] 5255or the equivalent 5256 5257include::{generated}/api/enums/VkSemaphoreImportFlagBitsKHR.adoc[] 5258endif::VK_KHR_external_semaphore[] 5259 5260These bits have the following meanings: 5261 5262 * ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT specifies that the semaphore 5263 payload will be imported only temporarily, as described in 5264 <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, 5265 regardless of the permanence of pname:handleType. 5266-- 5267 5268[open,refpage='VkSemaphoreImportFlags',desc='Bitmask of VkSemaphoreImportFlagBits',type='flags'] 5269-- 5270include::{generated}/api/flags/VkSemaphoreImportFlags.adoc[] 5271 5272ifdef::VK_KHR_external_semaphore[] 5273or the equivalent 5274 5275include::{generated}/api/flags/VkSemaphoreImportFlagsKHR.adoc[] 5276endif::VK_KHR_external_semaphore[] 5277 5278tname:VkSemaphoreImportFlags is a bitmask type for setting a mask of zero or 5279more elink:VkSemaphoreImportFlagBits. 5280-- 5281endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 5282endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 5283 5284 5285[[synchronization-events]] 5286== Events 5287 5288[open,refpage='VkEvent',desc='Opaque handle to an event object',type='handles'] 5289-- 5290Events are a synchronization primitive that can: be used to insert a 5291fine-grained dependency between commands submitted to the same queue, or 5292between the host and a queue. 5293Events must: not be used to insert a dependency between commands submitted 5294to different queues. 5295Events have two states - signaled and unsignaled. 5296An application can: signal or unsignal an event either on the host or on the 5297device. 5298A device can: be made to wait for an event to become signaled before 5299executing further operations. 5300No command exists to wait for an event to become signaled on the host, but 5301the current state of an event can: be queried. 5302 5303Events are represented by sname:VkEvent handles: 5304 5305include::{generated}/api/handles/VkEvent.adoc[] 5306-- 5307 5308[open,refpage='vkCreateEvent',desc='Create a new event object',type='protos'] 5309-- 5310:refpage: vkCreateEvent 5311:objectnameplural: events 5312:objectnamecamelcase: event 5313:objectcount: 1 5314 5315To create an event, call: 5316 5317include::{generated}/api/protos/vkCreateEvent.adoc[] 5318 5319 * pname:device is the logical device that creates the event. 5320 * pname:pCreateInfo is a pointer to a slink:VkEventCreateInfo structure 5321 containing information about how the event is to be created. 5322 * pname:pAllocator controls host memory allocation as described in the 5323 <<memory-allocation, Memory Allocation>> chapter. 5324 * pname:pEvent is a pointer to a handle in which the resulting event 5325 object is returned. 5326 5327When created, the event object is in the unsignaled state. 5328 5329include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5330 5331.Valid Usage 5332**** 5333ifdef::VK_KHR_portability_subset[] 5334 * [[VUID-vkCreateEvent-events-04468]] 5335 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 5336 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:events is 5337 ename:VK_FALSE, then the implementation does not support 5338 <<synchronization-events, events>>, and flink:vkCreateEvent must: not be 5339 used 5340endif::VK_KHR_portability_subset[] 5341include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] 5342**** 5343 5344include::{generated}/validity/protos/vkCreateEvent.adoc[] 5345-- 5346 5347[open,refpage='VkEventCreateInfo',desc='Structure specifying parameters of a newly created event',type='structs'] 5348-- 5349The sname:VkEventCreateInfo structure is defined as: 5350 5351include::{generated}/api/structs/VkEventCreateInfo.adoc[] 5352 5353 * pname:sType is a elink:VkStructureType value identifying this structure. 5354 * pname:pNext is `NULL` or a pointer to a structure extending this 5355 structure. 5356 * pname:flags is a bitmask of elink:VkEventCreateFlagBits defining 5357 additional creation parameters. 5358 5359ifdef::VK_EXT_metal_objects[] 5360.Valid Usage 5361**** 5362 * [[VUID-VkEventCreateInfo-pNext-06790]] 5363 If the pname:pNext chain includes a 5364 slink:VkExportMetalObjectCreateInfoEXT structure, its 5365 pname:exportObjectType member must: be 5366 ename:VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT 5367**** 5368endif::VK_EXT_metal_objects[] 5369 5370include::{generated}/validity/structs/VkEventCreateInfo.adoc[] 5371-- 5372 5373[open,refpage='VkEventCreateFlagBits',desc='Event creation flag bits',type='enums'] 5374-- 5375include::{generated}/api/enums/VkEventCreateFlagBits.adoc[] 5376 5377ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5378 * ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT specifies that host event commands 5379 will not be used with this event. 5380endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5381 5382ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5383[NOTE] 5384.Note 5385==== 5386All bits for this type are defined by extensions, and none of those 5387extensions are enabled in this build of the specification. 5388==== 5389endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5390-- 5391 5392[open,refpage='VkEventCreateFlags',desc='Bitmask of event creation flag bits',type='flags'] 5393-- 5394include::{generated}/api/flags/VkEventCreateFlags.adoc[] 5395 5396tname:VkEventCreateFlags is a bitmask type for setting a mask of 5397elink:VkEventCreateFlagBits. 5398-- 5399 5400[open,refpage='vkDestroyEvent',desc='Destroy an event object',type='protos'] 5401-- 5402To destroy an event, call: 5403 5404include::{generated}/api/protos/vkDestroyEvent.adoc[] 5405 5406 * pname:device is the logical device that destroys the event. 5407 * pname:event is the handle of the event to destroy. 5408 * pname:pAllocator controls host memory allocation as described in the 5409 <<memory-allocation, Memory Allocation>> chapter. 5410 5411.Valid Usage 5412**** 5413 * [[VUID-vkDestroyEvent-event-01145]] 5414 All submitted commands that refer to pname:event must: have completed 5415 execution 5416ifndef::VKSC_VERSION_1_0[] 5417 * [[VUID-vkDestroyEvent-event-01146]] 5418 If sname:VkAllocationCallbacks were provided when pname:event was 5419 created, a compatible set of callbacks must: be provided here 5420 * [[VUID-vkDestroyEvent-event-01147]] 5421 If no sname:VkAllocationCallbacks were provided when pname:event was 5422 created, pname:pAllocator must: be `NULL` 5423endif::VKSC_VERSION_1_0[] 5424**** 5425 5426include::{generated}/validity/protos/vkDestroyEvent.adoc[] 5427-- 5428 5429[open,refpage='vkGetEventStatus',desc='Retrieve the status of an event object',type='protos'] 5430-- 5431:refpage: vkGetEventStatus 5432 5433To query the state of an event from the host, call: 5434 5435include::{generated}/api/protos/vkGetEventStatus.adoc[] 5436 5437 * pname:device is the logical device that owns the event. 5438 * pname:event is the handle of the event to query. 5439 5440Upon success, fname:vkGetEventStatus returns the state of the event object 5441with the following return codes: 5442 5443.Event Object Status Codes 5444[width="80%",options="header"] 5445|==== 5446| Status | Meaning 5447| ename:VK_EVENT_SET | The event specified by pname:event is signaled. 5448| ename:VK_EVENT_RESET | The event specified by pname:event is unsignaled. 5449|==== 5450 5451If a fname:vkCmdSetEvent or fname:vkCmdResetEvent command is in a command 5452buffer that is in the <<commandbuffers-lifecycle, pending state>>, then the 5453value returned by this command may: immediately be out of date. 5454 5455The state of an event can: be updated by the host. 5456The state of the event is immediately changed, and subsequent calls to 5457fname:vkGetEventStatus will return the new state. 5458If an event is already in the requested state, then updating it to the same 5459state has no effect. 5460 5461include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5462 5463ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5464.Valid Usage 5465**** 5466 * [[VUID-vkGetEventStatus-event-03940]] 5467 pname:event must: not have been created with 5468 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5469**** 5470endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5471 5472include::{generated}/validity/protos/vkGetEventStatus.adoc[] 5473-- 5474 5475[[synchronization-events-signaling-host]] 5476[open,refpage='vkSetEvent',desc='Set an event to signaled state',type='protos'] 5477-- 5478:refpage: vkSetEvent 5479 5480To set the state of an event to signaled from the host, call: 5481 5482include::{generated}/api/protos/vkSetEvent.adoc[] 5483 5484 * pname:device is the logical device that owns the event. 5485 * pname:event is the event to set. 5486 5487When flink:vkSetEvent is executed on the host, it defines an _event signal 5488operation_ which sets the event to the signaled state. 5489 5490If pname:event is already in the signaled state when flink:vkSetEvent is 5491executed, then flink:vkSetEvent has no effect, and no event signal operation 5492occurs. 5493 5494[NOTE] 5495.Note 5496==== 5497If a command buffer is waiting for an event to be signaled from the host, 5498the application must signal the event before submitting the command buffer, 5499as described in the <<commandbuffers-submission-progress, queue forward 5500progress>> section. 5501==== 5502 5503include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5504 5505ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5506.Valid Usage 5507**** 5508 * [[VUID-vkSetEvent-event-03941]] 5509 pname:event must: not have been created with 5510 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5511**** 5512endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5513 5514include::{generated}/validity/protos/vkSetEvent.adoc[] 5515-- 5516 5517[[synchronization-events-unsignaling-host]] 5518[open,refpage='vkResetEvent',desc='Reset an event to non-signaled state',type='protos'] 5519-- 5520To set the state of an event to unsignaled from the host, call: 5521 5522include::{generated}/api/protos/vkResetEvent.adoc[] 5523 5524 * pname:device is the logical device that owns the event. 5525 * pname:event is the event to reset. 5526 5527When flink:vkResetEvent is executed on the host, it defines an _event 5528unsignal operation_ which resets the event to the unsignaled state. 5529 5530If pname:event is already in the unsignaled state when flink:vkResetEvent is 5531executed, then flink:vkResetEvent has no effect, and no event unsignal 5532operation occurs. 5533 5534.Valid Usage 5535**** 5536 * [[VUID-vkResetEvent-event-03821]] 5537 There must: be an execution dependency between fname:vkResetEvent and 5538 the execution of any flink:vkCmdWaitEvents that includes pname:event in 5539 its pname:pEvents parameter 5540ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5541 * [[VUID-vkResetEvent-event-03822]] 5542 There must: be an execution dependency between fname:vkResetEvent and 5543 the execution of any flink:vkCmdWaitEvents2 that includes pname:event in 5544 its pname:pEvents parameter 5545endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5546ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5547 * [[VUID-vkResetEvent-event-03823]] 5548 pname:event must: not have been created with 5549 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5550endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5551**** 5552 5553include::{generated}/validity/protos/vkResetEvent.adoc[] 5554-- 5555 5556The state of an event can: also be updated on the device by commands 5557inserted in command buffers. 5558 5559[[synchronization-events-signaling-device]] 5560ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5561[open,refpage='vkCmdSetEvent2',desc='Set an event object to signaled state',type='protos',alias='vkCmdSetEvent2KHR'] 5562-- 5563To signal an event from a device, call: 5564 5565ifdef::VK_VERSION_1_3[] 5566include::{generated}/api/protos/vkCmdSetEvent2.adoc[] 5567endif::VK_VERSION_1_3[] 5568 5569ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5570 5571ifdef::VK_KHR_synchronization2[] 5572include::{generated}/api/protos/vkCmdSetEvent2KHR.adoc[] 5573endif::VK_KHR_synchronization2[] 5574 5575 * pname:commandBuffer is the command buffer into which the command is 5576 recorded. 5577 * pname:event is the event that will be signaled. 5578 * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure 5579 defining the first scopes of this operation. 5580 5581When flink:vkCmdSetEvent2 is submitted to a queue, it defines the first half 5582of memory dependencies defined by pname:pDependencyInfo, as well as an event 5583signal operation which sets the event to the signaled state. 5584A memory dependency is defined between the event signal operation and 5585commands that occur earlier in submission order. 5586 5587The first <<synchronization-dependencies-scopes, synchronization scope>> and 5588<<synchronization-dependencies-access-scopes, access scope>> are defined by 5589the union of all the memory dependencies defined by pname:pDependencyInfo, 5590and are applied to all operations that occur earlier in 5591<<synchronization-submission-order,submission order>>. 5592<<synchronization-queue-transfers, Queue family ownership transfers>> and 5593<<synchronization-image-layout-transitions, image layout transitions>> 5594defined by pname:pDependencyInfo are also included in the first scopes. 5595 5596The second <<synchronization-dependencies-scopes, synchronization scope>> 5597includes only the event signal operation, and any 5598<<synchronization-queue-transfers, queue family ownership transfers>> and 5599<<synchronization-image-layout-transitions, image layout transitions>> 5600defined by pname:pDependencyInfo. 5601 5602The second <<synchronization-dependencies-access-scopes, access scope>> 5603includes only <<synchronization-queue-transfers, queue family ownership 5604transfers>> and <<synchronization-image-layout-transitions, image layout 5605transitions>>. 5606 5607Future flink:vkCmdWaitEvents2 commands rely on all values of each element in 5608pname:pDependencyInfo matching exactly with those used to signal the 5609corresponding event. 5610flink:vkCmdWaitEvents must: not be used to wait on the result of a signal 5611operation defined by fname:vkCmdSetEvent2. 5612 5613[NOTE] 5614.Note 5615==== 5616The extra information provided by flink:vkCmdSetEvent2 compared to 5617flink:vkCmdSetEvent allows implementations to more efficiently schedule the 5618operations required to satisfy the requested dependencies. 5619With flink:vkCmdSetEvent, the full dependency information is not known until 5620flink:vkCmdWaitEvents is recorded, forcing implementations to insert the 5621required operations at that point and not before. 5622==== 5623 5624If pname:event is already in the signaled state when flink:vkCmdSetEvent2 is 5625executed on the device, then flink:vkCmdSetEvent2 has no effect, no event 5626signal operation occurs, and no dependency is generated. 5627 5628.Valid Usage 5629**** 5630 * [[VUID-vkCmdSetEvent2-synchronization2-03824]] 5631 The <<features-synchronization2, pname:synchronization2>> feature must: 5632 be enabled 5633 * [[VUID-vkCmdSetEvent2-dependencyFlags-03825]] 5634 The pname:dependencyFlags member of pname:pDependencyInfo must: be `0` 5635 * [[VUID-vkCmdSetEvent2-srcStageMask-09391]] 5636 The pname:srcStageMask member of any element of the 5637 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5638 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not 5639 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5640 * [[VUID-vkCmdSetEvent2-dstStageMask-09392]] 5641 The pname:dstStageMask member of any element of the 5642 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5643 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not 5644 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5645ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5646 * [[VUID-vkCmdSetEvent2-commandBuffer-03826]] 5647 The current device mask of pname:commandBuffer must: include exactly one 5648 physical device 5649endif::VK_VERSION_1_1,VK_KHR_device_group[] 5650 * [[VUID-vkCmdSetEvent2-srcStageMask-03827]] 5651 The pname:srcStageMask member of any element of the 5652 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5653 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 5654 include pipeline stages valid for the queue family that was used to 5655 create the command pool that pname:commandBuffer was allocated from 5656 * [[VUID-vkCmdSetEvent2-dstStageMask-03828]] 5657 The pname:dstStageMask member of any element of the 5658 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5659 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 5660 include pipeline stages valid for the queue family that was used to 5661 create the command pool that pname:commandBuffer was allocated from 5662**** 5663 5664include::{generated}/validity/protos/vkCmdSetEvent2.adoc[] 5665-- 5666 5667[open,refpage='VkDependencyInfo',desc='Structure specifying dependency information for a synchronization command',type='structs',alias='VkDependencyInfoKHR'] 5668-- 5669The sname:VkDependencyInfo structure is defined as: 5670 5671include::{generated}/api/structs/VkDependencyInfo.adoc[] 5672 5673ifdef::VK_KHR_synchronization2[] 5674or the equivalent 5675 5676include::{generated}/api/structs/VkDependencyInfoKHR.adoc[] 5677endif::VK_KHR_synchronization2[] 5678 5679 * pname:sType is a elink:VkStructureType value identifying this structure. 5680 * pname:pNext is `NULL` or a pointer to a structure extending this 5681 structure. 5682 * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits 5683 specifying how execution and memory dependencies are formed. 5684 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 5685 array. 5686 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier2 5687 structures defining memory dependencies between any memory accesses. 5688 * pname:bufferMemoryBarrierCount is the length of the 5689 pname:pBufferMemoryBarriers array. 5690 * pname:pBufferMemoryBarriers is a pointer to an array of 5691 slink:VkBufferMemoryBarrier2 structures defining memory dependencies 5692 between buffer ranges. 5693 * pname:imageMemoryBarrierCount is the length of the 5694 pname:pImageMemoryBarriers array. 5695 * pname:pImageMemoryBarriers is a pointer to an array of 5696 slink:VkImageMemoryBarrier2 structures defining memory dependencies 5697 between image subresources. 5698 5699This structure defines a set of <<synchronization-dependencies-memory, 5700memory dependencies>>, as well as <<synchronization-queue-transfers, queue 5701family transfer operations>> and <<synchronization-image-layout-transitions, 5702image layout transitions>>. 5703 5704Each member of pname:pMemoryBarriers, pname:pBufferMemoryBarriers, and 5705pname:pImageMemoryBarriers defines a separate 5706<<synchronization-dependencies-memory, memory dependency>>. 5707 5708include::{generated}/validity/structs/VkDependencyInfo.adoc[] 5709-- 5710endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5711 5712[open,refpage='vkCmdSetEvent',desc='Set an event object to signaled state',type='protos'] 5713-- 5714:refpage: vkCmdSetEvent 5715 5716To set the state of an event to signaled from a device, call: 5717 5718include::{generated}/api/protos/vkCmdSetEvent.adoc[] 5719 5720 * pname:commandBuffer is the command buffer into which the command is 5721 recorded. 5722 * pname:event is the event that will be signaled. 5723 * pname:stageMask specifies the <<synchronization-pipeline-stages,source 5724 stage mask>> used to determine the first 5725 <<synchronization-dependencies-scopes, synchronization scope>>. 5726 5727 5728ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5729fname:vkCmdSetEvent behaves identically to flink:vkCmdSetEvent2, except that 5730it does not define an access scope, and must: only be used with 5731flink:vkCmdWaitEvents, not flink:vkCmdWaitEvents2. 5732endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5733 5734ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5735When flink:vkCmdSetEvent is submitted to a queue, it defines an execution 5736dependency on commands that were submitted before it, and defines an event 5737signal operation which sets the event to the signaled state. 5738 5739The first <<synchronization-dependencies-scopes, synchronization scope>> 5740includes all commands that occur earlier in 5741<<synchronization-submission-order,submission order>>. 5742The synchronization scope is limited to operations on the pipeline stages 5743determined by the <<synchronization-pipeline-stages-masks, source stage 5744mask>> specified by pname:stageMask. 5745 5746The second <<synchronization-dependencies-scopes, synchronization scope>> 5747includes only the event signal operation. 5748 5749If pname:event is already in the signaled state when flink:vkCmdSetEvent is 5750executed on the device, then flink:vkCmdSetEvent has no effect, no event 5751signal operation occurs, and no execution dependency is generated. 5752endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5753 5754.Valid Usage 5755**** 5756:stageMaskName: stageMask 5757include::{chapters}/commonvalidity/stage_mask_common.adoc[] 5758 * [[VUID-vkCmdSetEvent-stageMask-06457]] 5759 Any pipeline stage included in pname:stageMask must: be supported by the 5760 capabilities of the queue family specified by the pname:queueFamilyIndex 5761 member of the slink:VkCommandPoolCreateInfo structure that was used to 5762 create the sname:VkCommandPool that pname:commandBuffer was allocated 5763 from, as specified in the <<synchronization-pipeline-stages-supported, 5764 table of supported pipeline stages>> 5765 * [[VUID-vkCmdSetEvent-stageMask-01149]] 5766 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 5767ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5768 * [[VUID-vkCmdSetEvent-commandBuffer-01152]] 5769 The current device mask of pname:commandBuffer must: include exactly one 5770 physical device 5771endif::VK_VERSION_1_1,VK_KHR_device_group[] 5772**** 5773 5774include::{generated}/validity/protos/vkCmdSetEvent.adoc[] 5775-- 5776 5777[[synchronization-events-unsignaling-device]] 5778ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5779[open,refpage='vkCmdResetEvent2',desc='Reset an event object to non-signaled state',type='protos',alias='vkCmdResetEvent2KHR'] 5780-- 5781:refpage: vkCmdResetEvent2 5782 5783To unsignal the event from a device, call: 5784 5785ifdef::VK_VERSION_1_3[] 5786include::{generated}/api/protos/vkCmdResetEvent2.adoc[] 5787endif::VK_VERSION_1_3[] 5788 5789ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5790 5791ifdef::VK_KHR_synchronization2[] 5792include::{generated}/api/protos/vkCmdResetEvent2KHR.adoc[] 5793endif::VK_KHR_synchronization2[] 5794 5795 * pname:commandBuffer is the command buffer into which the command is 5796 recorded. 5797 * pname:event is the event that will be unsignaled. 5798 * pname:stageMask is a tlink:VkPipelineStageFlags2 mask of pipeline stages 5799 used to determine the first <<synchronization-dependencies-scopes, 5800 synchronization scope>>. 5801 5802When flink:vkCmdResetEvent2 is submitted to a queue, it defines an execution 5803dependency on commands that were submitted before it, and defines an event 5804unsignal operation which resets the event to the unsignaled state. 5805 5806The first <<synchronization-dependencies-scopes, synchronization scope>> 5807includes all commands that occur earlier in 5808<<synchronization-submission-order,submission order>>. 5809The synchronization scope is limited to operations by pname:stageMask or 5810stages that are <<synchronization-pipeline-stages-order,logically earlier>> 5811than pname:stageMask. 5812 5813The second <<synchronization-dependencies-scopes, synchronization scope>> 5814includes only the event unsignal operation. 5815 5816If pname:event is already in the unsignaled state when 5817flink:vkCmdResetEvent2 is executed on the device, then this command has no 5818effect, no event unsignal operation occurs, and no execution dependency is 5819generated. 5820 5821.Valid Usage 5822**** 5823:stageMaskName: stageMask 5824include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 5825 * [[VUID-vkCmdResetEvent2-synchronization2-03829]] 5826 The <<features-synchronization2, pname:synchronization2>> feature must: 5827 be enabled 5828 * [[VUID-vkCmdResetEvent2-stageMask-03830]] 5829 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5830 * [[VUID-vkCmdResetEvent2-event-03831]] 5831 There must: be an execution dependency between fname:vkCmdResetEvent2 5832 and the execution of any flink:vkCmdWaitEvents that includes pname:event 5833 in its pname:pEvents parameter 5834 * [[VUID-vkCmdResetEvent2-event-03832]] 5835 There must: be an execution dependency between fname:vkCmdResetEvent2 5836 and the execution of any flink:vkCmdWaitEvents2 that includes 5837 pname:event in its pname:pEvents parameter 5838ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5839 * [[VUID-vkCmdResetEvent2-commandBuffer-03833]] 5840 pname:commandBuffer's current device mask must: include exactly one 5841 physical device 5842endif::VK_VERSION_1_1,VK_KHR_device_group[] 5843**** 5844 5845include::{generated}/validity/protos/vkCmdResetEvent2.adoc[] 5846-- 5847endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5848 5849[open,refpage='vkCmdResetEvent',desc='Reset an event object to non-signaled state',type='protos'] 5850-- 5851:refpage: vkCmdResetEvent 5852 5853To set the state of an event to unsignaled from a device, call: 5854 5855include::{generated}/api/protos/vkCmdResetEvent.adoc[] 5856 5857 * pname:commandBuffer is the command buffer into which the command is 5858 recorded. 5859 * pname:event is the event that will be unsignaled. 5860 * pname:stageMask is a bitmask of elink:VkPipelineStageFlagBits specifying 5861 the <<synchronization-pipeline-stages, source stage mask>> used to 5862 determine when the pname:event is unsignaled. 5863 5864ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5865fname:vkCmdResetEvent behaves identically to flink:vkCmdResetEvent2. 5866endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5867 5868ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5869When flink:vkCmdResetEvent is submitted to a queue, it defines an execution 5870dependency on commands that were submitted before it, and defines an event 5871unsignal operation which resets the event to the unsignaled state. 5872 5873The first <<synchronization-dependencies-scopes, synchronization scope>> 5874includes all commands that occur earlier in 5875<<synchronization-submission-order,submission order>>. 5876The synchronization scope is limited to operations on the pipeline stages 5877determined by the <<synchronization-pipeline-stages-masks, source stage 5878mask>> specified by pname:stageMask. 5879 5880The second <<synchronization-dependencies-scopes, synchronization scope>> 5881includes only the event unsignal operation. 5882 5883If pname:event is already in the unsignaled state when flink:vkCmdResetEvent 5884is executed on the device, then flink:vkCmdResetEvent has no effect, no 5885event unsignal operation occurs, and no execution dependency is generated. 5886endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5887 5888.Valid Usage 5889**** 5890:stageMaskName: stageMask 5891include::{chapters}/commonvalidity/stage_mask_common.adoc[] 5892 * [[VUID-vkCmdResetEvent-stageMask-06458]] 5893 Any pipeline stage included in pname:stageMask must: be supported by the 5894 capabilities of the queue family specified by the pname:queueFamilyIndex 5895 member of the slink:VkCommandPoolCreateInfo structure that was used to 5896 create the sname:VkCommandPool that pname:commandBuffer was allocated 5897 from, as specified in the <<synchronization-pipeline-stages-supported, 5898 table of supported pipeline stages>> 5899 * [[VUID-vkCmdResetEvent-stageMask-01153]] 5900 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 5901 * [[VUID-vkCmdResetEvent-event-03834]] 5902 There must: be an execution dependency between fname:vkCmdResetEvent and 5903 the execution of any flink:vkCmdWaitEvents that includes pname:event in 5904 its pname:pEvents parameter 5905ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5906 * [[VUID-vkCmdResetEvent-event-03835]] 5907 There must: be an execution dependency between fname:vkCmdResetEvent and 5908 the execution of any flink:vkCmdWaitEvents2 that includes pname:event in 5909 its pname:pEvents parameter 5910endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5911ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5912 * [[VUID-vkCmdResetEvent-commandBuffer-01157]] 5913 pname:commandBuffer's current device mask must: include exactly one 5914 physical device 5915endif::VK_VERSION_1_1,VK_KHR_device_group[] 5916**** 5917 5918include::{generated}/validity/protos/vkCmdResetEvent.adoc[] 5919-- 5920 5921ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5922[open,refpage='vkCmdWaitEvents2',desc='Wait for one or more events',type='protos',alias='vkCmdWaitEvents2KHR'] 5923-- 5924To wait for one or more events to enter the signaled state on a device, 5925call: 5926 5927[[synchronization-events-waiting-device]] 5928ifdef::VK_VERSION_1_3[] 5929include::{generated}/api/protos/vkCmdWaitEvents2.adoc[] 5930endif::VK_VERSION_1_3[] 5931 5932ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5933 5934ifdef::VK_KHR_synchronization2[] 5935include::{generated}/api/protos/vkCmdWaitEvents2KHR.adoc[] 5936endif::VK_KHR_synchronization2[] 5937 5938 * pname:commandBuffer is the command buffer into which the command is 5939 recorded. 5940 * pname:eventCount is the length of the pname:pEvents array. 5941 * pname:pEvents is a pointer to an array of pname:eventCount events to 5942 wait on. 5943 * pname:pDependencyInfos is a pointer to an array of pname:eventCount 5944 slink:VkDependencyInfo structures, defining the second 5945 <<synchronization-dependencies-scopes, synchronization scope>>. 5946 5947When fname:vkCmdWaitEvents2 is submitted to a queue, it inserts memory 5948dependencies according to the elements of pname:pDependencyInfos and each 5949corresponding element of pname:pEvents. 5950fname:vkCmdWaitEvents2 must: not be used to wait on event signal operations 5951occurring on other queues, or signal operations executed by 5952flink:vkCmdSetEvent. 5953 5954The first <<synchronization-dependencies-scopes, synchronization scope>> and 5955<<synchronization-dependencies-access-scopes, access scope>> of each memory 5956dependency defined by any element [eq]#i# of pname:pDependencyInfos are 5957applied to operations that occurred earlier in 5958<<synchronization-submission-order,submission order>> than the last event 5959signal operation on element [eq]#i# of pname:pEvents. 5960 5961Signal operations for an event at index [eq]#i# are only included if: 5962 5963 * The event was signaled by a flink:vkCmdSetEvent2 command that occurred 5964 earlier in <<synchronization-submission-order,submission order>> with a 5965 pname:dependencyInfo parameter exactly equal to the element of 5966 pname:pDependencyInfos at index [eq]#i# ; or 5967 * The event was created without ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT, and 5968 the first <<synchronization-dependencies-scopes, synchronization scope>> 5969 defined by the element of pname:pDependencyInfos at index [eq]#i# only 5970 includes host operations (ename:VK_PIPELINE_STAGE_2_HOST_BIT). 5971 5972The second <<synchronization-dependencies-scopes, synchronization scope>> 5973and <<synchronization-dependencies-access-scopes, access scope>> of each 5974memory dependency defined by any element [eq]#i# of pname:pDependencyInfos 5975are applied to operations that occurred later in 5976<<synchronization-submission-order,submission order>> than 5977fname:vkCmdWaitEvents2. 5978 5979[NOTE] 5980.Note 5981==== 5982flink:vkCmdWaitEvents2 is used with flink:vkCmdSetEvent2 to define a memory 5983dependency between two sets of action commands, roughly in the same way as 5984pipeline barriers, but split into two commands such that work between the 5985two may: execute unhindered. 5986==== 5987 5988[NOTE] 5989.Note 5990==== 5991Applications should be careful to avoid race conditions when using events. 5992There is no direct ordering guarantee between fname:vkCmdSetEvent2 and 5993flink:vkCmdResetEvent2, flink:vkCmdResetEvent, or flink:vkCmdSetEvent. 5994Another execution dependency (e.g. a pipeline barrier or semaphore with 5995ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT) is needed to prevent such a race 5996condition. 5997==== 5998 5999.Valid Usage 6000**** 6001 * [[VUID-vkCmdWaitEvents2-synchronization2-03836]] 6002 The <<features-synchronization2, pname:synchronization2>> feature must: 6003 be enabled 6004 * [[VUID-vkCmdWaitEvents2-pEvents-03837]] 6005 Members of pname:pEvents must: not have been signaled by 6006 flink:vkCmdSetEvent 6007 * [[VUID-vkCmdWaitEvents2-pEvents-03838]] 6008 For any element [eq]#i# of pname:pEvents, if that event is signaled by 6009 flink:vkCmdSetEvent2, that command's pname:dependencyInfo parameter 6010 must: be exactly equal to the [eq]##i##th element of 6011 pname:pDependencyInfos 6012 * [[VUID-vkCmdWaitEvents2-pEvents-03839]] 6013 For any element [eq]#i# of pname:pEvents, if that event is signaled by 6014 flink:vkSetEvent, barriers in the [eq]##i##th element of 6015 pname:pDependencyInfos must: include only host operations in their first 6016 <<synchronization-dependencies-scopes, synchronization scope>> 6017 * [[VUID-vkCmdWaitEvents2-pEvents-03840]] 6018 For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th 6019 element of pname:pDependencyInfos include only host operations, the 6020 [eq]##i##th element of pname:pEvents must: be signaled before 6021 flink:vkCmdWaitEvents2 is executed 6022 * [[VUID-vkCmdWaitEvents2-pEvents-03841]] 6023 For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th 6024 element of pname:pDependencyInfos do not include host operations, the 6025 [eq]##i##th element of pname:pEvents must: be signaled by a 6026 corresponding flink:vkCmdSetEvent2 that occurred earlier in 6027 <<synchronization-submission-order,submission order>> 6028 * [[VUID-vkCmdWaitEvents2-srcStageMask-03842]] 6029 The pname:srcStageMask member of any element of the 6030 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6031 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: 6032 either include only pipeline stages valid for the queue family that was 6033 used to create the command pool that pname:commandBuffer was allocated 6034 from 6035 * [[VUID-vkCmdWaitEvents2-dstStageMask-03843]] 6036 The pname:dstStageMask member of any element of the 6037 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6038 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: only 6039 include pipeline stages valid for the queue family that was used to 6040 create the command pool that pname:commandBuffer was allocated from 6041 * [[VUID-vkCmdWaitEvents2-dependencyFlags-03844]] 6042 If fname:vkCmdWaitEvents2 is being called inside a render pass instance, 6043 the pname:srcStageMask member of any element of the 6044 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6045 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: not 6046 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 6047 * [[VUID-vkCmdWaitEvents2-commandBuffer-03846]] 6048 pname:commandBuffer's current device mask must: include exactly one 6049 physical device 6050**** 6051 6052include::{generated}/validity/protos/vkCmdWaitEvents2.adoc[] 6053-- 6054endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6055 6056[open,refpage='vkCmdWaitEvents',desc='Wait for one or more events and insert a set of memory',type='protos'] 6057-- 6058:refpage: vkCmdWaitEvents 6059 6060To wait for one or more events to enter the signaled state on a device, 6061call: 6062 6063[[synchronization-events-waiting-device]] 6064include::{generated}/api/protos/vkCmdWaitEvents.adoc[] 6065 6066 * pname:commandBuffer is the command buffer into which the command is 6067 recorded. 6068 * pname:eventCount is the length of the pname:pEvents array. 6069 * pname:pEvents is a pointer to an array of event object handles to wait 6070 on. 6071 * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits 6072 specifying the <<synchronization-pipeline-stages, source stage mask>>. 6073 * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits 6074 specifying the <<synchronization-pipeline-stages, destination stage 6075 mask>>. 6076 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 6077 array. 6078 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier 6079 structures. 6080 * pname:bufferMemoryBarrierCount is the length of the 6081 pname:pBufferMemoryBarriers array. 6082 * pname:pBufferMemoryBarriers is a pointer to an array of 6083 slink:VkBufferMemoryBarrier structures. 6084 * pname:imageMemoryBarrierCount is the length of the 6085 pname:pImageMemoryBarriers array. 6086 * pname:pImageMemoryBarriers is a pointer to an array of 6087 slink:VkImageMemoryBarrier structures. 6088 6089ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6090fname:vkCmdWaitEvents is largely similar to flink:vkCmdWaitEvents2, but can: 6091only wait on signal operations defined by flink:vkCmdSetEvent. 6092As flink:vkCmdSetEvent does not define any access scopes, 6093fname:vkCmdWaitEvents defines the first access scope for each event signal 6094operation in addition to its own access scopes. 6095 6096[NOTE] 6097.Note 6098==== 6099Since flink:vkCmdSetEvent does not have any dependency information beyond a 6100stage mask, implementations do not have the same opportunity to perform 6101<<synchronization-dependencies-available-and-visible, availability and 6102visibility operations>> or <<synchronization-image-layout-transitions, image 6103layout transitions>> in advance as they do with flink:vkCmdSetEvent2 and 6104flink:vkCmdWaitEvents2. 6105==== 6106endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6107 6108When fname:vkCmdWaitEvents is submitted to a queue, it defines a memory 6109dependency between prior event signal operations on the same queue or the 6110host, and subsequent commands. 6111fname:vkCmdWaitEvents must: not be used to wait on event signal operations 6112occurring on other queues. 6113 6114The first synchronization scope only includes event signal operations that 6115operate on members of pname:pEvents, and the operations that happened-before 6116the event signal operations. 6117Event signal operations performed by flink:vkCmdSetEvent that occur earlier 6118in <<synchronization-submission-order,submission order>> are included in the 6119first synchronization scope, if the <<synchronization-pipeline-stages-order, 6120logically latest>> pipeline stage in their pname:stageMask parameter is 6121<<synchronization-pipeline-stages-order, logically earlier>> than or equal 6122to the <<synchronization-pipeline-stages-order, logically latest>> pipeline 6123stage in pname:srcStageMask. 6124Event signal operations performed by flink:vkSetEvent are only included in 6125the first synchronization scope if ename:VK_PIPELINE_STAGE_HOST_BIT is 6126included in pname:srcStageMask. 6127 6128The second <<synchronization-dependencies-scopes, synchronization scope>> 6129includes all commands that occur later in 6130<<synchronization-submission-order,submission order>>. 6131The second synchronization scope is limited to operations on the pipeline 6132stages determined by the <<synchronization-pipeline-stages-masks, 6133destination stage mask>> specified by pname:dstStageMask. 6134 6135The first <<synchronization-dependencies-access-scopes, access scope>> is 6136limited to accesses in the pipeline stages determined by the 6137<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6138pname:srcStageMask. 6139Within that, the first access scope only includes the first access scopes 6140defined by elements of the pname:pMemoryBarriers, 6141pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6142each define a set of <<synchronization-memory-barriers, memory barriers>>. 6143If no memory barriers are specified, then the first access scope includes no 6144accesses. 6145 6146The second <<synchronization-dependencies-access-scopes, access scope>> is 6147limited to accesses in the pipeline stages determined by the 6148<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6149by pname:dstStageMask. 6150Within that, the second access scope only includes the second access scopes 6151defined by elements of the pname:pMemoryBarriers, 6152pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6153each define a set of <<synchronization-memory-barriers, memory barriers>>. 6154If no memory barriers are specified, then the second access scope includes 6155no accesses. 6156 6157ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6158[NOTE] 6159.Note 6160==== 6161flink:vkCmdWaitEvents is used with flink:vkCmdSetEvent to define a memory 6162dependency between two sets of action commands, roughly in the same way as 6163pipeline barriers, but split into two commands such that work between the 6164two may: execute unhindered. 6165 6166Unlike flink:vkCmdPipelineBarrier, a <<synchronization-queue-transfers, 6167queue family ownership transfer>> cannot: be performed using 6168flink:vkCmdWaitEvents. 6169==== 6170 6171[NOTE] 6172.Note 6173==== 6174Applications should be careful to avoid race conditions when using events. 6175There is no direct ordering guarantee between flink:vkCmdWaitEvents and 6176ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[flink:vkCmdResetEvent2,] 6177flink:vkCmdResetEvent, or flink:vkCmdSetEvent. 6178Another execution dependency (e.g. a pipeline barrier or semaphore with 6179ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) is needed to prevent such a race 6180condition. 6181==== 6182endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6183 6184.Valid Usage 6185**** 6186:stageMaskName: srcStageMask 6187:accessMaskName: srcAccessMask 6188include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6189include::{chapters}/commonvalidity/access_mask_common.adoc[] 6190 6191:stageMaskName: dstStageMask 6192:accessMaskName: dstAccessMask 6193include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6194include::{chapters}/commonvalidity/access_mask_common.adoc[] 6195include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] 6196 * [[VUID-vkCmdWaitEvents-srcStageMask-06459]] 6197 Any pipeline stage included in pname:srcStageMask must: be supported by 6198 the capabilities of the queue family specified by the 6199 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6200 structure that was used to create the sname:VkCommandPool that 6201 pname:commandBuffer was allocated from, as specified in the 6202 <<synchronization-pipeline-stages-supported, table of supported pipeline 6203 stages>> 6204 * [[VUID-vkCmdWaitEvents-dstStageMask-06460]] 6205 Any pipeline stage included in pname:dstStageMask must: be supported by 6206 the capabilities of the queue family specified by the 6207 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6208 structure that was used to create the sname:VkCommandPool that 6209 pname:commandBuffer was allocated from, as specified in the 6210 <<synchronization-pipeline-stages-supported, table of supported pipeline 6211 stages>> 6212 * [[VUID-vkCmdWaitEvents-srcStageMask-01158]] 6213 pname:srcStageMask must: be the bitwise OR of the pname:stageMask 6214 parameter used in previous calls to fname:vkCmdSetEvent with any of the 6215 elements of pname:pEvents and ename:VK_PIPELINE_STAGE_HOST_BIT if any of 6216 the elements of pname:pEvents was set using fname:vkSetEvent 6217 * [[VUID-vkCmdWaitEvents-srcStageMask-07308]] 6218 If fname:vkCmdWaitEvents is being called inside a render pass instance, 6219 pname:srcStageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 6220 * [[VUID-vkCmdWaitEvents-srcQueueFamilyIndex-02803]] 6221 The pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex members of 6222 any element of pname:pBufferMemoryBarriers or pname:pImageMemoryBarriers 6223 must: be equal 6224ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 6225 * [[VUID-vkCmdWaitEvents-commandBuffer-01167]] 6226 pname:commandBuffer's current device mask must: include exactly one 6227 physical device 6228endif::VK_VERSION_1_1,VK_KHR_device_group[] 6229ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6230 * [[VUID-vkCmdWaitEvents-pEvents-03847]] 6231 Elements of pname:pEvents must: not have been signaled by 6232 flink:vkCmdSetEvent2 6233endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6234**** 6235 6236include::{generated}/validity/protos/vkCmdWaitEvents.adoc[] 6237-- 6238 6239 6240[[synchronization-pipeline-barriers]] 6241== Pipeline Barriers 6242 6243ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6244[open,refpage='vkCmdPipelineBarrier2',desc='Insert a memory dependency',type='protos',alias='vkCmdPipelineBarrier2KHR'] 6245-- 6246:refpage: vkCmdPipelineBarrier2 6247 6248To record a pipeline barrier, call: 6249 6250ifdef::VK_VERSION_1_3[] 6251include::{generated}/api/protos/vkCmdPipelineBarrier2.adoc[] 6252endif::VK_VERSION_1_3[] 6253 6254ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 6255 6256ifdef::VK_KHR_synchronization2[] 6257include::{generated}/api/protos/vkCmdPipelineBarrier2KHR.adoc[] 6258endif::VK_KHR_synchronization2[] 6259 6260 * pname:commandBuffer is the command buffer into which the command is 6261 recorded. 6262 * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure 6263 defining the scopes of this operation. 6264 6265When flink:vkCmdPipelineBarrier2 is submitted to a queue, it defines memory 6266dependencies between commands that were submitted to the same queue before 6267it, and those submitted to the same queue after it. 6268 6269The first <<synchronization-dependencies-scopes, synchronization scope>> and 6270<<synchronization-dependencies-access-scopes, access scope>> of each memory 6271dependency defined by pname:pDependencyInfo are applied to operations that 6272occurred earlier in <<synchronization-submission-order,submission order>>. 6273 6274The second <<synchronization-dependencies-scopes, synchronization scope>> 6275and <<synchronization-dependencies-access-scopes, access scope>> of each 6276memory dependency defined by pname:pDependencyInfo are applied to operations 6277that occurred later in <<synchronization-submission-order,submission 6278order>>. 6279 6280If fname:vkCmdPipelineBarrier2 is recorded within a render pass instance, 6281the synchronization scopes are limited to operations within the same subpass 6282ifdef::VK_EXT_shader_tile_image[] 6283, or must: follow the restrictions for 6284<<synchronization-pipeline-barriers-explicit-renderpass-tileimage, Tile 6285Image Access Synchronization>> if the render pass instance was started with 6286flink:vkCmdBeginRendering 6287endif::VK_EXT_shader_tile_image[] 6288. 6289 6290.Valid Usage 6291**** 6292include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] 6293 * [[VUID-vkCmdPipelineBarrier2-synchronization2-03848]] 6294 The <<features-synchronization2, pname:synchronization2>> feature must: 6295 be enabled 6296 * [[VUID-vkCmdPipelineBarrier2-srcStageMask-03849]] 6297 The pname:srcStageMask member of any element of the 6298 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6299 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 6300 include pipeline stages valid for the queue family that was used to 6301 create the command pool that pname:commandBuffer was allocated from 6302 * [[VUID-vkCmdPipelineBarrier2-dstStageMask-03850]] 6303 The pname:dstStageMask member of any element of the 6304 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6305 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 6306 include pipeline stages valid for the queue family that was used to 6307 create the command pool that pname:commandBuffer was allocated from 6308**** 6309 6310include::{generated}/validity/protos/vkCmdPipelineBarrier2.adoc[] 6311-- 6312endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6313 6314[open,refpage='vkCmdPipelineBarrier',desc='Insert a memory dependency',type='protos'] 6315-- 6316:refpage: vkCmdPipelineBarrier 6317 6318To record a pipeline barrier, call: 6319 6320include::{generated}/api/protos/vkCmdPipelineBarrier.adoc[] 6321 6322 * pname:commandBuffer is the command buffer into which the command is 6323 recorded. 6324 * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits 6325 specifying the <<synchronization-pipeline-stages-masks,source stages>>. 6326 * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits 6327 specifying the <<synchronization-pipeline-stages-masks,destination 6328 stages>>. 6329 * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits 6330 specifying how execution and memory dependencies are formed. 6331 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 6332 array. 6333 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier 6334 structures. 6335 * pname:bufferMemoryBarrierCount is the length of the 6336 pname:pBufferMemoryBarriers array. 6337 * pname:pBufferMemoryBarriers is a pointer to an array of 6338 slink:VkBufferMemoryBarrier structures. 6339 * pname:imageMemoryBarrierCount is the length of the 6340 pname:pImageMemoryBarriers array. 6341 * pname:pImageMemoryBarriers is a pointer to an array of 6342 slink:VkImageMemoryBarrier structures. 6343 6344ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6345fname:vkCmdPipelineBarrier operates almost identically to 6346flink:vkCmdPipelineBarrier2, except that the scopes and barriers are defined 6347as direct parameters rather than being defined by an slink:VkDependencyInfo. 6348endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6349 6350When flink:vkCmdPipelineBarrier is submitted to a queue, it defines a memory 6351dependency between commands that were submitted to the same queue before it, 6352and those submitted to the same queue after it. 6353 6354If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, 6355the first <<synchronization-dependencies-scopes, synchronization scope>> 6356includes all commands that occur earlier in 6357<<synchronization-submission-order,submission order>>. 6358If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, 6359the first synchronization scope includes only commands that occur earlier in 6360<<synchronization-submission-order,submission order>> within the same 6361subpass. 6362In either case, the first synchronization scope is limited to operations on 6363the pipeline stages determined by the 6364<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6365pname:srcStageMask. 6366 6367If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, 6368the second <<synchronization-dependencies-scopes, synchronization scope>> 6369includes all commands that occur later in 6370<<synchronization-submission-order,submission order>>. 6371If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, 6372the second synchronization scope includes only commands that occur later in 6373<<synchronization-submission-order,submission order>> within the same 6374subpass. 6375In either case, the second synchronization scope is limited to operations on 6376the pipeline stages determined by the 6377<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6378by pname:dstStageMask. 6379 6380The first <<synchronization-dependencies-access-scopes, access scope>> is 6381limited to accesses in the pipeline stages determined by the 6382<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6383pname:srcStageMask. 6384Within that, the first access scope only includes the first access scopes 6385defined by elements of the pname:pMemoryBarriers, 6386pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6387each define a set of <<synchronization-memory-barriers, memory barriers>>. 6388If no memory barriers are specified, then the first access scope includes no 6389accesses. 6390 6391The second <<synchronization-dependencies-access-scopes, access scope>> is 6392limited to accesses in the pipeline stages determined by the 6393<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6394by pname:dstStageMask. 6395Within that, the second access scope only includes the second access scopes 6396defined by elements of the pname:pMemoryBarriers, 6397pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6398each define a set of <<synchronization-memory-barriers, memory barriers>>. 6399If no memory barriers are specified, then the second access scope includes 6400no accesses. 6401 6402If pname:dependencyFlags includes ename:VK_DEPENDENCY_BY_REGION_BIT, then 6403any dependency between <<synchronization-framebuffer-regions, 6404framebuffer-space>> pipeline stages is 6405<<synchronization-framebuffer-regions, framebuffer-local>> - otherwise it is 6406<<synchronization-framebuffer-regions, framebuffer-global>>. 6407 6408.Valid Usage 6409**** 6410:stageMaskName: srcStageMask 6411:accessMaskName: srcAccessMask 6412include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6413include::{chapters}/commonvalidity/access_mask_common.adoc[] 6414 6415:stageMaskName: dstStageMask 6416:accessMaskName: dstAccessMask 6417include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6418include::{chapters}/commonvalidity/access_mask_common.adoc[] 6419include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] 6420include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] 6421 * [[VUID-vkCmdPipelineBarrier-srcStageMask-06461]] 6422 Any pipeline stage included in pname:srcStageMask must: be supported by 6423 the capabilities of the queue family specified by the 6424 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6425 structure that was used to create the sname:VkCommandPool that 6426 pname:commandBuffer was allocated from, as specified in the 6427 <<synchronization-pipeline-stages-supported, table of supported pipeline 6428 stages>> 6429 * [[VUID-vkCmdPipelineBarrier-dstStageMask-06462]] 6430 Any pipeline stage included in pname:dstStageMask must: be supported by 6431 the capabilities of the queue family specified by the 6432 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6433 structure that was used to create the sname:VkCommandPool that 6434 pname:commandBuffer was allocated from, as specified in the 6435 <<synchronization-pipeline-stages-supported, table of supported pipeline 6436 stages>> 6437**** 6438 6439include::{generated}/validity/protos/vkCmdPipelineBarrier.adoc[] 6440-- 6441 6442[open,refpage='VkDependencyFlagBits',desc='Bitmask specifying how execution and memory dependencies are formed',type='enums'] 6443-- 6444Bits which can: be set in fname:vkCmdPipelineBarrier::pname:dependencyFlags, 6445specifying how execution and memory dependencies are formed, are: 6446 6447include::{generated}/api/enums/VkDependencyFlagBits.adoc[] 6448 6449 * ename:VK_DEPENDENCY_BY_REGION_BIT specifies that dependencies will be 6450 <<synchronization-framebuffer-regions, framebuffer-local>>. 6451ifdef::VK_VERSION_1_1,VK_KHR_multiview[] 6452 * ename:VK_DEPENDENCY_VIEW_LOCAL_BIT specifies that dependencies will be 6453 <<synchronization-view-local-dependencies, view-local>>. 6454endif::VK_VERSION_1_1,VK_KHR_multiview[] 6455ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 6456 * ename:VK_DEPENDENCY_DEVICE_GROUP_BIT specifies that dependencies are 6457 <<synchronization-device-local-dependencies, non-device-local>>. 6458endif::VK_VERSION_1_1,VK_KHR_device_group[] 6459ifdef::VK_EXT_attachment_feedback_loop_layout[] 6460 * ename:VK_DEPENDENCY_FEEDBACK_LOOP_BIT_EXT specifies that the render pass 6461 will write to and read from the same image using the 6462 ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout. 6463endif::VK_EXT_attachment_feedback_loop_layout[] 6464-- 6465 6466[open,refpage='VkDependencyFlags',desc='Bitmask of VkDependencyFlagBits',type='flags'] 6467-- 6468include::{generated}/api/flags/VkDependencyFlags.adoc[] 6469 6470tname:VkDependencyFlags is a bitmask type for setting a mask of zero or more 6471elink:VkDependencyFlagBits. 6472-- 6473 6474 6475ifdef::VK_EXT_shader_tile_image[] 6476[[synchronization-pipeline-barriers-explicit-renderpass-tileimage]] 6477=== Explicit Render Pass Tile Image Access Synchronization 6478 6479A fragment shader can: declare code:NonCoherentColorAttachmentReadEXT, 6480code:NonCoherentDepthAttachmentReadEXT, or 6481code:NonCoherentStencilAttachmentReadEXT execution modes to enable 6482non-coherent tile image reads for color, depth, or stencil, respectively. 6483When non-coherent tile image reads are enabled, writes via color, depth and 6484stencil attachments are not automatically made visible to the corresponding 6485attachment reads via tile images. 6486For the writes to be made visible, an explicit memory dependency must: be 6487inserted between when the attachment is written to and when it is read from 6488by later fragments. 6489Such memory dependencies must: be inserted every time a fragment will read 6490values at a particular sample (x, y, layer, sample) coordinate, if those 6491values have been written since the most recent pipeline barrier; or since 6492the start of the render pass instance, if there have been no pipeline 6493barriers since the start of the render pass instance. 6494When such memory dependencies are used the values at all sample locations 6495inside the fragment area are made visible, regardless of coverage. 6496 6497To insert a memory dependency for explicit render pass tile image 6498synchronization, call flink:vkCmdPipelineBarrier2 inside a render pass 6499instance started with flink:vkCmdBeginRendering. 6500The following restrictions apply for such pipeline barriers: 6501 6502 * pname:dependencyFlags must: include ename:VK_DEPENDENCY_BY_REGION_BIT. 6503 * The pipeline barriers can: only include memory barriers. 6504 That is, buffer memory barriers and image memory barriers must: not be 6505 used. 6506 * The stages in slink:VkMemoryBarrier2::pname:srcStageMask and 6507 slink:VkMemoryBarrier2::pname:dstStageMask are restricted to framebuffer 6508 space stages. 6509 * The access types in slink:VkMemoryBarrier2::pname:srcAccessMask and 6510 slink:VkMemoryBarrier2::pname:dstAccessMask are restricted to the 6511 following types: ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, 6512 ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, 6513 ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT, and 6514 ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT. 6515endif::VK_EXT_shader_tile_image[] 6516 6517[[synchronization-memory-barriers]] 6518== Memory Barriers 6519 6520_Memory barriers_ are used to explicitly control access to buffer and image 6521subresource ranges. 6522Memory barriers are used to <<synchronization-queue-transfers, transfer 6523ownership between queue families>>, 6524<<synchronization-image-layout-transitions, change image layouts>>, and 6525define <<synchronization-dependencies-available-and-visible, availability 6526and visibility operations>>. 6527They explicitly define the <<synchronization-access-types, access types>> 6528and buffer and image subresource ranges that are included in the 6529<<synchronization-dependencies-access-scopes, access scopes>> of a memory 6530dependency that is created by a synchronization command that includes them. 6531 6532 6533[[synchronization-global-memory-barriers]] 6534=== Global Memory Barriers 6535 6536Global memory barriers apply to memory accesses involving all memory objects 6537that exist at the time of its execution. 6538 6539ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6540[open,refpage='VkMemoryBarrier2',desc='Structure specifying a global memory barrier',type='structs',alias='VkMemoryBarrier2KHR'] 6541-- 6542:refpage: VkMemoryBarrier2 6543 6544The sname:VkMemoryBarrier2 structure is defined as: 6545 6546include::{generated}/api/structs/VkMemoryBarrier2.adoc[] 6547 6548ifdef::VK_KHR_synchronization2[] 6549or the equivalent 6550 6551include::{generated}/api/structs/VkMemoryBarrier2KHR.adoc[] 6552endif::VK_KHR_synchronization2[] 6553 6554 * pname:sType is a elink:VkStructureType value identifying this structure. 6555 * pname:pNext is `NULL` or a pointer to a structure extending this 6556 structure. 6557 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6558 stages to be included in the <<synchronization-dependencies-scopes, 6559 first synchronization scope>>. 6560 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6561 included in the <<synchronization-dependencies-access-scopes, first 6562 access scope>>. 6563 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6564 stages to be included in the <<synchronization-dependencies-scopes, 6565 second synchronization scope>>. 6566 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6567 included in the <<synchronization-dependencies-access-scopes, second 6568 access scope>>. 6569 6570This structure defines a <<synchronization-dependencies-memory, memory 6571dependency>> affecting all device memory. 6572 6573The first <<synchronization-dependencies-scopes, synchronization scope>> and 6574<<synchronization-dependencies-access-scopes, access scope>> described by 6575this structure include only operations and memory accesses specified by 6576pname:srcStageMask and pname:srcAccessMask. 6577 6578The second <<synchronization-dependencies-scopes, synchronization scope>> 6579and <<synchronization-dependencies-access-scopes, access scope>> described 6580by this structure include only operations and memory accesses specified by 6581pname:dstStageMask and pname:dstAccessMask. 6582 6583.Valid Usage 6584**** 6585:stageMaskName: srcStageMask 6586:accessMaskName: srcAccessMask 6587include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6588include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6589 6590:stageMaskName: dstStageMask 6591:accessMaskName: dstAccessMask 6592include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6593include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6594**** 6595 6596include::{generated}/validity/structs/VkMemoryBarrier2.adoc[] 6597-- 6598endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6599 6600[open,refpage='VkMemoryBarrier',desc='Structure specifying a global memory barrier',type='structs'] 6601-- 6602The sname:VkMemoryBarrier structure is defined as: 6603 6604include::{generated}/api/structs/VkMemoryBarrier.adoc[] 6605 6606 * pname:sType is a elink:VkStructureType value identifying this structure. 6607 * pname:pNext is `NULL` or a pointer to a structure extending this 6608 structure. 6609 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6610 <<synchronization-access-masks, source access mask>>. 6611 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6612 <<synchronization-access-masks, destination access mask>>. 6613 6614The first <<synchronization-dependencies-access-scopes, access scope>> is 6615limited to access types in the <<synchronization-access-masks, source access 6616mask>> specified by pname:srcAccessMask. 6617 6618The second <<synchronization-dependencies-access-scopes, access scope>> is 6619limited to access types in the <<synchronization-access-masks, destination 6620access mask>> specified by pname:dstAccessMask. 6621 6622include::{generated}/validity/structs/VkMemoryBarrier.adoc[] 6623-- 6624 6625 6626[[synchronization-buffer-memory-barriers]] 6627=== Buffer Memory Barriers 6628 6629Buffer memory barriers only apply to memory accesses involving a specific 6630buffer range. 6631That is, a memory dependency formed from a buffer memory barrier is 6632<<synchronization-dependencies-access-scopes, scoped>> to access via the 6633specified buffer range. 6634Buffer memory barriers can: also be used to define a 6635<<synchronization-queue-transfers, queue family ownership transfer>> for the 6636specified buffer range. 6637 6638ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6639[open,refpage='VkBufferMemoryBarrier2',desc='Structure specifying a buffer memory barrier',type='structs',alias='VkBufferMemoryBarrier2KHR'] 6640-- 6641:refpage: VkBufferMemoryBarrier2 6642 6643The sname:VkBufferMemoryBarrier2 structure is defined as: 6644 6645include::{generated}/api/structs/VkBufferMemoryBarrier2.adoc[] 6646 6647ifdef::VK_KHR_synchronization2[] 6648or the equivalent 6649 6650include::{generated}/api/structs/VkBufferMemoryBarrier2KHR.adoc[] 6651endif::VK_KHR_synchronization2[] 6652 6653 * pname:sType is a elink:VkStructureType value identifying this structure. 6654 * pname:pNext is `NULL` or a pointer to a structure extending this 6655 structure. 6656 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6657 stages to be included in the <<synchronization-dependencies-scopes, 6658 first synchronization scope>>. 6659 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6660 included in the <<synchronization-dependencies-access-scopes, first 6661 access scope>>. 6662 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6663 stages to be included in the <<synchronization-dependencies-scopes, 6664 second synchronization scope>>. 6665 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6666 included in the <<synchronization-dependencies-access-scopes, second 6667 access scope>>. 6668 * pname:srcQueueFamilyIndex is the source queue family for a 6669 <<synchronization-queue-transfers, queue family ownership transfer>>. 6670 * pname:dstQueueFamilyIndex is the destination queue family for a 6671 <<synchronization-queue-transfers, queue family ownership transfer>>. 6672 * pname:buffer is a handle to the buffer whose backing memory is affected 6673 by the barrier. 6674 * pname:offset is an offset in bytes into the backing memory for 6675 pname:buffer; this is relative to the base offset as bound to the buffer 6676 (see flink:vkBindBufferMemory). 6677 * pname:size is a size in bytes of the affected area of backing memory for 6678 pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset 6679 to the end of the buffer. 6680 6681This structure defines a <<synchronization-dependencies-memory, memory 6682dependency>> limited to a range of a buffer, and can: define a 6683<<synchronization-queue-transfers, queue family transfer operation>> for 6684that range. 6685 6686The first <<synchronization-dependencies-scopes, synchronization scope>> and 6687<<synchronization-dependencies-access-scopes, access scope>> described by 6688this structure include only operations and memory accesses specified by 6689pname:srcStageMask and pname:srcAccessMask. 6690 6691The second <<synchronization-dependencies-scopes, synchronization scope>> 6692and <<synchronization-dependencies-access-scopes, access scope>> described 6693by this structure include only operations and memory accesses specified by 6694pname:dstStageMask and pname:dstAccessMask. 6695 6696Both <<synchronization-dependencies-access-scopes, access scopes>> are 6697limited to only memory accesses to pname:buffer in the range defined by 6698pname:offset and pname:size. 6699 6700If pname:buffer was created with ename:VK_SHARING_MODE_EXCLUSIVE, and 6701pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this 6702memory barrier defines a <<synchronization-queue-transfers, queue family 6703transfer operation>>. 6704When executed on a queue in the family identified by 6705pname:srcQueueFamilyIndex, this barrier defines a 6706<<synchronization-queue-transfers-release, queue family release operation>> 6707for the specified buffer range, and the second synchronization and access 6708scopes do not synchronize operations on that queue. 6709When executed on a queue in the family identified by 6710pname:dstQueueFamilyIndex, this barrier defines a 6711<<synchronization-queue-transfers-acquire, queue family acquire operation>> 6712for the specified buffer range, and the first synchronization and access 6713scopes do not synchronize operations on that queue. 6714 6715ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6716A <<synchronization-queue-transfers, queue family transfer operation>> is 6717also defined if the values are not equal, and either is one of the special 6718queue family values reserved for external memory ownership transfers, as 6719described in <<synchronization-queue-transfers>>. 6720A <<synchronization-queue-transfers-release, queue family release 6721operation>> is defined when pname:dstQueueFamilyIndex is one of those 6722values, and a <<synchronization-queue-transfers-acquire, queue family 6723acquire operation>> is defined when pname:srcQueueFamilyIndex is one of 6724those values. 6725endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6726 6727 6728.Valid Usage 6729**** 6730 6731:stageMaskName: srcStageMask 6732:accessMaskName: srcAccessMask 6733include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6734include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6735 6736:stageMaskName: dstStageMask 6737:accessMaskName: dstAccessMask 6738include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6739include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6740include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] 6741 * [[VUID-VkBufferMemoryBarrier2-srcStageMask-03851]] 6742 If either pname:srcStageMask or pname:dstStageMask includes 6743 ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and 6744 pname:dstQueueFamilyIndex must: be equal 6745**** 6746 6747include::{generated}/validity/structs/VkBufferMemoryBarrier2.adoc[] 6748-- 6749endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6750 6751[open,refpage='VkBufferMemoryBarrier',desc='Structure specifying a buffer memory barrier',type='structs'] 6752-- 6753:refpage: VkBufferMemoryBarrier 6754 6755The sname:VkBufferMemoryBarrier structure is defined as: 6756 6757include::{generated}/api/structs/VkBufferMemoryBarrier.adoc[] 6758 6759 * pname:sType is a elink:VkStructureType value identifying this structure. 6760 * pname:pNext is `NULL` or a pointer to a structure extending this 6761 structure. 6762 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6763 <<synchronization-access-masks, source access mask>>. 6764 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6765 <<synchronization-access-masks, destination access mask>>. 6766 * pname:srcQueueFamilyIndex is the source queue family for a 6767 <<synchronization-queue-transfers, queue family ownership transfer>>. 6768 * pname:dstQueueFamilyIndex is the destination queue family for a 6769 <<synchronization-queue-transfers, queue family ownership transfer>>. 6770 * pname:buffer is a handle to the buffer whose backing memory is affected 6771 by the barrier. 6772 * pname:offset is an offset in bytes into the backing memory for 6773 pname:buffer; this is relative to the base offset as bound to the buffer 6774 (see flink:vkBindBufferMemory). 6775 * pname:size is a size in bytes of the affected area of backing memory for 6776 pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset 6777 to the end of the buffer. 6778 6779The first <<synchronization-dependencies-access-scopes, access scope>> is 6780limited to access to memory through the specified buffer range, via access 6781types in the <<synchronization-access-masks, source access mask>> specified 6782by pname:srcAccessMask. 6783If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, a 6784<<synchronization-dependencies-available-and-visible, memory domain 6785operation>> is performed where available memory in the host domain is also 6786made available to the device domain. 6787 6788The second <<synchronization-dependencies-access-scopes, access scope>> is 6789limited to access to memory through the specified buffer range, via access 6790types in the <<synchronization-access-masks, destination access mask>> 6791specified by pname:dstAccessMask. 6792If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or 6793ename:VK_ACCESS_HOST_READ_BIT, a 6794<<synchronization-dependencies-available-and-visible, memory domain 6795operation>> is performed where available memory in the device domain is also 6796made available to the host domain. 6797 6798[NOTE] 6799.Note 6800==== 6801When ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT is used, available memory in 6802host domain is automatically made visible to host domain, and any host write 6803is automatically made available to host domain. 6804==== 6805 6806If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and 6807pname:srcQueueFamilyIndex is equal to the current queue family, then the 6808memory barrier defines a <<synchronization-queue-transfers-release, queue 6809family release operation>> for the specified buffer range, and the second 6810access scope includes no access, as if pname:dstAccessMask was `0`. 6811 6812If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and 6813pname:dstQueueFamilyIndex is equal to the current queue family, then the 6814memory barrier defines a <<synchronization-queue-transfers-acquire, queue 6815family acquire operation>> for the specified buffer range, and the first 6816access scope includes no access, as if pname:srcAccessMask was `0`. 6817 6818.Valid Usage 6819**** 6820include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] 6821ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6822 * [[VUID-VkBufferMemoryBarrier-None-09049]] 6823 If 6824ifdef::VK_KHR_synchronization2[] 6825 the <<features-synchronization2, pname:synchronization2>> feature is not 6826 enabled, and 6827endif::VK_KHR_synchronization2[] 6828 pname:buffer was created with a sharing mode of 6829 ename:VK_SHARING_MODE_CONCURRENT, at least one of 6830 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be 6831 ename:VK_QUEUE_FAMILY_IGNORED 6832endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6833 * [[VUID-VkBufferMemoryBarrier-None-09050]] 6834 If 6835ifdef::VK_KHR_synchronization2[] 6836 the <<features-synchronization2, pname:synchronization2>> feature is not 6837 enabled, and 6838endif::VK_KHR_synchronization2[] 6839 pname:buffer was created with a sharing mode of 6840 ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be 6841 ename:VK_QUEUE_FAMILY_IGNORED 6842ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6843 or ename:VK_QUEUE_FAMILY_EXTERNAL 6844endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6845 * [[VUID-VkBufferMemoryBarrier-None-09051]] 6846 If 6847ifdef::VK_KHR_synchronization2[] 6848 the <<features-synchronization2, pname:synchronization2>> feature is not 6849 enabled, and 6850endif::VK_KHR_synchronization2[] 6851 pname:buffer was created with a sharing mode of 6852 ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be 6853 ename:VK_QUEUE_FAMILY_IGNORED 6854ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6855 or ename:VK_QUEUE_FAMILY_EXTERNAL 6856endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6857**** 6858 6859include::{generated}/validity/structs/VkBufferMemoryBarrier.adoc[] 6860-- 6861 6862[open,refpage='VK_WHOLE_SIZE',desc='Sentinel value to use entire remaining array length',type='consts'] 6863-- 6864ename:VK_WHOLE_SIZE is a special value indicating that the entire remaining 6865length of a buffer following a given pname:offset should be used. 6866It can: be specified for slink:VkBufferMemoryBarrier::pname:size and other 6867structures. 6868 6869include::{generated}/api/enums/VK_WHOLE_SIZE.adoc[] 6870-- 6871 6872 6873[[synchronization-image-memory-barriers]] 6874=== Image Memory Barriers 6875 6876Image memory barriers only apply to memory accesses involving a specific 6877image subresource range. 6878That is, a memory dependency formed from an image memory barrier is 6879<<synchronization-dependencies-access-scopes, scoped>> to access via the 6880specified image subresource range. 6881Image memory barriers can: also be used to define 6882<<synchronization-image-layout-transitions, image layout transitions>> or a 6883<<synchronization-queue-transfers, queue family ownership transfer>> for the 6884specified image subresource range. 6885 6886ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6887[open,refpage='VkImageMemoryBarrier2',desc='Structure specifying an image memory barrier',type='structs',alias='VkImageMemoryBarrier2KHR'] 6888-- 6889:refpage: VkImageMemoryBarrier2 6890 6891The sname:VkImageMemoryBarrier2 structure is defined as: 6892 6893include::{generated}/api/structs/VkImageMemoryBarrier2.adoc[] 6894 6895ifdef::VK_KHR_synchronization2[] 6896or the equivalent 6897 6898include::{generated}/api/structs/VkImageMemoryBarrier2KHR.adoc[] 6899endif::VK_KHR_synchronization2[] 6900 6901 * pname:sType is a elink:VkStructureType value identifying this structure. 6902 * pname:pNext is `NULL` or a pointer to a structure extending this 6903 structure. 6904 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6905 stages to be included in the <<synchronization-dependencies-scopes, 6906 first synchronization scope>>. 6907 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6908 included in the <<synchronization-dependencies-access-scopes, first 6909 access scope>>. 6910 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6911 stages to be included in the <<synchronization-dependencies-scopes, 6912 second synchronization scope>>. 6913 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6914 included in the <<synchronization-dependencies-access-scopes, second 6915 access scope>>. 6916 * pname:oldLayout is the old layout in an 6917 <<synchronization-image-layout-transitions, image layout transition>>. 6918 * pname:newLayout is the new layout in an 6919 <<synchronization-image-layout-transitions, image layout transition>>. 6920 * pname:srcQueueFamilyIndex is the source queue family for a 6921 <<synchronization-queue-transfers, queue family ownership transfer>>. 6922 * pname:dstQueueFamilyIndex is the destination queue family for a 6923 <<synchronization-queue-transfers, queue family ownership transfer>>. 6924 * pname:image is a handle to the image affected by this barrier. 6925 * pname:subresourceRange describes the <<resources-image-views, image 6926 subresource range>> within pname:image that is affected by this barrier. 6927 6928This structure defines a <<synchronization-dependencies-memory, memory 6929dependency>> limited to an image subresource range, and can: define a 6930<<synchronization-queue-transfers, queue family transfer operation>> and 6931<<synchronization-image-layout-transitions, image layout transition>> for 6932that subresource range. 6933 6934The first <<synchronization-dependencies-scopes, synchronization scope>> and 6935<<synchronization-dependencies-access-scopes, access scope>> described by 6936this structure include only operations and memory accesses specified by 6937pname:srcStageMask and pname:srcAccessMask. 6938 6939The second <<synchronization-dependencies-scopes, synchronization scope>> 6940and <<synchronization-dependencies-access-scopes, access scope>> described 6941by this structure include only operations and memory accesses specified by 6942pname:dstStageMask and pname:dstAccessMask. 6943 6944Both <<synchronization-dependencies-access-scopes, access scopes>> are 6945limited to only memory accesses to pname:image in the subresource range 6946defined by pname:subresourceRange. 6947 6948If pname:image was created with ename:VK_SHARING_MODE_EXCLUSIVE, and 6949pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this 6950memory barrier defines a <<synchronization-queue-transfers, queue family 6951transfer operation>>. 6952When executed on a queue in the family identified by 6953pname:srcQueueFamilyIndex, this barrier defines a 6954<<synchronization-queue-transfers-release, queue family release operation>> 6955for the specified image subresource range, and the second synchronization 6956and access scopes do not synchronize operations on that queue. 6957When executed on a queue in the family identified by 6958pname:dstQueueFamilyIndex, this barrier defines a 6959<<synchronization-queue-transfers-acquire, queue family acquire operation>> 6960for the specified image subresource range, and the first synchronization and 6961access scopes do not synchronize operations on that queue. 6962 6963ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6964A <<synchronization-queue-transfers, queue family transfer operation>> is 6965also defined if the values are not equal, and either is one of the special 6966queue family values reserved for external memory ownership transfers, as 6967described in <<synchronization-queue-transfers>>. 6968A <<synchronization-queue-transfers-release, queue family release 6969operation>> is defined when pname:dstQueueFamilyIndex is one of those 6970values, and a <<synchronization-queue-transfers-acquire, queue family 6971acquire operation>> is defined when pname:srcQueueFamilyIndex is one of 6972those values. 6973endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6974 6975If pname:oldLayout is not equal to pname:newLayout, then the memory barrier 6976defines an <<synchronization-image-layout-transitions, image layout 6977transition>> for the specified image subresource range. 6978If this memory barrier defines a <<synchronization-queue-transfers, queue 6979family transfer operation>>, the layout transition is only executed once 6980between the queues. 6981 6982[NOTE] 6983.Note 6984==== 6985When the old and new layout are equal, the layout values are ignored - data 6986is preserved no matter what values are specified, or what layout the image 6987is currently in. 6988==== 6989 6990ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 6991 6992If pname:image has a multi-planar format and the image is _disjoint_, then 6993including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of 6994pname:subresourceRange is equivalent to including 6995ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and 6996(for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. 6997 6998endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 6999 7000.Valid Usage 7001**** 7002 7003:stageMaskName: srcStageMask 7004:accessMaskName: srcAccessMask 7005include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 7006include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 7007 7008:stageMaskName: dstStageMask 7009:accessMaskName: dstAccessMask 7010include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 7011include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 7012include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] 7013include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7014 * [[VUID-VkImageMemoryBarrier2-srcStageMask-03854]] 7015 If either pname:srcStageMask or pname:dstStageMask includes 7016 ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and 7017 pname:dstQueueFamilyIndex must: be equal 7018 * [[VUID-VkImageMemoryBarrier2-srcStageMask-03855]] 7019 If pname:srcStageMask includes ename:VK_PIPELINE_STAGE_2_HOST_BIT, and 7020 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex define a 7021 <<synchronization-queue-transfers, queue family ownership transfer>> or 7022 pname:oldLayout and pname:newLayout define an 7023 <<synchronization-image-layout-transitions, image layout transition>>, 7024 pname:oldLayout must: be one of ename:VK_IMAGE_LAYOUT_PREINITIALIZED, 7025 ename:VK_IMAGE_LAYOUT_UNDEFINED, or ename:VK_IMAGE_LAYOUT_GENERAL 7026**** 7027 7028include::{generated}/validity/structs/VkImageMemoryBarrier2.adoc[] 7029-- 7030endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7031 7032[open,refpage='VkImageMemoryBarrier',desc='Structure specifying the parameters of an image memory barrier',type='structs'] 7033-- 7034:refpage: VkImageMemoryBarrier 7035 7036The sname:VkImageMemoryBarrier structure is defined as: 7037 7038include::{generated}/api/structs/VkImageMemoryBarrier.adoc[] 7039 7040 * pname:sType is a elink:VkStructureType value identifying this structure. 7041 * pname:pNext is `NULL` or a pointer to a structure extending this 7042 structure. 7043 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 7044 <<synchronization-access-masks, source access mask>>. 7045 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 7046 <<synchronization-access-masks, destination access mask>>. 7047 * pname:oldLayout is the old layout in an 7048 <<synchronization-image-layout-transitions, image layout transition>>. 7049 * pname:newLayout is the new layout in an 7050 <<synchronization-image-layout-transitions, image layout transition>>. 7051 * pname:srcQueueFamilyIndex is the source queue family for a 7052 <<synchronization-queue-transfers, queue family ownership transfer>>. 7053 * pname:dstQueueFamilyIndex is the destination queue family for a 7054 <<synchronization-queue-transfers, queue family ownership transfer>>. 7055 * pname:image is a handle to the image affected by this barrier. 7056 * pname:subresourceRange describes the <<resources-image-views, image 7057 subresource range>> within pname:image that is affected by this barrier. 7058 7059The first <<synchronization-dependencies-access-scopes, access scope>> is 7060limited to access to memory through the specified image subresource range, 7061via access types in the <<synchronization-access-masks, source access mask>> 7062specified by pname:srcAccessMask. 7063If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, memory 7064writes performed by that access type are also made visible, as that access 7065type is not performed through a resource. 7066 7067The second <<synchronization-dependencies-access-scopes, access scope>> is 7068limited to access to memory through the specified image subresource range, 7069via access types in the <<synchronization-access-masks, destination access 7070mask>> specified by pname:dstAccessMask. 7071If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or 7072ename:VK_ACCESS_HOST_READ_BIT, available memory writes are also made visible 7073to accesses of those types, as those access types are not performed through 7074a resource. 7075 7076If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and 7077pname:srcQueueFamilyIndex is equal to the current queue family, then the 7078memory barrier defines a <<synchronization-queue-transfers-release, queue 7079family release operation>> for the specified image subresource range, and 7080the second access scope includes no access, as if pname:dstAccessMask was 7081`0`. 7082 7083If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and 7084pname:dstQueueFamilyIndex is equal to the current queue family, then the 7085memory barrier defines a <<synchronization-queue-transfers-acquire, queue 7086family acquire operation>> for the specified image subresource range, and 7087the first access scope includes no access, as if pname:srcAccessMask was 7088`0`. 7089 7090ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7091If the <<features-synchronization2, pname:synchronization2>> feature is not 7092enabled or pname:oldLayout is not equal to pname:newLayout, 7093endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7094pname:oldLayout and pname:newLayout define an 7095<<synchronization-image-layout-transitions, image layout transition>> for 7096the specified image subresource range. 7097 7098ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7099[NOTE] 7100.Note 7101==== 7102If the <<features-synchronization2, pname:synchronization2>> feature is 7103enabled, when the old and new layout are equal, the layout values are 7104ignored - data is preserved no matter what values are specified, or what 7105layout the image is currently in. 7106==== 7107endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7108 7109ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 7110 7111If pname:image has a multi-planar format and the image is _disjoint_, then 7112including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of 7113pname:subresourceRange is equivalent to including 7114ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and 7115(for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. 7116 7117endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 7118 7119.Valid Usage 7120**** 7121include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] 7122include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7123ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7124 * [[VUID-VkImageMemoryBarrier-None-09052]] 7125 If 7126ifdef::VK_KHR_synchronization2[] 7127 the <<features-synchronization2, pname:synchronization2>> feature is not 7128 enabled, and 7129endif::VK_KHR_synchronization2[] 7130 pname:image was created with a sharing mode of 7131 ename:VK_SHARING_MODE_CONCURRENT, at least one of 7132 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be 7133 ename:VK_QUEUE_FAMILY_IGNORED 7134endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7135 * [[VUID-VkImageMemoryBarrier-None-09053]] 7136 If 7137ifdef::VK_KHR_synchronization2[] 7138 the <<features-synchronization2, pname:synchronization2>> feature is not 7139 enabled, and 7140endif::VK_KHR_synchronization2[] 7141 pname:image was created with a sharing mode of 7142 ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be 7143 ename:VK_QUEUE_FAMILY_IGNORED 7144ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7145 or ename:VK_QUEUE_FAMILY_EXTERNAL 7146endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7147 * [[VUID-VkImageMemoryBarrier-None-09054]] 7148 If 7149ifdef::VK_KHR_synchronization2[] 7150 the <<features-synchronization2, pname:synchronization2>> feature is not 7151 enabled, and 7152endif::VK_KHR_synchronization2[] 7153 pname:image was created with a sharing mode of 7154 ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be 7155 ename:VK_QUEUE_FAMILY_IGNORED 7156ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7157 or ename:VK_QUEUE_FAMILY_EXTERNAL 7158endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7159**** 7160 7161include::{generated}/validity/structs/VkImageMemoryBarrier.adoc[] 7162-- 7163 7164ifdef::VK_EXT_host_image_copy[] 7165To facilitate usage of images whose memory is initialized on the host, 7166Vulkan allows image layout transitions to be performed by the host as well, 7167albeit supporting limited layouts. 7168 7169[open,refpage='vkTransitionImageLayoutEXT',desc='Perform an image layout transition on the host',type='protos'] 7170-- 7171To perform an image layout transition on the host, call: 7172 7173include::{generated}/api/protos/vkTransitionImageLayoutEXT.adoc[] 7174 7175 * pname:device is the device which owns pname:pTransitions[i].pname:image. 7176 * pname:transitionCount is the number of image layout transitions to 7177 perform. 7178 * pname:pTransitions is a pointer to an array of 7179 slink:VkHostImageLayoutTransitionInfoEXT structures specifying the image 7180 and <<resources-image-views, subresource ranges>> within them to 7181 transition. 7182 7183include::{generated}/validity/protos/vkTransitionImageLayoutEXT.adoc[] 7184-- 7185 7186[open,refpage='VkHostImageLayoutTransitionInfoEXT',desc='Structure specifying the parameters of a host-side image layout transition',type='structs'] 7187-- 7188:refpage: VkHostImageLayoutTransitionInfoEXT 7189 7190The sname:VkHostImageLayoutTransitionInfoEXT structure is defined as: 7191 7192include::{generated}/api/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] 7193 7194 * pname:sType is a elink:VkStructureType value identifying this structure. 7195 * pname:pNext is `NULL` or a pointer to a structure extending this 7196 structure. 7197 * pname:image is a handle to the image affected by this layout transition. 7198 * pname:oldLayout is the old layout in an 7199 <<synchronization-image-layout-transitions, image layout transition>>. 7200 * pname:newLayout is the new layout in an 7201 <<synchronization-image-layout-transitions, image layout transition>>. 7202 * pname:subresourceRange describes the <<resources-image-views, image 7203 subresource range>> within pname:image that is affected by this layout 7204 transition. 7205 7206fname:vkTransitionImageLayoutEXT does not check whether the device memory 7207associated with an image is currently in use before performing the layout 7208transition. 7209The application must: guarantee that any previously submitted command that 7210reads from or writes to this subresource has completed before the host 7211performs the layout transition. 7212 7213[NOTE] 7214.Note 7215==== 7216Image layout transitions performed on the host do not require queue family 7217ownership transfers as the physical layout of the image will not vary 7218between queue families for the layouts supported by this function. 7219==== 7220 7221.Valid Usage 7222**** 7223 * [[VUID-VkHostImageLayoutTransitionInfoEXT-image-09055]] 7224 pname:image must: have been created with 7225 ename:VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT 7226include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7227 * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09229]] 7228 pname:oldLayout must: be either ename:VK_IMAGE_LAYOUT_UNDEFINED or the 7229 current layout of the image subresources as specified in 7230 pname:subresourceRange 7231 * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09230]] 7232 If pname:oldLayout is not ename:VK_IMAGE_LAYOUT_UNDEFINED or 7233 ename:VK_IMAGE_LAYOUT_PREINITIALIZED, it must: be one of the layouts in 7234 slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopySrcLayouts 7235 * [[VUID-VkHostImageLayoutTransitionInfoEXT-newLayout-09057]] 7236 pname:newLayout must: be one of the layouts in 7237 slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopyDstLayouts 7238**** 7239 7240include::{generated}/validity/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] 7241-- 7242endif::VK_EXT_host_image_copy[] 7243 7244[[synchronization-queue-transfers]] 7245=== Queue Family Ownership Transfer 7246 7247Resources created with a elink:VkSharingMode of 7248ename:VK_SHARING_MODE_EXCLUSIVE must: have their ownership explicitly 7249transferred from one queue family to another in order to access their 7250content in a well-defined manner on a queue in a different queue family. 7251 7252[open,refpage='VK_QUEUE_FAMILY_IGNORED',desc='Ignored queue family index sentinel',type='consts'] 7253-- 7254The special queue family index ename:VK_QUEUE_FAMILY_IGNORED indicates that 7255a queue family parameter or member is ignored. 7256 7257include::{generated}/api/enums/VK_QUEUE_FAMILY_IGNORED.adoc[] 7258-- 7259 7260ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7261Resources shared with external APIs or instances using external memory must: 7262also explicitly manage ownership transfers between local and external queues 7263(or equivalent constructs in external APIs) regardless of the 7264elink:VkSharingMode specified when creating them. 7265 7266[open,refpage='VK_QUEUE_FAMILY_EXTERNAL',desc='External queue family index sentinel',type='consts',alias='VK_QUEUE_FAMILY_EXTERNAL_KHR'] 7267-- 7268The special queue family index ename:VK_QUEUE_FAMILY_EXTERNAL represents any 7269queue external to the resource's current Vulkan instance, as long as the 7270queue uses the same underlying 7271ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] 7272physical device, and the same driver version as the resource's 7273slink:VkDevice, as indicated by 7274slink:VkPhysicalDeviceIDProperties::pname:deviceUUID and 7275slink:VkPhysicalDeviceIDProperties::pname:driverUUID. 7276 7277include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL.adoc[] 7278 7279ifdef::VK_KHR_external_memory[] 7280or the equivalent 7281 7282include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL_KHR.adoc[] 7283endif::VK_KHR_external_memory[] 7284-- 7285 7286ifdef::VK_EXT_queue_family_foreign[] 7287[open,refpage='VK_QUEUE_FAMILY_FOREIGN_EXT',desc='Foreign queue family index sentinel',type='consts'] 7288-- 7289The special queue family index ename:VK_QUEUE_FAMILY_FOREIGN_EXT represents 7290any queue external to the resource's current Vulkan instance, regardless of 7291the queue's underlying physical device or driver version. 7292This includes, for example, queues for fixed-function image processing 7293devices, media codec devices, and display devices, as well as all queues 7294that use the same underlying 7295ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] 7296physical device, and the same driver version as the resource's 7297slink:VkDevice. 7298 7299include::{generated}/api/enums/VK_QUEUE_FAMILY_FOREIGN_EXT.adoc[] 7300-- 7301endif::VK_EXT_queue_family_foreign[] 7302endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7303 7304If memory dependencies are correctly expressed between uses of such a 7305resource between two queues in different families, but no ownership transfer 7306is defined, the contents of that resource are undefined: for any read 7307accesses performed by the second queue family. 7308 7309[NOTE] 7310.Note 7311==== 7312If an application does not need the contents of a resource to remain valid 7313when transferring from one queue family to another, then the ownership 7314transfer should: be skipped. 7315==== 7316 7317ifdef::VK_EXT_queue_family_foreign[] 7318[NOTE] 7319.Note 7320==== 7321Applications should expect transfers to/from 7322ename:VK_QUEUE_FAMILY_FOREIGN_EXT to be more expensive than transfers 7323to/from ename:VK_QUEUE_FAMILY_EXTERNAL_KHR. 7324==== 7325endif::VK_EXT_queue_family_foreign[] 7326 7327A queue family ownership transfer consists of two distinct parts: 7328 7329 . Release exclusive ownership from the source queue family 7330 . Acquire exclusive ownership for the destination queue family 7331 7332An application must: ensure that these operations occur in the correct order 7333by defining an execution dependency between them, e.g. using a semaphore. 7334 7335[[synchronization-queue-transfers-release]] A _release operation_ is used to 7336release exclusive ownership of a range of a buffer or image subresource 7337range. 7338A release operation is defined by executing a 7339<<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a 7340buffer range) or an <<synchronization-image-memory-barriers, image memory 7341barrier>> (for an image subresource range) using a pipeline barrier command, 7342on a queue from the source queue family. 7343The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the 7344source queue family index, and the pname:dstQueueFamilyIndex parameter to 7345the destination queue family index. 7346pname:dstAccessMask is ignored for such a barrier, such that no visibility 7347operation is executed - the value of this mask does not affect the validity 7348of the barrier. 7349The release operation happens-after the availability operation, and 7350happens-before operations specified in the second synchronization scope of 7351the calling command. 7352 7353[[synchronization-queue-transfers-acquire]] An _acquire operation_ is used 7354to acquire exclusive ownership of a range of a buffer or image subresource 7355range. 7356An acquire operation is defined by executing a 7357<<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a 7358buffer range) or an <<synchronization-image-memory-barriers, image memory 7359barrier>> (for an image subresource range) using a pipeline barrier command, 7360on a queue from the destination queue family. 7361The buffer range or image subresource range specified in an acquire 7362operation must: match exactly that of a previous release operation. 7363The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the 7364source queue family index, and the pname:dstQueueFamilyIndex parameter to 7365the destination queue family index. 7366pname:srcAccessMask is ignored for such a barrier, such that no availability 7367operation is executed - the value of this mask does not affect the validity 7368of the barrier. 7369The acquire operation happens-after operations in the first synchronization 7370scope of the calling command, and happens-before the visibility operation. 7371 7372[NOTE] 7373.Note 7374==== 7375Whilst it is not invalid to provide destination or source access masks for 7376memory barriers used for release or acquire operations, respectively, they 7377have no practical effect. 7378Access after a release operation has undefined: results, and so visibility 7379for those accesses has no practical effect. 7380Similarly, write access before an acquire operation will produce undefined: 7381results for future access, so availability of those writes has no practical 7382use. 7383In an earlier version of the specification, these were required to match on 7384both sides - but this was subsequently relaxed. 7385These masks should: be set to 0. 7386==== 7387 7388If the transfer is via an image memory barrier, and an 7389<<synchronization-image-layout-transitions, image layout transition>> is 7390desired, then the values of pname:oldLayout and pname:newLayout in the 7391_release operation_'s memory barrier must: be equal to values of 7392pname:oldLayout and pname:newLayout in the _acquire operation_'s memory 7393barrier. 7394Although the image layout transition is submitted twice, it will only be 7395executed once. 7396A layout transition specified in this way happens-after the _release 7397operation_ and happens-before the _acquire operation_. 7398 7399If the values of pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex are 7400equal, no ownership transfer is performed, and the barrier operates as if 7401they were both set to ename:VK_QUEUE_FAMILY_IGNORED. 7402 7403Queue family ownership transfers may: perform read and write accesses on all 7404memory bound to the image subresource or buffer range, so applications must: 7405ensure that all memory writes have been made 7406<<synchronization-dependencies-available-and-visible, available>> before a 7407queue family ownership transfer is executed. 7408Available memory is automatically made visible to queue family release and 7409acquire operations, and writes performed by those operations are 7410automatically made available. 7411 7412Once a queue family has acquired ownership of a buffer range or image 7413subresource range of a ename:VK_SHARING_MODE_EXCLUSIVE resource, its 7414contents are undefined: to other queue families unless ownership is 7415transferred. 7416The contents of any portion of another resource which aliases memory that is 7417bound to the transferred buffer or image subresource range are undefined: 7418after a release or acquire operation. 7419 7420[NOTE] 7421.Note 7422==== 7423Because <<synchronization-events, events>> cannot: be used directly for 7424inter-queue synchronization, and because flink:vkCmdSetEvent does not have 7425the queue family index or memory barrier parameters needed by a _release 7426operation_, the release and acquire operations of a queue family ownership 7427transfer can: only be performed using flink:vkCmdPipelineBarrier. 7428==== 7429 7430ifdef::VK_EXT_external_memory_acquire_unmodified[] 7431[open,refpage='VkExternalMemoryAcquireUnmodifiedEXT',desc='Structure specifying that external memory has remained unmodified since releasing ownership',type='structs'] 7432-- 7433An _acquire operation_ may: have a performance penalty when acquiring 7434ownership of a subresource range from one of the special queue families 7435reserved for external memory ownership transfers described above. 7436The application can: reduce the performance penalty in some cases by adding 7437a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the pname:pNext 7438chain of the _acquire operation_'s memory barrier structure. 7439 7440The sname:VkExternalMemoryAcquireUnmodifiedEXT structure is defined as: 7441 7442include::{generated}/api/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] 7443 7444 * pname:sType is a elink:VkStructureType value identifying this structure. 7445 * pname:pNext is `NULL` or a pointer to a structure extending this 7446 structure. 7447 * pname:acquireUnmodifiedMemory specifies, if ename:VK_TRUE, that no range 7448 of slink:VkDeviceMemory bound to the resource of the memory barrier's 7449 subresource range was modified at any time since the resource's most 7450 recent release of ownership to the queue family specified by the memory 7451 barrier's pname:srcQueueFamilyIndex. 7452 If ename:VK_FALSE, it specifies nothing. 7453 7454If the application releases ownership of the subresource range to one of the 7455special queue families reserved for external memory ownership transfers with 7456a memory barrier structure, and later re-acquires ownership from the same 7457queue family with a memory barrier structure, and if no range of 7458slink:VkDeviceMemory bound to the resource was modified at any time between 7459the _release operation_ and the _acquire operation_, then the application 7460should: add a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the 7461pname:pNext chain of the _acquire operation_'s memory barrier structure 7462because this may: reduce the performance penalty. 7463 7464This struct is ignored if pname:acquireUnmodifiedMemory is ename:VK_FALSE. 7465In particular, ename:VK_FALSE does _not_ specify that memory was modified. 7466 7467This struct is ignored if the memory barrier's pname:srcQueueFamilyIndex is 7468not a special queue family reserved for external memory ownership transfers. 7469 7470[NOTE] 7471.Note 7472==== 7473The method by which the application determines whether memory was modified 7474between the _release operation_ and _acquire operation_ is outside the scope 7475of Vulkan. 7476 7477For any Vulkan operation that accesses a resource, the application must: not 7478assume the implementation accesses the resource's memory as read-only, even 7479for _apparently_ read-only operations such as transfer commands and shader 7480reads. 7481 7482The validity of 7483slink:VkExternalMemoryAcquireUnmodifiedEXT::pname:acquireUnmodifiedMemory is 7484independent of memory ranges outside the ranges of slink:VkDeviceMemory 7485bound to the resource. 7486In particular, it is independent of any implementation-private memory 7487associated with the resource. 7488==== 7489 7490.Valid Usage 7491**** 7492 * [[VUID-VkExternalMemoryAcquireUnmodifiedEXT-acquireUnmodifiedMemory-08922]] 7493 If pname:acquireUnmodifiedMemory is ename:VK_TRUE, and the memory 7494 barrier's pname:srcQueueFamilyIndex is a special queue family reserved 7495 for external memory ownership transfers (as described in 7496 <<synchronization-queue-transfers>>), then each range of 7497 slink:VkDeviceMemory bound to the resource must: have remained 7498 unmodified during all time since the resource's most recent release of 7499 ownership to the queue family. 7500**** 7501 7502include::{generated}/validity/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] 7503-- 7504endif::VK_EXT_external_memory_acquire_unmodified[] 7505 7506[[synchronization-wait-idle]] 7507== Wait Idle Operations 7508 7509[open,refpage='vkQueueWaitIdle',desc='Wait for a queue to become idle',type='protos'] 7510-- 7511:refpage: vkQueueWaitIdle 7512 7513To wait on the host for the completion of outstanding queue operations for a 7514given queue, call: 7515 7516include::{generated}/api/protos/vkQueueWaitIdle.adoc[] 7517 7518 * pname:queue is the queue on which to wait. 7519 7520fname:vkQueueWaitIdle is equivalent to having submitted a valid fence to 7521every previously executed <<devsandqueues-submission,queue submission 7522command>> that accepts a fence, then waiting for all of those fences to 7523signal using flink:vkWaitForFences with an infinite timeout and 7524pname:waitAll set to ename:VK_TRUE. 7525 7526include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7527 7528include::{generated}/validity/protos/vkQueueWaitIdle.adoc[] 7529-- 7530 7531[open,refpage='vkDeviceWaitIdle',desc='Wait for a device to become idle',type='protos'] 7532-- 7533:refpage: vkDeviceWaitIdle 7534 7535To wait on the host for the completion of outstanding queue operations for 7536all queues on a given logical device, call: 7537 7538include::{generated}/api/protos/vkDeviceWaitIdle.adoc[] 7539 7540 * pname:device is the logical device to idle. 7541 7542fname:vkDeviceWaitIdle is equivalent to calling fname:vkQueueWaitIdle for 7543all queues owned by pname:device. 7544 7545include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7546 7547include::{generated}/validity/protos/vkDeviceWaitIdle.adoc[] 7548-- 7549 7550 7551[[synchronization-submission-host-writes]] 7552== Host Write Ordering Guarantees 7553 7554When batches of command buffers are submitted to a queue via a 7555<<devsandqueues-submission, queue submission command>>, it defines a memory 7556dependency with prior host operations, and execution of command buffers 7557submitted to the queue. 7558 7559The first <<synchronization-dependencies-scopes, synchronization scope>> 7560includes execution of flink:vkQueueSubmit on the host and anything that 7561happened-before it, as defined by the host memory model. 7562 7563[NOTE] 7564.Note 7565==== 7566Some systems allow writes that do not directly integrate with the host 7567memory model; these have to be synchronized by the application manually. 7568One example of this is non-temporal store instructions on x86; to ensure 7569these happen-before submission, applications should call `_mm_sfence()`. 7570==== 7571 7572The second <<synchronization-dependencies-scopes, synchronization scope>> 7573includes all commands submitted in the same <<devsandqueues-submission, 7574queue submission>>, and all commands that occur later in 7575<<synchronization-submission-order,submission order>>. 7576 7577The first <<synchronization-dependencies-access-scopes, access scope>> 7578includes all host writes to mappable device memory that are available to the 7579host memory domain. 7580 7581The second <<synchronization-dependencies-access-scopes, access scope>> 7582includes all memory access performed by the device. 7583 7584ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 7585[[synchronization-device-group]] 7586== Synchronization and Multiple Physical Devices 7587 7588If a logical device includes more than one physical device, then fences, 7589semaphores, and events all still have a single instance of the signaled 7590state. 7591 7592A fence becomes signaled when all physical devices complete the necessary 7593queue operations. 7594 7595Semaphore wait and signal operations all include a device index that is the 7596sole physical device that performs the operation. 7597These indices are provided in the slink:VkDeviceGroupSubmitInfo 7598ifndef::VKSC_VERSION_1_0[and slink:VkDeviceGroupBindSparseInfo] 7599structures. 7600Semaphores are not exclusively owned by any physical device. 7601For example, a semaphore can be signaled by one physical device and then 7602waited on by a different physical device. 7603 7604An event can: only be waited on by the same physical device that signaled it 7605(or the host). 7606endif::VK_VERSION_1_1,VK_KHR_device_group[] 7607 7608 7609ifdef::VK_KHR_calibrated_timestamps,VK_EXT_calibrated_timestamps[] 7610[[calibrated-timestamps]] 7611== Calibrated Timestamps 7612 7613[open,refpage='vkGetCalibratedTimestampsKHR',desc='Query calibrated timestamps',type='protos',alias='vkGetCalibratedTimestampsEXT'] 7614-- 7615:refpage: vkGetCalibratedTimestampsKHR 7616 7617In order to be able to correlate the time a particular operation took place 7618at on timelines of different time domains (e.g. a device operation vs. a 7619host operation), Vulkan allows querying calibrated timestamps from multiple 7620time domains. 7621 7622To query calibrated timestamps from a set of time domains, call: 7623 7624ifdef::VK_KHR_calibrated_timestamps[] 7625include::{generated}/api/protos/vkGetCalibratedTimestampsKHR.adoc[] 7626endif::VK_KHR_calibrated_timestamps[] 7627 7628ifdef::VK_KHR_calibrated_timestamps+VK_EXT_calibrated_timestamps[or the equivalent command] 7629 7630ifdef::VK_EXT_calibrated_timestamps[] 7631include::{generated}/api/protos/vkGetCalibratedTimestampsEXT.adoc[] 7632endif::VK_EXT_calibrated_timestamps[] 7633 7634 * pname:device is the logical device used to perform the query. 7635 * pname:timestampCount is the number of timestamps to query. 7636 * pname:pTimestampInfos is a pointer to an array of pname:timestampCount 7637 slink:VkCalibratedTimestampInfoKHR structures, describing the time 7638 domains the calibrated timestamps should be captured from. 7639 * pname:pTimestamps is a pointer to an array of pname:timestampCount 7640 64-bit unsigned integer values in which the requested calibrated 7641 timestamp values are returned. 7642 * pname:pMaxDeviation is a pointer to a 64-bit unsigned integer value in 7643 which the strictly positive maximum deviation, in nanoseconds, of the 7644 calibrated timestamp values is returned. 7645 7646[NOTE] 7647.Note 7648==== 7649The maximum deviation may: vary between calls to 7650fname:vkGetCalibratedTimestampsKHR even for the same set of time domains due 7651to implementation and platform specific reasons. 7652It is the application's responsibility to assess whether the returned 7653maximum deviation makes the timestamp values suitable for any particular 7654purpose and can: choose to re-issue the timestamp calibration call pursuing 7655a lower deviation value. 7656==== 7657 7658Calibrated timestamp values can: be extrapolated to estimate future 7659coinciding timestamp values, however, depending on the nature of the time 7660domains and other properties of the platform extrapolating values over a 7661sufficiently long period of time may: no longer be accurate enough to fit 7662any particular purpose, so applications are expected to re-calibrate the 7663timestamps on a regular basis. 7664 7665.Valid Usage 7666**** 7667 * [[VUID-vkGetCalibratedTimestampsEXT-timeDomain-09246]] 7668 The pname:timeDomain value of each slink:VkCalibratedTimestampInfoEXT in 7669 pname:pTimestampInfos must: be unique 7670**** 7671 7672include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7673 7674include::{generated}/validity/protos/vkGetCalibratedTimestampsKHR.adoc[] 7675-- 7676 7677[open,refpage='VkCalibratedTimestampInfoKHR',desc='Structure specifying the input parameters of a calibrated timestamp query',type='structs',alias='VkCalibratedTimestampInfoEXT'] 7678-- 7679The sname:VkCalibratedTimestampInfoKHR structure is defined as: 7680 7681include::{generated}/api/structs/VkCalibratedTimestampInfoKHR.adoc[] 7682 7683ifdef::VK_EXT_calibrated_timestamps[] 7684or the equivalent 7685 7686include::{generated}/api/structs/VkCalibratedTimestampInfoEXT.adoc[] 7687endif::VK_EXT_calibrated_timestamps[] 7688 7689 * pname:sType is a elink:VkStructureType value identifying this structure. 7690 * pname:pNext is `NULL` or a pointer to a structure extending this 7691 structure. 7692 * pname:timeDomain is a elink:VkTimeDomainKHR value specifying the time 7693 domain from which the calibrated timestamp value should be returned. 7694 7695.Valid Usage 7696**** 7697 * [[VUID-VkCalibratedTimestampInfoEXT-timeDomain-02354]] 7698 pname:timeDomain must: be one of the elink:VkTimeDomainKHR values 7699 returned by flink:vkGetPhysicalDeviceCalibrateableTimeDomainsKHR 7700**** 7701include::{generated}/validity/structs/VkCalibratedTimestampInfoKHR.adoc[] 7702-- 7703 7704[open,refpage='VkTimeDomainKHR',desc='Supported time domains',type='enums',alias='VkTimeDomainEXT'] 7705-- 7706The set of supported time domains consists of: 7707 7708include::{generated}/api/enums/VkTimeDomainKHR.adoc[] 7709 7710ifdef::VK_EXT_calibrated_timestamps[] 7711or the equivalent 7712 7713include::{generated}/api/enums/VkTimeDomainEXT.adoc[] 7714endif::VK_EXT_calibrated_timestamps[] 7715 7716 * ename:VK_TIME_DOMAIN_DEVICE_KHR specifies the device time domain. 7717 Timestamp values in this time domain use the same units and are 7718 comparable with device timestamp values captured using 7719 flink:vkCmdWriteTimestamp 7720ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7721 or flink:vkCmdWriteTimestamp2 7722endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7723 and are defined to be incrementing according to the 7724 <<limits-timestampPeriod, pname:timestampPeriod>> of the device. 7725 7726 * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR specifies the CLOCK_MONOTONIC 7727 time domain available on POSIX platforms. 7728 Timestamp values in this time domain are in units of nanoseconds and are 7729 comparable with platform timestamp values captured using the POSIX 7730 clock_gettime API as computed by this example: 7731 7732[NOTE] 7733.Note 7734==== 7735An implementation supporting 7736ifdef::VK_KHR_calibrated_timestamps[`apiext:VK_KHR_calibrated_timestamps`] 7737ifdef::VK_KHR_calibrated_timestamps+VK_EXT_calibrated_timestamps[or] 7738ifdef::VK_EXT_calibrated_timestamps[`apiext:VK_EXT_calibrated_timestamps`] 7739will use the same time domain for all its slink:VkQueue so that timestamp 7740values reported for ename:VK_TIME_DOMAIN_DEVICE_KHR can be matched to any 7741timestamp captured through flink:vkCmdWriteTimestamp 7742ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7743or flink:vkCmdWriteTimestamp2 7744endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7745. 7746==== 7747 7748[source,c] 7749---- 7750struct timespec tv; 7751clock_gettime(CLOCK_MONOTONIC, &tv); 7752return tv.tv_nsec + tv.tv_sec*1000000000ull; 7753---- 7754 7755 * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR specifies the 7756 CLOCK_MONOTONIC_RAW time domain available on POSIX platforms. 7757 Timestamp values in this time domain are in units of nanoseconds and are 7758 comparable with platform timestamp values captured using the POSIX 7759 clock_gettime API as computed by this example: 7760 7761[source,c] 7762---- 7763struct timespec tv; 7764clock_gettime(CLOCK_MONOTONIC_RAW, &tv); 7765return tv.tv_nsec + tv.tv_sec*1000000000ull; 7766---- 7767 7768 * ename:VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR specifies the 7769 performance counter (QPC) time domain available on Windows. 7770 Timestamp values in this time domain are in the same units as those 7771 provided by the Windows QueryPerformanceCounter API and are comparable 7772 with platform timestamp values captured using that API as computed by 7773 this example: 7774 7775[source,c] 7776---- 7777LARGE_INTEGER counter; 7778QueryPerformanceCounter(&counter); 7779return counter.QuadPart; 7780---- 7781-- 7782endif::VK_KHR_calibrated_timestamps,VK_EXT_calibrated_timestamps[] 7783