1// Copyright 2015-2023 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 (if any) must: have also 3780 been 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**** 4042ifndef::VK_NV_external_sci_sync2[] 4043 * [[VUID-vkDestroySemaphore-semaphore-01137]] 4044 All submitted batches that refer to pname:semaphore must: have completed 4045 execution 4046endif::VK_NV_external_sci_sync2[] 4047ifdef::VK_NV_external_sci_sync2[] 4048 * [[VUID-vkDestroySemaphore-semaphore-05149]] 4049 If pname:semaphore was not created with 4050 slink:VkSemaphoreSciSyncCreateInfoNV present in the 4051 slink:VkSemaphoreCreateInfo::pname:pNext chain when it was created, all 4052 submitted batches that refer to pname:semaphore must: have completed 4053 execution 4054endif::VK_NV_external_sci_sync2[] 4055ifndef::VKSC_VERSION_1_0[] 4056 * [[VUID-vkDestroySemaphore-semaphore-01138]] 4057 If sname:VkAllocationCallbacks were provided when pname:semaphore was 4058 created, a compatible set of callbacks must: be provided here 4059 * [[VUID-vkDestroySemaphore-semaphore-01139]] 4060 If no sname:VkAllocationCallbacks were provided when pname:semaphore was 4061 created, pname:pAllocator must: be `NULL` 4062endif::VKSC_VERSION_1_0[] 4063**** 4064 4065include::{generated}/validity/protos/vkDestroySemaphore.adoc[] 4066-- 4067 4068ifdef::VK_NV_external_sci_sync2[] 4069=== Semaphore SciSync Pools 4070 4071A semaphore SciSync pool is used to represent a stext:NvSciSyncObj with one 4072or more primitives. 4073 4074[open,refpage='VkSemaphoreSciSyncPoolNV',desc='Opaque handle to a semaphore SciSync pool',type='handles'] 4075-- 4076Semaphore SciSync pools are represented by sname:VkSemaphoreSciSyncPoolNV 4077handles: 4078 4079include::{generated}/api/handles/VkSemaphoreSciSyncPoolNV.adoc[] 4080-- 4081 4082To import a stext:NvSciSyncObj with multiple primitives, use 4083flink:vkCreateSemaphoreSciSyncPoolNV to reserve a semaphore pool to map the 4084multiple semaphores allocated by stext:NvSciSyncObj. 4085Then create a slink:VkSemaphore from the semaphore pool using the index 4086provided by the stext:NvSciSyncFence when chaining the 4087slink:VkSemaphoreSciSyncCreateInfoNV structure to 4088slink:VkSemaphoreCreateInfo. 4089 4090[open,refpage='vkCreateSemaphoreSciSyncPoolNV',desc='Create a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] 4091-- 4092:refpage: vkCreateSemaphoreSciSyncPoolNV 4093 4094To create a sname:VkSemaphoreSciSyncPoolNV, call: 4095 4096include::{generated}/api/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] 4097 4098 * pname:device is the logical device that creates the semaphore pool. 4099 * pname:pCreateInfo is a pointer to a 4100 slink:VkSemaphoreSciSyncPoolCreateInfoNV structure containing 4101 information about the semaphore SciSync pool being created. 4102 * pname:pAllocator controls host memory allocation as described in the 4103 <<memory-allocation, Memory Allocation>> chapter. 4104 * pname:pSemaphorePool is a pointer to a handle in which the resulting 4105 semaphore pool object is returned. 4106 4107include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4108 4109.Valid Usage 4110**** 4111ifdef::VKSC_VERSION_1_0[] 4112 * [[VUID-vkCreateSemaphoreSciSyncPoolNV-device-05150]] 4113 The number of semaphore pools currently allocated from pname:device plus 4114 1 must: be less than or equal to the total number of semaphore pools 4115 requested via 4116 slink:VkDeviceSemaphoreSciSyncPoolReservationCreateInfoNV::pname:semaphoreSciSyncPoolRequestCount 4117 specified when pname:device was created 4118endif::VKSC_VERSION_1_0[] 4119 * [[VUID-vkCreateSemaphoreSciSyncPoolNV-sciSyncSemaphore2-05151]] 4120 The <<features-sciSyncSemaphore2, 4121 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> 4122 feature must: be enabled 4123**** 4124 4125include::{generated}/validity/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] 4126-- 4127 4128[open,refpage='VkSemaphoreSciSyncPoolCreateInfoNV',desc='Structure describing the creation parameters for a SciSync pool',type='structs'] 4129-- 4130The sname:VkSemaphoreSciSyncPoolCreateInfoNV structure is defined as: 4131 4132include::{generated}/api/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] 4133 4134 * pname:sType is a elink:VkStructureType value identifying this structure. 4135 * pname:pNext is `NULL` or a pointer to a structure extending this 4136 structure. 4137 * pname:handle is an external stext:NvSciSyncObj to import. 4138 4139During flink:vkCreateSemaphoreSciSyncPoolNV, the external stext:NvSciSyncObj 4140is imported to sname:VkSemaphoreSciSyncPoolNV. 4141The import does not transfer the ownership of the stext:NvSciSyncObj to the 4142implementation, but will increment the reference count of that object. 4143ifndef::VKSC_VERSION_1_0[] 4144flink:vkDestroySemaphoreSciSyncPoolNV will decrement the reference count of 4145that object. 4146endif::VKSC_VERSION_1_0[] 4147The application must: delete other references of the original 4148stext:NvSciSyncObj using <<NvSciSync2-extension-page, NvSciSync APIs>> when 4149it is no longer needed. 4150 4151Applications must: not import the same stext:NvSciSyncObj with signaler 4152access permissions to multiple instances of sname:VkSemaphoreSciSyncPoolNV. 4153 4154.Valid Usage 4155**** 4156 * [[VUID-VkSemaphoreSciSyncPoolCreateInfoNV-handle-05152]] 4157 pname:handle must: be a valid stext:NvSciSyncObj 4158**** 4159 4160include::{generated}/validity/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] 4161-- 4162 4163ifdef::VKSC_VERSION_1_0[] 4164ifdef::hidden[] 4165// tag::scremoved[] 4166ifdef::VK_NV_external_sci_sync2[] 4167 * fname:vkDestroySemaphoreSciSyncPoolNV <<SCID-4>> 4168endif::VK_NV_external_sci_sync2[] 4169// end::scremoved[] 4170endif::hidden[] 4171 4172Semaphore SciSync pools cannot: be freed <<SCID-4>>. 4173If 4174slink:VkPhysicalDeviceVulkanSC10Properties::<<limits-deviceDestroyFreesMemory,pname:deviceDestroyFreesMemory>> 4175is ename:VK_TRUE, the memory is returned to the system and the reference to 4176the stext:NvSciSyncObj that was imported is releasd when the device is 4177destroyed. 4178endif::VKSC_VERSION_1_0[] 4179 4180ifndef::VKSC_VERSION_1_0[] 4181[open,refpage='vkDestroySemaphoreSciSyncPoolNV',desc='Destroy a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] 4182-- 4183To destroy a slink:VkSemaphoreSciSyncPoolNV, call: 4184 4185include::{generated}/api/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] 4186 4187 * pname:device is the logical device that destroys the semaphore SciSync 4188 pool. 4189 * pname:semaphorePool is the handle of the semaphore SciSync pool to 4190 destroy. 4191 * pname:pAllocator controls host memory allocation as described in the 4192 <<memory-allocation, Memory Allocation>> chapter. 4193 4194.Valid Usage 4195**** 4196 * [[VUID-vkDestroySemaphoreSciSyncPoolNV-semaphorePool-05153]] 4197 All submitted batches that refer to a semaphore created from 4198 pname:semaphorePool must: have completed execution 4199 * [[VUID-vkDestroySemaphoreSciSyncPoolNV-sciSyncSemaphore2-05154]] 4200 The <<features-sciSyncSemaphore2, 4201 slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> 4202 feature must: be enabled 4203**** 4204 4205include::{generated}/validity/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] 4206-- 4207endif::VKSC_VERSION_1_0[] 4208endif::VK_NV_external_sci_sync2[] 4209 4210 4211[[synchronization-semaphores-signaling]] 4212=== Semaphore Signaling 4213 4214When a batch is submitted to a queue via a <<devsandqueues-submission, queue 4215submission>>, and it includes semaphores to be signaled, it defines a memory 4216dependency on the batch, and defines _semaphore signal operations_ which set 4217the semaphores to the signaled state. 4218 4219ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4220In case of semaphores created with a elink:VkSemaphoreType of 4221ename:VK_SEMAPHORE_TYPE_TIMELINE the semaphore is considered signaled with 4222respect to the counter value set to be signaled as specified in 4223slink:VkTimelineSemaphoreSubmitInfo or slink:VkSemaphoreSignalInfo. 4224endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4225 4226The first <<synchronization-dependencies-scopes, synchronization scope>> 4227includes every command submitted in the same batch. 4228ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4229In the case of flink:vkQueueSubmit2, the first synchronization scope is 4230limited to the pipeline stage specified by 4231slink:VkSemaphoreSubmitInfo::pname:stageMask. 4232endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4233Semaphore signal operations that are defined by flink:vkQueueSubmit 4234ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4235or flink:vkQueueSubmit2 4236endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4237additionally include all commands that occur earlier in 4238<<synchronization-submission-order,submission order>>. 4239Semaphore signal operations that are defined by flink:vkQueueSubmit 4240ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] 4241ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] 4242additionally include in the first synchronization scope any semaphore and 4243fence signal operations that occur earlier in 4244<<synchronization-signal-operation-order,signal operation order>>. 4245 4246The second <<synchronization-dependencies-scopes, synchronization scope>> 4247includes only the semaphore signal operation. 4248 4249The first <<synchronization-dependencies-access-scopes, access scope>> 4250includes all memory access performed by the device. 4251 4252The second <<synchronization-dependencies-access-scopes, access scope>> is 4253empty. 4254 4255 4256[[synchronization-semaphores-waiting]] 4257=== Semaphore Waiting 4258 4259When a batch is submitted to a queue via a <<devsandqueues-submission, queue 4260submission>>, and it includes semaphores to be waited on, it defines a 4261memory dependency between prior semaphore signal operations and the batch, 4262and defines _semaphore wait operations_. 4263 4264Such semaphore wait operations set the semaphores 4265ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4266created with a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY 4267endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4268to the unsignaled state. 4269ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4270In case of semaphores created with a elink:VkSemaphoreType of 4271ename:VK_SEMAPHORE_TYPE_TIMELINE a prior semaphore signal operation defines 4272a memory dependency with a semaphore wait operation if the value the 4273semaphore is signaled with is greater than or equal to the value the 4274semaphore is waited with, thus the semaphore will continue to be considered 4275signaled with respect to the counter value waited on as specified in 4276slink:VkTimelineSemaphoreSubmitInfo. 4277endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4278 4279The first synchronization scope includes all semaphore signal operations 4280that operate on semaphores waited on in the same batch, and that 4281happen-before the wait completes. 4282 4283The second <<synchronization-dependencies-scopes, synchronization scope>> 4284includes every command submitted in the same batch. 4285In the case of flink:vkQueueSubmit, the second synchronization scope is 4286limited to operations on the pipeline stages determined by the 4287<<synchronization-pipeline-stages-masks, destination stage mask>> specified 4288by the corresponding element of pname:pWaitDstStageMask. 4289ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4290In the case of flink:vkQueueSubmit2, the second synchronization scope is 4291limited to the pipeline stage specified by 4292slink:VkSemaphoreSubmitInfo::pname:stageMask. 4293endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4294Also, in the case of 4295ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 4296either flink:vkQueueSubmit2 or 4297endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 4298flink:vkQueueSubmit, the second synchronization scope additionally includes 4299all commands that occur later in 4300<<synchronization-submission-order,submission order>>. 4301 4302The first <<synchronization-dependencies-access-scopes, access scope>> is 4303empty. 4304 4305The second <<synchronization-dependencies-access-scopes, access scope>> 4306includes all memory access performed by the device. 4307 4308The semaphore wait operation happens-after the first set of operations in 4309the execution dependency, and happens-before the second set of operations in 4310the execution dependency. 4311 4312[NOTE] 4313.Note 4314==== 4315Unlike 4316ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4317timeline semaphores, 4318endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4319fences or events, the act of waiting for a binary semaphore also unsignals 4320that semaphore. 4321Applications must: ensure that between two such wait operations, the 4322semaphore is signaled again, with execution dependencies used to ensure 4323these occur in order. 4324Binary semaphore waits and signals should thus occur in discrete 1:1 pairs. 4325==== 4326 4327ifdef::VK_KHR_swapchain[] 4328[NOTE] 4329.Note 4330==== 4331A common scenario for using pname:pWaitDstStageMask with values other than 4332ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT is when synchronizing a window 4333system presentation operation against subsequent command buffers which 4334render the next frame. 4335In this case, a presentation image must: not be overwritten until the 4336presentation operation completes, but other pipeline stages can: execute 4337without waiting. 4338A mask of ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT prevents 4339subsequent color attachment writes from executing until the semaphore 4340signals. 4341Some implementations may: be able to execute transfer operations and/or 4342pre-rasterization work before the semaphore is signaled. 4343 4344If an image layout transition needs to be performed on a presentable image 4345before it is used in a framebuffer, that can: be performed as the first 4346operation submitted to the queue after acquiring the image, and should: not 4347prevent other work from overlapping with the presentation operation. 4348For example, a sname:VkImageMemoryBarrier could use: 4349 4350 * pname:srcStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 4351 * pname:srcAccessMask = 0 4352 * pname:dstStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT 4353 * pname:dstAccessMask = ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | 4354 ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. 4355 * pname:oldLayout = ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR 4356 * pname:newLayout = ename:VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL 4357 4358Alternatively, pname:oldLayout can: be ename:VK_IMAGE_LAYOUT_UNDEFINED, if 4359the image's contents need not be preserved. 4360 4361This barrier accomplishes a dependency chain between previous presentation 4362operations and subsequent color attachment output operations, with the 4363layout transition performed in between, and does not introduce a dependency 4364between previous work and any 4365<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4366stage>>s. 4367More precisely, the semaphore signals after the presentation operation 4368completes, the semaphore wait stalls the 4369ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage, and there is a 4370dependency from that same stage to itself with the layout transition 4371performed in between. 4372==== 4373endif::VK_KHR_swapchain[] 4374 4375 4376[[synchronization-semaphores-waiting-state]] 4377=== Semaphore State Requirements for Wait Operations 4378 4379Before waiting on a semaphore, the application must: ensure the semaphore is 4380in a valid state for a wait operation. 4381Specifically, when a <<synchronization-semaphores-waiting,semaphore wait 4382operation>> is submitted to a queue: 4383 4384 * A binary semaphore must: be signaled, or have an associated 4385 <<synchronization-semaphores-signaling,semaphore signal operation>> that 4386 is pending execution. 4387 * Any <<synchronization-semaphores-signaling,semaphore signal operations>> 4388 on which the pending binary semaphore signal operation depends must: 4389 also be completed or pending execution. 4390 * There must: be no other queue waiting on the same binary semaphore when 4391 the operation executes. 4392 4393 4394ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4395[[synchronization-semaphores-hostops]] 4396=== Host Operations on Semaphores 4397 4398In addition to <<synchronization-semaphores-signaling,semaphore signal 4399operations>> and <<synchronization-semaphores-waiting,semaphore wait 4400operations>> submitted to device queues, timeline semaphores support the 4401following host operations: 4402 4403 * Query the current counter value of the semaphore using the 4404 flink:vkGetSemaphoreCounterValue command. 4405 * Wait for a set of semaphores to reach particular counter values using 4406 the flink:vkWaitSemaphores command. 4407 * Signal the semaphore with a particular counter value from the host using 4408 the flink:vkSignalSemaphore command. 4409 4410[open,refpage='vkGetSemaphoreCounterValue',desc='Query the current state of a timeline semaphore',type='protos',alias='vkGetSemaphoreCounterValueKHR'] 4411-- 4412:refpage: vkGetSemaphoreCounterValue 4413 4414To query the current counter value of a semaphore created with a 4415elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE from the host, 4416call: 4417 4418ifdef::VK_VERSION_1_2[] 4419include::{generated}/api/protos/vkGetSemaphoreCounterValue.adoc[] 4420endif::VK_VERSION_1_2[] 4421 4422ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4423 4424ifdef::VK_KHR_timeline_semaphore[] 4425include::{generated}/api/protos/vkGetSemaphoreCounterValueKHR.adoc[] 4426endif::VK_KHR_timeline_semaphore[] 4427 4428 * pname:device is the logical device that owns the semaphore. 4429 * pname:semaphore is the handle of the semaphore to query. 4430 * pname:pValue is a pointer to a 64-bit integer value in which the current 4431 counter value of the semaphore is returned. 4432 4433[NOTE] 4434.Note 4435==== 4436If a <<devsandqueues-submission, queue submission>> command is pending 4437execution, then the value returned by this command may: immediately be out 4438of date. 4439==== 4440 4441include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4442 4443.Valid Usage 4444**** 4445 * [[VUID-vkGetSemaphoreCounterValue-semaphore-03255]] 4446 pname:semaphore must: have been created with a elink:VkSemaphoreType of 4447 ename:VK_SEMAPHORE_TYPE_TIMELINE 4448**** 4449 4450include::{generated}/validity/protos/vkGetSemaphoreCounterValue.adoc[] 4451-- 4452 4453[open,refpage='vkWaitSemaphores',desc='Wait for timeline semaphores on the host',type='protos',alias='vkWaitSemaphoresKHR'] 4454-- 4455:refpage: vkWaitSemaphores 4456 4457To wait for a set of semaphores created with a elink:VkSemaphoreType of 4458ename:VK_SEMAPHORE_TYPE_TIMELINE to reach particular counter values on the 4459host, call: 4460 4461ifdef::VK_VERSION_1_2[] 4462include::{generated}/api/protos/vkWaitSemaphores.adoc[] 4463endif::VK_VERSION_1_2[] 4464 4465ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4466 4467ifdef::VK_KHR_timeline_semaphore[] 4468include::{generated}/api/protos/vkWaitSemaphoresKHR.adoc[] 4469endif::VK_KHR_timeline_semaphore[] 4470 4471 * pname:device is the logical device that owns the semaphores. 4472 * pname:pWaitInfo is a pointer to a slink:VkSemaphoreWaitInfo structure 4473 containing information about the wait condition. 4474 * pname:timeout is the timeout period in units of nanoseconds. 4475 pname:timeout is adjusted to the closest value allowed by the 4476 implementation-dependent timeout accuracy, which may: be substantially 4477 longer than one nanosecond, and may: be longer than the requested 4478 period. 4479 4480If the condition is satisfied when fname:vkWaitSemaphores is called, then 4481fname:vkWaitSemaphores returns immediately. 4482If the condition is not satisfied at the time fname:vkWaitSemaphores is 4483called, then fname:vkWaitSemaphores will block and wait until the condition 4484is satisfied or the pname:timeout has expired, whichever is sooner. 4485 4486If pname:timeout is zero, then fname:vkWaitSemaphores does not wait, but 4487simply returns information about the current state of the semaphores. 4488ename:VK_TIMEOUT will be returned in this case if the condition is not 4489satisfied, even though no actual wait was performed. 4490 4491If the condition is satisfied before the pname:timeout has expired, 4492fname:vkWaitSemaphores returns ename:VK_SUCCESS. 4493Otherwise, fname:vkWaitSemaphores returns ename:VK_TIMEOUT after the 4494pname:timeout has expired. 4495 4496If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before 4497the timeout has expired, fname:vkWaitSemaphores must: return in finite time 4498with either ename:VK_SUCCESS or ename:VK_ERROR_DEVICE_LOST. 4499 4500include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4501 4502include::{generated}/validity/protos/vkWaitSemaphores.adoc[] 4503-- 4504 4505[open,refpage='VkSemaphoreWaitInfo',desc='Structure containing information about the semaphore wait condition',type='structs',alias='VkSemaphoreWaitInfoKHR'] 4506-- 4507The sname:VkSemaphoreWaitInfo structure is defined as: 4508 4509include::{generated}/api/structs/VkSemaphoreWaitInfo.adoc[] 4510 4511ifdef::VK_KHR_timeline_semaphore[] 4512or the equivalent 4513 4514include::{generated}/api/structs/VkSemaphoreWaitInfoKHR.adoc[] 4515endif::VK_KHR_timeline_semaphore[] 4516 4517 * pname:sType is a elink:VkStructureType value identifying this structure. 4518 * pname:pNext is `NULL` or a pointer to a structure extending this 4519 structure. 4520 * pname:flags is a bitmask of elink:VkSemaphoreWaitFlagBits specifying 4521 additional parameters for the semaphore wait operation. 4522 * pname:semaphoreCount is the number of semaphores to wait on. 4523 * pname:pSemaphores is a pointer to an array of pname:semaphoreCount 4524 semaphore handles to wait on. 4525 * pname:pValues is a pointer to an array of pname:semaphoreCount timeline 4526 semaphore values. 4527 4528.Valid Usage 4529**** 4530 * [[VUID-VkSemaphoreWaitInfo-pSemaphores-03256]] 4531 All of the elements of pname:pSemaphores must: reference a semaphore 4532 that was created with a elink:VkSemaphoreType of 4533 ename:VK_SEMAPHORE_TYPE_TIMELINE 4534ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4535 * [[VUID-VkSemaphoreWaitInfo-pSemaphores-05124]] 4536 If any of the semaphores in pname:pSemaphores have stext:NvSciSyncObj as 4537 payload, application must: calculate the corresponding timeline 4538 semaphore values in pname:pValues by calling 4539 <<NvSciSync2-extension-page, NvSciSync APIs>>. 4540endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4541**** 4542 4543include::{generated}/validity/structs/VkSemaphoreWaitInfo.adoc[] 4544-- 4545 4546[open,refpage='VkSemaphoreWaitFlagBits',desc='Bitmask specifying additional parameters of a semaphore wait operation',type='enums',alias='VkSemaphoreWaitFlagBitsKHR'] 4547-- 4548Bits which can: be set in slink:VkSemaphoreWaitInfo::pname:flags, specifying 4549additional parameters of a semaphore wait operation, are: 4550 4551include::{generated}/api/enums/VkSemaphoreWaitFlagBits.adoc[] 4552 4553ifdef::VK_KHR_timeline_semaphore[] 4554or the equivalent 4555 4556include::{generated}/api/enums/VkSemaphoreWaitFlagBitsKHR.adoc[] 4557endif::VK_KHR_timeline_semaphore[] 4558 4559 * ename:VK_SEMAPHORE_WAIT_ANY_BIT specifies that the semaphore wait 4560 condition is that at least one of the semaphores in 4561 sname:VkSemaphoreWaitInfo::pname:pSemaphores has reached the value 4562 specified by the corresponding element of 4563 sname:VkSemaphoreWaitInfo::pname:pValues. 4564 If ename:VK_SEMAPHORE_WAIT_ANY_BIT is not set, the semaphore wait 4565 condition is that all of the semaphores in 4566 sname:VkSemaphoreWaitInfo::pname:pSemaphores have reached the value 4567 specified by the corresponding element of 4568 sname:VkSemaphoreWaitInfo::pname:pValues. 4569-- 4570 4571[open,refpage='VkSemaphoreWaitFlags',desc='Bitmask of VkSemaphoreWaitFlagBits',type='flags',alias='VkSemaphoreWaitFlagsKHR'] 4572-- 4573include::{generated}/api/flags/VkSemaphoreWaitFlags.adoc[] 4574 4575ifdef::VK_KHR_timeline_semaphore[] 4576or the equivalent 4577 4578include::{generated}/api/flags/VkSemaphoreWaitFlagsKHR.adoc[] 4579endif::VK_KHR_timeline_semaphore[] 4580 4581tname:VkSemaphoreWaitFlags is a bitmask type for setting a mask of zero or 4582more elink:VkSemaphoreWaitFlagBits. 4583-- 4584 4585[open,refpage='vkSignalSemaphore',desc='Signal a timeline semaphore on the host',type='protos',alias='vkSignalSemaphoreKHR'] 4586-- 4587:refpage: vkSignalSemaphore 4588 4589To signal a semaphore created with a elink:VkSemaphoreType of 4590ename:VK_SEMAPHORE_TYPE_TIMELINE with a particular counter value, on the 4591host, call: 4592 4593ifdef::VK_VERSION_1_2[] 4594include::{generated}/api/protos/vkSignalSemaphore.adoc[] 4595endif::VK_VERSION_1_2[] 4596 4597ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] 4598 4599ifdef::VK_KHR_timeline_semaphore[] 4600include::{generated}/api/protos/vkSignalSemaphoreKHR.adoc[] 4601endif::VK_KHR_timeline_semaphore[] 4602 4603 * pname:device is the logical device that owns the semaphore. 4604 * pname:pSignalInfo is a pointer to a slink:VkSemaphoreSignalInfo 4605 structure containing information about the signal operation. 4606 4607When fname:vkSignalSemaphore is executed on the host, it defines and 4608immediately executes a <<synchronization-semaphores-signaling,_semaphore 4609signal operation_>> which sets the timeline semaphore to the given value. 4610 4611The first synchronization scope is defined by the host execution model, but 4612includes execution of fname:vkSignalSemaphore on the host and anything that 4613happened-before it. 4614 4615The second synchronization scope is empty. 4616 4617include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4618 4619include::{generated}/validity/protos/vkSignalSemaphore.adoc[] 4620-- 4621 4622[open,refpage='VkSemaphoreSignalInfo',desc='Structure containing information about a semaphore signal operation',type='structs',alias='VkSemaphoreSignalInfoKHR'] 4623-- 4624The sname:VkSemaphoreSignalInfo structure is defined as: 4625 4626include::{generated}/api/structs/VkSemaphoreSignalInfo.adoc[] 4627 4628ifdef::VK_KHR_timeline_semaphore[] 4629or the equivalent 4630 4631include::{generated}/api/structs/VkSemaphoreSignalInfoKHR.adoc[] 4632endif::VK_KHR_timeline_semaphore[] 4633 4634 * pname:sType is a elink:VkStructureType value identifying this structure. 4635 * pname:pNext is `NULL` or a pointer to a structure extending this 4636 structure. 4637 * pname:semaphore is the handle of the semaphore to signal. 4638 * pname:value is the value to signal. 4639 4640.Valid Usage 4641**** 4642 * [[VUID-VkSemaphoreSignalInfo-semaphore-03257]] 4643 pname:semaphore must: have been created with a elink:VkSemaphoreType of 4644 ename:VK_SEMAPHORE_TYPE_TIMELINE 4645 * [[VUID-VkSemaphoreSignalInfo-value-03258]] 4646 pname:value must: have a value greater than the current value of the 4647 semaphore 4648 * [[VUID-VkSemaphoreSignalInfo-value-03259]] 4649 pname:value must: be less than the value of any pending semaphore signal 4650 operations 4651 * [[VUID-VkSemaphoreSignalInfo-value-03260]] 4652 pname:value must: have a value which does not differ from the current 4653 value of the semaphore or the value of any outstanding semaphore wait or 4654 signal operation on pname:semaphore by more than 4655 <<limits-maxTimelineSemaphoreValueDifference, 4656 pname:maxTimelineSemaphoreValueDifference>> 4657ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4658 * [[VUID-VkSemaphoreSignalInfo-semaphores-05125]] 4659 If pname:semaphores has stext:NvSciSyncObj as payload, application must: 4660 calculate the corresponding timeline semaphore value in pname:value by 4661 calling <<NvSciSync2-extension-page, NvSciSync APIs>>. 4662endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] 4663**** 4664 4665include::{generated}/validity/structs/VkSemaphoreSignalInfo.adoc[] 4666-- 4667endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4668 4669 4670ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 4671[[synchronization-semaphores-importing]] 4672=== Importing Semaphore Payloads 4673 4674Applications can: import a semaphore payload into an existing semaphore 4675using an external semaphore handle. 4676The effects of the import operation will be either temporary or permanent, 4677as specified by the application. 4678If the import is temporary, the implementation must: restore the semaphore 4679to its prior permanent state after submitting the next semaphore wait 4680operation. 4681Performing a subsequent temporary import on a semaphore before performing a 4682semaphore wait has no effect on this requirement; the next wait submitted on 4683the semaphore must: still restore its last permanent state. 4684A permanent payload import behaves as if the target semaphore was destroyed, 4685and a new semaphore was created with the same handle but the imported 4686payload. 4687Because importing a semaphore payload temporarily or permanently detaches 4688the existing payload from a semaphore, similar usage restrictions to those 4689applied to fname:vkDestroySemaphore are applied to any command that imports 4690a semaphore payload. 4691Which of these import types is used is referred to as the import operation's 4692_permanence_. 4693Each handle type supports either one or both types of permanence. 4694 4695The implementation must: perform the import operation by either referencing 4696or copying the payload referred to by the specified external semaphore 4697handle, depending on the handle's type. 4698The import method used is referred to as the handle type's _transference_. 4699When using handle types with reference transference, importing a payload to 4700a semaphore adds the semaphore to the set of all semaphores sharing that 4701payload. 4702This set includes the semaphore from which the payload was exported. 4703Semaphore signaling and waiting operations performed on any semaphore in the 4704set must: behave as if the set were a single semaphore. 4705Importing a payload using handle types with copy transference creates a 4706duplicate copy of the payload at the time of import, but makes no further 4707reference to it. 4708Semaphore signaling and waiting operations performed on the target of copy 4709imports must: not affect any other semaphore or payload. 4710 4711Export operations have the same transference as the specified handle type's 4712import operations. 4713Additionally, exporting a semaphore payload to a handle with copy 4714transference has the same side effects on the source semaphore's payload as 4715executing a semaphore wait operation. 4716If the semaphore was using a temporarily imported payload, the semaphore's 4717prior permanent payload will be restored. 4718 4719ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 4720[NOTE] 4721.Note 4722==== 4723The permanence and transference of handle types can be found in: 4724 4725ifdef::VK_KHR_external_semaphore_win32[] 4726 * <<synchronization-semaphore-handletypes-win32,Handle Types Supported by 4727 sname:VkImportSemaphoreWin32HandleInfoKHR>> 4728endif::VK_KHR_external_semaphore_win32[] 4729ifdef::VK_KHR_external_semaphore_fd[] 4730 * <<synchronization-semaphore-handletypes-fd,Handle Types Supported by 4731 sname:VkImportSemaphoreFdInfoKHR>> 4732endif::VK_KHR_external_semaphore_fd[] 4733ifdef::VK_FUCHSIA_external_semaphore[] 4734 * <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported 4735 by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> 4736endif::VK_FUCHSIA_external_semaphore[] 4737==== 4738endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 4739 4740<<fundamentals-threadingbehavior,External synchronization>> allows 4741implementations to modify an object's internal state, i.e. payload, without 4742internal synchronization. 4743However, for semaphores sharing a payload across processes, satisfying the 4744external synchronization requirements of sname:VkSemaphore parameters as if 4745all semaphores in the set were the same object is sometimes infeasible. 4746Satisfying the <<synchronization-semaphores-waiting-state,wait operation 4747state requirements>> would similarly require impractical coordination or 4748levels of trust between processes. 4749Therefore, these constraints only apply to a specific semaphore handle, not 4750to its payload. 4751For distinct semaphore objects which share a payload, if the semaphores are 4752passed to separate queue submission commands concurrently, behavior will be 4753as if the commands were called in an arbitrary sequential order. 4754If the <<synchronization-semaphores-waiting-state,wait operation state 4755requirements>> are violated for the shared payload by a queue submission 4756command, or if a signal operation is queued for a shared payload that is 4757already signaled or has a pending signal operation, effects must: be limited 4758to one or more of the following: 4759 4760 * Returning ename:VK_ERROR_INITIALIZATION_FAILED from the command which 4761 resulted in the violation. 4762 * Losing the logical device on which the violation occurred immediately or 4763 at a future time, resulting in a ename:VK_ERROR_DEVICE_LOST error from 4764 subsequent commands, including the one causing the violation. 4765 * Continuing execution of the violating command or operation as if the 4766 semaphore wait completed successfully after an implementation-dependent 4767 timeout. 4768 In this case, the state of the payload becomes undefined:, and future 4769 operations on semaphores sharing the payload will be subject to these 4770 same rules. 4771 The semaphore must: be destroyed or have its payload replaced by an 4772 import operation to again have a well-defined state. 4773 4774[NOTE] 4775.Note 4776==== 4777These rules allow processes to synchronize access to shared memory without 4778trusting each other. 4779However, such processes must still be cautious not to use the shared 4780semaphore for more than synchronizing access to the shared memory. 4781For example, a process should not use a shared semaphore as part of an 4782execution dependency chain that, when complete, leads to objects being 4783destroyed, if it does not trust other processes sharing the semaphore 4784payload. 4785==== 4786 4787When a semaphore is using an imported payload, its 4788slink:VkExportSemaphoreCreateInfo::pname:handleTypes value is specified when 4789creating the semaphore from which the payload was exported, rather than 4790specified when creating the semaphore. 4791Additionally, 4792slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes 4793restricts which handle types can: be exported from such a semaphore based on 4794the specific handle type used to import the current payload. 4795ifdef::VK_KHR_swapchain[] 4796Passing a semaphore to flink:vkAcquireNextImageKHR is equivalent to 4797temporarily importing a semaphore payload to that semaphore. 4798 4799[NOTE] 4800.Note 4801==== 4802Because the exportable handle types of an imported semaphore correspond to 4803its current imported payload, and flink:vkAcquireNextImageKHR behaves the 4804same as a temporary import operation for which the source semaphore is 4805opaque to the application, applications have no way of determining whether 4806any external handle types can: be exported from a semaphore in this state. 4807Therefore, applications must: not attempt to export external handles from 4808semaphores using a temporarily imported payload from 4809flink:vkAcquireNextImageKHR. 4810==== 4811endif::VK_KHR_swapchain[] 4812 4813When importing a semaphore payload, it is the responsibility of the 4814application to ensure the external handles meet all valid usage 4815requirements. 4816However, implementations must: perform sufficient validation of external 4817handles to ensure that the operation results in a valid semaphore which will 4818not cause program termination, device loss, queue stalls, or corruption of 4819other resources when used as allowed according to its import parameters, and 4820excepting those side effects allowed for violations of the 4821<<synchronization-semaphores-waiting-state,valid semaphore state for wait 4822operations>> rules. 4823If the external handle provided does not meet these requirements, the 4824implementation must: fail the semaphore payload import operation with the 4825error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 4826 4827ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4828In addition, when importing a semaphore payload that is not compatible with 4829the payload type corresponding to the elink:VkSemaphoreType the semaphore 4830was created with, the implementation may: fail the semaphore payload import 4831operation with the error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 4832 4833[NOTE] 4834.Note 4835==== 4836As the introduction of the external semaphore handle type 4837ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT predates that of 4838timeline semaphores, support for importing semaphore payloads from external 4839handles of that type into semaphores created (implicitly or explicitly) with 4840a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY is preserved for 4841backwards compatibility. 4842However, applications should: prefer importing such handle types into 4843semaphores created with a elink:VkSemaphoreType of 4844ename:VK_SEMAPHORE_TYPE_TIMELINE. 4845==== 4846endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4847endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 4848 4849ifdef::VK_KHR_external_semaphore_win32[] 4850[open,refpage='vkImportSemaphoreWin32HandleKHR',desc='Import a semaphore from a Windows HANDLE',type='protos'] 4851-- 4852To import a semaphore payload from a Windows handle, call: 4853 4854include::{generated}/api/protos/vkImportSemaphoreWin32HandleKHR.adoc[] 4855 4856 * pname:device is the logical device that created the semaphore. 4857 * pname:pImportSemaphoreWin32HandleInfo is a pointer to a 4858 slink:VkImportSemaphoreWin32HandleInfoKHR structure specifying the 4859 semaphore and import parameters. 4860 4861Importing a semaphore payload from Windows handles does not transfer 4862ownership of the handle to the Vulkan implementation. 4863For handle types defined as NT handles, the application must: release 4864ownership using the code:CloseHandle system call when the handle is no 4865longer needed. 4866 4867Applications can: import the same semaphore payload into multiple instances 4868of Vulkan, into the same instance from which it was exported, and multiple 4869times into a given Vulkan instance. 4870 4871include::{generated}/validity/protos/vkImportSemaphoreWin32HandleKHR.adoc[] 4872-- 4873 4874[open,refpage='VkImportSemaphoreWin32HandleInfoKHR',desc='Structure specifying Windows handle to import to a semaphore',type='structs'] 4875-- 4876The sname:VkImportSemaphoreWin32HandleInfoKHR structure is defined as: 4877 4878include::{generated}/api/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] 4879 4880 * pname:sType is a elink:VkStructureType value identifying this structure. 4881 * pname:pNext is `NULL` or a pointer to a structure extending this 4882 structure. 4883 * pname:semaphore is the semaphore into which the payload will be 4884 imported. 4885 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 4886 additional parameters for the semaphore payload import operation. 4887 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 4888 specifying the type of pname:handle. 4889 * pname:handle is `NULL` or the external handle to import. 4890 * pname:name is `NULL` or a null-terminated UTF-16 string naming the 4891 underlying synchronization primitive to import. 4892 4893The handle types supported by pname:handleType are: 4894 4895[[synchronization-semaphore-handletypes-win32]] 4896.Handle Types Supported by sname:VkImportSemaphoreWin32HandleInfoKHR 4897[width="80%",options="header"] 4898|==== 4899| Handle Type | Transference | Permanence Supported 4900| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | Reference | Temporary,Permanent 4901| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | Reference | Temporary,Permanent 4902| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT | Reference | Temporary,Permanent 4903|==== 4904 4905.Valid Usage 4906**** 4907 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140]] 4908 pname:handleType must: be a value included in the 4909 <<synchronization-semaphore-handletypes-win32,Handle Types Supported by 4910 sname:VkImportSemaphoreWin32HandleInfoKHR>> table 4911 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01466]] 4912 If pname:handleType is not 4913 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4914 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, pname:name 4915 must: be `NULL` 4916 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01467]] 4917 If pname:handle is `NULL`, pname:name must: name a valid synchronization 4918 primitive of the type specified by pname:handleType 4919 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01468]] 4920 If pname:name is `NULL`, pname:handle must: be a valid handle of the 4921 type specified by pname:handleType 4922 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01469]] 4923 If pname:handle is not `NULL`, pname:name must: be `NULL` 4924 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01542]] 4925 If pname:handle is not `NULL`, it must: obey any requirements listed for 4926 pname:handleType in 4927 <<external-semaphore-handle-types-compatibility,external semaphore 4928 handle types compatibility>> 4929 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-name-01543]] 4930 If pname:name is not `NULL`, it must: obey any requirements listed for 4931 pname:handleType in 4932 <<external-semaphore-handle-types-compatibility,external semaphore 4933 handle types compatibility>> 4934 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03261]] 4935 If pname:handleType is 4936 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4937 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the 4938 slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the 4939 semaphore from which pname:handle or pname:name was exported 4940ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4941 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03262]] 4942 If pname:handleType is 4943 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or 4944 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the 4945 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match 4946 that of the semaphore from which pname:handle or pname:name was exported 4947 * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-flags-03322]] 4948 If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the 4949 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the 4950 semaphore from which pname:handle or pname:name was exported must: not 4951 be ename:VK_SEMAPHORE_TYPE_TIMELINE 4952endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 4953**** 4954 4955include::{generated}/validity/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] 4956-- 4957endif::VK_KHR_external_semaphore_win32[] 4958 4959ifdef::VK_KHR_external_semaphore_fd[] 4960[open,refpage='vkImportSemaphoreFdKHR',desc='Import a semaphore from a POSIX file descriptor',type='protos'] 4961-- 4962:refpage: vkImportSemaphoreFdKHR 4963 4964To import a semaphore payload from a POSIX file descriptor, call: 4965 4966include::{generated}/api/protos/vkImportSemaphoreFdKHR.adoc[] 4967 4968 * pname:device is the logical device that created the semaphore. 4969 * pname:pImportSemaphoreFdInfo is a pointer to a 4970 slink:VkImportSemaphoreFdInfoKHR structure specifying the semaphore and 4971 import parameters. 4972 4973Importing a semaphore payload from a file descriptor transfers ownership of 4974the file descriptor from the application to the Vulkan implementation. 4975The application must: not perform any operations on the file descriptor 4976after a successful import. 4977 4978Applications can: import the same semaphore payload into multiple instances 4979of Vulkan, into the same instance from which it was exported, and multiple 4980times into a given Vulkan instance. 4981 4982include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 4983 4984.Valid Usage 4985**** 4986 * [[VUID-vkImportSemaphoreFdKHR-semaphore-01142]] 4987 pname:semaphore must: not be associated with any queue command that has 4988 not yet completed execution on that queue 4989**** 4990 4991include::{generated}/validity/protos/vkImportSemaphoreFdKHR.adoc[] 4992-- 4993 4994[open,refpage='VkImportSemaphoreFdInfoKHR',desc='Structure specifying POSIX file descriptor to import to a semaphore',type='structs'] 4995-- 4996The sname:VkImportSemaphoreFdInfoKHR structure is defined as: 4997 4998include::{generated}/api/structs/VkImportSemaphoreFdInfoKHR.adoc[] 4999 5000 * pname:sType is a elink:VkStructureType value identifying this structure. 5001 * pname:pNext is `NULL` or a pointer to a structure extending this 5002 structure. 5003 * pname:semaphore is the semaphore into which the payload will be 5004 imported. 5005 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 5006 additional parameters for the semaphore payload import operation. 5007 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 5008 specifying the type of pname:fd. 5009 * pname:fd is the external handle to import. 5010 5011The handle types supported by pname:handleType are: 5012 5013[[synchronization-semaphore-handletypes-fd]] 5014.Handle Types Supported by sname:VkImportSemaphoreFdInfoKHR 5015[width="80%",options="header"] 5016|==== 5017| Handle Type | Transference | Permanence Supported 5018| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | Reference | Temporary,Permanent 5019| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT | Copy | Temporary 5020|==== 5021 5022.Valid Usage 5023**** 5024 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-01143]] 5025 pname:handleType must: be a value included in the 5026 <<synchronization-semaphore-handletypes-fd,Handle Types Supported by 5027 sname:VkImportSemaphoreFdInfoKHR>> table 5028 * [[VUID-VkImportSemaphoreFdInfoKHR-fd-01544]] 5029 pname:fd must: obey any requirements listed for pname:handleType in 5030 <<external-semaphore-handle-types-compatibility,external semaphore 5031 handle types compatibility>> 5032 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03263]] 5033 If pname:handleType is 5034 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the 5035 slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the 5036 semaphore from which pname:fd was exported 5037 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-07307]] 5038 If pname:handleType refers to a handle type with copy payload 5039 transference semantics, pname:flags must: contain 5040 ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT 5041ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5042 * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03264]] 5043 If pname:handleType is 5044 ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the 5045 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match 5046 that of the semaphore from which pname:fd was exported 5047 * [[VUID-VkImportSemaphoreFdInfoKHR-flags-03323]] 5048 If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the 5049 slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the 5050 semaphore from which pname:fd was exported must: not be 5051 ename:VK_SEMAPHORE_TYPE_TIMELINE 5052endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5053**** 5054 5055If pname:handleType is ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, 5056the special value `-1` for pname:fd is treated like a valid sync file 5057descriptor referring to an object that has already signaled. 5058The import operation will succeed and the sname:VkSemaphore will have a 5059temporarily imported payload as if a valid file descriptor had been 5060provided. 5061 5062[NOTE] 5063.Note 5064==== 5065This special behavior for importing an invalid sync file descriptor allows 5066easier interoperability with other system APIs which use the convention that 5067an invalid sync file descriptor represents work that has already completed 5068and does not need to be waited for. 5069It is consistent with the option for implementations to return a `-1` file 5070descriptor when exporting a 5071ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT from a sname:VkSemaphore 5072which is signaled. 5073==== 5074 5075include::{generated}/validity/structs/VkImportSemaphoreFdInfoKHR.adoc[] 5076-- 5077endif::VK_KHR_external_semaphore_fd[] 5078 5079ifdef::VK_FUCHSIA_external_semaphore[] 5080[open,refpage='vkImportSemaphoreZirconHandleFUCHSIA',desc='Import a semaphore from a Zircon event handle',type='protos'] 5081-- 5082To import a semaphore payload from a Zircon event handle, call: 5083 5084include::{generated}/api/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] 5085 5086 * pname:device is the logical device that created the semaphore. 5087 * pname:pImportSemaphoreZirconHandleInfo is a pointer to a 5088 slink:VkImportSemaphoreZirconHandleInfoFUCHSIA structure specifying the 5089 semaphore and import parameters. 5090 5091Importing a semaphore payload from a Zircon event handle transfers ownership 5092of the handle from the application to the Vulkan implementation. 5093The application must: not perform any operations on the handle after a 5094successful import. 5095 5096Applications can: import the same semaphore payload into multiple instances 5097of Vulkan, into the same instance from which it was exported, and multiple 5098times into a given Vulkan instance. 5099 5100.Valid Usage 5101**** 5102 * [[VUID-vkImportSemaphoreZirconHandleFUCHSIA-semaphore-04764]] 5103 pname:semaphore must: not be associated with any queue command that has 5104 not yet completed execution on that queue 5105**** 5106 5107include::{generated}/validity/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] 5108-- 5109 5110[open,refpage='VkImportSemaphoreZirconHandleInfoFUCHSIA',desc='Structure specifying Zircon event handle to import to a semaphore',type='structs'] 5111-- 5112The sname:VkImportSemaphoreZirconHandleInfoFUCHSIA structure is defined as: 5113 5114include::{generated}/api/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] 5115 5116 * pname:sType is a elink:VkStructureType value identifying this structure. 5117 * pname:pNext is `NULL` or a pointer to a structure extending this 5118 structure. 5119 * pname:semaphore is the semaphore into which the payload will be 5120 imported. 5121 * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying 5122 additional parameters for the semaphore payload import operation. 5123 * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value 5124 specifying the type of pname:zirconHandle. 5125 * pname:zirconHandle is the external handle to import. 5126 5127The handle types supported by pname:handleType are: 5128 5129[[synchronization-semaphore-handletypes-fuchsia]] 5130.Handle Types Supported by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA 5131[width="80%",options="header"] 5132|==== 5133| Handle Type | Transference | Permanence Supported 5134| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA | Reference | Temporary,Permanent 5135|==== 5136 5137.Valid Usage 5138**** 5139 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-handleType-04765]] 5140 pname:handleType must: be a value included in the 5141 <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported 5142 by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> table 5143 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04766]] 5144 pname:zirconHandle must: obey any requirements listed for 5145 pname:handleType in 5146 <<external-semaphore-handle-types-compatibility,external semaphore 5147 handle types compatibility>> 5148 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04767]] 5149 pname:zirconHandle must: have code:ZX_RIGHTS_BASIC and 5150 code:ZX_RIGHTS_SIGNAL rights 5151ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5152 * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-semaphoreType-04768]] 5153 The slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: not 5154 be ename:VK_SEMAPHORE_TYPE_TIMELINE 5155endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 5156**** 5157 5158include::{generated}/validity/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] 5159-- 5160endif::VK_FUCHSIA_external_semaphore[] 5161 5162ifdef::VK_NV_external_sci_sync[] 5163[open,refpage='vkImportSemaphoreSciSyncObjNV',desc='Import a semaphore from a SciSync handle',type='protos'] 5164-- 5165To import a semaphore payload from a stext:NvSciSyncObj, call: 5166 5167include::{generated}/api/protos/vkImportSemaphoreSciSyncObjNV.adoc[] 5168 5169 * pname:device is the logical device that created the semaphore. 5170 * pname:pImportSemaphoreSciSyncInfo is a pointer to a 5171 slink:VkImportSemaphoreSciSyncInfoNV structure containing parameters of 5172 the import operation 5173 5174Importing a semaphore payload from stext:NvSciSyncObj does not transfer 5175ownership of the handle to the Vulkan implementation. 5176When importing stext:NvSciSyncObj, Vulkan will make a new reference to that 5177object, the application must: release its ownership using 5178<<NvSciSync-extension-page, NvSciSync APIs>> when that ownership is no 5179longer needed. 5180 5181Application must: not import the same stext:NvSciSyncObj with signaler 5182access permissions into multiple instances of VkSemaphore, and must: not 5183import into the same instance from which it was exported. 5184 5185.Valid Usage 5186**** 5187 * [[VUID-vkImportSemaphoreSciSyncObjNV-sciSyncImport-05155]] 5188 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and 5189 slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore 5190 must: be enabled 5191**** 5192 5193include::{generated}/validity/protos/vkImportSemaphoreSciSyncObjNV.adoc[] 5194-- 5195 5196[open,refpage='VkImportSemaphoreSciSyncInfoNV',desc='Structure specifying SciSync handle to import to a semaphore',type='structs'] 5197-- 5198The sname:VkImportSemaphoreSciSyncInfoNV structure is defined as: 5199 5200include::{generated}/api/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] 5201 5202 * pname:sType is a elink:VkStructureType value identifying this structure. 5203 * pname:pNext is `NULL` or a pointer to a structure extending this 5204 structure. 5205 * pname:semaphore is the semaphore into which the payload will be 5206 imported. 5207 * pname:handleType specifies the type of stext:handle. 5208 * pname:handle is the external handle to import. 5209 5210The handle types supported by pname:handleType are: 5211 5212[[synchronization-semaphore-handletypes-sci-sync]] 5213.Handle Types Supported by sname:VkImportSemaphoreSciSyncInfoNV 5214[width="80%",options="header"] 5215|==== 5216| Handle Type | Transference | Permanence Supported 5217| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV | Reference | Permanent 5218|==== 5219 5220.Valid Usage 5221**** 5222 * [[VUID-VkImportSemaphoreSciSyncInfoNV-handleType-05126]] 5223 pname:handleType must: be a value included in the 5224 <<synchronization-semaphore-handletypes-sci-sync, Handle Types Supported 5225 by sname:VkImportSemaphoreSciSyncInfoNV>> table 5226 * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05127]] 5227 pname:semaphore must: have been created with a elink:VkSemaphoreType of 5228 ename:VK_SEMAPHORE_TYPE_TIMELINE 5229 * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05128]] 5230 pname:semaphore must: not be associated with any queue command that has 5231 not yet completed execution on that queue 5232**** 5233 5234include::{generated}/validity/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] 5235-- 5236endif::VK_NV_external_sci_sync[] 5237 5238ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] 5239ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 5240[open,refpage='VkSemaphoreImportFlagBits',desc='Bitmask specifying additional parameters of semaphore payload import',type='enums'] 5241-- 5242Bits which can: be set in 5243 5244ifdef::VK_KHR_external_semaphore_win32[] 5245 * slink:VkImportSemaphoreWin32HandleInfoKHR::pname:flags 5246endif::VK_KHR_external_semaphore_win32[] 5247ifdef::VK_KHR_external_semaphore_fd[] 5248 * slink:VkImportSemaphoreFdInfoKHR::pname:flags 5249endif::VK_KHR_external_semaphore_fd[] 5250ifdef::VK_FUCHSIA_external_semaphore[] 5251 * slink:VkImportSemaphoreZirconHandleInfoFUCHSIA::pname:flags 5252endif::VK_FUCHSIA_external_semaphore[] 5253 5254specifying additional parameters of a semaphore import operation are: 5255 5256include::{generated}/api/enums/VkSemaphoreImportFlagBits.adoc[] 5257 5258ifdef::VK_KHR_external_semaphore[] 5259or the equivalent 5260 5261include::{generated}/api/enums/VkSemaphoreImportFlagBitsKHR.adoc[] 5262endif::VK_KHR_external_semaphore[] 5263 5264These bits have the following meanings: 5265 5266 * ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT specifies that the semaphore 5267 payload will be imported only temporarily, as described in 5268 <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, 5269 regardless of the permanence of pname:handleType. 5270-- 5271 5272[open,refpage='VkSemaphoreImportFlags',desc='Bitmask of VkSemaphoreImportFlagBits',type='flags'] 5273-- 5274include::{generated}/api/flags/VkSemaphoreImportFlags.adoc[] 5275 5276ifdef::VK_KHR_external_semaphore[] 5277or the equivalent 5278 5279include::{generated}/api/flags/VkSemaphoreImportFlagsKHR.adoc[] 5280endif::VK_KHR_external_semaphore[] 5281 5282tname:VkSemaphoreImportFlags is a bitmask type for setting a mask of zero or 5283more elink:VkSemaphoreImportFlagBits. 5284-- 5285endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] 5286endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] 5287 5288 5289[[synchronization-events]] 5290== Events 5291 5292[open,refpage='VkEvent',desc='Opaque handle to an event object',type='handles'] 5293-- 5294Events are a synchronization primitive that can: be used to insert a 5295fine-grained dependency between commands submitted to the same queue, or 5296between the host and a queue. 5297Events must: not be used to insert a dependency between commands submitted 5298to different queues. 5299Events have two states - signaled and unsignaled. 5300An application can: signal or unsignal an event either on the host or on the 5301device. 5302A device can: be made to wait for an event to become signaled before 5303executing further operations. 5304No command exists to wait for an event to become signaled on the host, but 5305the current state of an event can: be queried. 5306 5307Events are represented by sname:VkEvent handles: 5308 5309include::{generated}/api/handles/VkEvent.adoc[] 5310-- 5311 5312[open,refpage='vkCreateEvent',desc='Create a new event object',type='protos'] 5313-- 5314:refpage: vkCreateEvent 5315:objectnameplural: events 5316:objectnamecamelcase: event 5317:objectcount: 1 5318 5319To create an event, call: 5320 5321include::{generated}/api/protos/vkCreateEvent.adoc[] 5322 5323 * pname:device is the logical device that creates the event. 5324 * pname:pCreateInfo is a pointer to a slink:VkEventCreateInfo structure 5325 containing information about how the event is to be created. 5326 * pname:pAllocator controls host memory allocation as described in the 5327 <<memory-allocation, Memory Allocation>> chapter. 5328 * pname:pEvent is a pointer to a handle in which the resulting event 5329 object is returned. 5330 5331When created, the event object is in the unsignaled state. 5332 5333include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5334 5335.Valid Usage 5336**** 5337ifdef::VK_KHR_portability_subset[] 5338 * [[VUID-vkCreateEvent-events-04468]] 5339 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 5340 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:events is 5341 ename:VK_FALSE, then the implementation does not support 5342 <<synchronization-events, events>>, and flink:vkCreateEvent must: not be 5343 used 5344endif::VK_KHR_portability_subset[] 5345include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] 5346**** 5347 5348include::{generated}/validity/protos/vkCreateEvent.adoc[] 5349-- 5350 5351[open,refpage='VkEventCreateInfo',desc='Structure specifying parameters of a newly created event',type='structs'] 5352-- 5353The sname:VkEventCreateInfo structure is defined as: 5354 5355include::{generated}/api/structs/VkEventCreateInfo.adoc[] 5356 5357 * pname:sType is a elink:VkStructureType value identifying this structure. 5358 * pname:pNext is `NULL` or a pointer to a structure extending this 5359 structure. 5360 * pname:flags is a bitmask of elink:VkEventCreateFlagBits defining 5361 additional creation parameters. 5362 5363ifdef::VK_EXT_metal_objects[] 5364.Valid Usage 5365**** 5366 * [[VUID-VkEventCreateInfo-pNext-06790]] 5367 If the pname:pNext chain includes a 5368 slink:VkExportMetalObjectCreateInfoEXT structure, its 5369 pname:exportObjectType member must: be 5370 ename:VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT 5371**** 5372endif::VK_EXT_metal_objects[] 5373 5374include::{generated}/validity/structs/VkEventCreateInfo.adoc[] 5375-- 5376 5377[open,refpage='VkEventCreateFlagBits',desc='Event creation flag bits',type='enums'] 5378-- 5379include::{generated}/api/enums/VkEventCreateFlagBits.adoc[] 5380 5381ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5382 * ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT specifies that host event commands 5383 will not be used with this event. 5384endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5385 5386ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5387[NOTE] 5388.Note 5389==== 5390All bits for this type are defined by extensions, and none of those 5391extensions are enabled in this build of the specification. 5392==== 5393endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5394-- 5395 5396[open,refpage='VkEventCreateFlags',desc='Bitmask of event creation flag bits',type='flags'] 5397-- 5398include::{generated}/api/flags/VkEventCreateFlags.adoc[] 5399 5400tname:VkEventCreateFlags is a bitmask type for setting a mask of 5401elink:VkEventCreateFlagBits. 5402-- 5403 5404[open,refpage='vkDestroyEvent',desc='Destroy an event object',type='protos'] 5405-- 5406To destroy an event, call: 5407 5408include::{generated}/api/protos/vkDestroyEvent.adoc[] 5409 5410 * pname:device is the logical device that destroys the event. 5411 * pname:event is the handle of the event to destroy. 5412 * pname:pAllocator controls host memory allocation as described in the 5413 <<memory-allocation, Memory Allocation>> chapter. 5414 5415.Valid Usage 5416**** 5417 * [[VUID-vkDestroyEvent-event-01145]] 5418 All submitted commands that refer to pname:event must: have completed 5419 execution 5420ifndef::VKSC_VERSION_1_0[] 5421 * [[VUID-vkDestroyEvent-event-01146]] 5422 If sname:VkAllocationCallbacks were provided when pname:event was 5423 created, a compatible set of callbacks must: be provided here 5424 * [[VUID-vkDestroyEvent-event-01147]] 5425 If no sname:VkAllocationCallbacks were provided when pname:event was 5426 created, pname:pAllocator must: be `NULL` 5427endif::VKSC_VERSION_1_0[] 5428**** 5429 5430include::{generated}/validity/protos/vkDestroyEvent.adoc[] 5431-- 5432 5433[open,refpage='vkGetEventStatus',desc='Retrieve the status of an event object',type='protos'] 5434-- 5435:refpage: vkGetEventStatus 5436 5437To query the state of an event from the host, call: 5438 5439include::{generated}/api/protos/vkGetEventStatus.adoc[] 5440 5441 * pname:device is the logical device that owns the event. 5442 * pname:event is the handle of the event to query. 5443 5444Upon success, fname:vkGetEventStatus returns the state of the event object 5445with the following return codes: 5446 5447.Event Object Status Codes 5448[width="80%",options="header"] 5449|==== 5450| Status | Meaning 5451| ename:VK_EVENT_SET | The event specified by pname:event is signaled. 5452| ename:VK_EVENT_RESET | The event specified by pname:event is unsignaled. 5453|==== 5454 5455If a fname:vkCmdSetEvent or fname:vkCmdResetEvent command is in a command 5456buffer that is in the <<commandbuffers-lifecycle, pending state>>, then the 5457value returned by this command may: immediately be out of date. 5458 5459The state of an event can: be updated by the host. 5460The state of the event is immediately changed, and subsequent calls to 5461fname:vkGetEventStatus will return the new state. 5462If an event is already in the requested state, then updating it to the same 5463state has no effect. 5464 5465include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5466 5467ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5468.Valid Usage 5469**** 5470 * [[VUID-vkGetEventStatus-event-03940]] 5471 pname:event must: not have been created with 5472 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5473**** 5474endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5475 5476include::{generated}/validity/protos/vkGetEventStatus.adoc[] 5477-- 5478 5479[[synchronization-events-signaling-host]] 5480[open,refpage='vkSetEvent',desc='Set an event to signaled state',type='protos'] 5481-- 5482:refpage: vkSetEvent 5483 5484To set the state of an event to signaled from the host, call: 5485 5486include::{generated}/api/protos/vkSetEvent.adoc[] 5487 5488 * pname:device is the logical device that owns the event. 5489 * pname:event is the event to set. 5490 5491When flink:vkSetEvent is executed on the host, it defines an _event signal 5492operation_ which sets the event to the signaled state. 5493 5494If pname:event is already in the signaled state when flink:vkSetEvent is 5495executed, then flink:vkSetEvent has no effect, and no event signal operation 5496occurs. 5497 5498[NOTE] 5499.Note 5500==== 5501If a command buffer is waiting for an event to be signaled from the host, 5502the application must signal the event before submitting the command buffer, 5503as described in the <<commandbuffers-submission-progress, queue forward 5504progress>> section. 5505==== 5506 5507include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 5508 5509ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5510.Valid Usage 5511**** 5512 * [[VUID-vkSetEvent-event-03941]] 5513 pname:event must: not have been created with 5514 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5515**** 5516endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5517 5518include::{generated}/validity/protos/vkSetEvent.adoc[] 5519-- 5520 5521[[synchronization-events-unsignaling-host]] 5522[open,refpage='vkResetEvent',desc='Reset an event to non-signaled state',type='protos'] 5523-- 5524To set the state of an event to unsignaled from the host, call: 5525 5526include::{generated}/api/protos/vkResetEvent.adoc[] 5527 5528 * pname:device is the logical device that owns the event. 5529 * pname:event is the event to reset. 5530 5531When flink:vkResetEvent is executed on the host, it defines an _event 5532unsignal operation_ which resets the event to the unsignaled state. 5533 5534If pname:event is already in the unsignaled state when flink:vkResetEvent is 5535executed, then flink:vkResetEvent has no effect, and no event unsignal 5536operation occurs. 5537 5538.Valid Usage 5539**** 5540 * [[VUID-vkResetEvent-event-03821]] 5541 There must: be an execution dependency between fname:vkResetEvent and 5542 the execution of any flink:vkCmdWaitEvents that includes pname:event in 5543 its pname:pEvents parameter 5544ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5545 * [[VUID-vkResetEvent-event-03822]] 5546 There must: be an execution dependency between fname:vkResetEvent and 5547 the execution of any flink:vkCmdWaitEvents2 that includes pname:event in 5548 its pname:pEvents parameter 5549endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5550ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5551 * [[VUID-vkResetEvent-event-03823]] 5552 pname:event must: not have been created with 5553 ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT 5554endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5555**** 5556 5557include::{generated}/validity/protos/vkResetEvent.adoc[] 5558-- 5559 5560The state of an event can: also be updated on the device by commands 5561inserted in command buffers. 5562 5563[[synchronization-events-signaling-device]] 5564ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5565[open,refpage='vkCmdSetEvent2',desc='Set an event object to signaled state',type='protos',alias='vkCmdSetEvent2KHR'] 5566-- 5567To signal an event from a device, call: 5568 5569ifdef::VK_VERSION_1_3[] 5570include::{generated}/api/protos/vkCmdSetEvent2.adoc[] 5571endif::VK_VERSION_1_3[] 5572 5573ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5574 5575ifdef::VK_KHR_synchronization2[] 5576include::{generated}/api/protos/vkCmdSetEvent2KHR.adoc[] 5577endif::VK_KHR_synchronization2[] 5578 5579 * pname:commandBuffer is the command buffer into which the command is 5580 recorded. 5581 * pname:event is the event that will be signaled. 5582 * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure 5583 defining the first scopes of this operation. 5584 5585When flink:vkCmdSetEvent2 is submitted to a queue, it defines the first half 5586of memory dependencies defined by pname:pDependencyInfo, as well as an event 5587signal operation which sets the event to the signaled state. 5588A memory dependency is defined between the event signal operation and 5589commands that occur earlier in submission order. 5590 5591The first <<synchronization-dependencies-scopes, synchronization scope>> and 5592<<synchronization-dependencies-access-scopes, access scope>> are defined by 5593the union of all the memory dependencies defined by pname:pDependencyInfo, 5594and are applied to all operations that occur earlier in 5595<<synchronization-submission-order,submission order>>. 5596<<synchronization-queue-transfers, Queue family ownership transfers>> and 5597<<synchronization-image-layout-transitions, image layout transitions>> 5598defined by pname:pDependencyInfo are also included in the first scopes. 5599 5600The second <<synchronization-dependencies-scopes, synchronization scope>> 5601includes only the event signal operation, and any 5602<<synchronization-queue-transfers, queue family ownership transfers>> and 5603<<synchronization-image-layout-transitions, image layout transitions>> 5604defined by pname:pDependencyInfo. 5605 5606The second <<synchronization-dependencies-access-scopes, access scope>> 5607includes only <<synchronization-queue-transfers, queue family ownership 5608transfers>> and <<synchronization-image-layout-transitions, image layout 5609transitions>>. 5610 5611Future flink:vkCmdWaitEvents2 commands rely on all values of each element in 5612pname:pDependencyInfo matching exactly with those used to signal the 5613corresponding event. 5614flink:vkCmdWaitEvents must: not be used to wait on the result of a signal 5615operation defined by fname:vkCmdSetEvent2. 5616 5617[NOTE] 5618.Note 5619==== 5620The extra information provided by flink:vkCmdSetEvent2 compared to 5621flink:vkCmdSetEvent allows implementations to more efficiently schedule the 5622operations required to satisfy the requested dependencies. 5623With flink:vkCmdSetEvent, the full dependency information is not known until 5624flink:vkCmdWaitEvents is recorded, forcing implementations to insert the 5625required operations at that point and not before. 5626==== 5627 5628If pname:event is already in the signaled state when flink:vkCmdSetEvent2 is 5629executed on the device, then flink:vkCmdSetEvent2 has no effect, no event 5630signal operation occurs, and no dependency is generated. 5631 5632.Valid Usage 5633**** 5634 * [[VUID-vkCmdSetEvent2-synchronization2-03824]] 5635 The <<features-synchronization2, pname:synchronization2>> feature must: 5636 be enabled 5637 * [[VUID-vkCmdSetEvent2-dependencyFlags-03825]] 5638 The pname:dependencyFlags member of pname:pDependencyInfo must: be `0` 5639 * [[VUID-vkCmdSetEvent2-srcStageMask-09391]] 5640 The pname:srcStageMask member of any element of the 5641 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5642 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not 5643 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5644 * [[VUID-vkCmdSetEvent2-dstStageMask-09392]] 5645 The pname:dstStageMask member of any element of the 5646 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5647 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not 5648 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5649ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5650 * [[VUID-vkCmdSetEvent2-commandBuffer-03826]] 5651 The current device mask of pname:commandBuffer must: include exactly one 5652 physical device 5653endif::VK_VERSION_1_1,VK_KHR_device_group[] 5654 * [[VUID-vkCmdSetEvent2-srcStageMask-03827]] 5655 The pname:srcStageMask member of any element of the 5656 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5657 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 5658 include pipeline stages valid for the queue family that was used to 5659 create the command pool that pname:commandBuffer was allocated from 5660 * [[VUID-vkCmdSetEvent2-dstStageMask-03828]] 5661 The pname:dstStageMask member of any element of the 5662 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 5663 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 5664 include pipeline stages valid for the queue family that was used to 5665 create the command pool that pname:commandBuffer was allocated from 5666**** 5667 5668include::{generated}/validity/protos/vkCmdSetEvent2.adoc[] 5669-- 5670 5671[open,refpage='VkDependencyInfo',desc='Structure specifying dependency information for a synchronization command',type='structs',alias='VkDependencyInfoKHR'] 5672-- 5673The sname:VkDependencyInfo structure is defined as: 5674 5675include::{generated}/api/structs/VkDependencyInfo.adoc[] 5676 5677ifdef::VK_KHR_synchronization2[] 5678or the equivalent 5679 5680include::{generated}/api/structs/VkDependencyInfoKHR.adoc[] 5681endif::VK_KHR_synchronization2[] 5682 5683 * pname:sType is a elink:VkStructureType value identifying this structure. 5684 * pname:pNext is `NULL` or a pointer to a structure extending this 5685 structure. 5686 * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits 5687 specifying how execution and memory dependencies are formed. 5688 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 5689 array. 5690 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier2 5691 structures defining memory dependencies between any memory accesses. 5692 * pname:bufferMemoryBarrierCount is the length of the 5693 pname:pBufferMemoryBarriers array. 5694 * pname:pBufferMemoryBarriers is a pointer to an array of 5695 slink:VkBufferMemoryBarrier2 structures defining memory dependencies 5696 between buffer ranges. 5697 * pname:imageMemoryBarrierCount is the length of the 5698 pname:pImageMemoryBarriers array. 5699 * pname:pImageMemoryBarriers is a pointer to an array of 5700 slink:VkImageMemoryBarrier2 structures defining memory dependencies 5701 between image subresources. 5702 5703This structure defines a set of <<synchronization-dependencies-memory, 5704memory dependencies>>, as well as <<synchronization-queue-transfers, queue 5705family transfer operations>> and <<synchronization-image-layout-transitions, 5706image layout transitions>>. 5707 5708Each member of pname:pMemoryBarriers, pname:pBufferMemoryBarriers, and 5709pname:pImageMemoryBarriers defines a separate 5710<<synchronization-dependencies-memory, memory dependency>>. 5711 5712include::{generated}/validity/structs/VkDependencyInfo.adoc[] 5713-- 5714endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5715 5716[open,refpage='vkCmdSetEvent',desc='Set an event object to signaled state',type='protos'] 5717-- 5718:refpage: vkCmdSetEvent 5719 5720To set the state of an event to signaled from a device, call: 5721 5722include::{generated}/api/protos/vkCmdSetEvent.adoc[] 5723 5724 * pname:commandBuffer is the command buffer into which the command is 5725 recorded. 5726 * pname:event is the event that will be signaled. 5727 * pname:stageMask specifies the <<synchronization-pipeline-stages,source 5728 stage mask>> used to determine the first 5729 <<synchronization-dependencies-scopes, synchronization scope>>. 5730 5731 5732ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5733fname:vkCmdSetEvent behaves identically to flink:vkCmdSetEvent2, except that 5734it does not define an access scope, and must: only be used with 5735flink:vkCmdWaitEvents, not flink:vkCmdWaitEvents2. 5736endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5737 5738ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5739When flink:vkCmdSetEvent is submitted to a queue, it defines an execution 5740dependency on commands that were submitted before it, and defines an event 5741signal operation which sets the event to the signaled state. 5742 5743The first <<synchronization-dependencies-scopes, synchronization scope>> 5744includes all commands that occur earlier in 5745<<synchronization-submission-order,submission order>>. 5746The synchronization scope is limited to operations on the pipeline stages 5747determined by the <<synchronization-pipeline-stages-masks, source stage 5748mask>> specified by pname:stageMask. 5749 5750The second <<synchronization-dependencies-scopes, synchronization scope>> 5751includes only the event signal operation. 5752 5753If pname:event is already in the signaled state when flink:vkCmdSetEvent is 5754executed on the device, then flink:vkCmdSetEvent has no effect, no event 5755signal operation occurs, and no execution dependency is generated. 5756endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5757 5758.Valid Usage 5759**** 5760:stageMaskName: stageMask 5761include::{chapters}/commonvalidity/stage_mask_common.adoc[] 5762 * [[VUID-vkCmdSetEvent-stageMask-06457]] 5763 Any pipeline stage included in pname:stageMask must: be supported by the 5764 capabilities of the queue family specified by the pname:queueFamilyIndex 5765 member of the slink:VkCommandPoolCreateInfo structure that was used to 5766 create the sname:VkCommandPool that pname:commandBuffer was allocated 5767 from, as specified in the <<synchronization-pipeline-stages-supported, 5768 table of supported pipeline stages>> 5769 * [[VUID-vkCmdSetEvent-stageMask-01149]] 5770 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 5771ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5772 * [[VUID-vkCmdSetEvent-commandBuffer-01152]] 5773 The current device mask of pname:commandBuffer must: include exactly one 5774 physical device 5775endif::VK_VERSION_1_1,VK_KHR_device_group[] 5776**** 5777 5778include::{generated}/validity/protos/vkCmdSetEvent.adoc[] 5779-- 5780 5781[[synchronization-events-unsignaling-device]] 5782ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5783[open,refpage='vkCmdResetEvent2',desc='Reset an event object to non-signaled state',type='protos',alias='vkCmdResetEvent2KHR'] 5784-- 5785:refpage: vkCmdResetEvent2 5786 5787To unsignal the event from a device, call: 5788 5789ifdef::VK_VERSION_1_3[] 5790include::{generated}/api/protos/vkCmdResetEvent2.adoc[] 5791endif::VK_VERSION_1_3[] 5792 5793ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5794 5795ifdef::VK_KHR_synchronization2[] 5796include::{generated}/api/protos/vkCmdResetEvent2KHR.adoc[] 5797endif::VK_KHR_synchronization2[] 5798 5799 * pname:commandBuffer is the command buffer into which the command is 5800 recorded. 5801 * pname:event is the event that will be unsignaled. 5802 * pname:stageMask is a tlink:VkPipelineStageFlags2 mask of pipeline stages 5803 used to determine the first <<synchronization-dependencies-scopes, 5804 synchronization scope>>. 5805 5806When flink:vkCmdResetEvent2 is submitted to a queue, it defines an execution 5807dependency on commands that were submitted before it, and defines an event 5808unsignal operation which resets the event to the unsignaled state. 5809 5810The first <<synchronization-dependencies-scopes, synchronization scope>> 5811includes all commands that occur earlier in 5812<<synchronization-submission-order,submission order>>. 5813The synchronization scope is limited to operations by pname:stageMask or 5814stages that are <<synchronization-pipeline-stages-order,logically earlier>> 5815than pname:stageMask. 5816 5817The second <<synchronization-dependencies-scopes, synchronization scope>> 5818includes only the event unsignal operation. 5819 5820If pname:event is already in the unsignaled state when 5821flink:vkCmdResetEvent2 is executed on the device, then this command has no 5822effect, no event unsignal operation occurs, and no execution dependency is 5823generated. 5824 5825.Valid Usage 5826**** 5827:stageMaskName: stageMask 5828include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 5829 * [[VUID-vkCmdResetEvent2-synchronization2-03829]] 5830 The <<features-synchronization2, pname:synchronization2>> feature must: 5831 be enabled 5832 * [[VUID-vkCmdResetEvent2-stageMask-03830]] 5833 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_2_HOST_BIT 5834 * [[VUID-vkCmdResetEvent2-event-03831]] 5835 There must: be an execution dependency between fname:vkCmdResetEvent2 5836 and the execution of any flink:vkCmdWaitEvents that includes pname:event 5837 in its pname:pEvents parameter 5838 * [[VUID-vkCmdResetEvent2-event-03832]] 5839 There must: be an execution dependency between fname:vkCmdResetEvent2 5840 and the execution of any flink:vkCmdWaitEvents2 that includes 5841 pname:event in its pname:pEvents parameter 5842ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5843 * [[VUID-vkCmdResetEvent2-commandBuffer-03833]] 5844 pname:commandBuffer's current device mask must: include exactly one 5845 physical device 5846endif::VK_VERSION_1_1,VK_KHR_device_group[] 5847**** 5848 5849include::{generated}/validity/protos/vkCmdResetEvent2.adoc[] 5850-- 5851endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5852 5853[open,refpage='vkCmdResetEvent',desc='Reset an event object to non-signaled state',type='protos'] 5854-- 5855:refpage: vkCmdResetEvent 5856 5857To set the state of an event to unsignaled from a device, call: 5858 5859include::{generated}/api/protos/vkCmdResetEvent.adoc[] 5860 5861 * pname:commandBuffer is the command buffer into which the command is 5862 recorded. 5863 * pname:event is the event that will be unsignaled. 5864 * pname:stageMask is a bitmask of elink:VkPipelineStageFlagBits specifying 5865 the <<synchronization-pipeline-stages, source stage mask>> used to 5866 determine when the pname:event is unsignaled. 5867 5868ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5869fname:vkCmdResetEvent behaves identically to flink:vkCmdResetEvent2. 5870endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5871 5872ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5873When flink:vkCmdResetEvent is submitted to a queue, it defines an execution 5874dependency on commands that were submitted before it, and defines an event 5875unsignal operation which resets the event to the unsignaled state. 5876 5877The first <<synchronization-dependencies-scopes, synchronization scope>> 5878includes all commands that occur earlier in 5879<<synchronization-submission-order,submission order>>. 5880The synchronization scope is limited to operations on the pipeline stages 5881determined by the <<synchronization-pipeline-stages-masks, source stage 5882mask>> specified by pname:stageMask. 5883 5884The second <<synchronization-dependencies-scopes, synchronization scope>> 5885includes only the event unsignal operation. 5886 5887If pname:event is already in the unsignaled state when flink:vkCmdResetEvent 5888is executed on the device, then flink:vkCmdResetEvent has no effect, no 5889event unsignal operation occurs, and no execution dependency is generated. 5890endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5891 5892.Valid Usage 5893**** 5894:stageMaskName: stageMask 5895include::{chapters}/commonvalidity/stage_mask_common.adoc[] 5896 * [[VUID-vkCmdResetEvent-stageMask-06458]] 5897 Any pipeline stage included in pname:stageMask must: be supported by the 5898 capabilities of the queue family specified by the pname:queueFamilyIndex 5899 member of the slink:VkCommandPoolCreateInfo structure that was used to 5900 create the sname:VkCommandPool that pname:commandBuffer was allocated 5901 from, as specified in the <<synchronization-pipeline-stages-supported, 5902 table of supported pipeline stages>> 5903 * [[VUID-vkCmdResetEvent-stageMask-01153]] 5904 pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 5905 * [[VUID-vkCmdResetEvent-event-03834]] 5906 There must: be an execution dependency between fname:vkCmdResetEvent and 5907 the execution of any flink:vkCmdWaitEvents that includes pname:event in 5908 its pname:pEvents parameter 5909ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5910 * [[VUID-vkCmdResetEvent-event-03835]] 5911 There must: be an execution dependency between fname:vkCmdResetEvent and 5912 the execution of any flink:vkCmdWaitEvents2 that includes pname:event in 5913 its pname:pEvents parameter 5914endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 5915ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 5916 * [[VUID-vkCmdResetEvent-commandBuffer-01157]] 5917 pname:commandBuffer's current device mask must: include exactly one 5918 physical device 5919endif::VK_VERSION_1_1,VK_KHR_device_group[] 5920**** 5921 5922include::{generated}/validity/protos/vkCmdResetEvent.adoc[] 5923-- 5924 5925ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 5926[open,refpage='vkCmdWaitEvents2',desc='Wait for one or more events',type='protos',alias='vkCmdWaitEvents2KHR'] 5927-- 5928To wait for one or more events to enter the signaled state on a device, 5929call: 5930 5931[[synchronization-events-waiting-device]] 5932ifdef::VK_VERSION_1_3[] 5933include::{generated}/api/protos/vkCmdWaitEvents2.adoc[] 5934endif::VK_VERSION_1_3[] 5935 5936ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 5937 5938ifdef::VK_KHR_synchronization2[] 5939include::{generated}/api/protos/vkCmdWaitEvents2KHR.adoc[] 5940endif::VK_KHR_synchronization2[] 5941 5942 * pname:commandBuffer is the command buffer into which the command is 5943 recorded. 5944 * pname:eventCount is the length of the pname:pEvents array. 5945 * pname:pEvents is a pointer to an array of pname:eventCount events to 5946 wait on. 5947 * pname:pDependencyInfos is a pointer to an array of pname:eventCount 5948 slink:VkDependencyInfo structures, defining the second 5949 <<synchronization-dependencies-scopes, synchronization scope>>. 5950 5951When fname:vkCmdWaitEvents2 is submitted to a queue, it inserts memory 5952dependencies according to the elements of pname:pDependencyInfos and each 5953corresponding element of pname:pEvents. 5954fname:vkCmdWaitEvents2 must: not be used to wait on event signal operations 5955occurring on other queues, or signal operations executed by 5956flink:vkCmdSetEvent. 5957 5958The first <<synchronization-dependencies-scopes, synchronization scope>> and 5959<<synchronization-dependencies-access-scopes, access scope>> of each memory 5960dependency defined by any element [eq]#i# of pname:pDependencyInfos are 5961applied to operations that occurred earlier in 5962<<synchronization-submission-order,submission order>> than the last event 5963signal operation on element [eq]#i# of pname:pEvents. 5964 5965Signal operations for an event at index [eq]#i# are only included if: 5966 5967 * The event was signaled by a flink:vkCmdSetEvent2 command that occurred 5968 earlier in <<synchronization-submission-order,submission order>> with a 5969 pname:dependencyInfo parameter exactly equal to the element of 5970 pname:pDependencyInfos at index [eq]#i# ; or 5971 * The event was created without ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT, and 5972 the first <<synchronization-dependencies-scopes, synchronization scope>> 5973 defined by the element of pname:pDependencyInfos at index [eq]#i# only 5974 includes host operations (ename:VK_PIPELINE_STAGE_2_HOST_BIT). 5975 5976The second <<synchronization-dependencies-scopes, synchronization scope>> 5977and <<synchronization-dependencies-access-scopes, access scope>> of each 5978memory dependency defined by any element [eq]#i# of pname:pDependencyInfos 5979are applied to operations that occurred later in 5980<<synchronization-submission-order,submission order>> than 5981fname:vkCmdWaitEvents2. 5982 5983[NOTE] 5984.Note 5985==== 5986flink:vkCmdWaitEvents2 is used with flink:vkCmdSetEvent2 to define a memory 5987dependency between two sets of action commands, roughly in the same way as 5988pipeline barriers, but split into two commands such that work between the 5989two may: execute unhindered. 5990==== 5991 5992[NOTE] 5993.Note 5994==== 5995Applications should be careful to avoid race conditions when using events. 5996There is no direct ordering guarantee between fname:vkCmdSetEvent2 and 5997flink:vkCmdResetEvent2, flink:vkCmdResetEvent, or flink:vkCmdSetEvent. 5998Another execution dependency (e.g. a pipeline barrier or semaphore with 5999ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT) is needed to prevent such a race 6000condition. 6001==== 6002 6003.Valid Usage 6004**** 6005 * [[VUID-vkCmdWaitEvents2-synchronization2-03836]] 6006 The <<features-synchronization2, pname:synchronization2>> feature must: 6007 be enabled 6008 * [[VUID-vkCmdWaitEvents2-pEvents-03837]] 6009 Members of pname:pEvents must: not have been signaled by 6010 flink:vkCmdSetEvent 6011 * [[VUID-vkCmdWaitEvents2-pEvents-03838]] 6012 For any element [eq]#i# of pname:pEvents, if that event is signaled by 6013 flink:vkCmdSetEvent2, that command's pname:dependencyInfo parameter 6014 must: be exactly equal to the [eq]##i##th element of 6015 pname:pDependencyInfos 6016 * [[VUID-vkCmdWaitEvents2-pEvents-03839]] 6017 For any element [eq]#i# of pname:pEvents, if that event is signaled by 6018 flink:vkSetEvent, barriers in the [eq]##i##th element of 6019 pname:pDependencyInfos must: include only host operations in their first 6020 <<synchronization-dependencies-scopes, synchronization scope>> 6021 * [[VUID-vkCmdWaitEvents2-pEvents-03840]] 6022 For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th 6023 element of pname:pDependencyInfos include only host operations, the 6024 [eq]##i##th element of pname:pEvents must: be signaled before 6025 flink:vkCmdWaitEvents2 is executed 6026 * [[VUID-vkCmdWaitEvents2-pEvents-03841]] 6027 For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th 6028 element of pname:pDependencyInfos do not include host operations, the 6029 [eq]##i##th element of pname:pEvents must: be signaled by a 6030 corresponding flink:vkCmdSetEvent2 that occurred earlier in 6031 <<synchronization-submission-order,submission order>> 6032 * [[VUID-vkCmdWaitEvents2-srcStageMask-03842]] 6033 The pname:srcStageMask member of any element of the 6034 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6035 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: 6036 either include only pipeline stages valid for the queue family that was 6037 used to create the command pool that pname:commandBuffer was allocated 6038 from, or include only ename:VK_PIPELINE_STAGE_2_HOST_BIT 6039 * [[VUID-vkCmdWaitEvents2-dstStageMask-03843]] 6040 The pname:dstStageMask member of any element of the 6041 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6042 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: only 6043 include pipeline stages valid for the queue family that was used to 6044 create the command pool that pname:commandBuffer was allocated from 6045 * [[VUID-vkCmdWaitEvents2-dependencyFlags-03844]] 6046 If fname:vkCmdWaitEvents2 is being called inside a render pass instance, 6047 the pname:srcStageMask member of any element of the 6048 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6049 pname:pImageMemoryBarriers members of pname:pDependencyInfos must: not 6050 include ename:VK_PIPELINE_STAGE_2_HOST_BIT 6051 * [[VUID-vkCmdWaitEvents2-commandBuffer-03846]] 6052 pname:commandBuffer's current device mask must: include exactly one 6053 physical device 6054**** 6055 6056include::{generated}/validity/protos/vkCmdWaitEvents2.adoc[] 6057-- 6058endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6059 6060[open,refpage='vkCmdWaitEvents',desc='Wait for one or more events and insert a set of memory',type='protos'] 6061-- 6062:refpage: vkCmdWaitEvents 6063 6064To wait for one or more events to enter the signaled state on a device, 6065call: 6066 6067[[synchronization-events-waiting-device]] 6068include::{generated}/api/protos/vkCmdWaitEvents.adoc[] 6069 6070 * pname:commandBuffer is the command buffer into which the command is 6071 recorded. 6072 * pname:eventCount is the length of the pname:pEvents array. 6073 * pname:pEvents is a pointer to an array of event object handles to wait 6074 on. 6075 * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits 6076 specifying the <<synchronization-pipeline-stages, source stage mask>>. 6077 * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits 6078 specifying the <<synchronization-pipeline-stages, destination stage 6079 mask>>. 6080 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 6081 array. 6082 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier 6083 structures. 6084 * pname:bufferMemoryBarrierCount is the length of the 6085 pname:pBufferMemoryBarriers array. 6086 * pname:pBufferMemoryBarriers is a pointer to an array of 6087 slink:VkBufferMemoryBarrier structures. 6088 * pname:imageMemoryBarrierCount is the length of the 6089 pname:pImageMemoryBarriers array. 6090 * pname:pImageMemoryBarriers is a pointer to an array of 6091 slink:VkImageMemoryBarrier structures. 6092 6093ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6094fname:vkCmdWaitEvents is largely similar to flink:vkCmdWaitEvents2, but can: 6095only wait on signal operations defined by flink:vkCmdSetEvent. 6096As flink:vkCmdSetEvent does not define any access scopes, 6097fname:vkCmdWaitEvents defines the first access scope for each event signal 6098operation in addition to its own access scopes. 6099 6100[NOTE] 6101.Note 6102==== 6103Since flink:vkCmdSetEvent does not have any dependency information beyond a 6104stage mask, implementations do not have the same opportunity to perform 6105<<synchronization-dependencies-available-and-visible, availability and 6106visibility operations>> or <<synchronization-image-layout-transitions, image 6107layout transitions>> in advance as they do with flink:vkCmdSetEvent2 and 6108flink:vkCmdWaitEvents2. 6109==== 6110endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6111 6112When fname:vkCmdWaitEvents is submitted to a queue, it defines a memory 6113dependency between prior event signal operations on the same queue or the 6114host, and subsequent commands. 6115fname:vkCmdWaitEvents must: not be used to wait on event signal operations 6116occurring on other queues. 6117 6118The first synchronization scope only includes event signal operations that 6119operate on members of pname:pEvents, and the operations that happened-before 6120the event signal operations. 6121Event signal operations performed by flink:vkCmdSetEvent that occur earlier 6122in <<synchronization-submission-order,submission order>> are included in the 6123first synchronization scope, if the <<synchronization-pipeline-stages-order, 6124logically latest>> pipeline stage in their pname:stageMask parameter is 6125<<synchronization-pipeline-stages-order, logically earlier>> than or equal 6126to the <<synchronization-pipeline-stages-order, logically latest>> pipeline 6127stage in pname:srcStageMask. 6128Event signal operations performed by flink:vkSetEvent are only included in 6129the first synchronization scope if ename:VK_PIPELINE_STAGE_HOST_BIT is 6130included in pname:srcStageMask. 6131 6132The second <<synchronization-dependencies-scopes, synchronization scope>> 6133includes all commands that occur later in 6134<<synchronization-submission-order,submission order>>. 6135The second synchronization scope is limited to operations on the pipeline 6136stages determined by the <<synchronization-pipeline-stages-masks, 6137destination stage mask>> specified by pname:dstStageMask. 6138 6139The first <<synchronization-dependencies-access-scopes, access scope>> is 6140limited to accesses in the pipeline stages determined by the 6141<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6142pname:srcStageMask. 6143Within that, the first access scope only includes the first access scopes 6144defined by elements of the pname:pMemoryBarriers, 6145pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6146each define a set of <<synchronization-memory-barriers, memory barriers>>. 6147If no memory barriers are specified, then the first access scope includes no 6148accesses. 6149 6150The second <<synchronization-dependencies-access-scopes, access scope>> is 6151limited to accesses in the pipeline stages determined by the 6152<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6153by pname:dstStageMask. 6154Within that, the second access scope only includes the second access scopes 6155defined by elements of the pname:pMemoryBarriers, 6156pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6157each define a set of <<synchronization-memory-barriers, memory barriers>>. 6158If no memory barriers are specified, then the second access scope includes 6159no accesses. 6160 6161ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6162[NOTE] 6163.Note 6164==== 6165flink:vkCmdWaitEvents is used with flink:vkCmdSetEvent to define a memory 6166dependency between two sets of action commands, roughly in the same way as 6167pipeline barriers, but split into two commands such that work between the 6168two may: execute unhindered. 6169 6170Unlike flink:vkCmdPipelineBarrier, a <<synchronization-queue-transfers, 6171queue family ownership transfer>> cannot: be performed using 6172flink:vkCmdWaitEvents. 6173==== 6174 6175[NOTE] 6176.Note 6177==== 6178Applications should be careful to avoid race conditions when using events. 6179There is no direct ordering guarantee between flink:vkCmdWaitEvents and 6180ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[flink:vkCmdResetEvent2,] 6181flink:vkCmdResetEvent, or flink:vkCmdSetEvent. 6182Another execution dependency (e.g. a pipeline barrier or semaphore with 6183ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) is needed to prevent such a race 6184condition. 6185==== 6186endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6187 6188.Valid Usage 6189**** 6190:stageMaskName: srcStageMask 6191:accessMaskName: srcAccessMask 6192include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6193include::{chapters}/commonvalidity/access_mask_common.adoc[] 6194 6195:stageMaskName: dstStageMask 6196:accessMaskName: dstAccessMask 6197include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6198include::{chapters}/commonvalidity/access_mask_common.adoc[] 6199include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] 6200 * [[VUID-vkCmdWaitEvents-srcStageMask-06459]] 6201 Any pipeline stage included in pname:srcStageMask must: be supported by 6202 the capabilities of the queue family specified by the 6203 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6204 structure that was used to create the sname:VkCommandPool that 6205 pname:commandBuffer was allocated from, as specified in the 6206 <<synchronization-pipeline-stages-supported, table of supported pipeline 6207 stages>> 6208 * [[VUID-vkCmdWaitEvents-dstStageMask-06460]] 6209 Any pipeline stage included in pname:dstStageMask must: be supported by 6210 the capabilities of the queue family specified by the 6211 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6212 structure that was used to create the sname:VkCommandPool that 6213 pname:commandBuffer was allocated from, as specified in the 6214 <<synchronization-pipeline-stages-supported, table of supported pipeline 6215 stages>> 6216 * [[VUID-vkCmdWaitEvents-srcStageMask-01158]] 6217 pname:srcStageMask must: be the bitwise OR of the pname:stageMask 6218 parameter used in previous calls to fname:vkCmdSetEvent with any of the 6219 elements of pname:pEvents and ename:VK_PIPELINE_STAGE_HOST_BIT if any of 6220 the elements of pname:pEvents was set using fname:vkSetEvent 6221 * [[VUID-vkCmdWaitEvents-srcStageMask-07308]] 6222 If fname:vkCmdWaitEvents is being called inside a render pass instance, 6223 pname:srcStageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT 6224 * [[VUID-vkCmdWaitEvents-srcQueueFamilyIndex-02803]] 6225 The pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex members of 6226 any element of pname:pBufferMemoryBarriers or pname:pImageMemoryBarriers 6227 must: be equal 6228ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 6229 * [[VUID-vkCmdWaitEvents-commandBuffer-01167]] 6230 pname:commandBuffer's current device mask must: include exactly one 6231 physical device 6232endif::VK_VERSION_1_1,VK_KHR_device_group[] 6233ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6234 * [[VUID-vkCmdWaitEvents-pEvents-03847]] 6235 Elements of pname:pEvents must: not have been signaled by 6236 flink:vkCmdSetEvent2 6237endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6238**** 6239 6240include::{generated}/validity/protos/vkCmdWaitEvents.adoc[] 6241-- 6242 6243 6244[[synchronization-pipeline-barriers]] 6245== Pipeline Barriers 6246 6247ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6248[open,refpage='vkCmdPipelineBarrier2',desc='Insert a memory dependency',type='protos',alias='vkCmdPipelineBarrier2KHR'] 6249-- 6250:refpage: vkCmdPipelineBarrier2 6251 6252To record a pipeline barrier, call: 6253 6254ifdef::VK_VERSION_1_3[] 6255include::{generated}/api/protos/vkCmdPipelineBarrier2.adoc[] 6256endif::VK_VERSION_1_3[] 6257 6258ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] 6259 6260ifdef::VK_KHR_synchronization2[] 6261include::{generated}/api/protos/vkCmdPipelineBarrier2KHR.adoc[] 6262endif::VK_KHR_synchronization2[] 6263 6264 * pname:commandBuffer is the command buffer into which the command is 6265 recorded. 6266 * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure 6267 defining the scopes of this operation. 6268 6269When flink:vkCmdPipelineBarrier2 is submitted to a queue, it defines memory 6270dependencies between commands that were submitted to the same queue before 6271it, and those submitted to the same queue after it. 6272 6273The first <<synchronization-dependencies-scopes, synchronization scope>> and 6274<<synchronization-dependencies-access-scopes, access scope>> of each memory 6275dependency defined by pname:pDependencyInfo are applied to operations that 6276occurred earlier in <<synchronization-submission-order,submission order>>. 6277 6278The second <<synchronization-dependencies-scopes, synchronization scope>> 6279and <<synchronization-dependencies-access-scopes, access scope>> of each 6280memory dependency defined by pname:pDependencyInfo are applied to operations 6281that occurred later in <<synchronization-submission-order,submission 6282order>>. 6283 6284If fname:vkCmdPipelineBarrier2 is recorded within a render pass instance, 6285the synchronization scopes are limited to operations within the same subpass 6286ifdef::VK_EXT_shader_tile_image[] 6287, or must: follow the restrictions for 6288<<synchronization-pipeline-barriers-explicit-renderpass-tileimage, Tile 6289Image Access Synchronization>> if the render pass instance was started with 6290flink:vkCmdBeginRendering 6291endif::VK_EXT_shader_tile_image[] 6292. 6293 6294.Valid Usage 6295**** 6296include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] 6297 * [[VUID-vkCmdPipelineBarrier2-synchronization2-03848]] 6298 The <<features-synchronization2, pname:synchronization2>> feature must: 6299 be enabled 6300 * [[VUID-vkCmdPipelineBarrier2-srcStageMask-03849]] 6301 The pname:srcStageMask member of any element of the 6302 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6303 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 6304 include pipeline stages valid for the queue family that was used to 6305 create the command pool that pname:commandBuffer was allocated from 6306 * [[VUID-vkCmdPipelineBarrier2-dstStageMask-03850]] 6307 The pname:dstStageMask member of any element of the 6308 pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or 6309 pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only 6310 include pipeline stages valid for the queue family that was used to 6311 create the command pool that pname:commandBuffer was allocated from 6312**** 6313 6314include::{generated}/validity/protos/vkCmdPipelineBarrier2.adoc[] 6315-- 6316endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6317 6318[open,refpage='vkCmdPipelineBarrier',desc='Insert a memory dependency',type='protos'] 6319-- 6320:refpage: vkCmdPipelineBarrier 6321 6322To record a pipeline barrier, call: 6323 6324include::{generated}/api/protos/vkCmdPipelineBarrier.adoc[] 6325 6326 * pname:commandBuffer is the command buffer into which the command is 6327 recorded. 6328 * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits 6329 specifying the <<synchronization-pipeline-stages-masks,source stages>>. 6330 * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits 6331 specifying the <<synchronization-pipeline-stages-masks,destination 6332 stages>>. 6333 * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits 6334 specifying how execution and memory dependencies are formed. 6335 * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers 6336 array. 6337 * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier 6338 structures. 6339 * pname:bufferMemoryBarrierCount is the length of the 6340 pname:pBufferMemoryBarriers array. 6341 * pname:pBufferMemoryBarriers is a pointer to an array of 6342 slink:VkBufferMemoryBarrier structures. 6343 * pname:imageMemoryBarrierCount is the length of the 6344 pname:pImageMemoryBarriers array. 6345 * pname:pImageMemoryBarriers is a pointer to an array of 6346 slink:VkImageMemoryBarrier structures. 6347 6348ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6349fname:vkCmdPipelineBarrier operates almost identically to 6350flink:vkCmdPipelineBarrier2, except that the scopes and barriers are defined 6351as direct parameters rather than being defined by an slink:VkDependencyInfo. 6352endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6353 6354When flink:vkCmdPipelineBarrier is submitted to a queue, it defines a memory 6355dependency between commands that were submitted to the same queue before it, 6356and those submitted to the same queue after it. 6357 6358If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, 6359the first <<synchronization-dependencies-scopes, synchronization scope>> 6360includes all commands that occur earlier in 6361<<synchronization-submission-order,submission order>>. 6362If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, 6363the first synchronization scope includes only commands that occur earlier in 6364<<synchronization-submission-order,submission order>> within the same 6365subpass. 6366In either case, the first synchronization scope is limited to operations on 6367the pipeline stages determined by the 6368<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6369pname:srcStageMask. 6370 6371If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, 6372the second <<synchronization-dependencies-scopes, synchronization scope>> 6373includes all commands that occur later in 6374<<synchronization-submission-order,submission order>>. 6375If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, 6376the second synchronization scope includes only commands that occur later in 6377<<synchronization-submission-order,submission order>> within the same 6378subpass. 6379In either case, the second synchronization scope is limited to operations on 6380the pipeline stages determined by the 6381<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6382by pname:dstStageMask. 6383 6384The first <<synchronization-dependencies-access-scopes, access scope>> is 6385limited to accesses in the pipeline stages determined by the 6386<<synchronization-pipeline-stages-masks, source stage mask>> specified by 6387pname:srcStageMask. 6388Within that, the first access scope only includes the first access scopes 6389defined by elements of the pname:pMemoryBarriers, 6390pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6391each define a set of <<synchronization-memory-barriers, memory barriers>>. 6392If no memory barriers are specified, then the first access scope includes no 6393accesses. 6394 6395The second <<synchronization-dependencies-access-scopes, access scope>> is 6396limited to accesses in the pipeline stages determined by the 6397<<synchronization-pipeline-stages-masks, destination stage mask>> specified 6398by pname:dstStageMask. 6399Within that, the second access scope only includes the second access scopes 6400defined by elements of the pname:pMemoryBarriers, 6401pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which 6402each define a set of <<synchronization-memory-barriers, memory barriers>>. 6403If no memory barriers are specified, then the second access scope includes 6404no accesses. 6405 6406If pname:dependencyFlags includes ename:VK_DEPENDENCY_BY_REGION_BIT, then 6407any dependency between <<synchronization-framebuffer-regions, 6408framebuffer-space>> pipeline stages is 6409<<synchronization-framebuffer-regions, framebuffer-local>> - otherwise it is 6410<<synchronization-framebuffer-regions, framebuffer-global>>. 6411 6412.Valid Usage 6413**** 6414:stageMaskName: srcStageMask 6415:accessMaskName: srcAccessMask 6416include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6417include::{chapters}/commonvalidity/access_mask_common.adoc[] 6418 6419:stageMaskName: dstStageMask 6420:accessMaskName: dstAccessMask 6421include::{chapters}/commonvalidity/stage_mask_common.adoc[] 6422include::{chapters}/commonvalidity/access_mask_common.adoc[] 6423include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] 6424include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] 6425 * [[VUID-vkCmdPipelineBarrier-srcStageMask-06461]] 6426 Any pipeline stage included in pname:srcStageMask must: be supported by 6427 the capabilities of the queue family specified by the 6428 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6429 structure that was used to create the sname:VkCommandPool that 6430 pname:commandBuffer was allocated from, as specified in the 6431 <<synchronization-pipeline-stages-supported, table of supported pipeline 6432 stages>> 6433 * [[VUID-vkCmdPipelineBarrier-dstStageMask-06462]] 6434 Any pipeline stage included in pname:dstStageMask must: be supported by 6435 the capabilities of the queue family specified by the 6436 pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo 6437 structure that was used to create the sname:VkCommandPool that 6438 pname:commandBuffer was allocated from, as specified in the 6439 <<synchronization-pipeline-stages-supported, table of supported pipeline 6440 stages>> 6441**** 6442 6443include::{generated}/validity/protos/vkCmdPipelineBarrier.adoc[] 6444-- 6445 6446[open,refpage='VkDependencyFlagBits',desc='Bitmask specifying how execution and memory dependencies are formed',type='enums'] 6447-- 6448Bits which can: be set in fname:vkCmdPipelineBarrier::pname:dependencyFlags, 6449specifying how execution and memory dependencies are formed, are: 6450 6451include::{generated}/api/enums/VkDependencyFlagBits.adoc[] 6452 6453 * ename:VK_DEPENDENCY_BY_REGION_BIT specifies that dependencies will be 6454 <<synchronization-framebuffer-regions, framebuffer-local>>. 6455ifdef::VK_VERSION_1_1,VK_KHR_multiview[] 6456 * ename:VK_DEPENDENCY_VIEW_LOCAL_BIT specifies that dependencies will be 6457 <<synchronization-view-local-dependencies, view-local>>. 6458endif::VK_VERSION_1_1,VK_KHR_multiview[] 6459ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 6460 * ename:VK_DEPENDENCY_DEVICE_GROUP_BIT specifies that dependencies are 6461 <<synchronization-device-local-dependencies, non-device-local>>. 6462endif::VK_VERSION_1_1,VK_KHR_device_group[] 6463ifdef::VK_EXT_attachment_feedback_loop_layout[] 6464 * ename:VK_DEPENDENCY_FEEDBACK_LOOP_BIT_EXT specifies that the render pass 6465 will write to and read from the same image using the 6466 ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout. 6467endif::VK_EXT_attachment_feedback_loop_layout[] 6468-- 6469 6470[open,refpage='VkDependencyFlags',desc='Bitmask of VkDependencyFlagBits',type='flags'] 6471-- 6472include::{generated}/api/flags/VkDependencyFlags.adoc[] 6473 6474tname:VkDependencyFlags is a bitmask type for setting a mask of zero or more 6475elink:VkDependencyFlagBits. 6476-- 6477 6478 6479ifdef::VK_EXT_shader_tile_image[] 6480[[synchronization-pipeline-barriers-explicit-renderpass-tileimage]] 6481=== Explicit Render Pass Tile Image Access Synchronization 6482 6483A fragment shader can: declare code:NonCoherentColorAttachmentReadEXT, 6484code:NonCoherentDepthAttachmentReadEXT, or 6485code:NonCoherentStencilAttachmentReadEXT execution modes to enable 6486non-coherent tile image reads for color, depth, or stencil, respectively. 6487When non-coherent tile image reads are enabled, writes via color, depth and 6488stencil attachments are not automatically made visible to the corresponding 6489attachment reads via tile images. 6490For the writes to be made visible, an explicit memory dependency must: be 6491inserted between when the attachment is written to and when it is read from 6492by later fragments. 6493Such memory dependencies must: be inserted every time a fragment will read 6494values at a particular sample (x, y, layer, sample) coordinate, if those 6495values have been written since the most recent pipeline barrier; or since 6496the start of the render pass instance, if there have been no pipeline 6497barriers since the start of the render pass instance. 6498When such memory dependencies are used the values at all sample locations 6499inside the fragment area are made visible, regardless of coverage. 6500 6501To insert a memory dependency for explicit render pass tile image 6502synchronization, call flink:vkCmdPipelineBarrier2 inside a render pass 6503instance started with flink:vkCmdBeginRendering. 6504The following restrictions apply for such pipeline barriers: 6505 6506 * pname:dependencyFlags must: include ename:VK_DEPENDENCY_BY_REGION_BIT. 6507 * The pipeline barriers can: only include memory barriers. 6508 That is, buffer memory barriers and image memory barriers must: not be 6509 used. 6510 * The stages in slink:VkMemoryBarrier2::pname:srcStageMask and 6511 slink:VkMemoryBarrier2::pname:dstStageMask are restricted to framebuffer 6512 space stages. 6513 * The access types in slink:VkMemoryBarrier2::pname:srcAccessMask and 6514 slink:VkMemoryBarrier2::pname:dstAccessMask are restricted to the 6515 following types: ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, 6516 ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, 6517 ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT, and 6518 ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT. 6519endif::VK_EXT_shader_tile_image[] 6520 6521[[synchronization-memory-barriers]] 6522== Memory Barriers 6523 6524_Memory barriers_ are used to explicitly control access to buffer and image 6525subresource ranges. 6526Memory barriers are used to <<synchronization-queue-transfers, transfer 6527ownership between queue families>>, 6528<<synchronization-image-layout-transitions, change image layouts>>, and 6529define <<synchronization-dependencies-available-and-visible, availability 6530and visibility operations>>. 6531They explicitly define the <<synchronization-access-types, access types>> 6532and buffer and image subresource ranges that are included in the 6533<<synchronization-dependencies-access-scopes, access scopes>> of a memory 6534dependency that is created by a synchronization command that includes them. 6535 6536 6537[[synchronization-global-memory-barriers]] 6538=== Global Memory Barriers 6539 6540Global memory barriers apply to memory accesses involving all memory objects 6541that exist at the time of its execution. 6542 6543ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6544[open,refpage='VkMemoryBarrier2',desc='Structure specifying a global memory barrier',type='structs',alias='VkMemoryBarrier2KHR'] 6545-- 6546:refpage: VkMemoryBarrier2 6547 6548The sname:VkMemoryBarrier2 structure is defined as: 6549 6550include::{generated}/api/structs/VkMemoryBarrier2.adoc[] 6551 6552ifdef::VK_KHR_synchronization2[] 6553or the equivalent 6554 6555include::{generated}/api/structs/VkMemoryBarrier2KHR.adoc[] 6556endif::VK_KHR_synchronization2[] 6557 6558 * pname:sType is a elink:VkStructureType value identifying this structure. 6559 * pname:pNext is `NULL` or a pointer to a structure extending this 6560 structure. 6561 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6562 stages to be included in the <<synchronization-dependencies-scopes, 6563 first synchronization scope>>. 6564 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6565 included in the <<synchronization-dependencies-access-scopes, first 6566 access scope>>. 6567 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6568 stages to be included in the <<synchronization-dependencies-scopes, 6569 second synchronization scope>>. 6570 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6571 included in the <<synchronization-dependencies-access-scopes, second 6572 access scope>>. 6573 6574This structure defines a <<synchronization-dependencies-memory, memory 6575dependency>> affecting all device memory. 6576 6577The first <<synchronization-dependencies-scopes, synchronization scope>> and 6578<<synchronization-dependencies-access-scopes, access scope>> described by 6579this structure include only operations and memory accesses specified by 6580pname:srcStageMask and pname:srcAccessMask. 6581 6582The second <<synchronization-dependencies-scopes, synchronization scope>> 6583and <<synchronization-dependencies-access-scopes, access scope>> described 6584by this structure include only operations and memory accesses specified by 6585pname:dstStageMask and pname:dstAccessMask. 6586 6587.Valid Usage 6588**** 6589:stageMaskName: srcStageMask 6590:accessMaskName: srcAccessMask 6591include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6592include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6593 6594:stageMaskName: dstStageMask 6595:accessMaskName: dstAccessMask 6596include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6597include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6598**** 6599 6600include::{generated}/validity/structs/VkMemoryBarrier2.adoc[] 6601-- 6602endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6603 6604[open,refpage='VkMemoryBarrier',desc='Structure specifying a global memory barrier',type='structs'] 6605-- 6606The sname:VkMemoryBarrier structure is defined as: 6607 6608include::{generated}/api/structs/VkMemoryBarrier.adoc[] 6609 6610 * pname:sType is a elink:VkStructureType value identifying this structure. 6611 * pname:pNext is `NULL` or a pointer to a structure extending this 6612 structure. 6613 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6614 <<synchronization-access-masks, source access mask>>. 6615 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6616 <<synchronization-access-masks, destination access mask>>. 6617 6618The first <<synchronization-dependencies-access-scopes, access scope>> is 6619limited to access types in the <<synchronization-access-masks, source access 6620mask>> specified by pname:srcAccessMask. 6621 6622The second <<synchronization-dependencies-access-scopes, access scope>> is 6623limited to access types in the <<synchronization-access-masks, destination 6624access mask>> specified by pname:dstAccessMask. 6625 6626include::{generated}/validity/structs/VkMemoryBarrier.adoc[] 6627-- 6628 6629 6630[[synchronization-buffer-memory-barriers]] 6631=== Buffer Memory Barriers 6632 6633Buffer memory barriers only apply to memory accesses involving a specific 6634buffer range. 6635That is, a memory dependency formed from a buffer memory barrier is 6636<<synchronization-dependencies-access-scopes, scoped>> to access via the 6637specified buffer range. 6638Buffer memory barriers can: also be used to define a 6639<<synchronization-queue-transfers, queue family ownership transfer>> for the 6640specified buffer range. 6641 6642ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6643[open,refpage='VkBufferMemoryBarrier2',desc='Structure specifying a buffer memory barrier',type='structs',alias='VkBufferMemoryBarrier2KHR'] 6644-- 6645:refpage: VkBufferMemoryBarrier2 6646 6647The sname:VkBufferMemoryBarrier2 structure is defined as: 6648 6649include::{generated}/api/structs/VkBufferMemoryBarrier2.adoc[] 6650 6651ifdef::VK_KHR_synchronization2[] 6652or the equivalent 6653 6654include::{generated}/api/structs/VkBufferMemoryBarrier2KHR.adoc[] 6655endif::VK_KHR_synchronization2[] 6656 6657 * pname:sType is a elink:VkStructureType value identifying this structure. 6658 * pname:pNext is `NULL` or a pointer to a structure extending this 6659 structure. 6660 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6661 stages to be included in the <<synchronization-dependencies-scopes, 6662 first synchronization scope>>. 6663 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6664 included in the <<synchronization-dependencies-access-scopes, first 6665 access scope>>. 6666 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6667 stages to be included in the <<synchronization-dependencies-scopes, 6668 second synchronization scope>>. 6669 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6670 included in the <<synchronization-dependencies-access-scopes, second 6671 access scope>>. 6672 * pname:srcQueueFamilyIndex is the source queue family for a 6673 <<synchronization-queue-transfers, queue family ownership transfer>>. 6674 * pname:dstQueueFamilyIndex is the destination queue family for a 6675 <<synchronization-queue-transfers, queue family ownership transfer>>. 6676 * pname:buffer is a handle to the buffer whose backing memory is affected 6677 by the barrier. 6678 * pname:offset is an offset in bytes into the backing memory for 6679 pname:buffer; this is relative to the base offset as bound to the buffer 6680 (see flink:vkBindBufferMemory). 6681 * pname:size is a size in bytes of the affected area of backing memory for 6682 pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset 6683 to the end of the buffer. 6684 6685This structure defines a <<synchronization-dependencies-memory, memory 6686dependency>> limited to a range of a buffer, and can: define a 6687<<synchronization-queue-transfers, queue family transfer operation>> for 6688that range. 6689 6690The first <<synchronization-dependencies-scopes, synchronization scope>> and 6691<<synchronization-dependencies-access-scopes, access scope>> described by 6692this structure include only operations and memory accesses specified by 6693pname:srcStageMask and pname:srcAccessMask. 6694 6695The second <<synchronization-dependencies-scopes, synchronization scope>> 6696and <<synchronization-dependencies-access-scopes, access scope>> described 6697by this structure include only operations and memory accesses specified by 6698pname:dstStageMask and pname:dstAccessMask. 6699 6700Both <<synchronization-dependencies-access-scopes, access scopes>> are 6701limited to only memory accesses to pname:buffer in the range defined by 6702pname:offset and pname:size. 6703 6704If pname:buffer was created with ename:VK_SHARING_MODE_EXCLUSIVE, and 6705pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this 6706memory barrier defines a <<synchronization-queue-transfers, queue family 6707transfer operation>>. 6708When executed on a queue in the family identified by 6709pname:srcQueueFamilyIndex, this barrier defines a 6710<<synchronization-queue-transfers-release, queue family release operation>> 6711for the specified buffer range, and the second synchronization and access 6712scopes do not synchronize operations on that queue. 6713When executed on a queue in the family identified by 6714pname:dstQueueFamilyIndex, this barrier defines a 6715<<synchronization-queue-transfers-acquire, queue family acquire operation>> 6716for the specified buffer range, and the first synchronization and access 6717scopes do not synchronize operations on that queue. 6718 6719ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6720A <<synchronization-queue-transfers, queue family transfer operation>> is 6721also defined if the values are not equal, and either is one of the special 6722queue family values reserved for external memory ownership transfers, as 6723described in <<synchronization-queue-transfers>>. 6724A <<synchronization-queue-transfers-release, queue family release 6725operation>> is defined when pname:dstQueueFamilyIndex is one of those 6726values, and a <<synchronization-queue-transfers-acquire, queue family 6727acquire operation>> is defined when pname:srcQueueFamilyIndex is one of 6728those values. 6729endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6730 6731 6732.Valid Usage 6733**** 6734 6735:stageMaskName: srcStageMask 6736:accessMaskName: srcAccessMask 6737include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6738include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6739 6740:stageMaskName: dstStageMask 6741:accessMaskName: dstAccessMask 6742include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 6743include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 6744include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] 6745 * [[VUID-VkBufferMemoryBarrier2-srcStageMask-03851]] 6746 If either pname:srcStageMask or pname:dstStageMask includes 6747 ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and 6748 pname:dstQueueFamilyIndex must: be equal 6749**** 6750 6751include::{generated}/validity/structs/VkBufferMemoryBarrier2.adoc[] 6752-- 6753endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 6754 6755[open,refpage='VkBufferMemoryBarrier',desc='Structure specifying a buffer memory barrier',type='structs'] 6756-- 6757:refpage: VkBufferMemoryBarrier 6758 6759The sname:VkBufferMemoryBarrier structure is defined as: 6760 6761include::{generated}/api/structs/VkBufferMemoryBarrier.adoc[] 6762 6763 * pname:sType is a elink:VkStructureType value identifying this structure. 6764 * pname:pNext is `NULL` or a pointer to a structure extending this 6765 structure. 6766 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6767 <<synchronization-access-masks, source access mask>>. 6768 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 6769 <<synchronization-access-masks, destination access mask>>. 6770 * pname:srcQueueFamilyIndex is the source queue family for a 6771 <<synchronization-queue-transfers, queue family ownership transfer>>. 6772 * pname:dstQueueFamilyIndex is the destination queue family for a 6773 <<synchronization-queue-transfers, queue family ownership transfer>>. 6774 * pname:buffer is a handle to the buffer whose backing memory is affected 6775 by the barrier. 6776 * pname:offset is an offset in bytes into the backing memory for 6777 pname:buffer; this is relative to the base offset as bound to the buffer 6778 (see flink:vkBindBufferMemory). 6779 * pname:size is a size in bytes of the affected area of backing memory for 6780 pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset 6781 to the end of the buffer. 6782 6783The first <<synchronization-dependencies-access-scopes, access scope>> is 6784limited to access to memory through the specified buffer range, via access 6785types in the <<synchronization-access-masks, source access mask>> specified 6786by pname:srcAccessMask. 6787If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, a 6788<<synchronization-dependencies-available-and-visible, memory domain 6789operation>> is performed where available memory in the host domain is also 6790made available to the device domain. 6791 6792The second <<synchronization-dependencies-access-scopes, access scope>> is 6793limited to access to memory through the specified buffer range, via access 6794types in the <<synchronization-access-masks, destination access mask>> 6795specified by pname:dstAccessMask. 6796If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or 6797ename:VK_ACCESS_HOST_READ_BIT, a 6798<<synchronization-dependencies-available-and-visible, memory domain 6799operation>> is performed where available memory in the device domain is also 6800made available to the host domain. 6801 6802[NOTE] 6803.Note 6804==== 6805When ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT is used, available memory in 6806host domain is automatically made visible to host domain, and any host write 6807is automatically made available to host domain. 6808==== 6809 6810If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and 6811pname:srcQueueFamilyIndex is equal to the current queue family, then the 6812memory barrier defines a <<synchronization-queue-transfers-release, queue 6813family release operation>> for the specified buffer range, and the second 6814access scope includes no access, as if pname:dstAccessMask was `0`. 6815 6816If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and 6817pname:dstQueueFamilyIndex is equal to the current queue family, then the 6818memory barrier defines a <<synchronization-queue-transfers-acquire, queue 6819family acquire operation>> for the specified buffer range, and the first 6820access scope includes no access, as if pname:srcAccessMask was `0`. 6821 6822.Valid Usage 6823**** 6824include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] 6825ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6826 * [[VUID-VkBufferMemoryBarrier-None-09049]] 6827 If 6828ifdef::VK_KHR_synchronization2[] 6829 the <<features-synchronization2, pname:synchronization2>> feature is not 6830 enabled, and 6831endif::VK_KHR_synchronization2[] 6832 pname:buffer was created with a sharing mode of 6833 ename:VK_SHARING_MODE_CONCURRENT, at least one of 6834 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be 6835 ename:VK_QUEUE_FAMILY_IGNORED 6836endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6837 * [[VUID-VkBufferMemoryBarrier-None-09050]] 6838 If 6839ifdef::VK_KHR_synchronization2[] 6840 the <<features-synchronization2, pname:synchronization2>> feature is not 6841 enabled, and 6842endif::VK_KHR_synchronization2[] 6843 pname:buffer was created with a sharing mode of 6844 ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be 6845 ename:VK_QUEUE_FAMILY_IGNORED 6846ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6847 or ename:VK_QUEUE_FAMILY_EXTERNAL 6848endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6849 * [[VUID-VkBufferMemoryBarrier-None-09051]] 6850 If 6851ifdef::VK_KHR_synchronization2[] 6852 the <<features-synchronization2, pname:synchronization2>> feature is not 6853 enabled, and 6854endif::VK_KHR_synchronization2[] 6855 pname:buffer was created with a sharing mode of 6856 ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be 6857 ename:VK_QUEUE_FAMILY_IGNORED 6858ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6859 or ename:VK_QUEUE_FAMILY_EXTERNAL 6860endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6861**** 6862 6863include::{generated}/validity/structs/VkBufferMemoryBarrier.adoc[] 6864-- 6865 6866[open,refpage='VK_WHOLE_SIZE',desc='Sentinel value to use entire remaining array length',type='consts'] 6867-- 6868ename:VK_WHOLE_SIZE is a special value indicating that the entire remaining 6869length of a buffer following a given pname:offset should be used. 6870It can: be specified for slink:VkBufferMemoryBarrier::pname:size and other 6871structures. 6872 6873include::{generated}/api/enums/VK_WHOLE_SIZE.adoc[] 6874-- 6875 6876 6877[[synchronization-image-memory-barriers]] 6878=== Image Memory Barriers 6879 6880Image memory barriers only apply to memory accesses involving a specific 6881image subresource range. 6882That is, a memory dependency formed from an image memory barrier is 6883<<synchronization-dependencies-access-scopes, scoped>> to access via the 6884specified image subresource range. 6885Image memory barriers can: also be used to define 6886<<synchronization-image-layout-transitions, image layout transitions>> or a 6887<<synchronization-queue-transfers, queue family ownership transfer>> for the 6888specified image subresource range. 6889 6890ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 6891[open,refpage='VkImageMemoryBarrier2',desc='Structure specifying an image memory barrier',type='structs',alias='VkImageMemoryBarrier2KHR'] 6892-- 6893:refpage: VkImageMemoryBarrier2 6894 6895The sname:VkImageMemoryBarrier2 structure is defined as: 6896 6897include::{generated}/api/structs/VkImageMemoryBarrier2.adoc[] 6898 6899ifdef::VK_KHR_synchronization2[] 6900or the equivalent 6901 6902include::{generated}/api/structs/VkImageMemoryBarrier2KHR.adoc[] 6903endif::VK_KHR_synchronization2[] 6904 6905 * pname:sType is a elink:VkStructureType value identifying this structure. 6906 * pname:pNext is `NULL` or a pointer to a structure extending this 6907 structure. 6908 * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6909 stages to be included in the <<synchronization-dependencies-scopes, 6910 first synchronization scope>>. 6911 * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6912 included in the <<synchronization-dependencies-access-scopes, first 6913 access scope>>. 6914 * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline 6915 stages to be included in the <<synchronization-dependencies-scopes, 6916 second synchronization scope>>. 6917 * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be 6918 included in the <<synchronization-dependencies-access-scopes, second 6919 access scope>>. 6920 * pname:oldLayout is the old layout in an 6921 <<synchronization-image-layout-transitions, image layout transition>>. 6922 * pname:newLayout is the new layout in an 6923 <<synchronization-image-layout-transitions, image layout transition>>. 6924 * pname:srcQueueFamilyIndex is the source queue family for a 6925 <<synchronization-queue-transfers, queue family ownership transfer>>. 6926 * pname:dstQueueFamilyIndex is the destination queue family for a 6927 <<synchronization-queue-transfers, queue family ownership transfer>>. 6928 * pname:image is a handle to the image affected by this barrier. 6929 * pname:subresourceRange describes the <<resources-image-views, image 6930 subresource range>> within pname:image that is affected by this barrier. 6931 6932This structure defines a <<synchronization-dependencies-memory, memory 6933dependency>> limited to an image subresource range, and can: define a 6934<<synchronization-queue-transfers, queue family transfer operation>> and 6935<<synchronization-image-layout-transitions, image layout transition>> for 6936that subresource range. 6937 6938The first <<synchronization-dependencies-scopes, synchronization scope>> and 6939<<synchronization-dependencies-access-scopes, access scope>> described by 6940this structure include only operations and memory accesses specified by 6941pname:srcStageMask and pname:srcAccessMask. 6942 6943The second <<synchronization-dependencies-scopes, synchronization scope>> 6944and <<synchronization-dependencies-access-scopes, access scope>> described 6945by this structure include only operations and memory accesses specified by 6946pname:dstStageMask and pname:dstAccessMask. 6947 6948Both <<synchronization-dependencies-access-scopes, access scopes>> are 6949limited to only memory accesses to pname:image in the subresource range 6950defined by pname:subresourceRange. 6951 6952If pname:image was created with ename:VK_SHARING_MODE_EXCLUSIVE, and 6953pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this 6954memory barrier defines a <<synchronization-queue-transfers, queue family 6955transfer operation>>. 6956When executed on a queue in the family identified by 6957pname:srcQueueFamilyIndex, this barrier defines a 6958<<synchronization-queue-transfers-release, queue family release operation>> 6959for the specified image subresource range, and the second synchronization 6960and access scopes do not synchronize operations on that queue. 6961When executed on a queue in the family identified by 6962pname:dstQueueFamilyIndex, this barrier defines a 6963<<synchronization-queue-transfers-acquire, queue family acquire operation>> 6964for the specified image subresource range, and the first synchronization and 6965access scopes do not synchronize operations on that queue. 6966 6967ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 6968A <<synchronization-queue-transfers, queue family transfer operation>> is 6969also defined if the values are not equal, and either is one of the special 6970queue family values reserved for external memory ownership transfers, as 6971described in <<synchronization-queue-transfers>>. 6972A <<synchronization-queue-transfers-release, queue family release 6973operation>> is defined when pname:dstQueueFamilyIndex is one of those 6974values, and a <<synchronization-queue-transfers-acquire, queue family 6975acquire operation>> is defined when pname:srcQueueFamilyIndex is one of 6976those values. 6977endif::VK_VERSION_1_1,VK_KHR_external_memory[] 6978 6979If pname:oldLayout is not equal to pname:newLayout, then the memory barrier 6980defines an <<synchronization-image-layout-transitions, image layout 6981transition>> for the specified image subresource range. 6982If this memory barrier defines a <<synchronization-queue-transfers, queue 6983family transfer operation>>, the layout transition is only executed once 6984between the queues. 6985 6986[NOTE] 6987.Note 6988==== 6989When the old and new layout are equal, the layout values are ignored - data 6990is preserved no matter what values are specified, or what layout the image 6991is currently in. 6992==== 6993 6994ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 6995 6996If pname:image has a multi-planar format and the image is _disjoint_, then 6997including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of 6998pname:subresourceRange is equivalent to including 6999ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and 7000(for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. 7001 7002endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 7003 7004.Valid Usage 7005**** 7006 7007:stageMaskName: srcStageMask 7008:accessMaskName: srcAccessMask 7009include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 7010include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 7011 7012:stageMaskName: dstStageMask 7013:accessMaskName: dstAccessMask 7014include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] 7015include::{chapters}/commonvalidity/access_mask_2_common.adoc[] 7016include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] 7017include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7018 * [[VUID-VkImageMemoryBarrier2-srcStageMask-03854]] 7019 If either pname:srcStageMask or pname:dstStageMask includes 7020 ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and 7021 pname:dstQueueFamilyIndex must: be equal 7022 * [[VUID-VkImageMemoryBarrier2-srcStageMask-03855]] 7023 If pname:srcStageMask includes ename:VK_PIPELINE_STAGE_2_HOST_BIT, and 7024 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex define a 7025 <<synchronization-queue-transfers, queue family ownership transfer>> or 7026 pname:oldLayout and pname:newLayout define an 7027 <<synchronization-image-layout-transitions, image layout transition>>, 7028 pname:oldLayout must: be one of ename:VK_IMAGE_LAYOUT_PREINITIALIZED, 7029 ename:VK_IMAGE_LAYOUT_UNDEFINED, or ename:VK_IMAGE_LAYOUT_GENERAL 7030**** 7031 7032include::{generated}/validity/structs/VkImageMemoryBarrier2.adoc[] 7033-- 7034endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7035 7036[open,refpage='VkImageMemoryBarrier',desc='Structure specifying the parameters of an image memory barrier',type='structs'] 7037-- 7038:refpage: VkImageMemoryBarrier 7039 7040The sname:VkImageMemoryBarrier structure is defined as: 7041 7042include::{generated}/api/structs/VkImageMemoryBarrier.adoc[] 7043 7044 * pname:sType is a elink:VkStructureType value identifying this structure. 7045 * pname:pNext is `NULL` or a pointer to a structure extending this 7046 structure. 7047 * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 7048 <<synchronization-access-masks, source access mask>>. 7049 * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a 7050 <<synchronization-access-masks, destination access mask>>. 7051 * pname:oldLayout is the old layout in an 7052 <<synchronization-image-layout-transitions, image layout transition>>. 7053 * pname:newLayout is the new layout in an 7054 <<synchronization-image-layout-transitions, image layout transition>>. 7055 * pname:srcQueueFamilyIndex is the source queue family for a 7056 <<synchronization-queue-transfers, queue family ownership transfer>>. 7057 * pname:dstQueueFamilyIndex is the destination queue family for a 7058 <<synchronization-queue-transfers, queue family ownership transfer>>. 7059 * pname:image is a handle to the image affected by this barrier. 7060 * pname:subresourceRange describes the <<resources-image-views, image 7061 subresource range>> within pname:image that is affected by this barrier. 7062 7063The first <<synchronization-dependencies-access-scopes, access scope>> is 7064limited to access to memory through the specified image subresource range, 7065via access types in the <<synchronization-access-masks, source access mask>> 7066specified by pname:srcAccessMask. 7067If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, memory 7068writes performed by that access type are also made visible, as that access 7069type is not performed through a resource. 7070 7071The second <<synchronization-dependencies-access-scopes, access scope>> is 7072limited to access to memory through the specified image subresource range, 7073via access types in the <<synchronization-access-masks, destination access 7074mask>> specified by pname:dstAccessMask. 7075If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or 7076ename:VK_ACCESS_HOST_READ_BIT, available memory writes are also made visible 7077to accesses of those types, as those access types are not performed through 7078a resource. 7079 7080If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and 7081pname:srcQueueFamilyIndex is equal to the current queue family, then the 7082memory barrier defines a <<synchronization-queue-transfers-release, queue 7083family release operation>> for the specified image subresource range, and 7084the second access scope includes no access, as if pname:dstAccessMask was 7085`0`. 7086 7087If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and 7088pname:dstQueueFamilyIndex is equal to the current queue family, then the 7089memory barrier defines a <<synchronization-queue-transfers-acquire, queue 7090family acquire operation>> for the specified image subresource range, and 7091the first access scope includes no access, as if pname:srcAccessMask was 7092`0`. 7093 7094ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7095If the <<features-synchronization2, pname:synchronization2>> feature is not 7096enabled or pname:oldLayout is not equal to pname:newLayout, 7097endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7098pname:oldLayout and pname:newLayout define an 7099<<synchronization-image-layout-transitions, image layout transition>> for 7100the specified image subresource range. 7101 7102ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7103[NOTE] 7104.Note 7105==== 7106If the <<features-synchronization2, pname:synchronization2>> feature is 7107enabled, when the old and new layout are equal, the layout values are 7108ignored - data is preserved no matter what values are specified, or what 7109layout the image is currently in. 7110==== 7111endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7112 7113ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 7114 7115If pname:image has a multi-planar format and the image is _disjoint_, then 7116including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of 7117pname:subresourceRange is equivalent to including 7118ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and 7119(for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. 7120 7121endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 7122 7123.Valid Usage 7124**** 7125include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] 7126include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7127ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7128 * [[VUID-VkImageMemoryBarrier-None-09052]] 7129 If 7130ifdef::VK_KHR_synchronization2[] 7131 the <<features-synchronization2, pname:synchronization2>> feature is not 7132 enabled, and 7133endif::VK_KHR_synchronization2[] 7134 pname:image was created with a sharing mode of 7135 ename:VK_SHARING_MODE_CONCURRENT, at least one of 7136 pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be 7137 ename:VK_QUEUE_FAMILY_IGNORED 7138endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7139 * [[VUID-VkImageMemoryBarrier-None-09053]] 7140 If 7141ifdef::VK_KHR_synchronization2[] 7142 the <<features-synchronization2, pname:synchronization2>> feature is not 7143 enabled, and 7144endif::VK_KHR_synchronization2[] 7145 pname:image was created with a sharing mode of 7146 ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be 7147 ename:VK_QUEUE_FAMILY_IGNORED 7148ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7149 or ename:VK_QUEUE_FAMILY_EXTERNAL 7150endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7151 * [[VUID-VkImageMemoryBarrier-None-09054]] 7152 If 7153ifdef::VK_KHR_synchronization2[] 7154 the <<features-synchronization2, pname:synchronization2>> feature is not 7155 enabled, and 7156endif::VK_KHR_synchronization2[] 7157 pname:image was created with a sharing mode of 7158 ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be 7159 ename:VK_QUEUE_FAMILY_IGNORED 7160ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7161 or ename:VK_QUEUE_FAMILY_EXTERNAL 7162endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7163**** 7164 7165include::{generated}/validity/structs/VkImageMemoryBarrier.adoc[] 7166-- 7167 7168ifdef::VK_EXT_host_image_copy[] 7169To facilitate usage of images whose memory is initialized on the host, 7170Vulkan allows image layout transitions to be performed by the host as well, 7171albeit supporting limited layouts. 7172 7173[open,refpage='vkTransitionImageLayoutEXT',desc='Perform an image layout transition on the host',type='protos'] 7174-- 7175To perform an image layout transition on the host, call: 7176 7177include::{generated}/api/protos/vkTransitionImageLayoutEXT.adoc[] 7178 7179 * pname:device is the device which owns pname:pTransitions[i].pname:image. 7180 * pname:transitionCount is the number of image layout transitions to 7181 perform. 7182 * pname:pTransitions is a pointer to an array of 7183 slink:VkHostImageLayoutTransitionInfoEXT structures specifying the image 7184 and <<resources-image-views, subresource ranges>> within them to 7185 transition. 7186 7187include::{generated}/validity/protos/vkTransitionImageLayoutEXT.adoc[] 7188-- 7189 7190[open,refpage='VkHostImageLayoutTransitionInfoEXT',desc='Structure specifying the parameters of a host-side image layout transition',type='structs'] 7191-- 7192:refpage: VkHostImageLayoutTransitionInfoEXT 7193 7194The sname:VkHostImageLayoutTransitionInfoEXT structure is defined as: 7195 7196include::{generated}/api/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] 7197 7198 * pname:sType is a elink:VkStructureType value identifying this structure. 7199 * pname:pNext is `NULL` or a pointer to a structure extending this 7200 structure. 7201 * pname:image is a handle to the image affected by this layout transition. 7202 * pname:oldLayout is the old layout in an 7203 <<synchronization-image-layout-transitions, image layout transition>>. 7204 * pname:newLayout is the new layout in an 7205 <<synchronization-image-layout-transitions, image layout transition>>. 7206 * pname:subresourceRange describes the <<resources-image-views, image 7207 subresource range>> within pname:image that is affected by this layout 7208 transition. 7209 7210fname:vkTransitionImageLayoutEXT does not check whether the device memory 7211associated with an image is currently in use before performing the layout 7212transition. 7213The application must: guarantee that any previously submitted command that 7214reads from or writes to this subresource has completed before the host 7215performs the layout transition. 7216 7217[NOTE] 7218.Note 7219==== 7220Image layout transitions performed on the host do not require queue family 7221ownership transfers as the physical layout of the image will not vary 7222between queue families for the layouts supported by this function. 7223==== 7224 7225.Valid Usage 7226**** 7227 * [[VUID-VkHostImageLayoutTransitionInfoEXT-image-09055]] 7228 pname:image must: have been created with 7229 ename:VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT 7230include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] 7231 * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09229]] 7232 pname:oldLayout must: be either ename:VK_IMAGE_LAYOUT_UNDEFINED or the 7233 current layout of the image subresources as specified in 7234 pname:subresourceRange 7235 * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09230]] 7236 If pname:oldLayout is not ename:VK_IMAGE_LAYOUT_UNDEFINED or 7237 ename:VK_IMAGE_LAYOUT_PREINITIALIZED, it must: be one of the layouts in 7238 slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopySrcLayouts 7239 * [[VUID-VkHostImageLayoutTransitionInfoEXT-newLayout-09057]] 7240 pname:newLayout must: be one of the layouts in 7241 slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopyDstLayouts 7242**** 7243 7244include::{generated}/validity/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] 7245-- 7246endif::VK_EXT_host_image_copy[] 7247 7248[[synchronization-queue-transfers]] 7249=== Queue Family Ownership Transfer 7250 7251Resources created with a elink:VkSharingMode of 7252ename:VK_SHARING_MODE_EXCLUSIVE must: have their ownership explicitly 7253transferred from one queue family to another in order to access their 7254content in a well-defined manner on a queue in a different queue family. 7255 7256[open,refpage='VK_QUEUE_FAMILY_IGNORED',desc='Ignored queue family index sentinel',type='consts'] 7257-- 7258The special queue family index ename:VK_QUEUE_FAMILY_IGNORED indicates that 7259a queue family parameter or member is ignored. 7260 7261include::{generated}/api/enums/VK_QUEUE_FAMILY_IGNORED.adoc[] 7262-- 7263 7264ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 7265Resources shared with external APIs or instances using external memory must: 7266also explicitly manage ownership transfers between local and external queues 7267(or equivalent constructs in external APIs) regardless of the 7268elink:VkSharingMode specified when creating them. 7269 7270[open,refpage='VK_QUEUE_FAMILY_EXTERNAL',desc='External queue family index sentinel',type='consts',alias='VK_QUEUE_FAMILY_EXTERNAL_KHR'] 7271-- 7272The special queue family index ename:VK_QUEUE_FAMILY_EXTERNAL represents any 7273queue external to the resource's current Vulkan instance, as long as the 7274queue uses the same underlying 7275ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] 7276physical device, and the same driver version as the resource's 7277slink:VkDevice, as indicated by 7278slink:VkPhysicalDeviceIDProperties::pname:deviceUUID and 7279slink:VkPhysicalDeviceIDProperties::pname:driverUUID. 7280 7281include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL.adoc[] 7282 7283ifdef::VK_KHR_external_memory[] 7284or the equivalent 7285 7286include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL_KHR.adoc[] 7287endif::VK_KHR_external_memory[] 7288-- 7289 7290ifdef::VK_EXT_queue_family_foreign[] 7291[open,refpage='VK_QUEUE_FAMILY_FOREIGN_EXT',desc='Foreign queue family index sentinel',type='consts'] 7292-- 7293The special queue family index ename:VK_QUEUE_FAMILY_FOREIGN_EXT represents 7294any queue external to the resource's current Vulkan instance, regardless of 7295the queue's underlying physical device or driver version. 7296This includes, for example, queues for fixed-function image processing 7297devices, media codec devices, and display devices, as well as all queues 7298that use the same underlying 7299ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] 7300physical device, and the same driver version as the resource's 7301slink:VkDevice. 7302 7303include::{generated}/api/enums/VK_QUEUE_FAMILY_FOREIGN_EXT.adoc[] 7304-- 7305endif::VK_EXT_queue_family_foreign[] 7306endif::VK_VERSION_1_1,VK_KHR_external_memory[] 7307 7308If memory dependencies are correctly expressed between uses of such a 7309resource between two queues in different families, but no ownership transfer 7310is defined, the contents of that resource are undefined: for any read 7311accesses performed by the second queue family. 7312 7313[NOTE] 7314.Note 7315==== 7316If an application does not need the contents of a resource to remain valid 7317when transferring from one queue family to another, then the ownership 7318transfer should: be skipped. 7319==== 7320 7321ifdef::VK_EXT_queue_family_foreign[] 7322[NOTE] 7323.Note 7324==== 7325Applications should expect transfers to/from 7326ename:VK_QUEUE_FAMILY_FOREIGN_EXT to be more expensive than transfers 7327to/from ename:VK_QUEUE_FAMILY_EXTERNAL_KHR. 7328==== 7329endif::VK_EXT_queue_family_foreign[] 7330 7331A queue family ownership transfer consists of two distinct parts: 7332 7333 . Release exclusive ownership from the source queue family 7334 . Acquire exclusive ownership for the destination queue family 7335 7336An application must: ensure that these operations occur in the correct order 7337by defining an execution dependency between them, e.g. using a semaphore. 7338 7339[[synchronization-queue-transfers-release]] A _release operation_ is used to 7340release exclusive ownership of a range of a buffer or image subresource 7341range. 7342A release operation is defined by executing a 7343<<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a 7344buffer range) or an <<synchronization-image-memory-barriers, image memory 7345barrier>> (for an image subresource range) using a pipeline barrier command, 7346on a queue from the source queue family. 7347The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the 7348source queue family index, and the pname:dstQueueFamilyIndex parameter to 7349the destination queue family index. 7350pname:dstAccessMask is ignored for such a barrier, such that no visibility 7351operation is executed - the value of this mask does not affect the validity 7352of the barrier. 7353The release operation happens-after the availability operation, and 7354happens-before operations specified in the second synchronization scope of 7355the calling command. 7356 7357[[synchronization-queue-transfers-acquire]] An _acquire operation_ is used 7358to acquire exclusive ownership of a range of a buffer or image subresource 7359range. 7360An acquire operation is defined by executing a 7361<<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a 7362buffer range) or an <<synchronization-image-memory-barriers, image memory 7363barrier>> (for an image subresource range) using a pipeline barrier command, 7364on a queue from the destination queue family. 7365The buffer range or image subresource range specified in an acquire 7366operation must: match exactly that of a previous release operation. 7367The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the 7368source queue family index, and the pname:dstQueueFamilyIndex parameter to 7369the destination queue family index. 7370pname:srcAccessMask is ignored for such a barrier, such that no availability 7371operation is executed - the value of this mask does not affect the validity 7372of the barrier. 7373The acquire operation happens-after operations in the first synchronization 7374scope of the calling command, and happens-before the visibility operation. 7375 7376[NOTE] 7377.Note 7378==== 7379Whilst it is not invalid to provide destination or source access masks for 7380memory barriers used for release or acquire operations, respectively, they 7381have no practical effect. 7382Access after a release operation has undefined: results, and so visibility 7383for those accesses has no practical effect. 7384Similarly, write access before an acquire operation will produce undefined: 7385results for future access, so availability of those writes has no practical 7386use. 7387In an earlier version of the specification, these were required to match on 7388both sides - but this was subsequently relaxed. 7389These masks should: be set to 0. 7390==== 7391 7392If the transfer is via an image memory barrier, and an 7393<<synchronization-image-layout-transitions, image layout transition>> is 7394desired, then the values of pname:oldLayout and pname:newLayout in the 7395_release operation_'s memory barrier must: be equal to values of 7396pname:oldLayout and pname:newLayout in the _acquire operation_'s memory 7397barrier. 7398Although the image layout transition is submitted twice, it will only be 7399executed once. 7400A layout transition specified in this way happens-after the _release 7401operation_ and happens-before the _acquire operation_. 7402 7403If the values of pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex are 7404equal, no ownership transfer is performed, and the barrier operates as if 7405they were both set to ename:VK_QUEUE_FAMILY_IGNORED. 7406 7407Queue family ownership transfers may: perform read and write accesses on all 7408memory bound to the image subresource or buffer range, so applications must: 7409ensure that all memory writes have been made 7410<<synchronization-dependencies-available-and-visible, available>> before a 7411queue family ownership transfer is executed. 7412Available memory is automatically made visible to queue family release and 7413acquire operations, and writes performed by those operations are 7414automatically made available. 7415 7416Once a queue family has acquired ownership of a buffer range or image 7417subresource range of a ename:VK_SHARING_MODE_EXCLUSIVE resource, its 7418contents are undefined: to other queue families unless ownership is 7419transferred. 7420The contents of any portion of another resource which aliases memory that is 7421bound to the transferred buffer or image subresource range are undefined: 7422after a release or acquire operation. 7423 7424[NOTE] 7425.Note 7426==== 7427Because <<synchronization-events, events>> cannot: be used directly for 7428inter-queue synchronization, and because flink:vkCmdSetEvent does not have 7429the queue family index or memory barrier parameters needed by a _release 7430operation_, the release and acquire operations of a queue family ownership 7431transfer can: only be performed using flink:vkCmdPipelineBarrier. 7432==== 7433 7434ifdef::VK_EXT_external_memory_acquire_unmodified[] 7435[open,refpage='VkExternalMemoryAcquireUnmodifiedEXT',desc='Structure specifying that external memory has remained unmodified since releasing ownership',type='structs'] 7436-- 7437An _acquire operation_ may: have a performance penalty when acquiring 7438ownership of a subresource range from one of the special queue families 7439reserved for external memory ownership transfers described above. 7440The application can: reduce the performance penalty in some cases by adding 7441a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the pname:pNext 7442chain of the _acquire operation_'s memory barrier structure. 7443 7444The sname:VkExternalMemoryAcquireUnmodifiedEXT structure is defined as: 7445 7446include::{generated}/api/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] 7447 7448 * pname:sType is a elink:VkStructureType value identifying this structure. 7449 * pname:pNext is `NULL` or a pointer to a structure extending this 7450 structure. 7451 * pname:acquireUnmodifiedMemory specifies, if ename:VK_TRUE, that no range 7452 of slink:VkDeviceMemory bound to the resource of the memory barrier's 7453 subresource range was modified at any time since the resource's most 7454 recent release of ownership to the queue family specified by the memory 7455 barrier's pname:srcQueueFamilyIndex. 7456 If ename:VK_FALSE, it specifies nothing. 7457 7458If the application releases ownership of the subresource range to one of the 7459special queue families reserved for external memory ownership transfers with 7460a memory barrier structure, and later re-acquires ownership from the same 7461queue family with a memory barrier structure, and if no range of 7462slink:VkDeviceMemory bound to the resource was modified at any time between 7463the _release operation_ and the _acquire operation_, then the application 7464should: add a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the 7465pname:pNext chain of the _acquire operation_'s memory barrier structure 7466because this may: reduce the performance penalty. 7467 7468This struct is ignored if pname:acquireUnmodifiedMemory is ename:VK_FALSE. 7469In particular, ename:VK_FALSE does _not_ specify that memory was modified. 7470 7471This struct is ignored if the memory barrier's pname:srcQueueFamilyIndex is 7472not a special queue family reserved for external memory ownership transfers. 7473 7474[NOTE] 7475.Note 7476==== 7477The method by which the application determines whether memory was modified 7478between the _release operation_ and _acquire operation_ is outside the scope 7479of Vulkan. 7480 7481For any Vulkan operation that accesses a resource, the application must: not 7482assume the implementation accesses the resource's memory as read-only, even 7483for _apparently_ read-only operations such as transfer commands and shader 7484reads. 7485 7486The validity of 7487slink:VkExternalMemoryAcquireUnmodifiedEXT::pname:acquireUnmodifiedMemory is 7488independent of memory ranges outside the ranges of slink:VkDeviceMemory 7489bound to the resource. 7490In particular, it is independent of any implementation-private memory 7491associated with the resource. 7492==== 7493 7494.Valid Usage 7495**** 7496 * [[VUID-VkExternalMemoryAcquireUnmodifiedEXT-acquireUnmodifiedMemory-08922]] 7497 If pname:acquireUnmodifiedMemory is ename:VK_TRUE, and the memory 7498 barrier's pname:srcQueueFamilyIndex is a special queue family reserved 7499 for external memory ownership transfers (as described in 7500 <<synchronization-queue-transfers>>), then each range of 7501 slink:VkDeviceMemory bound to the resource must: have remained 7502 unmodified during all time since the resource's most recent release of 7503 ownership to the queue family. 7504**** 7505 7506include::{generated}/validity/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] 7507-- 7508endif::VK_EXT_external_memory_acquire_unmodified[] 7509 7510[[synchronization-wait-idle]] 7511== Wait Idle Operations 7512 7513[open,refpage='vkQueueWaitIdle',desc='Wait for a queue to become idle',type='protos'] 7514-- 7515:refpage: vkQueueWaitIdle 7516 7517To wait on the host for the completion of outstanding queue operations for a 7518given queue, call: 7519 7520include::{generated}/api/protos/vkQueueWaitIdle.adoc[] 7521 7522 * pname:queue is the queue on which to wait. 7523 7524fname:vkQueueWaitIdle is equivalent to having submitted a valid fence to 7525every previously executed <<devsandqueues-submission,queue submission 7526command>> that accepts a fence, then waiting for all of those fences to 7527signal using flink:vkWaitForFences with an infinite timeout and 7528pname:waitAll set to ename:VK_TRUE. 7529 7530include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7531 7532include::{generated}/validity/protos/vkQueueWaitIdle.adoc[] 7533-- 7534 7535[open,refpage='vkDeviceWaitIdle',desc='Wait for a device to become idle',type='protos'] 7536-- 7537:refpage: vkDeviceWaitIdle 7538 7539To wait on the host for the completion of outstanding queue operations for 7540all queues on a given logical device, call: 7541 7542include::{generated}/api/protos/vkDeviceWaitIdle.adoc[] 7543 7544 * pname:device is the logical device to idle. 7545 7546fname:vkDeviceWaitIdle is equivalent to calling fname:vkQueueWaitIdle for 7547all queues owned by pname:device. 7548 7549include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7550 7551include::{generated}/validity/protos/vkDeviceWaitIdle.adoc[] 7552-- 7553 7554 7555[[synchronization-submission-host-writes]] 7556== Host Write Ordering Guarantees 7557 7558When batches of command buffers are submitted to a queue via a 7559<<devsandqueues-submission, queue submission command>>, it defines a memory 7560dependency with prior host operations, and execution of command buffers 7561submitted to the queue. 7562 7563The first <<synchronization-dependencies-scopes, synchronization scope>> 7564includes execution of flink:vkQueueSubmit on the host and anything that 7565happened-before it, as defined by the host memory model. 7566 7567[NOTE] 7568.Note 7569==== 7570Some systems allow writes that do not directly integrate with the host 7571memory model; these have to be synchronized by the application manually. 7572One example of this is non-temporal store instructions on x86; to ensure 7573these happen-before submission, applications should call `_mm_sfence()`. 7574==== 7575 7576The second <<synchronization-dependencies-scopes, synchronization scope>> 7577includes all commands submitted in the same <<devsandqueues-submission, 7578queue submission>>, and all commands that occur later in 7579<<synchronization-submission-order,submission order>>. 7580 7581The first <<synchronization-dependencies-access-scopes, access scope>> 7582includes all host writes to mappable device memory that are available to the 7583host memory domain. 7584 7585The second <<synchronization-dependencies-access-scopes, access scope>> 7586includes all memory access performed by the device. 7587 7588ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 7589[[synchronization-device-group]] 7590== Synchronization and Multiple Physical Devices 7591 7592If a logical device includes more than one physical device, then fences, 7593semaphores, and events all still have a single instance of the signaled 7594state. 7595 7596A fence becomes signaled when all physical devices complete the necessary 7597queue operations. 7598 7599Semaphore wait and signal operations all include a device index that is the 7600sole physical device that performs the operation. 7601These indices are provided in the slink:VkDeviceGroupSubmitInfo 7602ifndef::VKSC_VERSION_1_0[and slink:VkDeviceGroupBindSparseInfo] 7603structures. 7604Semaphores are not exclusively owned by any physical device. 7605For example, a semaphore can be signaled by one physical device and then 7606waited on by a different physical device. 7607 7608An event can: only be waited on by the same physical device that signaled it 7609(or the host). 7610endif::VK_VERSION_1_1,VK_KHR_device_group[] 7611 7612 7613ifdef::VK_EXT_calibrated_timestamps[] 7614[[calibrated-timestamps]] 7615== Calibrated Timestamps 7616 7617[open,refpage='vkGetCalibratedTimestampsEXT',desc='Query calibrated timestamps',type='protos'] 7618-- 7619:refpage: vkGetCalibratedTimestampsEXT 7620 7621In order to be able to correlate the time a particular operation took place 7622at on timelines of different time domains (e.g. a device operation vs. a 7623host operation), Vulkan allows querying calibrated timestamps from multiple 7624time domains. 7625 7626To query calibrated timestamps from a set of time domains, call: 7627 7628include::{generated}/api/protos/vkGetCalibratedTimestampsEXT.adoc[] 7629 7630 * pname:device is the logical device used to perform the query. 7631 * pname:timestampCount is the number of timestamps to query. 7632 * pname:pTimestampInfos is a pointer to an array of pname:timestampCount 7633 slink:VkCalibratedTimestampInfoEXT structures, describing the time 7634 domains the calibrated timestamps should be captured from. 7635 * pname:pTimestamps is a pointer to an array of pname:timestampCount 7636 64-bit unsigned integer values in which the requested calibrated 7637 timestamp values are returned. 7638 * pname:pMaxDeviation is a pointer to a 64-bit unsigned integer value in 7639 which the strictly positive maximum deviation, in nanoseconds, of the 7640 calibrated timestamp values is returned. 7641 7642[NOTE] 7643.Note 7644==== 7645The maximum deviation may: vary between calls to 7646fname:vkGetCalibratedTimestampsEXT even for the same set of time domains due 7647to implementation and platform specific reasons. 7648It is the application's responsibility to assess whether the returned 7649maximum deviation makes the timestamp values suitable for any particular 7650purpose and can: choose to re-issue the timestamp calibration call pursuing 7651a lower deviation value. 7652==== 7653 7654Calibrated timestamp values can: be extrapolated to estimate future 7655coinciding timestamp values, however, depending on the nature of the time 7656domains and other properties of the platform extrapolating values over a 7657sufficiently long period of time may: no longer be accurate enough to fit 7658any particular purpose, so applications are expected to re-calibrate the 7659timestamps on a regular basis. 7660 7661.Valid Usage 7662**** 7663 * [[VUID-vkGetCalibratedTimestampsEXT-timeDomain-09246]] 7664 The pname:timeDomain value of each slink:VkCalibratedTimestampInfoEXT in 7665 pname:pTimestampInfos must: be unique 7666**** 7667 7668include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 7669 7670include::{generated}/validity/protos/vkGetCalibratedTimestampsEXT.adoc[] 7671-- 7672 7673[open,refpage='VkCalibratedTimestampInfoEXT',desc='Structure specifying the input parameters of a calibrated timestamp query',type='structs'] 7674-- 7675The sname:VkCalibratedTimestampInfoEXT structure is defined as: 7676 7677include::{generated}/api/structs/VkCalibratedTimestampInfoEXT.adoc[] 7678 7679 * pname:sType is a elink:VkStructureType value identifying this structure. 7680 * pname:pNext is `NULL` or a pointer to a structure extending this 7681 structure. 7682 * pname:timeDomain is a elink:VkTimeDomainEXT value specifying the time 7683 domain from which the calibrated timestamp value should be returned. 7684 7685.Valid Usage 7686**** 7687 * [[VUID-VkCalibratedTimestampInfoEXT-timeDomain-02354]] 7688 pname:timeDomain must: be one of the elink:VkTimeDomainEXT values 7689 returned by flink:vkGetPhysicalDeviceCalibrateableTimeDomainsEXT 7690**** 7691include::{generated}/validity/structs/VkCalibratedTimestampInfoEXT.adoc[] 7692-- 7693 7694[open,refpage='VkTimeDomainEXT',desc='Supported time domains',type='enums'] 7695-- 7696The set of supported time domains consists of: 7697 7698include::{generated}/api/enums/VkTimeDomainEXT.adoc[] 7699 7700 * ename:VK_TIME_DOMAIN_DEVICE_EXT specifies the device time domain. 7701 Timestamp values in this time domain use the same units and are 7702 comparable with device timestamp values captured using 7703 flink:vkCmdWriteTimestamp 7704ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7705 or flink:vkCmdWriteTimestamp2 7706endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7707 and are defined to be incrementing according to the 7708 <<limits-timestampPeriod, pname:timestampPeriod>> of the device. 7709 7710 * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT specifies the CLOCK_MONOTONIC 7711 time domain available on POSIX platforms. 7712 Timestamp values in this time domain are in units of nanoseconds and are 7713 comparable with platform timestamp values captured using the POSIX 7714 clock_gettime API as computed by this example: 7715 7716[NOTE] 7717.Note 7718==== 7719An implementation supporting `apiext:VK_EXT_calibrated_timestamps` will use 7720the same time domain for all its slink:VkQueue so that timestamp values 7721reported for ename:VK_TIME_DOMAIN_DEVICE_EXT can be matched to any timestamp 7722captured through flink:vkCmdWriteTimestamp 7723ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] 7724or flink:vkCmdWriteTimestamp2 7725endif::VK_VERSION_1_3,VK_KHR_synchronization2[] 7726. 7727==== 7728 7729[source,c] 7730---- 7731struct timespec tv; 7732clock_gettime(CLOCK_MONOTONIC, &tv); 7733return tv.tv_nsec + tv.tv_sec*1000000000ull; 7734---- 7735 7736 * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT specifies the 7737 CLOCK_MONOTONIC_RAW time domain available on POSIX platforms. 7738 Timestamp values in this time domain are in units of nanoseconds and are 7739 comparable with platform timestamp values captured using the POSIX 7740 clock_gettime API as computed by this example: 7741 7742[source,c] 7743---- 7744struct timespec tv; 7745clock_gettime(CLOCK_MONOTONIC_RAW, &tv); 7746return tv.tv_nsec + tv.tv_sec*1000000000ull; 7747---- 7748 7749 * ename:VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT specifies the 7750 performance counter (QPC) time domain available on Windows. 7751 Timestamp values in this time domain are in the same units as those 7752 provided by the Windows QueryPerformanceCounter API and are comparable 7753 with platform timestamp values captured using that API as computed by 7754 this example: 7755 7756[source,c] 7757---- 7758LARGE_INTEGER counter; 7759QueryPerformanceCounter(&counter); 7760return counter.QuadPart; 7761---- 7762-- 7763endif::VK_EXT_calibrated_timestamps[] 7764