| // Copyright 2015-2023 The Khronos Group Inc. |
| // |
| // SPDX-License-Identifier: CC-BY-4.0 |
| |
| [[synchronization]] |
| = Synchronization and Cache Control |
| |
| Synchronization of access to resources is primarily the responsibility of |
| the application in Vulkan. |
| The order of execution of commands with respect to the host and other |
| commands on the device has few implicit guarantees, and needs to be |
| explicitly specified. |
| Memory caches and other optimizations are also explicitly managed, requiring |
| that the flow of data through the system is largely under application |
| control. |
| |
| Whilst some implicit guarantees exist between commands, five explicit |
| synchronization mechanisms are exposed by Vulkan: |
| |
| <<synchronization-fences,Fences>>:: |
| Fences can: be used to communicate to the host that execution of some |
| task on the device has completed, controlling resource access between |
| host and device. |
| |
| <<synchronization-semaphores,Semaphores>>:: |
| Semaphores can: be used to control resource access across multiple |
| queues. |
| |
| <<synchronization-events,Events>>:: |
| Events provide a fine-grained synchronization primitive which can: be |
| signaled either within a command buffer or by the host, and can: be |
| waited upon within a command buffer or queried on the host. |
| Events can: be used to control resource access within a single queue. |
| |
| <<synchronization-pipeline-barriers,Pipeline Barriers>>:: |
| Pipeline barriers also provide synchronization control within a command |
| buffer, but at a single point, rather than with separate signal and wait |
| operations. |
| Pipeline barriers can: be used to control resource access within a |
| single queue. |
| |
| <<renderpass,Render Passes>>:: |
| Render passes provide a useful synchronization framework for most |
| rendering tasks, built upon the concepts in this chapter. |
| Many cases that would otherwise need an application to use other |
| synchronization primitives can: be expressed more efficiently as part of |
| a render pass. |
| Render pass objects can: be used to control resource access within a |
| single queue. |
| |
| |
| [[synchronization-dependencies]] |
| == Execution and Memory Dependencies |
| |
| An _operation_ is an arbitrary amount of work to be executed on the host, a |
| device, or an external entity such as a presentation engine. |
| Synchronization commands introduce explicit _execution dependencies_, and |
| _memory dependencies_ between two sets of operations defined by the |
| command's two _synchronization scopes_. |
| |
| [[synchronization-dependencies-scopes]] |
| The synchronization scopes define which other operations a synchronization |
| command is able to create execution dependencies with. |
| Any type of operation that is not in a synchronization command's |
| synchronization scopes will not be included in the resulting dependency. |
| For example, for many synchronization commands, the synchronization scopes |
| can: be limited to just operations executing in specific |
| <<synchronization-pipeline-stages,pipeline stages>>, which allows other |
| pipeline stages to be excluded from a dependency. |
| Other scoping options are possible, depending on the particular command. |
| |
| [[synchronization-dependencies-execution]] |
| An _execution dependency_ is a guarantee that for two sets of operations, |
| the first set must: _happen-before_ the second set. |
| If an operation happens-before another operation, then the first operation |
| must: complete before the second operation is initiated. |
| More precisely: |
| |
| * Let *Ops~1~* and *Ops~2~* be separate sets of operations. |
| * Let *Sync* be a synchronization command. |
| * Let *Scope~1st~* and *Scope~2nd~* be the synchronization scopes of |
| *Sync*. |
| * Let *ScopedOps~1~* be the intersection of sets *Ops~1~* and |
| *Scope~1st~*. |
| * Let *ScopedOps~2~* be the intersection of sets *Ops~2~* and |
| *Scope~2nd~*. |
| * Submitting *Ops~1~*, *Sync* and *Ops~2~* for execution, in that order, |
| will result in execution dependency *ExeDep* between *ScopedOps~1~* and |
| *ScopedOps~2~*. |
| * Execution dependency *ExeDep* guarantees that *ScopedOps~1~* |
| happen-before *ScopedOps~2~*. |
| |
| [[synchronization-dependencies-chains]] |
| An _execution dependency chain_ is a sequence of execution dependencies that |
| form a happens-before relation between the first dependency's *ScopedOps~1~* |
| and the final dependency's *ScopedOps~2~*. |
| For each consecutive pair of execution dependencies, a chain exists if the |
| intersection of *Scope~2nd~* in the first dependency and *Scope~1st~* in the |
| second dependency is not an empty set. |
| The formation of a single execution dependency from an execution dependency |
| chain can be described by substituting the following in the description of |
| execution dependencies: |
| |
| * Let *Sync* be a set of synchronization commands that generate an |
| execution dependency chain. |
| * Let *Scope~1st~* be the first synchronization scope of the first command |
| in *Sync*. |
| * Let *Scope~2nd~* be the second synchronization scope of the last command |
| in *Sync*. |
| |
| Execution dependencies alone are not sufficient to guarantee that values |
| resulting from writes in one set of operations can: be read from another set |
| of operations. |
| |
| [[synchronization-dependencies-available-and-visible]] |
| Three additional types of operations are used to control memory access. |
| _Availability operations_ cause the values generated by specified memory |
| write accesses to become _available_ to a memory domain for future access. |
| Any available value remains available until a subsequent write to the same |
| memory location occurs (whether it is made available or not) or the memory |
| is freed. |
| _Memory domain operations_ cause writes that are available to a source |
| memory domain to become available to a destination memory domain (an example |
| of this is making writes available to the host domain available to the |
| device domain). |
| _Visibility operations_ cause values available to a memory domain to become |
| _visible_ to specified memory accesses. |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_vulkan_memory_model[] |
| Availability, visibility, memory domains, and memory domain operations are |
| formally defined in the <<memory-model-availability-visibility,Availability |
| and Visibility>> section of the <<memory-model,Memory Model>> chapter. |
| Which API operations perform each of these operations is defined in |
| <<memory-model-vulkan-availability-visibility,Availability, Visibility, and |
| Domain Operations>>. |
| endif::VK_VERSION_1_2,VK_KHR_vulkan_memory_model[] |
| |
| [[synchronization-dependencies-memory]] |
| A _memory dependency_ is an execution dependency which includes availability |
| and visibility operations such that: |
| |
| * The first set of operations happens-before the availability operation. |
| * The availability operation happens-before the visibility operation. |
| * The visibility operation happens-before the second set of operations. |
| |
| Once written values are made visible to a particular type of memory access, |
| they can: be read or written by that type of memory access. |
| Most synchronization commands in Vulkan define a memory dependency. |
| |
| [[synchronization-dependencies-access-scopes]] |
| The specific memory accesses that are made available and visible are defined |
| by the _access scopes_ of a memory dependency. |
| Any type of access that is in a memory dependency's first access scope and |
| occurs in *ScopedOps~1~* is made available. |
| Any type of access that is in a memory dependency's second access scope and |
| occurs in *ScopedOps~2~* has any available writes made visible to it. |
| Any type of operation that is not in a synchronization command's access |
| scopes will not be included in the resulting dependency. |
| |
| A memory dependency enforces availability and visibility of memory accesses |
| and execution order between two sets of operations. |
| Adding to the description of <<synchronization-dependencies-chains, |
| execution dependency chains>>: |
| |
| * Let *MemOps~1~* be the set of memory accesses performed by |
| *ScopedOps~1~*. |
| * Let *MemOps~2~* be the set of memory accesses performed by |
| *ScopedOps~2~*. |
| * Let *AccessScope~1st~* be the first access scope of the first command in |
| the *Sync* chain. |
| * Let *AccessScope~2nd~* be the second access scope of the last command in |
| the *Sync* chain. |
| * Let *ScopedMemOps~1~* be the intersection of sets *MemOps~1~* and |
| *AccessScope~1st~*. |
| * Let *ScopedMemOps~2~* be the intersection of sets *MemOps~2~* and |
| *AccessScope~2nd~*. |
| * Submitting *Ops~1~*, *Sync*, and *Ops~2~* for execution, in that order, |
| will result in a memory dependency *MemDep* between *ScopedOps~1~* and |
| *ScopedOps~2~*. |
| * Memory dependency *MemDep* guarantees that: |
| ** Memory writes in *ScopedMemOps~1~* are made available. |
| ** Available memory writes, including those from *ScopedMemOps~1~*, are |
| made visible to *ScopedMemOps~2~*. |
| |
| [NOTE] |
| .Note |
| ==== |
| Execution and memory dependencies are used to solve data hazards, i.e. to |
| ensure that read and write operations occur in a well-defined order. |
| Write-after-read hazards can be solved with just an execution dependency, |
| but read-after-write and write-after-write hazards need appropriate memory |
| dependencies to be included between them. |
| If an application does not include dependencies to solve these hazards, the |
| results and execution orders of memory accesses are undefined:. |
| ==== |
| |
| |
| [[synchronization-image-layout-transitions]] |
| === Image Layout Transitions |
| |
| Image subresources can: be transitioned from one <<resources-image-layouts, |
| layout>> to another as part of a <<synchronization-dependencies-memory, |
| memory dependency>> (e.g. by using an |
| <<synchronization-image-memory-barriers,image memory barrier>>). |
| When a layout transition is specified in a memory dependency, it |
| happens-after the availability operations in the memory dependency, and |
| happens-before the visibility operations. |
| Image layout transitions may: perform read and write accesses on all memory |
| bound to the image subresource range, so applications must: ensure that all |
| memory writes have been made |
| <<synchronization-dependencies-available-and-visible, available>> before a |
| layout transition is executed. |
| Available memory is automatically made visible to a layout transition, and |
| writes performed by a layout transition are automatically made available. |
| |
| Layout transitions always apply to a particular image subresource range, and |
| specify both an old layout and new layout. |
| The old layout must: either be ename:VK_IMAGE_LAYOUT_UNDEFINED, or match the |
| current layout of the image subresource range. |
| If the old layout matches the current layout of the image subresource range, |
| the transition preserves the contents of that range. |
| If the old layout is ename:VK_IMAGE_LAYOUT_UNDEFINED, the contents of that |
| range may: be discarded. |
| |
| [NOTE] |
| .Note |
| ==== |
| Image layout transitions with ename:VK_IMAGE_LAYOUT_UNDEFINED allow the |
| implementation to discard the image subresource range, which can provide |
| performance or power benefits. |
| Tile-based architectures may be able to avoid flushing tile data to memory, |
| and immediate style renderers may be able to achieve fast metadata clears to |
| reinitialize frame buffer compression state, or similar. |
| |
| If the contents of an attachment are not needed after a render pass |
| completes, then applications should: use |
| ename:VK_ATTACHMENT_STORE_OP_DONT_CARE. |
| ==== |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| As image layout transitions may: perform read and write accesses on the |
| memory bound to the image, if the image subresource affected by the layout |
| transition is bound to peer memory for any device in the current device mask |
| then the memory heap the bound memory comes from must: support the |
| ename:VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT and |
| ename:VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT capabilities as returned by |
| flink:vkGetDeviceGroupPeerMemoryFeatures. |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| |
| [NOTE] |
| .Note |
| ==== |
| Applications must: ensure that layout transitions happen-after all |
| operations accessing the image with the old layout, and happen-before any |
| operations that will access the image with the new layout. |
| Layout transitions are potentially read/write operations, so not defining |
| appropriate memory dependencies to guarantee this will result in a data |
| race. |
| ==== |
| |
| Image layout transitions interact with <<resources-memory-aliasing,memory |
| aliasing>>. |
| |
| |
| [[synchronization-image-barrier-layout-transition-order]] |
| Layout transitions that are performed via image memory barriers execute in |
| their entirety in <<synchronization-submission-order, submission order>>, |
| relative to other image layout transitions submitted to the same queue, |
| including those performed by <<renderpass, render passes>>. |
| In effect there is an implicit execution dependency from each such layout |
| transition to all layout transitions previously submitted to the same queue. |
| |
| ifdef::VK_EXT_sample_locations[] |
| |
| The image layout of each image subresource of a depth/stencil image created |
| with ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT is |
| dependent on the last sample locations used to render to the image |
| subresource as a depth/stencil attachment, thus when the pname:image member |
| of an <<synchronization-image-memory-barriers, image memory barrier>> is an |
| image created with this flag the application can: chain a |
| slink:VkSampleLocationsInfoEXT structure to the pname:pNext chain of |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| slink:VkImageMemoryBarrier2 or |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| slink:VkImageMemoryBarrier to specify the sample locations to use during any |
| image layout transition. |
| |
| If the sname:VkSampleLocationsInfoEXT structure does not match the sample |
| location state last used to render to the image subresource range specified |
| by pname:subresourceRange, or if no sname:VkSampleLocationsInfoEXT structure |
| is present, then the contents of the given image subresource range becomes |
| undefined: as if pname:oldLayout would equal |
| ename:VK_IMAGE_LAYOUT_UNDEFINED. |
| |
| endif::VK_EXT_sample_locations[] |
| |
| |
| [[synchronization-pipeline-stages]] |
| === Pipeline Stages |
| |
| The work performed by an <<fundamentals-queueoperation-command-types, action |
| command>> consists of multiple operations, which are performed as a sequence |
| of logically independent steps known as _pipeline stages_. |
| The exact pipeline stages executed depend on the particular command that is |
| used, and current command buffer state when the command was recorded. |
| |
| [NOTE] |
| .Note |
| ==== |
| Operations performed by synchronization commands (e.g. |
| <<synchronization-dependencies-available-and-visible, availability and |
| visibility operations>>) are not executed by a defined pipeline stage. |
| However other commands can still synchronize with them by using the |
| <<synchronization-dependencies-scopes, synchronization scopes>> to create a |
| <<synchronization-dependencies-chains, dependency chain>>. |
| ==== |
| |
| Execution of operations across pipeline stages must: adhere to |
| <<synchronization-implicit, implicit ordering guarantees>>, particularly |
| including <<synchronization-pipeline-stages-order, pipeline stage order>>. |
| Otherwise, execution across pipeline stages may: overlap or execute out of |
| order with regards to other stages, unless otherwise enforced by an |
| execution dependency. |
| |
| Several of the synchronization commands include pipeline stage parameters, |
| restricting the <<synchronization-dependencies-scopes, synchronization |
| scopes>> for that command to just those stages. |
| This allows fine grained control over the exact execution dependencies and |
| accesses performed by action commands. |
| Implementations should: use these pipeline stages to avoid unnecessary |
| stalls or cache flushing. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='VkPipelineStageFlagBits2',desc='Pipeline stage flags for VkPipelineStageFlags2',type='enums',alias='VkPipelineStageFlagBits2KHR'] |
| -- |
| Bits which can: be set in a tlink:VkPipelineStageFlags2 mask, specifying |
| stages of execution, are: |
| |
| ifdef::editing-notes[] |
| [NOTE] |
| .editing-note |
| ==== |
| The many places pipeline stage flags are used are not currently listed here. |
| ==== |
| endif::editing-notes[] |
| |
| include::{generated}/api/enums/VkPipelineStageFlagBits2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkPipelineStageFlagBits2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * ename:VK_PIPELINE_STAGE_2_NONE specifies no stages of execution. |
| * ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT specifies the stage of the |
| pipeline where indirect command parameters are consumed. |
| ifdef::VK_NV_device_generated_commands[] |
| This stage also includes reading commands written by |
| flink:vkCmdPreprocessGeneratedCommandsNV. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| * ename:VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_EXT specifies the task shader |
| stage. |
| * ename:VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_EXT specifies the mesh shader |
| stage. |
| endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| * ename:VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT specifies the stage of the |
| pipeline where index buffers are consumed. |
| * ename:VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT specifies the stage |
| of the pipeline where vertex buffers are consumed. |
| * ename:VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT is equivalent to the logical |
| OR of: |
| include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT.adoc[] |
| * ename:VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT specifies the vertex shader |
| stage. |
| * ename:VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT specifies the |
| tessellation control shader stage. |
| * ename:VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT specifies |
| the tessellation evaluation shader stage. |
| * ename:VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT specifies the geometry |
| shader stage. |
| * ename:VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT is equivalent to |
| specifying all supported |
| <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader |
| stages>>: |
| include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT.adoc[] |
| * ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT specifies the fragment |
| shader stage. |
| * ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT specifies the stage |
| of the pipeline where early fragment tests (depth and stencil tests |
| before fragment shading) are performed. |
| This stage also includes <<renderpass-load-operations, render pass load |
| operations>> for framebuffer attachments with a depth/stencil format. |
| * ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT specifies the stage of |
| the pipeline where late fragment tests (depth and stencil tests after |
| fragment shading) are performed. |
| This stage also includes <<renderpass-store-operations, render pass |
| store operations>> for framebuffer attachments with a depth/stencil |
| format. |
| * ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT specifies the |
| stage of the pipeline where final color values are output from the |
| pipeline. |
| This stage includes <<framebuffer-blending, blending>>, |
| <<framebuffer-logicop, logic operations>>, render pass |
| <<renderpass-load-operations, load>> and <<renderpass-store-operations, |
| store>> operations for color attachments, |
| <<renderpass-resolve-operations, render pass multisample resolve |
| operations>>, and flink:vkCmdClearAttachments. |
| * ename:VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT specifies the compute |
| shader stage. |
| * ename:VK_PIPELINE_STAGE_2_HOST_BIT specifies a pseudo-stage indicating |
| execution on the host of reads/writes of device memory. |
| This stage is not invoked by any commands recorded in a command buffer. |
| * ename:VK_PIPELINE_STAGE_2_COPY_BIT specifies the execution of all |
| <<copies,copy commands>>, including flink:vkCmdCopyQueryPoolResults. |
| * ename:VK_PIPELINE_STAGE_2_BLIT_BIT specifies the execution of |
| flink:vkCmdBlitImage. |
| * ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT specifies the execution of |
| flink:vkCmdResolveImage. |
| * ename:VK_PIPELINE_STAGE_2_CLEAR_BIT specifies the execution of |
| <<clears,clear commands>>, with the exception of |
| flink:vkCmdClearAttachments. |
| * ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT is equivalent to specifying |
| all of: |
| include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT.adoc[] |
| ifdef::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[] |
| * ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR specifies the |
| execution of the ray tracing shader stages. |
| endif::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[] |
| ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| * ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR specifies |
| the execution of <<acceleration-structure, acceleration structure |
| commands>> or <<acceleration-structure-copying, acceleration structure |
| copy commands>>. |
| ifdef::VK_KHR_ray_tracing_maintenance1[] |
| * ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR specifies |
| the execution of <<acceleration-structure-copying, acceleration |
| structure copy commands>>. |
| endif::VK_KHR_ray_tracing_maintenance1[] |
| endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| * ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT specifies the execution of |
| all graphics pipeline stages, and is equivalent to the logical OR of: |
| include::{generated}/sync/flagDefinitions/VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT.adoc[] |
| * ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT specifies all operations |
| performed by all commands supported on the queue it is used with. |
| ifdef::VK_EXT_conditional_rendering[] |
| * ename:VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT specifies the |
| stage of the pipeline where the predicate of conditional rendering is |
| consumed. |
| endif::VK_EXT_conditional_rendering[] |
| ifdef::VK_EXT_transform_feedback[] |
| * ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT specifies the stage |
| of the pipeline where vertex attribute output values are written to the |
| transform feedback buffers. |
| endif::VK_EXT_transform_feedback[] |
| ifdef::VK_NV_device_generated_commands[] |
| * ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV specifies the stage |
| of the pipeline where device-side generation of commands via |
| flink:vkCmdPreprocessGeneratedCommandsNV is handled. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| * ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR |
| specifies the stage of the pipeline where the |
| ifdef::VK_KHR_fragment_shading_rate[] |
| <<primsrast-fragment-shading-rate-attachment, fragment shading rate |
| attachment>> |
| endif::VK_KHR_fragment_shading_rate[] |
| ifdef::VK_KHR_fragment_shading_rate+VK_NV_shading_rate_image[or] |
| ifdef::VK_NV_shading_rate_image[] |
| <<primsrast-shading-rate-image, shading rate image>> |
| endif::VK_NV_shading_rate_image[] |
| is read to determine the fragment shading rate for portions of a |
| rasterized primitive. |
| endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| ifdef::VK_EXT_fragment_density_map[] |
| * ename:VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT specifies the |
| stage of the pipeline where the fragment density map is read to |
| <<fragmentdensitymapops,generate the fragment areas>>. |
| endif::VK_EXT_fragment_density_map[] |
| ifdef::VK_HUAWEI_invocation_mask[] |
| * ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI specifies the stage |
| of the pipeline where the invocation mask image is read by the |
| implementation to optimize the ray dispatch. |
| endif::VK_HUAWEI_invocation_mask[] |
| ifdef::VK_KHR_video_decode_queue[] |
| * ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR specifies the execution |
| of <<video-decode-operations, video decode operations>>. |
| endif::VK_KHR_video_decode_queue[] |
| ifdef::VK_KHR_video_encode_queue[] |
| * ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR specifies the execution |
| of <<video-encode-operations, video encode operations>>. |
| endif::VK_KHR_video_encode_queue[] |
| ifdef::VK_NV_optical_flow[] |
| * ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV specifies the stage of the |
| pipeline where <<opticalflow-operations, optical flow operation>> are |
| performed. |
| endif::VK_NV_optical_flow[] |
| ifdef::VK_HUAWEI_subpass_shading[] |
| * ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI specifies the |
| subpass shading shader stage. |
| endif::VK_HUAWEI_subpass_shading[] |
| ifdef::VK_EXT_opacity_micromap[] |
| * ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT specifies the execution |
| of <<micromap, micromap commands>>. |
| endif::VK_EXT_opacity_micromap[] |
| ifdef::VK_HUAWEI_cluster_culling_shader[] |
| * ename:VK_PIPELINE_STAGE_2_CLUSTER_CULLING_SHADER_BIT_HUAWEI specifies |
| the cluster culling shader stage. |
| endif::VK_HUAWEI_cluster_culling_shader[] |
| * ename:VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT is equivalent to |
| ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT with tlink:VkAccessFlags2 set |
| to `0` when specified in the second synchronization scope, but |
| equivalent to ename:VK_PIPELINE_STAGE_2_NONE in the first scope. |
| * ename:VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT is equivalent to |
| ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT with tlink:VkAccessFlags2 set |
| to `0` when specified in the first synchronization scope, but equivalent |
| to ename:VK_PIPELINE_STAGE_2_NONE in the second scope. |
| |
| [NOTE] |
| .Note |
| ==== |
| The etext:TOP and etext:BOTTOM pipeline stages are deprecated, and |
| applications should prefer ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT and |
| ename:VK_PIPELINE_STAGE_2_NONE. |
| ==== |
| |
| [NOTE] |
| .Note |
| ==== |
| The tname:VkPipelineStageFlags2 bitmask goes beyond the 31 individual bit |
| flags allowable within a C99 enum, which is how |
| elink:VkPipelineStageFlagBits is defined. |
| The first 31 values are common to both, and are interchangeable. |
| ==== |
| -- |
| |
| [open,refpage='VkPipelineStageFlags2',desc='64-bit mask of pipeline stage flags',type='flags',alias='VkPipelineStageFlags2KHR'] |
| -- |
| tname:VkPipelineStageFlags2 is a bitmask type for setting a mask of zero or |
| more elink:VkPipelineStageFlagBits2 flags: |
| |
| include::{generated}/api/flags/VkPipelineStageFlags2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/flags/VkPipelineStageFlags2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='VkPipelineStageFlagBits',desc='Bitmask specifying pipeline stages',type='enums'] |
| -- |
| Bits which can: be set in a tlink:VkPipelineStageFlags mask, specifying |
| stages of execution, are: |
| |
| include::{generated}/api/enums/VkPipelineStageFlagBits.adoc[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| These values all have the same meaning as the equivalently named values for |
| tlink:VkPipelineStageFlags2. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_PIPELINE_STAGE_NONE specifies no stages of execution. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT specifies the stage of the |
| pipeline where stext:VkDrawIndirect* / stext:VkDispatchIndirect* / |
| stext:VkTraceRaysIndirect* data structures are consumed. |
| ifdef::VK_NV_device_generated_commands[] |
| This stage also includes reading commands written by |
| flink:vkCmdExecuteGeneratedCommandsNV. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| * ename:VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT specifies the task shader |
| stage. |
| * ename:VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT specifies the mesh shader |
| stage. |
| endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| * ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT specifies the stage of the |
| pipeline where vertex and index buffers are consumed. |
| * ename:VK_PIPELINE_STAGE_VERTEX_SHADER_BIT specifies the vertex shader |
| stage. |
| * ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT specifies the |
| tessellation control shader stage. |
| * ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT specifies the |
| tessellation evaluation shader stage. |
| * ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT specifies the geometry |
| shader stage. |
| * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT specifies the fragment |
| shader stage. |
| * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT specifies the stage of |
| the pipeline where early fragment tests (depth and stencil tests before |
| fragment shading) are performed. |
| This stage also includes <<renderpass-load-operations, render pass load |
| operations>> for framebuffer attachments with a depth/stencil format. |
| * ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT specifies the stage of |
| the pipeline where late fragment tests (depth and stencil tests after |
| fragment shading) are performed. |
| This stage also includes <<renderpass-store-operations, render pass |
| store operations>> for framebuffer attachments with a depth/stencil |
| format. |
| * ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT specifies the stage |
| of the pipeline after blending where the final color values are output |
| from the pipeline. |
| This stage includes <<framebuffer-blending, blending>>, |
| <<framebuffer-logicop, logic operations>>, render pass |
| <<renderpass-load-operations, load>> and <<renderpass-store-operations, |
| store>> operations for color attachments, |
| <<renderpass-resolve-operations, render pass multisample resolve |
| operations>>, and flink:vkCmdClearAttachments. |
| * ename:VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT specifies the execution of a |
| compute shader. |
| * [[synchronization-pipeline-stages-transfer]] |
| ename:VK_PIPELINE_STAGE_TRANSFER_BIT specifies the following commands: |
| ** All <<copies,copy commands>>, including flink:vkCmdCopyQueryPoolResults |
| ifndef::VK_VERSION_1_3,VK_KHR_copy_commands2[] |
| ** flink:vkCmdBlitImage |
| ** flink:vkCmdResolveImage |
| endif::VK_VERSION_1_3,VK_KHR_copy_commands2[] |
| ifdef::VK_VERSION_1_3,VK_KHR_copy_commands2[] |
| ** flink:vkCmdBlitImage2 and flink:vkCmdBlitImage |
| ** flink:vkCmdResolveImage2 and flink:vkCmdResolveImage |
| endif::VK_VERSION_1_3,VK_KHR_copy_commands2[] |
| ** All <<clears,clear commands>>, with the exception of |
| flink:vkCmdClearAttachments |
| * ename:VK_PIPELINE_STAGE_HOST_BIT specifies a pseudo-stage indicating |
| execution on the host of reads/writes of device memory. |
| This stage is not invoked by any commands recorded in a command buffer. |
| ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] |
| * ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR specifies |
| the execution of |
| ifdef::VK_NV_ray_tracing[] |
| flink:vkCmdBuildAccelerationStructureNV, |
| flink:vkCmdCopyAccelerationStructureNV, |
| flink:vkCmdWriteAccelerationStructuresPropertiesNV |
| endif::VK_NV_ray_tracing[] |
| ifdef::VK_NV_ray_tracing+VK_KHR_acceleration_structure[,] |
| ifdef::VK_KHR_acceleration_structure[] |
| flink:vkCmdBuildAccelerationStructuresKHR, |
| flink:vkCmdBuildAccelerationStructuresIndirectKHR, |
| flink:vkCmdCopyAccelerationStructureKHR, |
| flink:vkCmdCopyAccelerationStructureToMemoryKHR, |
| flink:vkCmdCopyMemoryToAccelerationStructureKHR, and |
| flink:vkCmdWriteAccelerationStructuresPropertiesKHR. |
| endif::VK_KHR_acceleration_structure[] |
| endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] |
| ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| * ename:VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR specifies the |
| execution of the ray tracing shader stages, via |
| ifdef::VK_NV_ray_tracing[flink:vkCmdTraceRaysNV] |
| ifdef::VK_NV_ray_tracing+VK_KHR_ray_tracing_pipeline[,] |
| ifdef::VK_KHR_ray_tracing_pipeline[flink:vkCmdTraceRaysKHR, or flink:vkCmdTraceRaysIndirectKHR] |
| endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| * ename:VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT specifies the execution of all |
| graphics pipeline stages, and is equivalent to the logical OR of: |
| ** ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT |
| ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| ** ename:VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT |
| ** ename:VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT |
| endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| ** ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
| ** ename:VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
| ** ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT |
| ** ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT |
| ** ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT |
| ** ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
| ** ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
| ** ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
| ** ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
| ifdef::VK_EXT_conditional_rendering[] |
| ** ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT |
| endif::VK_EXT_conditional_rendering[] |
| ifdef::VK_EXT_transform_feedback[] |
| ** ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT |
| endif::VK_EXT_transform_feedback[] |
| ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| ** ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR |
| endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| ifdef::VK_EXT_fragment_density_map[] |
| ** ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT |
| endif::VK_EXT_fragment_density_map[] |
| * ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT specifies all operations |
| performed by all commands supported on the queue it is used with. |
| ifdef::VK_EXT_conditional_rendering[] |
| * ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT specifies the |
| stage of the pipeline where the predicate of conditional rendering is |
| consumed. |
| endif::VK_EXT_conditional_rendering[] |
| ifdef::VK_EXT_transform_feedback[] |
| * ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT specifies the stage |
| of the pipeline where vertex attribute output values are written to the |
| transform feedback buffers. |
| endif::VK_EXT_transform_feedback[] |
| ifdef::VK_NV_device_generated_commands[] |
| * ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV specifies the stage of |
| the pipeline where device-side preprocessing for generated commands via |
| flink:vkCmdPreprocessGeneratedCommandsNV is handled. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR |
| specifies the stage of the pipeline where the |
| ifdef::VK_KHR_fragment_shading_rate[] |
| <<primsrast-fragment-shading-rate-attachment, fragment shading rate |
| attachment>> |
| endif::VK_KHR_fragment_shading_rate[] |
| ifdef::VK_KHR_fragment_shading_rate+VK_NV_shading_rate_image[or] |
| ifdef::VK_NV_shading_rate_image[] |
| <<primsrast-shading-rate-image, shading rate image>> |
| endif::VK_NV_shading_rate_image[] |
| is read to determine the fragment shading rate for portions of a |
| rasterized primitive. |
| endif::VK_KHR_fragment_shading_rate,VK_NV_shading_rate_image[] |
| ifdef::VK_EXT_fragment_density_map[] |
| * ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT specifies the |
| stage of the pipeline where the fragment density map is read to |
| <<fragmentdensitymapops,generate the fragment areas>>. |
| endif::VK_EXT_fragment_density_map[] |
| * ename:VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT is equivalent to |
| ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT with tlink:VkAccessFlags set to |
| `0` when specified in the second synchronization scope, but specifies no |
| stage of execution when specified in the first scope. |
| * ename:VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT is equivalent to |
| ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT with tlink:VkAccessFlags set to |
| `0` when specified in the first synchronization scope, but specifies no |
| stage of execution when specified in the second scope. |
| -- |
| |
| [open,refpage='VkPipelineStageFlags',desc='Bitmask of VkPipelineStageFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkPipelineStageFlags.adoc[] |
| |
| tname:VkPipelineStageFlags is a bitmask type for setting a mask of zero or |
| more elink:VkPipelineStageFlagBits. |
| -- |
| |
| [[synchronization-pipeline-stages-masks]] |
| If a synchronization command includes a source stage mask, its first |
| <<synchronization-dependencies-scopes, synchronization scope>> only includes |
| execution of the pipeline stages specified in that mask and any |
| <<synchronization-pipeline-stages-order, logically earlier>> stages. |
| Its first <<synchronization-dependencies-access-scopes, access scope>> only |
| includes memory accesses performed by pipeline stages explicitly specified |
| in the source stage mask. |
| |
| If a synchronization command includes a destination stage mask, its second |
| <<synchronization-dependencies-scopes, synchronization scope>> only includes |
| execution of the pipeline stages specified in that mask and any |
| <<synchronization-pipeline-stages-order, logically later>> stages. |
| Its second <<synchronization-dependencies-access-scopes, access scope>> only |
| includes memory accesses performed by pipeline stages explicitly specified |
| in the destination stage mask. |
| |
| [NOTE] |
| .Note |
| ==== |
| Note that <<synchronization-dependencies-access-scopes, access scopes>> do |
| not interact with the logically earlier or later stages for either scope - |
| only the stages the app specifies are considered part of each access scope. |
| ==== |
| |
| Certain pipeline stages are only available on queues that support a |
| particular set of operations. |
| The following table lists, for each pipeline stage flag, which queue |
| capability flag must: be supported by the queue. |
| When multiple flags are enumerated in the second column of the table, it |
| means that the pipeline stage is supported on the queue if it supports any |
| of the listed capability flags. |
| For further details on queue capabilities see |
| <<devsandqueues-physical-device-enumeration,Physical Device Enumeration>> |
| and <<devsandqueues-queues,Queues>>. |
| |
| [[synchronization-pipeline-stages-supported]] |
| .Supported pipeline stage flags |
| [cols="70%,30%",options="header"] |
| |==== |
| |Pipeline stage flag | Required queue capability flag |
| include::{generated}/sync/supportedPipelineStages.adoc[] |
| |==== |
| |
| [[synchronization-pipeline-stages-order]] |
| Pipeline stages that execute as a result of a command logically complete |
| execution in a specific order, such that completion of a logically later |
| pipeline stage must: not happen-before completion of a logically earlier |
| stage. |
| This means that including any stage in the source stage mask for a |
| particular synchronization command also implies that any logically earlier |
| stages are included in *Scope~1st~* for that command. |
| |
| Similarly, initiation of a logically earlier pipeline stage must: not |
| happen-after initiation of a logically later pipeline stage. |
| Including any given stage in the destination stage mask for a particular |
| synchronization command also implies that any logically later stages are |
| included in *Scope~2nd~* for that command. |
| |
| [NOTE] |
| .Note |
| ==== |
| Implementations may: not support synchronization at every pipeline stage for |
| every synchronization operation. |
| If a pipeline stage that an implementation does not support synchronization |
| for appears in a source stage mask, it may: substitute any logically later |
| stage in its place for the first synchronization scope. |
| If a pipeline stage that an implementation does not support synchronization |
| for appears in a destination stage mask, it may: substitute any logically |
| earlier stage in its place for the second synchronization scope. |
| |
| For example, if an implementation is unable to signal an event immediately |
| after vertex shader execution is complete, it may: instead signal the event |
| after color attachment output has completed. |
| |
| If an implementation makes such a substitution, it must: not affect the |
| semantics of execution or memory dependencies or image and buffer memory |
| barriers. |
| ==== |
| |
| [[synchronization-pipeline-stages-types]][[synchronization-pipeline-graphics]] |
| <<pipelines-graphics, Graphics pipelines>> are executable on queues |
| supporting ename:VK_QUEUE_GRAPHICS_BIT. |
| Stages executed by graphics pipelines can: only be specified in commands |
| recorded for queues supporting ename:VK_QUEUE_GRAPHICS_BIT. |
| |
| The graphics |
| ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| primitive |
| endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| pipeline executes the following stages, with the logical ordering of the |
| stages matching the order specified here: |
| |
| include::{generated}/sync/pipelineOrders/graphics_primitive.adoc[] |
| |
| ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| The graphics mesh pipeline executes the following stages, with the logical |
| ordering of the stages matching the order specified here: |
| |
| include::{generated}/sync/pipelineOrders/graphics_mesh.adoc[] |
| endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] |
| |
| For the compute pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/compute.adoc[] |
| |
| ifdef::VK_HUAWEI_subpass_shading[] |
| For the subpass shading pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/subpass_shading.adoc[] |
| endif::VK_HUAWEI_subpass_shading[] |
| |
| ifdef::VK_EXT_fragment_density_map[] |
| For graphics pipeline commands executing in a render pass with a fragment |
| density map attachment, the following pipeline stage where the fragment |
| density map read happens has no particular order relative to the other |
| stages, except that it is logically earlier than |
| ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT: |
| |
| * ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT |
| * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
| endif::VK_EXT_fragment_density_map[] |
| |
| ifdef::VK_EXT_conditional_rendering[] |
| The conditional rendering stage is formally part of both the graphics, and |
| the compute pipeline. |
| The pipeline stage where the predicate read happens has unspecified order |
| relative to other stages of these pipelines: |
| |
| * ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT |
| endif::VK_EXT_conditional_rendering[] |
| |
| For the transfer pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/transfer.adoc[] |
| |
| For host operations, only one pipeline stage occurs, so no order is |
| guaranteed: |
| |
| include::{generated}/sync/pipelineOrders/host.adoc[] |
| |
| ifdef::VK_NV_device_generated_commands[] |
| For the command preprocessing pipeline, the following stages occur in this |
| order: |
| |
| include::{generated}/sync/pipelineOrders/command_preprocessing.adoc[] |
| endif::VK_NV_device_generated_commands[] |
| |
| ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] |
| For acceleration structure build operations, only one pipeline stage occurs, |
| so no order is guaranteed: |
| |
| include::{generated}/sync/pipelineOrders/acceleration_structure_build.adoc[] |
| |
| For acceleration structure copy operations, only one pipeline stage occurs, |
| so no order is guaranteed: |
| |
| include::{generated}/sync/pipelineOrders/acceleration_structure_copy.adoc[] |
| endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] |
| |
| ifdef::VK_EXT_opacity_micromap[] |
| For opacity micromap build operations, only one pipeline stage occurs, so no |
| order is guaranteed: |
| |
| include::{generated}/sync/pipelineOrders/opacity_micromap.adoc[] |
| endif::VK_EXT_opacity_micromap[] |
| |
| ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| For the ray tracing pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/ray_tracing.adoc[] |
| endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| |
| ifdef::VK_KHR_video_decode_queue[] |
| For the video decode pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/video_decode.adoc[] |
| endif::VK_KHR_video_decode_queue[] |
| |
| ifdef::VK_KHR_video_encode_queue[] |
| For the video encode pipeline, the following stages occur in this order: |
| |
| include::{generated}/sync/pipelineOrders/video_encode.adoc[] |
| endif::VK_KHR_video_encode_queue[] |
| |
| [[synchronization-access-types]] |
| === Access Types |
| |
| Memory in Vulkan can: be accessed from within shader invocations and via |
| some fixed-function stages of the pipeline. |
| The _access type_ is a function of the <<descriptorsets, descriptor type>> |
| used, or how a fixed-function stage accesses memory. |
| |
| [[synchronization-access-masks]] |
| Some synchronization commands take sets of access types as parameters to |
| define the <<synchronization-dependencies-access-scopes, access scopes>> of |
| a memory dependency. |
| If a synchronization command includes a _source access mask_, its first |
| <<synchronization-dependencies-access-scopes, access scope>> only includes |
| accesses via the access types specified in that mask. |
| Similarly, if a synchronization command includes a _destination access |
| mask_, its second <<synchronization-dependencies-access-scopes, access |
| scope>> only includes accesses via the access types specified in that mask. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='VkAccessFlagBits2',desc='Access flags for VkAccessFlags2',type='enums',alias='VkAccessFlagBits2KHR'] |
| -- |
| Bits which can: be set in the pname:srcAccessMask and pname:dstAccessMask |
| members of slink:VkMemoryBarrier2KHR, slink:VkImageMemoryBarrier2KHR, and |
| slink:VkBufferMemoryBarrier2KHR, specifying access behavior, are: |
| |
| include::{generated}/api/enums/VkAccessFlagBits2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkAccessFlagBits2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * ename:VK_ACCESS_2_NONE specifies no accesses. |
| * ename:VK_ACCESS_2_MEMORY_READ_BIT specifies all read accesses. |
| It is always valid in any access mask, and is treated as equivalent to |
| setting all etext:READ access flags that are valid where it is used. |
| * ename:VK_ACCESS_2_MEMORY_WRITE_BIT specifies all write accesses. |
| It is always valid in any access mask, and is treated as equivalent to |
| setting all etext:WRITE access flags that are valid where it is used. |
| * ename:VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT specifies read access to |
| command data read from indirect buffers as part of an indirect |
| ifdef::VK_KHR_acceleration_structure[build,] |
| ifdef::VK_KHR_ray_tracing_pipeline[trace,] |
| drawing or dispatch command. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT |
| pipeline stage. |
| * ename:VK_ACCESS_2_INDEX_READ_BIT specifies read access to an index |
| buffer as part of an indexed drawing command, bound by |
| ifdef::VK_KHR_maintenance5[flink:vkCmdBindIndexBuffer2KHR and] |
| flink:vkCmdBindIndexBuffer. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT |
| pipeline stage. |
| * ename:VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT specifies read access to a |
| vertex buffer as part of a drawing command, bound by |
| flink:vkCmdBindVertexBuffers. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT pipeline stage. |
| * ename:VK_ACCESS_2_UNIFORM_READ_BIT specifies read access to a |
| <<descriptorsets-uniformbuffer, uniform buffer>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT specifies read access to an |
| <<renderpass, input attachment>> within a render pass during |
| ifdef::VK_HUAWEI_subpass_shading[] |
| subpass shading or |
| endif::VK_HUAWEI_subpass_shading[] |
| fragment shading. |
| Such access occurs in the |
| ifdef::VK_HUAWEI_subpass_shading[] |
| ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI or |
| endif::VK_HUAWEI_subpass_shading[] |
| ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. |
| * ename:VK_ACCESS_2_SHADER_SAMPLED_READ_BIT specifies read access to a |
| <<descriptorsets-uniformtexelbuffer, uniform texel buffer>> or |
| <<descriptorsets-sampledimage, sampled image>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_2_SHADER_STORAGE_READ_BIT specifies read access to a |
| <<descriptorsets-storagebuffer, storage buffer>>, |
| ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] |
| <<descriptorsets-physical-storage-buffer, physical storage buffer>>, |
| endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] |
| <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or |
| <<descriptorsets-storageimage, storage image>> in any shader pipeline |
| stage. |
| ifdef::VK_KHR_ray_tracing_maintenance1+VK_KHR_ray_tracing_pipeline[] |
| * ename:VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR specifies read |
| access to a <<shader-binding-table, shader binding table>> in any shader |
| pipeline stage. |
| endif::VK_KHR_ray_tracing_maintenance1+VK_KHR_ray_tracing_pipeline[] |
| * ename:VK_ACCESS_2_SHADER_READ_BIT |
| ifndef::VK_KHR_ray_tracing_maintenance1[] |
| ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| specifies read access to a <<shader-binding-table, shader binding |
| table>> in any shader pipeline. |
| In addition, it |
| endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| endif::VK_KHR_ray_tracing_maintenance1[] |
| is equivalent to the logical OR of: |
| include::{generated}/sync/flagDefinitions/VK_ACCESS_2_SHADER_READ_BIT.adoc[] |
| * ename:VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT specifies write access to a |
| <<descriptorsets-storagebuffer, storage buffer>>, |
| ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] |
| <<descriptorsets-physical-storage-buffer, physical storage buffer>>, |
| endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_buffer_device_address[] |
| <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or |
| <<descriptorsets-storageimage, storage image>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_2_SHADER_WRITE_BIT is equivalent to |
| ename:VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT. |
| * ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT specifies read access to a |
| <<renderpass, color attachment>>, such as via |
| ifndef::VK_EXT_blend_operation_advanced[<<framebuffer-blending, blending>>,] |
| ifdef::VK_EXT_blend_operation_advanced[] |
| <<framebuffer-blending, blending>> (other than |
| <<framebuffer-blend-advanced, advanced blend operations>>), |
| endif::VK_EXT_blend_operation_advanced[] |
| <<framebuffer-logicop, logic operations>> or certain |
| ifndef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| ifdef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>> in the |
| ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage or |
| via <<fragops-shader-tileimage-reads, fragment shader tile image reads>> |
| in the ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| * ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT specifies write access to a |
| <<renderpass, color attachment>> during a <<renderpass, render pass>> or |
| via certain render pass <<renderpass-load-operations, load>>, |
| <<renderpass-store-operations, store>>, and |
| <<renderpass-resolve-operations, multisample resolve>> operations. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| * ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT specifies read |
| access to a <<renderpass, depth/stencil attachment>>, via |
| <<fragops-ds-state, depth or stencil operations>> or certain |
| ifndef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages. |
| endif::VK_EXT_shader_tile_image[] |
| ifdef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>> in the |
| ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages or via |
| <<fragops-shader-tileimage-reads, fragment shader tile image reads>> in |
| the ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| * ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT specifies write |
| access to a <<renderpass, depth/stencil attachment>>, via |
| <<fragops-ds-state, depth or stencil operations>> or certain render pass |
| <<renderpass-load-operations, load>> and <<renderpass-store-operations, |
| store>> operations. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT pipeline stages. |
| * ename:VK_ACCESS_2_TRANSFER_READ_BIT specifies read access to an image or |
| buffer in a <<copies, copy>> operation. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_COPY_BIT, |
| ename:VK_PIPELINE_STAGE_2_BLIT_BIT, or |
| ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT pipeline stages. |
| * ename:VK_ACCESS_2_TRANSFER_WRITE_BIT specifies write access to an image |
| or buffer in a <<clears, clear>> or <<copies, copy>> operation. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_COPY_BIT, |
| ename:VK_PIPELINE_STAGE_2_BLIT_BIT, ename:VK_PIPELINE_STAGE_2_CLEAR_BIT, |
| or ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT pipeline stages. |
| * ename:VK_ACCESS_2_HOST_READ_BIT specifies read access by a host |
| operation. |
| Accesses of this type are not performed through a resource, but directly |
| on memory. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_HOST_BIT pipeline |
| stage. |
| * ename:VK_ACCESS_2_HOST_WRITE_BIT specifies write access by a host |
| operation. |
| Accesses of this type are not performed through a resource, but directly |
| on memory. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_HOST_BIT pipeline |
| stage. |
| ifdef::VK_EXT_conditional_rendering[] |
| * ename:VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT specifies read |
| access to a predicate as part of conditional rendering. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT pipeline stage. |
| endif::VK_EXT_conditional_rendering[] |
| ifdef::VK_EXT_transform_feedback[] |
| * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT specifies write |
| access to a transform feedback buffer made when transform feedback is |
| active. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT specifies read |
| access to a transform feedback counter buffer which is read when |
| flink:vkCmdBeginTransformFeedbackEXT executes. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| * ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT specifies |
| write access to a transform feedback counter buffer which is written |
| when flink:vkCmdEndTransformFeedbackEXT executes. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| endif::VK_EXT_transform_feedback[] |
| ifdef::VK_NV_device_generated_commands[] |
| * ename:VK_ACCESS_2_COMMAND_PREPROCESS_READ_BIT_NV specifies reads from |
| buffer inputs to flink:vkCmdPreprocessGeneratedCommandsNV. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV pipeline stage. |
| * ename:VK_ACCESS_2_COMMAND_PREPROCESS_WRITE_BIT_NV specifies writes to |
| the target command buffer preprocess outputs. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV pipeline stage. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_EXT_blend_operation_advanced[] |
| * ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT specifies |
| read access to <<renderpass, color attachments>>, including |
| <<framebuffer-blend-advanced,advanced blend operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| endif::VK_EXT_blend_operation_advanced[] |
| ifdef::VK_HUAWEI_invocation_mask[] |
| * ename:VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI specifies read access |
| to a invocation mask image in the |
| ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI pipeline stage. |
| endif::VK_HUAWEI_invocation_mask[] |
| ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| * ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR specifies read |
| access to an acceleration structure as part of a trace, build, or copy |
| command, or to an <<acceleration-structure-scratch, acceleration |
| structure scratch buffer>> as part of a build command. |
| Such access occurs in the |
| ifdef::VK_KHR_ray_tracing_pipeline[] |
| ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR pipeline stage or |
| endif::VK_KHR_ray_tracing_pipeline[] |
| ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline |
| stage. |
| * ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR specifies write |
| access to an acceleration structure or <<acceleration-structure-scratch, |
| acceleration structure scratch buffer>> as part of a build or copy |
| command. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline |
| stage. |
| endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| ifdef::VK_EXT_fragment_density_map[] |
| * ename:VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT specifies read |
| access to a <<renderpass-fragmentdensitymapattachment, fragment density |
| map attachment>> during dynamic <<fragmentdensitymapops, fragment |
| density map operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT pipeline |
| stage. |
| endif::VK_EXT_fragment_density_map[] |
| ifdef::VK_KHR_fragment_shading_rate[] |
| * ename:VK_ACCESS_2_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR |
| specifies read access to a fragment shading rate attachment during |
| rasterization. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR |
| pipeline stage. |
| endif::VK_KHR_fragment_shading_rate[] |
| ifdef::VK_NV_shading_rate_image[] |
| * ename:VK_ACCESS_2_SHADING_RATE_IMAGE_READ_BIT_NV specifies read access |
| to a shading rate image during rasterization. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_SHADING_RATE_IMAGE_BIT_NV pipeline stage. |
| ifdef::VK_KHR_fragment_shading_rate[] |
| It is equivalent to |
| ename:VK_ACCESS_2_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR. |
| endif::VK_KHR_fragment_shading_rate[] |
| endif::VK_NV_shading_rate_image[] |
| ifdef::VK_KHR_video_decode_queue[] |
| * ename:VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR specifies read access to an |
| image or buffer resource in a <<video-decode-operations, video decode |
| operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR |
| pipeline stage. |
| * ename:VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR specifies write access to |
| an image or buffer resource in a <<video-decode-operations, video decode |
| operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR |
| pipeline stage. |
| endif::VK_KHR_video_decode_queue[] |
| ifdef::VK_KHR_video_encode_queue[] |
| * ename:VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR specifies read access to an |
| image or buffer resource in a <<video-encode-operations, video encode |
| operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR |
| pipeline stage. |
| * ename:VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR specifies write access to |
| an image or buffer resource in a <<video-encode-operations, video encode |
| operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR |
| pipeline stage. |
| endif::VK_KHR_video_encode_queue[] |
| ifdef::VK_EXT_descriptor_buffer[] |
| * ename:VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT specifies read access |
| to a <<descriptorbuffers, descriptor buffer>> in any shader pipeline |
| stage. |
| endif::VK_EXT_descriptor_buffer[] |
| ifdef::VK_NV_optical_flow[] |
| * ename:VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV specifies read access to an |
| image or buffer resource as part of a <<opticalflow-operations, optical |
| flow operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV |
| pipeline stage. |
| * ename:VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV specifies write access to an |
| image or buffer resource as part of a <<opticalflow-operations, optical |
| flow operation>>. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV |
| pipeline stage. |
| endif::VK_NV_optical_flow[] |
| ifdef::VK_EXT_opacity_micromap[] |
| * ename:VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT specifies write access to a |
| micromap object. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT pipeline stage. |
| * ename:VK_ACCESS_2_MICROMAP_READ_BIT_EXT specifies read access to a |
| micromap object. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT and |
| ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline |
| stages. |
| endif::VK_EXT_opacity_micromap[] |
| |
| [NOTE] |
| .Note |
| ==== |
| In situations where an application wishes to select all access types for a |
| given set of pipeline stages, ename:VK_ACCESS_2_MEMORY_READ_BIT or |
| ename:VK_ACCESS_2_MEMORY_WRITE_BIT can be used. |
| This is particularly useful when specifying stages that only have a single |
| access type. |
| ==== |
| |
| [NOTE] |
| .Note |
| ==== |
| The tname:VkAccessFlags2 bitmask goes beyond the 31 individual bit flags |
| allowable within a C99 enum, which is how elink:VkAccessFlagBits is defined. |
| The first 31 values are common to both, and are interchangeable. |
| ==== |
| -- |
| |
| [open,refpage='VkAccessFlags2',desc='64-bit mask of access flags',type='flags',alias='VkAccessFlags2KHR'] |
| -- |
| tname:VkAccessFlags2 is a bitmask type for setting a mask of zero or more |
| elink:VkAccessFlagBits2: |
| |
| include::{generated}/api/flags/VkAccessFlags2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/flags/VkAccessFlags2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='VkAccessFlagBits',desc='Bitmask specifying memory access types that will participate in a memory dependency',type='enums'] |
| -- |
| Bits which can: be set in the pname:srcAccessMask and pname:dstAccessMask |
| members of slink:VkSubpassDependency, |
| ifdef::VK_KHR_synchronization2[slink:VkSubpassDependency2,] |
| slink:VkMemoryBarrier, slink:VkBufferMemoryBarrier, and |
| slink:VkImageMemoryBarrier, specifying access behavior, are: |
| |
| include::{generated}/api/enums/VkAccessFlagBits.adoc[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| These values all have the same meaning as the equivalently named values for |
| tlink:VkAccessFlags2. |
| |
| * ename:VK_ACCESS_NONE specifies no accesses. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_ACCESS_MEMORY_READ_BIT specifies all read accesses. |
| It is always valid in any access mask, and is treated as equivalent to |
| setting all etext:READ access flags that are valid where it is used. |
| * ename:VK_ACCESS_MEMORY_WRITE_BIT specifies all write accesses. |
| It is always valid in any access mask, and is treated as equivalent to |
| setting all etext:WRITE access flags that are valid where it is used. |
| * ename:VK_ACCESS_INDIRECT_COMMAND_READ_BIT specifies read access to |
| indirect command data read as part of an indirect |
| ifdef::VK_KHR_acceleration_structure[build,] |
| ifdef::VK_KHR_ray_tracing_pipeline[trace,] |
| drawing or dispatching command. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT |
| pipeline stage. |
| * ename:VK_ACCESS_INDEX_READ_BIT specifies read access to an index buffer |
| as part of an indexed drawing command, bound by |
| ifdef::VK_KHR_maintenance5[flink:vkCmdBindIndexBuffer2KHR and] |
| flink:vkCmdBindIndexBuffer. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
| pipeline stage. |
| * ename:VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT specifies read access to a |
| vertex buffer as part of a drawing command, bound by |
| flink:vkCmdBindVertexBuffers. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
| pipeline stage. |
| * ename:VK_ACCESS_UNIFORM_READ_BIT specifies read access to a |
| <<descriptorsets-uniformbuffer, uniform buffer>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_INPUT_ATTACHMENT_READ_BIT specifies read access to an |
| <<renderpass, input attachment>> within a render pass during |
| ifdef::VK_HUAWEI_subpass_shading[] |
| subpass shading or |
| endif::VK_HUAWEI_subpass_shading[] |
| fragment shading. |
| Such access occurs in the |
| ifdef::VK_HUAWEI_subpass_shading[] |
| ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI or |
| endif::VK_HUAWEI_subpass_shading[] |
| ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. |
| * ename:VK_ACCESS_SHADER_READ_BIT specifies read access to a |
| <<descriptorsets-uniformtexelbuffer, uniform texel buffer>>, |
| <<descriptorsets-sampledimage, sampled image>>, |
| <<descriptorsets-storagebuffer, storage buffer>>, |
| ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] |
| <<descriptorsets-physical-storage-buffer, physical storage buffer>>, |
| endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] |
| ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| <<shader-binding-table, shader binding table>>, |
| endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] |
| <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or |
| <<descriptorsets-storageimage, storage image>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_SHADER_WRITE_BIT specifies write access to a |
| <<descriptorsets-storagebuffer, storage buffer>>, |
| ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] |
| <<descriptorsets-physical-storage-buffer, physical storage buffer>>, |
| endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] |
| <<descriptorsets-storagetexelbuffer, storage texel buffer>>, or |
| <<descriptorsets-storageimage, storage image>> in any shader pipeline |
| stage. |
| * ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT specifies read access to a |
| <<renderpass, color attachment>>, such as via |
| ifndef::VK_EXT_blend_operation_advanced[<<framebuffer-blending, blending>>,] |
| ifdef::VK_EXT_blend_operation_advanced[] |
| <<framebuffer-blending, blending>> (other than |
| <<framebuffer-blend-advanced, advanced blend operations>>), |
| endif::VK_EXT_blend_operation_advanced[] |
| <<framebuffer-logicop, logic operations>> or certain |
| ifndef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| ifdef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>> in the |
| ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage or |
| via <<fragops-shader-tileimage-reads, fragment shader tile image reads>> |
| in the ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| * ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT specifies write access to a |
| ifndef::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] |
| <<renderpass, color or resolve attachment>> |
| endif::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] |
| ifdef::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] |
| <<renderpass, color, resolve, or depth/stencil resolve attachment>> |
| endif::VK_VERSION_1_2,VK_KHR_depth_stencil_resolve[] |
| during a <<renderpass, render pass>> or via certain render pass |
| <<renderpass-load-operations, load>> and <<renderpass-store-operations, |
| store>> operations. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| * ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT specifies read access |
| to a <<renderpass, depth/stencil attachment>>, via <<fragops-ds-state, |
| depth or stencil operations>> or certain |
| ifndef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages. |
| endif::VK_EXT_shader_tile_image[] |
| ifdef::VK_EXT_shader_tile_image[] |
| <<renderpass-load-operations, render pass load operations>> in the |
| ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages or via |
| <<fragops-shader-tileimage-reads, fragment shader tile image reads>> in |
| the ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT pipeline stage. |
| endif::VK_EXT_shader_tile_image[] |
| * ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT specifies write |
| access to a <<renderpass, depth/stencil attachment>>, via |
| <<fragops-ds-state, depth or stencil operations>> or certain render pass |
| <<renderpass-load-operations, load>> and <<renderpass-store-operations, |
| store>> operations. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT or |
| ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stages. |
| * ename:VK_ACCESS_TRANSFER_READ_BIT specifies read access to an image or |
| buffer in a <<copies, copy>> operation. |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT |
| pipeline stage. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_ACCESS_TRANSFER_WRITE_BIT specifies write access to an image or |
| buffer in a <<clears, clear>> or <<copies, copy>> operation. |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| Such access occurs in the ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT |
| pipeline stage. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_ACCESS_HOST_READ_BIT specifies read access by a host operation. |
| Accesses of this type are not performed through a resource, but directly |
| on memory. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_HOST_BIT pipeline |
| stage. |
| * ename:VK_ACCESS_HOST_WRITE_BIT specifies write access by a host |
| operation. |
| Accesses of this type are not performed through a resource, but directly |
| on memory. |
| Such access occurs in the ename:VK_PIPELINE_STAGE_HOST_BIT pipeline |
| stage. |
| ifdef::VK_EXT_conditional_rendering[] |
| * ename:VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT specifies read access |
| to a predicate as part of conditional rendering. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT pipeline stage. |
| endif::VK_EXT_conditional_rendering[] |
| ifdef::VK_EXT_transform_feedback[] |
| * ename:VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT specifies write access |
| to a transform feedback buffer made when transform feedback is active. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| * ename:VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT specifies read |
| access to a transform feedback counter buffer which is read when |
| fname:vkCmdBeginTransformFeedbackEXT executes. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| * ename:VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT specifies write |
| access to a transform feedback counter buffer which is written when |
| fname:vkCmdEndTransformFeedbackEXT executes. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT pipeline stage. |
| endif::VK_EXT_transform_feedback[] |
| ifdef::VK_NV_device_generated_commands[] |
| * ename:VK_ACCESS_COMMAND_PREPROCESS_READ_BIT_NV specifies reads from |
| buffer inputs to flink:vkCmdPreprocessGeneratedCommandsNV. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV pipeline stage. |
| * ename:VK_ACCESS_COMMAND_PREPROCESS_WRITE_BIT_NV specifies writes to the |
| target command buffer preprocess outputs in |
| flink:vkCmdPreprocessGeneratedCommandsNV. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV pipeline stage. |
| endif::VK_NV_device_generated_commands[] |
| ifdef::VK_EXT_blend_operation_advanced[] |
| * ename:VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT specifies read |
| access to <<renderpass, color attachments>>, including |
| <<framebuffer-blend-advanced,advanced blend operations>>. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. |
| endif::VK_EXT_blend_operation_advanced[] |
| ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| ifdef::VK_HUAWEI_invocation_mask[] |
| * ename:VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI specifies read access |
| to a invocation mask image in the |
| ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI pipeline stage. |
| endif::VK_HUAWEI_invocation_mask[] |
| * ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR specifies read |
| access to an acceleration structure as part of a trace, build, or copy |
| command, or to an <<acceleration-structure-scratch, acceleration |
| structure scratch buffer>> as part of a build command. |
| Such access occurs in the |
| ifdef::VK_KHR_ray_tracing_pipeline[] |
| ename:VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR pipeline stage or |
| endif::VK_KHR_ray_tracing_pipeline[] |
| ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline |
| stage. |
| * ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR specifies write |
| access to an acceleration structure or <<acceleration-structure-scratch, |
| acceleration structure scratch buffer>> as part of a build or copy |
| command. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline |
| stage. |
| endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] |
| ifdef::VK_EXT_fragment_density_map[] |
| * ename:VK_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT specifies read access |
| to a <<renderpass-fragmentdensitymapattachment, fragment density map |
| attachment>> during dynamic <<fragmentdensitymapops, fragment density |
| map operations>> Such access occurs in the |
| ename:VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT pipeline stage. |
| endif::VK_EXT_fragment_density_map[] |
| ifdef::VK_KHR_fragment_shading_rate[] |
| * ename:VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR specifies |
| read access to a fragment shading rate attachment during rasterization. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR |
| pipeline stage. |
| endif::VK_KHR_fragment_shading_rate[] |
| ifdef::VK_NV_shading_rate_image[] |
| * ename:VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV specifies read access to |
| a shading rate image during rasterization. |
| Such access occurs in the |
| ename:VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV pipeline stage. |
| ifdef::VK_KHR_fragment_shading_rate[] |
| It is equivalent to |
| ename:VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR. |
| endif::VK_KHR_fragment_shading_rate[] |
| endif::VK_NV_shading_rate_image[] |
| |
| Certain access types are only performed by a subset of pipeline stages. |
| Any synchronization command that takes both stage masks and access masks |
| uses both to define the <<synchronization-dependencies-access-scopes, access |
| scopes>> - only the specified access types performed by the specified stages |
| are included in the access scope. |
| An application must: not specify an access flag in a synchronization command |
| if it does not include a pipeline stage in the corresponding stage mask that |
| is able to perform accesses of that type. |
| The following table lists, for each access flag, which pipeline stages can: |
| perform that type of access. |
| |
| [[synchronization-access-types-supported]] |
| .Supported access types |
| [cols="50,50",options="header"] |
| |==== |
| |Access flag | Supported pipeline stages |
| include::{generated}/sync/supportedAccessTypes.adoc[] |
| |==== |
| -- |
| |
| [open,refpage='VkAccessFlags',desc='Bitmask of VkAccessFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkAccessFlags.adoc[] |
| |
| tname:VkAccessFlags is a bitmask type for setting a mask of zero or more |
| elink:VkAccessFlagBits. |
| -- |
| |
| |
| [[synchronization-host-access-types]] |
| If a memory object does not have the |
| ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT property, then |
| flink:vkFlushMappedMemoryRanges must: be called in order to guarantee that |
| writes to the memory object from the host are made available to the host |
| domain, where they can: be further made available to the device domain via a |
| domain operation. |
| Similarly, flink:vkInvalidateMappedMemoryRanges must: be called to guarantee |
| that writes which are available to the host domain are made visible to host |
| operations. |
| |
| If the memory object does have the |
| ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT property flag, writes to the |
| memory object from the host are automatically made available to the host |
| domain. |
| Similarly, writes made available to the host domain are automatically made |
| visible to the host. |
| |
| [NOTE] |
| .Note |
| ==== |
| <<devsandqueues-submission, Queue submission commands>> automatically |
| perform a <<synchronization-submission-host-writes,domain operation from |
| host to device>> for all writes performed before the command executes, so in |
| most cases an explicit memory barrier is not needed for this case. |
| In the few circumstances where a submit does not occur between the host |
| write and the device read access, writes can: be made available by using an |
| explicit memory barrier. |
| ==== |
| |
| |
| [[synchronization-framebuffer-regions]] |
| === Framebuffer Region Dependencies |
| |
| <<synchronization-pipeline-stages, Pipeline stages>> that operate on, or |
| with respect to, the framebuffer are collectively the _framebuffer-space_ |
| pipeline stages. |
| These stages are: |
| |
| * ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
| * ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
| * ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
| * ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
| |
| For these pipeline stages, an execution or memory dependency from the first |
| set of operations to the second set can: either be a single |
| _framebuffer-global_ dependency, or split into multiple _framebuffer-local_ |
| dependencies. |
| A dependency with non-framebuffer-space pipeline stages is neither |
| framebuffer-global nor framebuffer-local. |
| |
| ifndef::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| A _framebuffer region_ is a set of sample (x, y, layer, sample) coordinates |
| that is a subset of the entire framebuffer. |
| endif::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| ifdef::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| A _framebuffer region_ is a subset of the entire framebuffer, and can: |
| either be: |
| |
| * A _sample region_, which is set of sample (x, y, layer, sample) |
| coordinates that is a subset of the entire framebuffer, or |
| * A _fragment region_, which is a set of fragment (x, y, layer) |
| coordinates that is a subset of the entire framebuffer. |
| endif::VK_QCOM_render_pass_shader_resolve,VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| |
| Both <<synchronization-dependencies-scopes, synchronization scopes>> of a |
| framebuffer-local dependency include only the operations performed within |
| corresponding framebuffer regions (as defined below). |
| No ordering guarantees are made between different framebuffer regions for a |
| framebuffer-local dependency. |
| |
| Both <<synchronization-dependencies-scopes, synchronization scopes>> of a |
| framebuffer-global dependency include operations on all framebuffer-regions. |
| |
| If the first synchronization scope includes operations on pixels/fragments |
| with N samples and the second synchronization scope includes operations on |
| pixels/fragments with M samples, where N does not equal M, then a |
| framebuffer region containing all samples at a given (x, y, layer) |
| coordinate in the first synchronization scope corresponds to a region |
| containing all samples at the same coordinate in the second synchronization |
| scope. |
| ifndef::VK_QCOM_render_pass_shader_resolve[] |
| In other words, it is a pixel granularity dependency. |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| ifdef::VK_QCOM_render_pass_shader_resolve[] |
| In other words, the framebuffer region is a fragment region and it is a |
| pixel granularity dependency. |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| If N equals M, |
| ifdef::VK_QCOM_render_pass_shader_resolve[] |
| and if the sname:VkSubpassDescription::pname:flags does not specify the |
| ename:VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM flag, |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| then a framebuffer region containing a single (x, y, layer, sample) |
| coordinate in the first synchronization scope corresponds to a region |
| containing the same sample at the same coordinate in the second |
| synchronization scope. |
| ifndef::VK_QCOM_render_pass_shader_resolve[] |
| In other words, it is a sample granularity dependency. |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| ifdef::VK_QCOM_render_pass_shader_resolve[] |
| In other words, the framebuffer region is a sample region and it is a sample |
| granularity dependency. |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| |
| ifdef::VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| If the pipeline performing the operation was created with |
| ename:VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT, |
| ename:VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, |
| or |
| ename:VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, |
| the framebuffer region is a fragment region and it is a pixel granularity |
| dependency. |
| endif::VK_EXT_rasterization_order_attachment_access,VK_ARM_rasterization_order_attachment_access[] |
| |
| [NOTE] |
| .Note |
| ==== |
| Since fragment shader invocations are not specified to run in any particular |
| groupings, the size of a framebuffer region is implementation-dependent, not |
| known to the application, and must: be assumed to be no larger than |
| specified above. |
| ==== |
| |
| [NOTE] |
| .Note |
| ==== |
| Practically, the pixel vs. sample granularity dependency means that if an |
| input attachment has a different number of samples than the pipeline's |
| pname:rasterizationSamples, then a fragment can: access any sample in the |
| input attachment's pixel even if it only uses framebuffer-local |
| dependencies. |
| If the input attachment has the same number of samples, then the fragment |
| can: only access the covered samples in its input code:SampleMask (i.e. the |
| fragment operations happen-after a framebuffer-local dependency for each |
| sample the fragment covers). |
| To access samples that are not covered, |
| ifdef::VK_QCOM_render_pass_shader_resolve[] |
| either the sname:VkSubpassDescription::pname:flags |
| ename:VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM flag is required, or |
| endif::VK_QCOM_render_pass_shader_resolve[] |
| a framebuffer-global dependency is required. |
| ==== |
| |
| If a synchronization command includes a pname:dependencyFlags parameter, and |
| specifies the ename:VK_DEPENDENCY_BY_REGION_BIT flag, then it defines |
| framebuffer-local dependencies for the framebuffer-space pipeline stages in |
| that synchronization command, for all framebuffer regions. |
| If no pname:dependencyFlags parameter is included, or the |
| ename:VK_DEPENDENCY_BY_REGION_BIT flag is not specified, then a |
| framebuffer-global dependency is specified for those stages. |
| The ename:VK_DEPENDENCY_BY_REGION_BIT flag does not affect the dependencies |
| between non-framebuffer-space pipeline stages, nor does it affect the |
| dependencies between framebuffer-space and non-framebuffer-space pipeline |
| stages. |
| |
| [NOTE] |
| .Note |
| ==== |
| Framebuffer-local dependencies are more efficient for most architectures; |
| particularly tile-based architectures - which can keep framebuffer-regions |
| entirely in on-chip registers and thus avoid external bandwidth across such |
| a dependency. |
| Including a framebuffer-global dependency in your rendering will usually |
| force all implementations to flush data to memory, or to a higher level |
| cache, breaking any potential locality optimizations. |
| ==== |
| |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_multiview[] |
| [[synchronization-view-local-dependencies]] |
| === View-Local Dependencies |
| |
| In a render pass instance that has <<renderpass-multiview,multiview>> |
| enabled, dependencies can: be either view-local or view-global. |
| |
| A view-local dependency only includes operations from a single |
| <<renderpass-multiview-view-local,source view>> from the source subpass in |
| the first synchronization scope, and only includes operations from a single |
| <<renderpass-multiview-view-local,destination view>> from the destination |
| subpass in the second synchronization scope. |
| A view-global dependency includes all views in the view mask of the source |
| and destination subpasses in the corresponding synchronization scopes. |
| |
| If a synchronization command includes a pname:dependencyFlags parameter and |
| specifies the ename:VK_DEPENDENCY_VIEW_LOCAL_BIT flag, then it defines |
| view-local dependencies for that synchronization command, for all views. |
| If no pname:dependencyFlags parameter is included or the |
| ename:VK_DEPENDENCY_VIEW_LOCAL_BIT flag is not specified, then a view-global |
| dependency is specified. |
| endif::VK_VERSION_1_1,VK_KHR_multiview[] |
| |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| [[synchronization-device-local-dependencies]] |
| === Device-Local Dependencies |
| |
| Dependencies can: be either device-local or non-device-local. |
| A device-local dependency acts as multiple separate dependencies, one for |
| each physical device that executes the synchronization command, where each |
| dependency only includes operations from that physical device in both |
| synchronization scopes. |
| A non-device-local dependency is a single dependency where both |
| synchronization scopes include operations from all physical devices that |
| participate in the synchronization command. |
| For subpass dependencies, all physical devices in the |
| slink:VkDeviceGroupRenderPassBeginInfo::pname:deviceMask participate in the |
| dependency, and for pipeline barriers all physical devices that are set in |
| the command buffer's current device mask participate in the dependency. |
| |
| If a synchronization command includes a pname:dependencyFlags parameter and |
| specifies the ename:VK_DEPENDENCY_DEVICE_GROUP_BIT flag, then it defines a |
| non-device-local dependency for that synchronization command. |
| If no pname:dependencyFlags parameter is included or the |
| ename:VK_DEPENDENCY_DEVICE_GROUP_BIT flag is not specified, then it defines |
| device-local dependencies for that synchronization command, for all |
| participating physical devices. |
| |
| Semaphore and event dependencies are device-local and only execute on the |
| one physical device that performs the dependency. |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| |
| |
| [[synchronization-implicit]] |
| == Implicit Synchronization Guarantees |
| |
| A small number of implicit ordering guarantees are provided by Vulkan, |
| ensuring that the order in which commands are submitted is meaningful, and |
| avoiding unnecessary complexity in common operations. |
| |
| [[synchronization-submission-order]] |
| _Submission order_ is a fundamental ordering in Vulkan, giving meaning to |
| the order in which <<fundamentals-queueoperation-command-types, action and |
| synchronization commands>> are recorded and submitted to a single queue. |
| Explicit and implicit ordering guarantees between commands in Vulkan all |
| work on the premise that this ordering is meaningful. |
| This order does not itself define any execution or memory dependencies; |
| synchronization commands and other orderings within the API use this |
| ordering to define their scopes. |
| |
| Submission order for any given set of commands is based on the order in |
| which they were recorded to command buffers and then submitted. |
| This order is determined as follows: |
| |
| . The initial order is determined by the order in which |
| flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| and flink:vkQueueSubmit2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| commands are executed on the host, for a single queue, from first to |
| last. |
| . The order in which slink:VkSubmitInfo structures are specified in the |
| pname:pSubmits parameter of flink:vkQueueSubmit, |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or in which slink:VkSubmitInfo2 structures are specified in the |
| pname:pSubmits parameter of flink:vkQueueSubmit2, |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| from lowest index to highest. |
| . The order in which command buffers are specified in the |
| pname:pCommandBuffers member of slink:VkSubmitInfo |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or slink:VkSubmitInfo2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| from lowest index to highest. |
| . The order in which commands were recorded to a command buffer on the |
| host, from first to last: |
| ** For commands recorded outside a render pass, this includes all other |
| commands recorded outside a render pass, including |
| flink:vkCmdBeginRenderPass and flink:vkCmdEndRenderPass commands; it |
| does not directly include commands inside a render pass. |
| ** For commands recorded inside a render pass, this includes all other |
| commands recorded inside the same subpass, including the |
| flink:vkCmdBeginRenderPass and flink:vkCmdEndRenderPass commands that |
| delimit the same render pass instance; it does not include commands |
| recorded to other subpasses. |
| <<fundamentals-queueoperation-command-types, State commands>> do not execute |
| any operations on the device, instead they set the state of the command |
| buffer when they execute on the host, in the order that they are recorded. |
| <<fundamentals-queueoperation-command-types, Action commands>> consume the |
| current state of the command buffer when they are recorded, and will execute |
| state changes on the device as required to match the recorded state. |
| |
| <<drawing-primitive-order, The order of primitives passing through the |
| graphics pipeline>> and |
| <<synchronization-image-barrier-layout-transition-order, image layout |
| transitions as part of an image memory barrier>> provide additional |
| guarantees based on submission order. |
| |
| Execution of <<synchronization-pipeline-stages-order, pipeline stages>> |
| within a given command also has a loose ordering, dependent only on a single |
| command. |
| |
| [[synchronization-signal-operation-order]] |
| _Signal operation order_ is a fundamental ordering in Vulkan, giving meaning |
| to the order in which semaphore and fence signal operations occur when |
| submitted to a single queue. |
| The signal operation order for queue operations is determined as follows: |
| |
| . The initial order is determined by the order in which |
| flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| and flink:vkQueueSubmit2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| commands are executed on the host, for a single queue, from first to |
| last. |
| . The order in which slink:VkSubmitInfo structures are specified in the |
| pname:pSubmits parameter of flink:vkQueueSubmit, |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or in which slink:VkSubmitInfo2 structures are specified in the |
| pname:pSubmits parameter of flink:vkQueueSubmit2, |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| from lowest index to highest. |
| . The fence signal operation defined by the pname:fence parameter of a |
| flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] |
| ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] |
| command is ordered after all semaphore signal operations defined by that |
| command. |
| |
| Semaphore signal operations defined by a single slink:VkSubmitInfo |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or slink:VkSubmitInfo2] |
| ifndef::VKSC_VERSION_1_0[or slink:VkBindSparseInfo] |
| structure are unordered with respect to other semaphore signal operations |
| defined within the same structure. |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| The flink:vkSignalSemaphore command does not execute on a queue but instead |
| performs the signal operation from the host. |
| The semaphore signal operation defined by executing a |
| flink:vkSignalSemaphore command happens-after the flink:vkSignalSemaphore |
| command is invoked and happens-before the command returns. |
| |
| [NOTE] |
| .Note |
| ==== |
| When signaling timeline semaphores, it is the responsibility of the |
| application to ensure that they are ordered such that the semaphore value is |
| strictly increasing. |
| Because the first synchronization scope for a semaphore signal operation |
| contains all semaphore signal operations which occur earlier in submission |
| order, all semaphore signal operations contained in any given batch are |
| guaranteed to happen-after all semaphore signal operations contained in any |
| previous batches. |
| However, no ordering guarantee is provided between the semaphore signal |
| operations defined within a single batch. |
| This, combined with the requirement that timeline semaphore values strictly |
| increase, means that it is invalid to signal the same timeline semaphore |
| twice within a single batch. |
| |
| If an application wishes to ensure that some semaphore signal operation |
| happens-after some other semaphore signal operation, it can submit a |
| separate batch containing only semaphore signal operations, which will |
| happen-after the semaphore signal operations in any earlier batches. |
| |
| When signaling a semaphore from the host, the only ordering guarantee is |
| that the signal operation happens-after when flink:vkSignalSemaphore is |
| called and happens-before it returns. |
| Therefore, it is invalid to call fname:vkSignalSemaphore while there are any |
| outstanding signal operations on that semaphore from any queue submissions |
| unless those queue submissions have some dependency which ensures that they |
| happen-after the host signal operation. |
| One example of this would be if the pending signal operation is, itself, |
| waiting on the same semaphore at a lower value and the call to |
| fname:vkSignalSemaphore signals that lower value. |
| Furthermore, if there are two or more processes or threads signaling the |
| same timeline semaphore from the host, the application must ensure that the |
| fname:vkSignalSemaphore with the lower semaphore value returns before |
| fname:vkSignalSemaphore is called with the higher value. |
| ==== |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| |
| [[synchronization-fences]] |
| == Fences |
| |
| [open,refpage='VkFence',desc='Opaque handle to a fence object',type='handles'] |
| -- |
| Fences are a synchronization primitive that can: be used to insert a |
| dependency from a queue to the host. |
| Fences have two states - signaled and unsignaled. |
| A fence can: be signaled as part of the execution of a |
| <<devsandqueues-submission, queue submission>> command. |
| Fences can: be unsignaled on the host with flink:vkResetFences. |
| Fences can: be waited on by the host with the flink:vkWaitForFences command, |
| and the current state can: be queried with flink:vkGetFenceStatus. |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] |
| [[synchronization-fences-payloads]] |
| The internal data of a fence may: include a reference to any resources and |
| pending work associated with signal or unsignal operations performed on that |
| fence object, collectively referred to as the fence's _payload_. |
| Mechanisms to import and export that internal data to and from fences are |
| provided <<VkExportFenceCreateInfo, below>>. |
| These mechanisms indirectly enable applications to share fence state between |
| two or more fences and other synchronization primitives across process and |
| API boundaries. |
| |
| endif::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| Fences are represented by sname:VkFence handles: |
| |
| include::{generated}/api/handles/VkFence.adoc[] |
| -- |
| |
| [open,refpage='vkCreateFence',desc='Create a new fence object',type='protos'] |
| -- |
| :refpage: vkCreateFence |
| :objectnameplural: fences |
| :objectnamecamelcase: fence |
| :objectcount: 1 |
| |
| To create a fence, call: |
| |
| include::{generated}/api/protos/vkCreateFence.adoc[] |
| |
| * pname:device is the logical device that creates the fence. |
| * pname:pCreateInfo is a pointer to a slink:VkFenceCreateInfo structure |
| containing information about how the fence is to be created. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| * pname:pFence is a pointer to a handle in which the resulting fence |
| object is returned. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| ifdef::VKSC_VERSION_1_0,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| .Valid Usage |
| **** |
| include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| * [[VUID-vkCreateFence-pNext-05106]] |
| If the pname:pNext chain of slink:VkFenceCreateInfo includes |
| slink:VkExportFenceSciSyncInfoNV, then |
| slink:VkFenceCreateInfo::pname:flags must: not include |
| ename:VK_FENCE_CREATE_SIGNALED_BIT |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| **** |
| endif::VKSC_VERSION_1_0,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| |
| include::{generated}/validity/protos/vkCreateFence.adoc[] |
| -- |
| |
| [open,refpage='VkFenceCreateInfo',desc='Structure specifying parameters of a newly created fence',type='structs'] |
| -- |
| The sname:VkFenceCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkFenceCreateInfo.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:flags is a bitmask of elink:VkFenceCreateFlagBits specifying the |
| initial state and behavior of the fence. |
| |
| include::{generated}/validity/structs/VkFenceCreateInfo.adoc[] |
| -- |
| |
| [open,refpage='VkFenceCreateFlagBits',desc='Bitmask specifying initial state and behavior of a fence',type='enums'] |
| -- |
| include::{generated}/api/enums/VkFenceCreateFlagBits.adoc[] |
| |
| * ename:VK_FENCE_CREATE_SIGNALED_BIT specifies that the fence object is |
| created in the signaled state. |
| Otherwise, it is created in the unsignaled state. |
| -- |
| |
| [open,refpage='VkFenceCreateFlags',desc='Bitmask of VkFenceCreateFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkFenceCreateFlags.adoc[] |
| |
| tname:VkFenceCreateFlags is a bitmask type for setting a mask of zero or |
| more elink:VkFenceCreateFlagBits. |
| -- |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] |
| [open,refpage='VkExportFenceCreateInfo',desc='Structure specifying handle types that can be exported from a fence',type='structs'] |
| -- |
| To create a fence whose payload can: be exported to external handles, add a |
| slink:VkExportFenceCreateInfo structure to the pname:pNext chain of the |
| slink:VkFenceCreateInfo structure. |
| The sname:VkExportFenceCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkExportFenceCreateInfo.adoc[] |
| |
| ifdef::VK_KHR_external_fence[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkExportFenceCreateInfoKHR.adoc[] |
| endif::VK_KHR_external_fence[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:handleTypes is a bitmask of |
| elink:VkExternalFenceHandleTypeFlagBits specifying one or more fence |
| handle types the application can: export from the resulting fence. |
| The application can: request multiple handle types for the same fence. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportFenceCreateInfo-handleTypes-01446]] |
| The bits in pname:handleTypes must: be supported and compatible, as |
| reported by slink:VkExternalFenceProperties |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| * [[VUID-VkExportFenceCreateInfo-pNext-05107]] |
| If the pname:pNext chain includes a slink:VkExportFenceSciSyncInfoNV |
| structure, |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence and |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncExport, or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence and |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncExport |
| must: be enabled |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| **** |
| |
| include::{generated}/validity/structs/VkExportFenceCreateInfo.adoc[] |
| -- |
| endif::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| ifdef::VK_KHR_external_fence_win32[] |
| [open,refpage='VkExportFenceWin32HandleInfoKHR',desc='Structure specifying additional attributes of Windows handles exported from a fence',type='structs'] |
| -- |
| To specify additional attributes of NT handles exported from a fence, add a |
| slink:VkExportFenceWin32HandleInfoKHR structure to the pname:pNext chain of |
| the slink:VkFenceCreateInfo structure. |
| The sname:VkExportFenceWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkExportFenceWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:pAttributes is a pointer to a Windows code:SECURITY_ATTRIBUTES |
| structure specifying security attributes of the handle. |
| * pname:dwAccess is a code:DWORD specifying access rights of the handle. |
| * pname:name is a null-terminated UTF-16 string to associate with the |
| underlying synchronization primitive referenced by NT handles exported |
| from the created fence. |
| |
| If slink:VkExportFenceCreateInfo is not included in the same pname:pNext |
| chain, this structure is ignored. |
| |
| If slink:VkExportFenceCreateInfo is included in the pname:pNext chain of |
| slink:VkFenceCreateInfo with a Windows pname:handleType, but either |
| sname:VkExportFenceWin32HandleInfoKHR is not included in the pname:pNext |
| chain, or it is included but pname:pAttributes is set to `NULL`, default |
| security descriptor values will be used, and child processes created by the |
| application will not inherit the handle, as described in the MSDN |
| documentation for "`Synchronization Object Security and Access Rights`"^1^. |
| Further, if the structure is not present, the access rights will be |
| |
| code:DXGI_SHARED_RESOURCE_READ | code:DXGI_SHARED_RESOURCE_WRITE |
| |
| for handles of the following types: |
| |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT |
| |
| 1:: |
| https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportFenceWin32HandleInfoKHR-handleTypes-01447]] |
| If slink:VkExportFenceCreateInfo::pname:handleTypes does not include |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, a |
| sname:VkExportFenceWin32HandleInfoKHR structure must: not be included in |
| the pname:pNext chain of slink:VkFenceCreateInfo |
| **** |
| |
| include::{generated}/validity/structs/VkExportFenceWin32HandleInfoKHR.adoc[] |
| -- |
| |
| [open,refpage='vkGetFenceWin32HandleKHR',desc='Get a Windows HANDLE for a fence',type='protos'] |
| -- |
| To export a Windows handle representing the state of a fence, call: |
| |
| include::{generated}/api/protos/vkGetFenceWin32HandleKHR.adoc[] |
| |
| * pname:device is the logical device that created the fence being |
| exported. |
| * pname:pGetWin32HandleInfo is a pointer to a |
| slink:VkFenceGetWin32HandleInfoKHR structure containing parameters of |
| the export operation. |
| * pname:pHandle will return the Windows handle representing the fence |
| state. |
| |
| For handle types defined as NT handles, the handles returned by |
| fname:vkGetFenceWin32HandleKHR are owned by the application. |
| To avoid leaking resources, the application must: release ownership of them |
| using the code:CloseHandle system call when they are no longer needed. |
| |
| Exporting a Windows handle from a fence may: have side effects depending on |
| the transference of the specified handle type, as described in |
| <<synchronization-fences-importing,Importing Fence Payloads>>. |
| |
| include::{generated}/validity/protos/vkGetFenceWin32HandleKHR.adoc[] |
| -- |
| |
| [open,refpage='VkFenceGetWin32HandleInfoKHR',desc='Structure describing a Win32 handle fence export operation',type='structs'] |
| -- |
| The sname:VkFenceGetWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkFenceGetWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence from which state will be exported. |
| * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value |
| specifying the type of handle requested. |
| |
| The properties of the handle returned depend on the value of |
| pname:handleType. |
| See elink:VkExternalFenceHandleTypeFlagBits for a description of the |
| properties of the defined external fence handle types. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01448]] |
| pname:handleType must: have been included in |
| slink:VkExportFenceCreateInfo::pname:handleTypes when the pname:fence's |
| current payload was created |
| * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01449]] |
| If pname:handleType is defined as an NT handle, |
| flink:vkGetFenceWin32HandleKHR must: be called no more than once for |
| each valid unique combination of pname:fence and pname:handleType |
| * [[VUID-VkFenceGetWin32HandleInfoKHR-fence-01450]] |
| pname:fence must: not currently have its payload replaced by an imported |
| payload as described below in |
| <<synchronization-fences-importing,Importing Fence Payloads>> unless |
| that imported payload's handle type was included in |
| slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes for |
| pname:handleType |
| * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01451]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:fence must: be signaled, or have an |
| associated <<synchronization-fences-signaling,fence signal operation>> |
| pending execution |
| * [[VUID-VkFenceGetWin32HandleInfoKHR-handleType-01452]] |
| pname:handleType must: be defined as an NT handle or a global share |
| handle |
| **** |
| |
| include::{generated}/validity/structs/VkFenceGetWin32HandleInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_fence_win32[] |
| |
| ifdef::VK_KHR_external_fence_fd[] |
| [open,refpage='vkGetFenceFdKHR',desc='Get a POSIX file descriptor handle for a fence',type='protos'] |
| -- |
| :refpage: vkGetFenceFdKHR |
| |
| To export a POSIX file descriptor representing the payload of a fence, call: |
| |
| include::{generated}/api/protos/vkGetFenceFdKHR.adoc[] |
| |
| * pname:device is the logical device that created the fence being |
| exported. |
| * pname:pGetFdInfo is a pointer to a slink:VkFenceGetFdInfoKHR structure |
| containing parameters of the export operation. |
| * pname:pFd will return the file descriptor representing the fence |
| payload. |
| |
| Each call to fname:vkGetFenceFdKHR must: create a new file descriptor and |
| transfer ownership of it to the application. |
| To avoid leaking resources, the application must: release ownership of the |
| file descriptor when it is no longer needed. |
| |
| [NOTE] |
| .Note |
| ==== |
| Ownership can be released in many ways. |
| For example, the application can call code:close() on the file descriptor, |
| or transfer ownership back to Vulkan by using the file descriptor to import |
| a fence payload. |
| ==== |
| |
| If pname:pGetFdInfo->handleType is |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT and the fence is signaled at |
| the time fname:vkGetFenceFdKHR is called, pname:pFd may: return the value |
| `-1` instead of a valid file descriptor. |
| |
| Where supported by the operating system, the implementation must: set the |
| file descriptor to be closed automatically when an code:execve system call |
| is made. |
| |
| Exporting a file descriptor from a fence may: have side effects depending on |
| the transference of the specified handle type, as described in |
| <<synchronization-fences-importing,Importing Fence State>>. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkGetFenceFdKHR.adoc[] |
| -- |
| |
| [open,refpage='VkFenceGetFdInfoKHR',desc='Structure describing a POSIX FD fence export operation',type='structs'] |
| -- |
| The sname:VkFenceGetFdInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkFenceGetFdInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence from which state will be exported. |
| * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value |
| specifying the type of handle requested. |
| |
| The properties of the file descriptor returned depend on the value of |
| pname:handleType. |
| See elink:VkExternalFenceHandleTypeFlagBits for a description of the |
| properties of the defined external fence handle types. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkFenceGetFdInfoKHR-handleType-01453]] |
| pname:handleType must: have been included in |
| slink:VkExportFenceCreateInfo::pname:handleTypes when pname:fence's |
| current payload was created |
| * [[VUID-VkFenceGetFdInfoKHR-handleType-01454]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:fence must: be signaled, or have an |
| associated <<synchronization-fences-signaling,fence signal operation>> |
| pending execution |
| * [[VUID-VkFenceGetFdInfoKHR-fence-01455]] |
| pname:fence must: not currently have its payload replaced by an imported |
| payload as described below in |
| <<synchronization-fences-importing,Importing Fence Payloads>> unless |
| that imported payload's handle type was included in |
| slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes for |
| pname:handleType |
| * [[VUID-VkFenceGetFdInfoKHR-handleType-01456]] |
| pname:handleType must: be defined as a POSIX file descriptor handle |
| **** |
| |
| include::{generated}/validity/structs/VkFenceGetFdInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_fence_fd[] |
| |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| [open,refpage='VkExportFenceSciSyncInfoNV',desc='Structure specifying additional attributes SciSync handles exported from a fence',type='structs'] |
| -- |
| To specify additional attributes of stext:NvSciSync handles exported from a |
| fence, add a slink:VkExportFenceSciSyncInfoNV structure to the pname:pNext |
| chain of the slink:VkFenceCreateInfo structure. |
| The sname:VkExportFenceSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkExportFenceSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:pAttributes is an opaque sname:NvSciSyncAttrList describing the |
| attributes of the NvSciSync object that will be exported. |
| |
| If slink:VkExportFenceCreateInfo is not present in the same pname:pNext |
| chain, this structure is ignored. |
| If the pname:pNext chain of slink:VkFenceCreateInfo includes a |
| slink:VkExportFenceCreateInfo structure with a NvSciSync pname:handleType, |
| but either slink:VkExportFenceSciSyncInfoNV is not included in the |
| pname:pNext chain, or it is included but pname:pAttributes is set to `NULL`, |
| flink:vkCreateFence will return ename:VK_ERROR_INITIALIZATION_FAILED. |
| |
| The pname:pAttributes must: be a reconciled sname:NvSciSyncAttrList. |
| Before exporting the NvSciSync handles, applications must: use the |
| flink:vkGetPhysicalDeviceSciSyncAttributesNV command to get the unreconciled |
| sname:NvSciSyncAttrList and then use the NvSciSync API to reconcile it. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportFenceSciSyncInfoNV-pAttributes-05108]] |
| pname:pAttributes must: be a reconciled stext:NvSciSyncAttrList |
| **** |
| |
| include::{generated}/validity/structs/VkExportFenceSciSyncInfoNV.adoc[] |
| -- |
| |
| [open,refpage='vkGetPhysicalDeviceSciSyncAttributesNV',desc='Get the implementation-specific NvSciSync attributes',type='protos'] |
| -- |
| |
| To obtain the implementation-specific NvSciSync attributes in an |
| unreconciled sname:NvSciSyncAttrList, call: |
| |
| include::{generated}/api/protos/vkGetPhysicalDeviceSciSyncAttributesNV.adoc[] |
| |
| * pname:physicalDevice is the handle to the physical device that will be |
| used to determine the attributes. |
| * pname:pSciSyncAttributesInfo is a pointer to a |
| slink:VkSciSyncAttributesInfoNV structure containing information about |
| how the attributes are to be filled. |
| * pname:pAttributes is an opaque stext:NvSciSyncAttrList in which the |
| implementation will set the requested attributes. |
| |
| On success, pname:pAttributes will contain an unreconciled |
| stext:NvSciSyncAttrList whose private attributes and some public attributes |
| are filled in by the implementation. |
| If the attributes of pname:physicalDevice could not be obtained, |
| ename:VK_ERROR_INITIALIZATION_FAILED is returned. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pSciSyncAttributesInfo-05109]] |
| If pname:pSciSyncAttributesInfo->primitiveType is |
| ename:VK_SCI_SYNC_PRIMITIVE_TYPE_FENCE_NV then |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence |
| must: be enabled |
| * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pSciSyncAttributesInfo-05110]] |
| If pname:pSciSyncAttributesInfo->primitiveType is |
| ename:VK_SCI_SYNC_PRIMITIVE_TYPE_SEMAPHORE_NV then |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore |
| or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2 |
| must: be enabled |
| * [[VUID-vkGetPhysicalDeviceSciSyncAttributesNV-pAttributes-05111]] |
| pname:pAttributes must: be a valid stext:NvSciSyncAttrList and must: not |
| be `NULL` |
| **** |
| |
| include::{generated}/validity/protos/vkGetPhysicalDeviceSciSyncAttributesNV.adoc[] |
| -- |
| |
| [open,refpage='VkSciSyncAttributesInfoNV',desc='Structure describing SciSync attribute information',type='structs'] |
| -- |
| The sname:VkSciSyncAttributesInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkSciSyncAttributesInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:clientType is the permission type of client. |
| * pname:primitiveType is the synchronization primitive type. |
| |
| NvSciSync disallows multi-signalers, therefore clients must: specify their |
| permission types as one of signaler, waiter or signaler_waiter. |
| In addition, NvSciSync requires clients to specify which primitive type is |
| to be used in synchronization, hence clients also need to provide the |
| primitive type (slink:VkFence or slink:VkSemaphore) that will be used. |
| |
| include::{generated}/validity/structs/VkSciSyncAttributesInfoNV.adoc[] |
| -- |
| |
| [open,refpage='VkSciSyncClientTypeNV',desc='Enums specifying client permission types',type='enums'] |
| -- |
| The ename:VkSciSyncClientTypeNV enum is defined as: |
| |
| include::{generated}/api/enums/VkSciSyncClientTypeNV.adoc[] |
| |
| * ename:VK_SCI_SYNC_CLIENT_TYPE_SIGNALER_NV specifies the permission of |
| the client as signaler. |
| It indicates that the client can only signal the created fence or |
| semaphore and disallows waiting on it. |
| * ename:VK_SCI_SYNC_CLIENT_TYPE_WAITER_NV specifies the permission of the |
| client as waiter. |
| It indicates that the client can only wait on the imported fence or |
| semaphore and disallows signalling it. |
| This type of permission is only used when the client imports NvSciSync |
| handles, and export is not allowed. |
| * ename:VK_SCI_SYNC_CLIENT_TYPE_SIGNALER_WAITER_NV specifies the |
| permission of client as both signaler and waiter. |
| It indicates that the client can: signal and wait on the created fence |
| or semaphore. |
| -- |
| |
| [open,refpage='VkSciSyncPrimitiveTypeNV',desc='Enums specifying the primitive types',type='enums'] |
| -- |
| The ename:VkSciSyncPrimitiveTypeNV enum is defined as: |
| |
| include::{generated}/api/enums/VkSciSyncPrimitiveTypeNV.adoc[] |
| |
| * ename:VK_SCI_SYNC_PRIMITIVE_TYPE_FENCE_NV specifies that the |
| synchronization primitive type the client will create is a |
| slink:VkFence. |
| * ename:VK_SCI_SYNC_PRIMITIVE_TYPE_SEMAPHORE_NV specifies that the |
| synchronization primitive type the client will create is a |
| slink:VkSemaphore. |
| -- |
| |
| [open,refpage='vkGetFenceSciSyncFenceNV',desc='Get a stext:NvSciSyncFence handle for a fence',type='protos'] |
| -- |
| To export a stext:NvSciSyncFence handle representing the payload of a fence, |
| call: |
| |
| include::{generated}/api/protos/vkGetFenceSciSyncFenceNV.adoc[] |
| |
| * pname:device is the logical device that created the fence being |
| exported. |
| * pname:pGetSciSyncHandleInfo is a pointer to a |
| slink:VkFenceGetSciSyncInfoNV structure containing parameters of the |
| export operation. |
| * pname:pHandle is a pointer to a stext:NvSciSyncFence which will contain |
| the fence payload on return. |
| |
| Each call to fname:vkGetFenceSciSyncFenceNV will duplicate the underlying |
| stext:NvSciSyncFence handle and transfer the ownership of the |
| stext:NvSciSyncFence handle to the application. |
| To avoid leaking resources, the application must: release of the ownership |
| of the stext:NvSciSyncFence handle when it is no longer needed. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetFenceSciSyncFenceNV-pGetSciSyncHandleInfo-05112]] |
| pname:pGetSciSyncHandleInfo->handleType must: be |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV |
| * [[VUID-vkGetFenceSciSyncFenceNV-sciSyncFence-05113]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence |
| must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkGetFenceSciSyncFenceNV.adoc[] |
| -- |
| |
| [open,refpage='vkGetFenceSciSyncObjNV',desc='Get a stext:NvSciSyncObj handle for a fence',type='protos'] |
| -- |
| To export a stext:NvSciSyncObj handle representing the payload of a fence, |
| call: |
| |
| include::{generated}/api/protos/vkGetFenceSciSyncObjNV.adoc[] |
| |
| * pname:device is the logical device that created the fence being |
| exported. |
| * pname:pGetSciSyncHandleInfo is a pointer to a |
| slink:VkFenceGetSciSyncInfoNV structure containing parameters of the |
| export operation. |
| * pname:pHandle will return the stext:NvSciSyncObj handle representing the |
| fence payload. |
| |
| Each call to fname:vkGetFenceSciSyncObjNV will duplicate the underlying |
| stext:NvSciSyncObj handle and transfer the ownership of the |
| stext:NvSciSyncObj handle to the application. |
| To avoid leaking resources, the application must: release of the ownership |
| of the stext:NvSciSyncObj handle when it is no longer needed. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetFenceSciSyncObjNV-pGetSciSyncHandleInfo-05114]] |
| pname:pGetSciSyncHandleInfo->handleType must: be |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV |
| * [[VUID-vkGetFenceSciSyncObjNV-sciSyncFence-05115]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence |
| must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkGetFenceSciSyncObjNV.adoc[] |
| -- |
| |
| [open,refpage='VkFenceGetSciSyncInfoNV',desc='Structure describing a slink:VkFence export operation to NvSciSync',type='structs'] |
| -- |
| The sname:VkFenceGetSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkFenceGetSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence from which state will be exported. |
| * pname:handleType is the type of NvSciSync handle (stext:NvSciSyncObj or |
| stext:NvSciSyncFence) representing the fence payload that will be |
| exported. |
| |
| If pname:handleType is |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV, a |
| stext:NvSciSyncObj will be exported. |
| If pname:handleType is |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV, a |
| stext:NvSciSyncFence will be exported. |
| |
| include::{generated}/validity/structs/VkFenceGetSciSyncInfoNV.adoc[] |
| -- |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| |
| [open,refpage='vkDestroyFence',desc='Destroy a fence object',type='protos'] |
| -- |
| To destroy a fence, call: |
| |
| include::{generated}/api/protos/vkDestroyFence.adoc[] |
| |
| * pname:device is the logical device that destroys the fence. |
| * pname:fence is the handle of the fence to destroy. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkDestroyFence-fence-01120]] |
| All <<devsandqueues-submission, queue submission>> commands that refer |
| to pname:fence must: have completed execution |
| ifndef::VKSC_VERSION_1_0[] |
| * [[VUID-vkDestroyFence-fence-01121]] |
| If sname:VkAllocationCallbacks were provided when pname:fence was |
| created, a compatible set of callbacks must: be provided here |
| * [[VUID-vkDestroyFence-fence-01122]] |
| If no sname:VkAllocationCallbacks were provided when pname:fence was |
| created, pname:pAllocator must: be `NULL` |
| endif::VKSC_VERSION_1_0[] |
| **** |
| |
| include::{generated}/validity/protos/vkDestroyFence.adoc[] |
| -- |
| |
| [open,refpage='vkGetFenceStatus',desc='Return the status of a fence',type='protos'] |
| -- |
| :refpage: vkGetFenceStatus |
| |
| To query the status of a fence from the host, call: |
| |
| include::{generated}/api/protos/vkGetFenceStatus.adoc[] |
| |
| * pname:device is the logical device that owns the fence. |
| * pname:fence is the handle of the fence to query. |
| |
| Upon success, fname:vkGetFenceStatus returns the status of the fence object, |
| with the following return codes: |
| |
| .Fence Object Status Codes |
| [width="80%",options="header"] |
| |==== |
| | Status | Meaning |
| | ename:VK_SUCCESS | The fence specified by pname:fence is signaled. |
| | ename:VK_NOT_READY | The fence specified by pname:fence is unsignaled. |
| | ename:VK_ERROR_DEVICE_LOST | The device has been lost. See <<devsandqueues-lost-device,Lost Device>>. |
| |==== |
| |
| If a <<devsandqueues-submission, queue submission>> command is pending |
| execution, then the value returned by this command may: immediately be out |
| of date. |
| |
| If the device has been lost (see <<devsandqueues-lost-device,Lost Device>>), |
| fname:vkGetFenceStatus may: return any of the above status codes. |
| If the device has been lost and fname:vkGetFenceStatus is called repeatedly, |
| it will eventually return either ename:VK_SUCCESS or |
| ename:VK_ERROR_DEVICE_LOST. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkGetFenceStatus.adoc[] |
| -- |
| |
| [[synchronization-fences-unsignaling]] |
| [open,refpage='vkResetFences',desc='Resets one or more fence objects',type='protos'] |
| -- |
| To set the state of fences to unsignaled from the host, call: |
| |
| include::{generated}/api/protos/vkResetFences.adoc[] |
| |
| * pname:device is the logical device that owns the fences. |
| * pname:fenceCount is the number of fences to reset. |
| * pname:pFences is a pointer to an array of fence handles to reset. |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| If any member of pname:pFences currently has its |
| <<synchronization-fences-importing, payload imported>> with temporary |
| permanence, that fence's prior permanent payload is first restored. |
| The remaining operations described therefore operate on the restored |
| payload. |
| |
| endif::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| When flink:vkResetFences is executed on the host, it defines a _fence |
| unsignal operation_ for each fence, which resets the fence to the unsignaled |
| state. |
| |
| If any member of pname:pFences is already in the unsignaled state when |
| flink:vkResetFences is executed, then flink:vkResetFences has no effect on |
| that fence. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkResetFences-pFences-01123]] |
| Each element of pname:pFences must: not be currently associated with any |
| queue command that has not yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/protos/vkResetFences.adoc[] |
| -- |
| |
| [[synchronization-fences-signaling]] |
| When a fence is submitted to a queue as part of a |
| <<devsandqueues-submission, queue submission>> command, it defines a memory |
| dependency on the batches that were submitted as part of that command, and |
| defines a _fence signal operation_ which sets the fence to the signaled |
| state. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes every batch submitted in the same <<devsandqueues-submission, queue |
| submission>> command. |
| Fence signal operations that are defined by flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] |
| additionally include in the first synchronization scope all commands that |
| occur earlier in <<synchronization-submission-order,submission order>>. |
| Fence signal operations that are defined by flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] |
| ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] |
| additionally include in the first synchronization scope any semaphore and |
| fence signal operations that occur earlier in |
| <<synchronization-signal-operation-order,signal operation order>>. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| only includes the fence signal operation. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> |
| includes all memory access performed by the device. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| empty. |
| |
| [open,refpage='vkWaitForFences',desc='Wait for one or more fences to become signaled',type='protos'] |
| -- |
| :refpage: vkWaitForFences |
| |
| To wait for one or more fences to enter the signaled state on the host, |
| call: |
| |
| include::{generated}/api/protos/vkWaitForFences.adoc[] |
| |
| * pname:device is the logical device that owns the fences. |
| * pname:fenceCount is the number of fences to wait on. |
| * pname:pFences is a pointer to an array of pname:fenceCount fence |
| handles. |
| * pname:waitAll is the condition that must: be satisfied to successfully |
| unblock the wait. |
| If pname:waitAll is ename:VK_TRUE, then the condition is that all fences |
| in pname:pFences are signaled. |
| Otherwise, the condition is that at least one fence in pname:pFences is |
| signaled. |
| * pname:timeout is the timeout period in units of nanoseconds. |
| pname:timeout is adjusted to the closest value allowed by the |
| implementation-dependent timeout accuracy, which may: be substantially |
| longer than one nanosecond, and may: be longer than the requested |
| period. |
| |
| If the condition is satisfied when fname:vkWaitForFences is called, then |
| fname:vkWaitForFences returns immediately. |
| If the condition is not satisfied at the time fname:vkWaitForFences is |
| called, then fname:vkWaitForFences will block and wait until the condition |
| is satisfied or the pname:timeout has expired, whichever is sooner. |
| |
| If pname:timeout is zero, then fname:vkWaitForFences does not wait, but |
| simply returns the current state of the fences. |
| ename:VK_TIMEOUT will be returned in this case if the condition is not |
| satisfied, even though no actual wait was performed. |
| |
| If the condition is satisfied before the pname:timeout has expired, |
| fname:vkWaitForFences returns ename:VK_SUCCESS. |
| Otherwise, fname:vkWaitForFences returns ename:VK_TIMEOUT after the |
| pname:timeout has expired. |
| |
| If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before |
| the timeout has expired, fname:vkWaitForFences must: return in finite time |
| with either ename:VK_SUCCESS or ename:VK_ERROR_DEVICE_LOST. |
| |
| [NOTE] |
| .Note |
| ==== |
| While we guarantee that fname:vkWaitForFences must: return in finite time, |
| no guarantees are made that it returns immediately upon device loss. |
| However, the client can reasonably expect that the delay will be on the |
| order of seconds and that calling fname:vkWaitForFences will not result in a |
| permanently (or seemingly permanently) dead process. |
| ==== |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkWaitForFences.adoc[] |
| -- |
| |
| [[synchronization-fences-waiting]] |
| An execution dependency is defined by waiting for a fence to become |
| signaled, either via flink:vkWaitForFences or by polling on |
| flink:vkGetFenceStatus. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the fence signal operation. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes the host operations of flink:vkWaitForFences or |
| flink:vkGetFenceStatus indicating that the fence has become signaled. |
| |
| [NOTE] |
| .Note |
| ==== |
| Signaling a fence and waiting on the host does not guarantee that the |
| results of memory accesses will be visible to the host, as the access scope |
| of a memory dependency defined by a fence only includes device access. |
| A <<synchronization-memory-barriers, memory barrier>> or other memory |
| dependency must: be used to guarantee this. |
| See the description of <<synchronization-host-access-types, host access |
| types>> for more information. |
| ==== |
| |
| ifdef::VK_EXT_display_control[] |
| include::{chapters}/VK_EXT_display_control/fence_events.adoc[] |
| endif::VK_EXT_display_control[] |
| |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] |
| [[synchronization-fences-importing]] |
| === Importing Fence Payloads |
| |
| Applications can: import a fence payload into an existing fence using an |
| external fence handle. |
| The effects of the import operation will be either temporary or permanent, |
| as specified by the application. |
| If the import is temporary, the fence will be _restored_ to its permanent |
| state the next time that fence is passed to flink:vkResetFences. |
| |
| [NOTE] |
| .Note |
| ==== |
| Restoring a fence to its prior permanent payload is a distinct operation |
| from resetting a fence payload. |
| See flink:vkResetFences for more detail. |
| ==== |
| |
| Performing a subsequent temporary import on a fence before resetting it has |
| no effect on this requirement; the next unsignal of the fence must: still |
| restore its last permanent state. |
| A permanent payload import behaves as if the target fence was destroyed, and |
| a new fence was created with the same handle but the imported payload. |
| Because importing a fence payload temporarily or permanently detaches the |
| existing payload from a fence, similar usage restrictions to those applied |
| to fname:vkDestroyFence are applied to any command that imports a fence |
| payload. |
| Which of these import types is used is referred to as the import operation's |
| _permanence_. |
| Each handle type supports either one or both types of permanence. |
| |
| The implementation must: perform the import operation by either referencing |
| or copying the payload referred to by the specified external fence handle, |
| depending on the handle's type. |
| The import method used is referred to as the handle type's _transference_. |
| When using handle types with reference transference, importing a payload to |
| a fence adds the fence to the set of all fences sharing that payload. |
| This set includes the fence from which the payload was exported. |
| Fence signaling, waiting, and resetting operations performed on any fence in |
| the set must: behave as if the set were a single fence. |
| Importing a payload using handle types with copy transference creates a |
| duplicate copy of the payload at the time of import, but makes no further |
| reference to it. |
| Fence signaling, waiting, and resetting operations performed on the target |
| of copy imports must: not affect any other fence or payload. |
| |
| Export operations have the same transference as the specified handle type's |
| import operations. |
| Additionally, exporting a fence payload to a handle with copy transference |
| has the same side effects on the source fence's payload as executing a fence |
| reset operation. |
| If the fence was using a temporarily imported payload, the fence's prior |
| permanent payload will be restored. |
| |
| ifdef::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] |
| [NOTE] |
| .Note |
| ==== |
| The |
| ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[tables] |
| ifndef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[table] |
| ifdef::VK_KHR_external_fence_win32[] |
| <<synchronization-fence-handletypes-win32,Handle Types Supported by |
| sname:VkImportFenceWin32HandleInfoKHR>> |
| endif::VK_KHR_external_fence_win32[] |
| ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[and] |
| ifdef::VK_KHR_external_fence_fd[] |
| <<synchronization-fence-handletypes-fd,Handle Types Supported by |
| sname:VkImportFenceFdInfoKHR>> |
| endif::VK_KHR_external_fence_fd[] |
| ifdef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[define] |
| ifndef::VK_KHR_external_fence_win32+VK_KHR_external_fence_fd[defines] |
| the permanence and transference of each handle type. |
| ==== |
| endif::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] |
| |
| <<fundamentals-threadingbehavior,External synchronization>> allows |
| implementations to modify an object's internal state, i.e. payload, without |
| internal synchronization. |
| However, for fences sharing a payload across processes, satisfying the |
| external synchronization requirements of sname:VkFence parameters as if all |
| fences in the set were the same object is sometimes infeasible. |
| Satisfying valid usage constraints on the state of a fence would similarly |
| require impractical coordination or levels of trust between processes. |
| Therefore, these constraints only apply to a specific fence handle, not to |
| its payload. |
| For distinct fence objects which share a payload: |
| |
| * If multiple commands which queue a signal operation, or which unsignal a |
| fence, are called concurrently, behavior will be as if the commands were |
| called in an arbitrary sequential order. |
| * If a queue submission command is called with a fence that is sharing a |
| payload, and the payload is already associated with another queue |
| command that has not yet completed execution, either one or both of the |
| commands will cause the fence to become signaled when they complete |
| execution. |
| * If a fence payload is reset while it is associated with a queue command |
| that has not yet completed execution, the payload will become |
| unsignaled, but may: become signaled again when the command completes |
| execution. |
| * In the preceding cases, any of the devices associated with the fences |
| sharing the payload may: be lost, or any of the queue submission or |
| fence reset commands may: return ename:VK_ERROR_INITIALIZATION_FAILED. |
| |
| Other than these non-deterministic results, behavior is well defined. |
| In particular: |
| |
| * The implementation must: not crash or enter an internally inconsistent |
| state where future valid Vulkan commands might cause undefined: results, |
| * Timeouts on future wait commands on fences sharing the payload must: be |
| effective. |
| |
| [NOTE] |
| .Note |
| ==== |
| These rules allow processes to synchronize access to shared memory without |
| trusting each other. |
| However, such processes must still be cautious not to use the shared fence |
| for more than synchronizing access to the shared memory. |
| For example, a process should not use a fence with shared payload to tell |
| when commands it submitted to a queue have completed and objects used by |
| those commands may be destroyed, since the other process can accidentally or |
| maliciously cause the fence to signal before the commands actually complete. |
| ==== |
| |
| When a fence is using an imported payload, its |
| slink:VkExportFenceCreateInfo::pname:handleTypes value is specified when |
| creating the fence from which the payload was exported, rather than |
| specified when creating the fence. |
| Additionally, |
| slink:VkExternalFenceProperties::pname:exportFromImportedHandleTypes |
| restricts which handle types can: be exported from such a fence based on the |
| specific handle type used to import the current payload. |
| ifdef::VK_KHR_swapchain[] |
| Passing a fence to flink:vkAcquireNextImageKHR is equivalent to temporarily |
| importing a fence payload to that fence. |
| |
| [NOTE] |
| .Note |
| ==== |
| Because the exportable handle types of an imported fence correspond to its |
| current imported payload, and flink:vkAcquireNextImageKHR behaves the same |
| as a temporary import operation for which the source fence is opaque to the |
| application, applications have no way of determining whether any external |
| handle types can: be exported from a fence in this state. |
| Therefore, applications must: not attempt to export handles from fences |
| using a temporarily imported payload from flink:vkAcquireNextImageKHR. |
| ==== |
| endif::VK_KHR_swapchain[] |
| |
| When importing a fence payload, it is the responsibility of the application |
| to ensure the external handles meet all valid usage requirements. |
| However, implementations must: perform sufficient validation of external |
| handles to ensure that the operation results in a valid fence which will not |
| cause program termination, device loss, queue stalls, host thread stalls, or |
| corruption of other resources when used as allowed according to its import |
| parameters. |
| If the external handle provided does not meet these requirements, the |
| implementation must: fail the fence payload import operation with the error |
| code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. |
| endif::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| ifdef::VK_KHR_external_fence_win32[] |
| [open,refpage='vkImportFenceWin32HandleKHR',desc='Import a fence from a Windows HANDLE',type='protos'] |
| -- |
| To import a fence payload from a Windows handle, call: |
| |
| include::{generated}/api/protos/vkImportFenceWin32HandleKHR.adoc[] |
| |
| * pname:device is the logical device that created the fence. |
| * pname:pImportFenceWin32HandleInfo is a pointer to a |
| slink:VkImportFenceWin32HandleInfoKHR structure specifying the fence and |
| import parameters. |
| |
| Importing a fence payload from Windows handles does not transfer ownership |
| of the handle to the Vulkan implementation. |
| For handle types defined as NT handles, the application must: release |
| ownership using the code:CloseHandle system call when the handle is no |
| longer needed. |
| |
| Applications can: import the same fence payload into multiple instances of |
| Vulkan, into the same instance from which it was exported, and multiple |
| times into a given Vulkan instance. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportFenceWin32HandleKHR-fence-04448]] |
| pname:fence must: not be associated with any queue command that has not |
| yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/protos/vkImportFenceWin32HandleKHR.adoc[] |
| -- |
| |
| [open,refpage='VkImportFenceWin32HandleInfoKHR',desc='(None)',type='structs'] |
| -- |
| The sname:VkImportFenceWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkImportFenceWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence into which the state will be imported. |
| * pname:flags is a bitmask of elink:VkFenceImportFlagBits specifying |
| additional parameters for the fence payload import operation. |
| * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value |
| specifying the type of pname:handle. |
| * pname:handle is `NULL` or the external handle to import. |
| * pname:name is `NULL` or a null-terminated UTF-16 string naming the |
| underlying synchronization primitive to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-fence-handletypes-win32]] |
| .Handle Types Supported by sname:VkImportFenceWin32HandleInfoKHR |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT | Reference | Temporary,Permanent |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | Reference | Temporary,Permanent |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457]] |
| pname:handleType must: be a value included in the |
| <<synchronization-fence-handletypes-win32, Handle Types Supported by |
| sname:VkImportFenceWin32HandleInfoKHR>> table |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01459]] |
| If pname:handleType is not |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, pname:name must: |
| be `NULL` |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01460]] |
| If pname:handle is `NULL`, pname:name must: name a valid synchronization |
| primitive of the type specified by pname:handleType |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handleType-01461]] |
| If pname:name is `NULL`, pname:handle must: be a valid handle of the |
| type specified by pname:handleType |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handle-01462]] |
| If pname:handle is not `NULL`, pname:name must: be `NULL` |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-handle-01539]] |
| If pname:handle is not `NULL`, it must: obey any requirements listed for |
| pname:handleType in <<external-fence-handle-types-compatibility,external |
| fence handle types compatibility>> |
| * [[VUID-VkImportFenceWin32HandleInfoKHR-name-01540]] |
| If pname:name is not `NULL`, it must: obey any requirements listed for |
| pname:handleType in <<external-fence-handle-types-compatibility,external |
| fence handle types compatibility>> |
| **** |
| |
| include::{generated}/validity/structs/VkImportFenceWin32HandleInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_fence_win32[] |
| |
| ifdef::VK_KHR_external_fence_fd[] |
| [open,refpage='vkImportFenceFdKHR',desc='Import a fence from a POSIX file descriptor',type='protos'] |
| -- |
| :refpage: vkImportFenceFdKHR |
| |
| To import a fence payload from a POSIX file descriptor, call: |
| |
| include::{generated}/api/protos/vkImportFenceFdKHR.adoc[] |
| |
| * pname:device is the logical device that created the fence. |
| * pname:pImportFenceFdInfo is a pointer to a slink:VkImportFenceFdInfoKHR |
| structure specifying the fence and import parameters. |
| |
| Importing a fence payload from a file descriptor transfers ownership of the |
| file descriptor from the application to the Vulkan implementation. |
| The application must: not perform any operations on the file descriptor |
| after a successful import. |
| |
| Applications can: import the same fence payload into multiple instances of |
| Vulkan, into the same instance from which it was exported, and multiple |
| times into a given Vulkan instance. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportFenceFdKHR-fence-01463]] |
| pname:fence must: not be associated with any queue command that has not |
| yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/protos/vkImportFenceFdKHR.adoc[] |
| -- |
| |
| [open,refpage='VkImportFenceFdInfoKHR',desc='(None)',type='structs'] |
| -- |
| The sname:VkImportFenceFdInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkImportFenceFdInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence into which the payload will be imported. |
| * pname:flags is a bitmask of elink:VkFenceImportFlagBits specifying |
| additional parameters for the fence payload import operation. |
| * pname:handleType is a elink:VkExternalFenceHandleTypeFlagBits value |
| specifying the type of pname:fd. |
| * pname:fd is the external handle to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-fence-handletypes-fd]] |
| .Handle Types Supported by sname:VkImportFenceFdInfoKHR |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT | Reference | Temporary,Permanent |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT | Copy | Temporary |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportFenceFdInfoKHR-handleType-01464]] |
| pname:handleType must: be a value included in the |
| <<synchronization-fence-handletypes-fd, Handle Types Supported by |
| sname:VkImportFenceFdInfoKHR>> table |
| * [[VUID-VkImportFenceFdInfoKHR-fd-01541]] |
| pname:fd must: obey any requirements listed for pname:handleType in |
| <<external-fence-handle-types-compatibility,external fence handle types |
| compatibility>> |
| * [[VUID-VkImportFenceFdInfoKHR-handleType-07306]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:flags must: contain |
| ename:VK_FENCE_IMPORT_TEMPORARY_BIT |
| **** |
| |
| If pname:handleType is ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT, the |
| special value `-1` for pname:fd is treated like a valid sync file descriptor |
| referring to an object that has already signaled. |
| The import operation will succeed and the sname:VkFence will have a |
| temporarily imported payload as if a valid file descriptor had been |
| provided. |
| |
| [NOTE] |
| .Note |
| ==== |
| This special behavior for importing an invalid sync file descriptor allows |
| easier interoperability with other system APIs which use the convention that |
| an invalid sync file descriptor represents work that has already completed |
| and does not need to be waited for. |
| It is consistent with the option for implementations to return a `-1` file |
| descriptor when exporting a ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT |
| from a sname:VkFence which is signaled. |
| ==== |
| |
| include::{generated}/validity/structs/VkImportFenceFdInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_fence_fd[] |
| |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| [open,refpage='vkImportFenceSciSyncFenceNV',desc='Import a fence from a stext:NvSciSyncFence handle',type='protos'] |
| -- |
| To import a fence payload from a stext:NvSciSyncFence handle, call: |
| |
| include::{generated}/api/protos/vkImportFenceSciSyncFenceNV.adoc[] |
| |
| * pname:device is the logical device that created the fence. |
| * pname:pImportFenceSciSyncInfo is a pointer to a |
| slink:VkImportFenceSciSyncInfoNV structure containing parameters of the |
| import operation |
| |
| Importing a fence payload from stext:NvSciSyncFence does not transfer |
| ownership of the handle to the Vulkan implementation. |
| Vulkan will make a copy of stext:NvSciSyncFence when importing it. |
| The application must: release ownership using the NvSciSync API when the |
| handle is no longer needed. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportFenceSciSyncFenceNV-sciSyncImport-05140]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence, or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncImport |
| and slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence |
| must: be enabled |
| * [[VUID-vkImportFenceSciSyncFenceNV-fence-05141]] |
| pname:fence must: not be associated with any queue command that has not |
| yet completed execution on that queue |
| * [[VUID-vkImportFenceSciSyncFenceNV-pImportFenceSciSyncInfo-05142]] |
| pname:pImportFenceSciSyncInfo->handleType must: be |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV |
| **** |
| |
| include::{generated}/validity/protos/vkImportFenceSciSyncFenceNV.adoc[] |
| -- |
| |
| [open,refpage='vkImportFenceSciSyncObjNV',desc='Import a fence from a stext:NvSciSyncObj handle',type='protos'] |
| -- |
| To import a fence payload from a stext:NvSciSyncObj handle, call: |
| |
| include::{generated}/api/protos/vkImportFenceSciSyncObjNV.adoc[] |
| |
| * pname:device is the logical device that created the fence. |
| * pname:pImportFenceSciSyncInfo is a pointer to a |
| slink:VkImportFenceSciSyncInfoNV structure containing parameters of the |
| import operation |
| |
| Importing a fence payload from a stext:NvSciSyncObj does not transfer |
| ownership of the handle to the Vulkan implementation. |
| Vulkan will make a new reference to the stext:NvSciSyncObj object when |
| importing it. |
| The application must: release ownership using the NvSciSync API when the |
| handle is no longer needed. |
| |
| The application must: not import the same stext:NvSciSyncObj with signaler |
| access permissions into multiple instances of slink:VkFence, and must: not |
| import into the same instance from which it was exported. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportFenceSciSyncObjNV-sciSyncImport-05143]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncFence, or |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncImport |
| and slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncFence |
| must: be enabled |
| * [[VUID-vkImportFenceSciSyncObjNV-fence-05144]] |
| pname:fence must: not be associated with any queue command that has not |
| yet completed execution on that queue |
| * [[VUID-vkImportFenceSciSyncObjNV-pImportFenceSciSyncInfo-05145]] |
| pname:pImportFenceSciSyncInfo->handleType must: be |
| ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV |
| **** |
| |
| include::{generated}/validity/protos/vkImportFenceSciSyncObjNV.adoc[] |
| -- |
| |
| |
| [open,refpage='VkImportFenceSciSyncInfoNV',desc='Structure specifying attributes for importing a SciSync handle as a fence',type='structs'] |
| -- |
| The sname:VkImportFenceSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkImportFenceSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:fence is the fence into which the state will be imported. |
| * pname:handleType specifies the type of stext:handle. |
| * pname:handle is the external handle to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-fence-handletypes-sci-sync]] |
| .Handle Types Supported by sname:VkImportFenceSciSyncInfoNV |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV | Reference | Permanent |
| | ename:VK_EXTERNAL_FENCE_HANDLE_TYPE_SCI_SYNC_FENCE_BIT_NV | Copy | Temporary |
| |==== |
| |
| include::{generated}/validity/structs/VkImportFenceSciSyncInfoNV.adoc[] |
| -- |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_fence[] |
| ifdef::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] |
| [open,refpage='VkFenceImportFlagBits',desc='Bitmask specifying additional parameters of fence payload import',type='enums'] |
| -- |
| Bits which can: be set in |
| |
| ifdef::VK_KHR_external_fence_win32[] |
| * slink:VkImportFenceWin32HandleInfoKHR::pname:flags |
| endif::VK_KHR_external_fence_win32[] |
| ifdef::VK_KHR_external_fence_fd[] |
| * slink:VkImportFenceFdInfoKHR::pname:flags |
| endif::VK_KHR_external_fence_fd[] |
| |
| specifying additional parameters of a fence import operation are: |
| |
| include::{generated}/api/enums/VkFenceImportFlagBits.adoc[] |
| |
| ifdef::VK_KHR_external_fence[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkFenceImportFlagBitsKHR.adoc[] |
| endif::VK_KHR_external_fence[] |
| |
| * ename:VK_FENCE_IMPORT_TEMPORARY_BIT specifies that the fence payload |
| will be imported only temporarily, as described in |
| <<synchronization-fences-importing,Importing Fence Payloads>>, |
| regardless of the permanence of pname:handleType. |
| -- |
| |
| [open,refpage='VkFenceImportFlags',desc='Bitmask of VkFenceImportFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkFenceImportFlags.adoc[] |
| |
| ifdef::VK_KHR_external_fence[] |
| or the equivalent |
| |
| include::{generated}/api/flags/VkFenceImportFlagsKHR.adoc[] |
| endif::VK_KHR_external_fence[] |
| |
| tname:VkFenceImportFlags is a bitmask type for setting a mask of zero or |
| more elink:VkFenceImportFlagBits. |
| -- |
| endif::VK_KHR_external_fence_win32,VK_KHR_external_fence_fd[] |
| endif::VK_VERSION_1_1,VK_KHR_external_fence[] |
| |
| |
| [[synchronization-semaphores]] |
| == Semaphores |
| |
| [open,refpage='VkSemaphore',desc='Opaque handle to a semaphore object',type='handles'] |
| -- |
| Semaphores are a synchronization primitive that can: be used to insert a |
| dependency |
| ifndef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| between queue operations. |
| Semaphores have two states - signaled and unsignaled. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| between queue operations or between a queue operation and the host. |
| <<glossary, Binary semaphores>> have two states - signaled and unsignaled. |
| <<glossary, Timeline semaphores>> have a strictly increasing 64-bit unsigned |
| integer payload and are signaled with respect to a particular reference |
| value. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| A semaphore can: be signaled after execution of a queue operation is |
| completed, and a queue operation can: wait for a semaphore to become |
| signaled before it begins execution. |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| A timeline semaphore can: additionally be signaled from the host with the |
| flink:vkSignalSemaphore command and waited on from the host with the |
| flink:vkWaitSemaphores command. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| [[synchronization-semaphores-payloads]] |
| The internal data of a semaphore may: include a reference to any resources |
| and pending work associated with signal or unsignal operations performed on |
| that semaphore object, collectively referred to as the semaphore's |
| _payload_. |
| Mechanisms to import and export that internal data to and from semaphores |
| are provided <<VkExportSemaphoreCreateInfo, below>>. |
| These mechanisms indirectly enable applications to share semaphore state |
| between two or more semaphores and other synchronization primitives across |
| process and API boundaries. |
| |
| endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| |
| Semaphores are represented by sname:VkSemaphore handles: |
| |
| include::{generated}/api/handles/VkSemaphore.adoc[] |
| -- |
| |
| [open,refpage='vkCreateSemaphore',desc='Create a new queue semaphore object',type='protos'] |
| -- |
| :refpage: vkCreateSemaphore |
| :objectnameplural: semaphores |
| :objectnamecamelcase: semaphore |
| :objectcount: 1 |
| |
| To create a semaphore, call: |
| |
| include::{generated}/api/protos/vkCreateSemaphore.adoc[] |
| |
| * pname:device is the logical device that creates the semaphore. |
| * pname:pCreateInfo is a pointer to a slink:VkSemaphoreCreateInfo |
| structure containing information about how the semaphore is to be |
| created. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| * pname:pSemaphore is a pointer to a handle in which the resulting |
| semaphore object is returned. |
| |
| ifndef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| This command creates a _binary semaphore_ that has a boolean payload |
| indicating whether the semaphore is currently signaled or unsignaled. |
| When created, the semaphore is in the unsignaled state. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| ifdef::VKSC_VERSION_1_0[] |
| .Valid Usage |
| **** |
| include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] |
| **** |
| endif::VKSC_VERSION_1_0[] |
| |
| include::{generated}/validity/protos/vkCreateSemaphore.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreCreateInfo',desc='Structure specifying parameters of a newly created semaphore',type='structs'] |
| -- |
| The sname:VkSemaphoreCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreCreateInfo.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:flags is reserved for future use. |
| |
| ifdef::VK_EXT_metal_objects,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| .Valid Usage |
| **** |
| ifdef::VK_EXT_metal_objects[] |
| * [[VUID-VkSemaphoreCreateInfo-pNext-06789]] |
| If the pname:pNext chain includes a |
| slink:VkExportMetalObjectCreateInfoEXT structure, its |
| pname:exportObjectType member must: be |
| ename:VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT |
| endif::VK_EXT_metal_objects[] |
| ifdef::VK_NV_external_sci_sync[] |
| * [[VUID-VkSemaphoreCreateInfo-pNext-05118]] |
| If the pname:pNext chain includes slink:VkExportSemaphoreSciSyncInfoNV, |
| it must: also include slink:VkSemaphoreTypeCreateInfo with a |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| endif::VK_NV_external_sci_sync[] |
| ifdef::VK_NV_external_sci_sync2[] |
| * [[VUID-VkSemaphoreCreateInfo-pNext-05146]] |
| If the pname:pNext chain includes slink:VkSemaphoreSciSyncCreateInfoNV, |
| it must: also include slink:VkSemaphoreTypeCreateInfo with a |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| endif::VK_NV_external_sci_sync2[] |
| **** |
| endif::VK_EXT_metal_objects,VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| |
| include::{generated}/validity/structs/VkSemaphoreCreateInfo.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreCreateFlags',desc='Reserved for future use',type='flags'] |
| -- |
| include::{generated}/api/flags/VkSemaphoreCreateFlags.adoc[] |
| |
| tname:VkSemaphoreCreateFlags is a bitmask type for setting a mask, but is |
| currently reserved for future use. |
| -- |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| [open,refpage='VkSemaphoreTypeCreateInfo',desc='Structure specifying the type of a newly created semaphore',type='structs',alias='VkSemaphoreTypeCreateInfoKHR'] |
| -- |
| The sname:VkSemaphoreTypeCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreTypeCreateInfo.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkSemaphoreTypeCreateInfoKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphoreType is a elink:VkSemaphoreType value specifying the type |
| of the semaphore. |
| * pname:initialValue is the initial payload value if pname:semaphoreType |
| is ename:VK_SEMAPHORE_TYPE_TIMELINE. |
| |
| To create a semaphore of a specific type, add a |
| sname:VkSemaphoreTypeCreateInfo structure to the |
| slink:VkSemaphoreCreateInfo::pname:pNext chain. |
| |
| If no sname:VkSemaphoreTypeCreateInfo structure is included in the |
| pname:pNext chain of slink:VkSemaphoreCreateInfo, then the created semaphore |
| will have a default elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY. |
| |
| ifdef::VK_NV_external_sci_sync2[] |
| If slink:VkSemaphoreSciSyncCreateInfoNV structure is included in the |
| pname:pNext chain of sname:VkSemaphoreTypeCreateInfo, pname:initialValue is |
| ignored. |
| endif::VK_NV_external_sci_sync2[] |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreTypeCreateInfo-timelineSemaphore-03252]] |
| If the <<features-timelineSemaphore, pname:timelineSemaphore>> feature |
| is not enabled, pname:semaphoreType must: not equal |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| * [[VUID-VkSemaphoreTypeCreateInfo-semaphoreType-03279]] |
| If pname:semaphoreType is ename:VK_SEMAPHORE_TYPE_BINARY, |
| pname:initialValue must: be zero |
| ifdef::VK_NV_external_sci_sync[] |
| * [[VUID-VkSemaphoreTypeCreateInfo-pNext-05119]] |
| If the pname:pNext chain includes slink:VkExportSemaphoreSciSyncInfoNV, |
| pname:initialValue must: be zero. |
| endif::VK_NV_external_sci_sync[] |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreTypeCreateInfo.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreType',desc='Specifies the type of a semaphore object',type='enums',alias='VkSemaphoreTypeKHR'] |
| -- |
| Possible values of slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType, |
| specifying the type of a semaphore, are: |
| |
| include::{generated}/api/enums/VkSemaphoreType.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkSemaphoreTypeKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * ename:VK_SEMAPHORE_TYPE_BINARY specifies a _binary semaphore_ type that |
| has a boolean payload indicating whether the semaphore is currently |
| signaled or unsignaled. |
| When created, the semaphore is in the unsignaled state. |
| * ename:VK_SEMAPHORE_TYPE_TIMELINE specifies a _timeline semaphore_ type |
| that has a strictly increasing 64-bit unsigned integer payload |
| indicating whether the semaphore is signaled with respect to a |
| particular reference value. |
| When created, the semaphore payload has the value given by the |
| pname:initialValue field of slink:VkSemaphoreTypeCreateInfo. |
| -- |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| [open,refpage='VkExportSemaphoreCreateInfo',desc='Structure specifying handle types that can be exported from a semaphore',type='structs'] |
| -- |
| To create a semaphore whose payload can: be exported to external handles, |
| add a slink:VkExportSemaphoreCreateInfo structure to the pname:pNext chain |
| of the slink:VkSemaphoreCreateInfo structure. |
| The sname:VkExportSemaphoreCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkExportSemaphoreCreateInfo.adoc[] |
| |
| ifdef::VK_KHR_external_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkExportSemaphoreCreateInfoKHR.adoc[] |
| endif::VK_KHR_external_semaphore[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:handleTypes is a bitmask of |
| elink:VkExternalSemaphoreHandleTypeFlagBits specifying one or more |
| semaphore handle types the application can: export from the resulting |
| semaphore. |
| The application can: request multiple handle types for the same |
| semaphore. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportSemaphoreCreateInfo-handleTypes-01124]] |
| The bits in pname:handleTypes must: be supported and compatible, as |
| reported by slink:VkExternalSemaphoreProperties |
| ifdef::VK_NV_external_sci_sync[] |
| * [[VUID-VkExportSemaphoreCreateInfo-pNext-05120]] |
| If the pname:pNext chain includes a sname:VkExportSemaphoreSciSyncInfoNV |
| structure, |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemapore |
| and slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncExport |
| must: be enabled |
| endif::VK_NV_external_sci_sync[] |
| **** |
| |
| include::{generated}/validity/structs/VkExportSemaphoreCreateInfo.adoc[] |
| -- |
| endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| |
| ifdef::VK_KHR_external_semaphore_win32[] |
| [open,refpage='VkExportSemaphoreWin32HandleInfoKHR',desc='Structure specifying additional attributes of Windows handles exported from a semaphore',type='structs'] |
| -- |
| To specify additional attributes of NT handles exported from a semaphore, |
| add a sname:VkExportSemaphoreWin32HandleInfoKHR structure to the pname:pNext |
| chain of the slink:VkSemaphoreCreateInfo structure. |
| The sname:VkExportSemaphoreWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkExportSemaphoreWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:pAttributes is a pointer to a Windows code:SECURITY_ATTRIBUTES |
| structure specifying security attributes of the handle. |
| * pname:dwAccess is a code:DWORD specifying access rights of the handle. |
| * pname:name is a null-terminated UTF-16 string to associate with the |
| underlying synchronization primitive referenced by NT handles exported |
| from the created semaphore. |
| |
| If slink:VkExportSemaphoreCreateInfo is not included in the same pname:pNext |
| chain, this structure is ignored. |
| |
| If slink:VkExportSemaphoreCreateInfo is included in the pname:pNext chain of |
| slink:VkSemaphoreCreateInfo with a Windows pname:handleType, but either |
| sname:VkExportSemaphoreWin32HandleInfoKHR is not included in the pname:pNext |
| chain, or it is included but pname:pAttributes is set to `NULL`, default |
| security descriptor values will be used, and child processes created by the |
| application will not inherit the handle, as described in the MSDN |
| documentation for "`Synchronization Object Security and Access Rights`"^1^. |
| Further, if the structure is not present, the access rights used depend on |
| the handle type. |
| |
| For handles of the following types: |
| |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT |
| |
| The implementation must: ensure the access rights allow both signal and wait |
| operations on the semaphore. |
| |
| For handles of the following types: |
| |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT |
| |
| The access rights must: be: |
| |
| code:GENERIC_ALL |
| |
| 1:: |
| https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportSemaphoreWin32HandleInfoKHR-handleTypes-01125]] |
| If slink:VkExportSemaphoreCreateInfo::pname:handleTypes does not include |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, |
| sname:VkExportSemaphoreWin32HandleInfoKHR must: not be included in the |
| pname:pNext chain of slink:VkSemaphoreCreateInfo |
| **** |
| |
| include::{generated}/validity/structs/VkExportSemaphoreWin32HandleInfoKHR.adoc[] |
| -- |
| |
| [open,refpage='vkGetSemaphoreWin32HandleKHR',desc='Get a Windows HANDLE for a semaphore',type='protos'] |
| -- |
| To export a Windows handle representing the payload of a semaphore, call: |
| |
| include::{generated}/api/protos/vkGetSemaphoreWin32HandleKHR.adoc[] |
| |
| * pname:device is the logical device that created the semaphore being |
| exported. |
| * pname:pGetWin32HandleInfo is a pointer to a |
| slink:VkSemaphoreGetWin32HandleInfoKHR structure containing parameters |
| of the export operation. |
| * pname:pHandle will return the Windows handle representing the semaphore |
| state. |
| |
| For handle types defined as NT handles, the handles returned by |
| fname:vkGetSemaphoreWin32HandleKHR are owned by the application. |
| To avoid leaking resources, the application must: release ownership of them |
| using the code:CloseHandle system call when they are no longer needed. |
| |
| Exporting a Windows handle from a semaphore may: have side effects depending |
| on the transference of the specified handle type, as described in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>>. |
| |
| include::{generated}/validity/protos/vkGetSemaphoreWin32HandleKHR.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreGetWin32HandleInfoKHR',desc='Structure describing a Win32 handle semaphore export operation',type='structs'] |
| -- |
| The sname:VkSemaphoreGetWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreGetWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore from which state will be exported. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of handle requested. |
| |
| The properties of the handle returned depend on the value of |
| pname:handleType. |
| See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the |
| properties of the defined external semaphore handle types. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01126]] |
| pname:handleType must: have been included in |
| slink:VkExportSemaphoreCreateInfo::pname:handleTypes when the |
| pname:semaphore's current payload was created |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01127]] |
| If pname:handleType is defined as an NT handle, |
| flink:vkGetSemaphoreWin32HandleKHR must: be called no more than once for |
| each valid unique combination of pname:semaphore and pname:handleType |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-semaphore-01128]] |
| pname:semaphore must: not currently have its payload replaced by an |
| imported payload as described below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>> |
| unless that imported payload's handle type was included in |
| slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes |
| for pname:handleType |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01129]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, as defined below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, |
| there must: be no queue waiting on pname:semaphore |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01130]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:semaphore must: be signaled, or have an |
| associated <<synchronization-semaphores-signaling,semaphore signal |
| operation>> pending execution |
| * [[VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01131]] |
| pname:handleType must: be defined as an NT handle or a global share |
| handle |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreGetWin32HandleInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_semaphore_win32[] |
| |
| |
| ifdef::VK_NV_low_latency[] |
| [open,refpage='VkQueryLowLatencySupportNV',desc='Structure used for NVIDIA Reflex Support',type='structs'] |
| -- |
| The sname:VkQueryLowLatencySupportNV structure is defined as: |
| |
| include::{generated}/api/structs/VkQueryLowLatencySupportNV.adoc[] |
| |
| This structure describes the following feature: |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:pQueriedLowLatencyData is used for NVIDIA Reflex Support. |
| |
| include::{generated}/validity/structs/VkQueryLowLatencySupportNV.adoc[] |
| -- |
| endif::VK_NV_low_latency[] |
| |
| ifdef::VK_KHR_external_semaphore_fd[] |
| [open,refpage='vkGetSemaphoreFdKHR',desc='Get a POSIX file descriptor handle for a semaphore',type='protos'] |
| -- |
| :refpage: vkGetSemaphoreFdKHR |
| |
| To export a POSIX file descriptor representing the payload of a semaphore, |
| call: |
| |
| include::{generated}/api/protos/vkGetSemaphoreFdKHR.adoc[] |
| |
| * pname:device is the logical device that created the semaphore being |
| exported. |
| * pname:pGetFdInfo is a pointer to a slink:VkSemaphoreGetFdInfoKHR |
| structure containing parameters of the export operation. |
| * pname:pFd will return the file descriptor representing the semaphore |
| payload. |
| |
| Each call to fname:vkGetSemaphoreFdKHR must: create a new file descriptor |
| and transfer ownership of it to the application. |
| To avoid leaking resources, the application must: release ownership of the |
| file descriptor when it is no longer needed. |
| |
| [NOTE] |
| .Note |
| ==== |
| Ownership can be released in many ways. |
| For example, the application can call code:close() on the file descriptor, |
| or transfer ownership back to Vulkan by using the file descriptor to import |
| a semaphore payload. |
| ==== |
| Where supported by the operating system, the implementation must: set the |
| file descriptor to be closed automatically when an code:execve system call |
| is made. |
| |
| Exporting a file descriptor from a semaphore may: have side effects |
| depending on the transference of the specified handle type, as described in |
| <<synchronization-semaphores-importing,Importing Semaphore State>>. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkGetSemaphoreFdKHR.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreGetFdInfoKHR',desc='Structure describing a POSIX FD semaphore export operation',type='structs'] |
| -- |
| The sname:VkSemaphoreGetFdInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreGetFdInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore from which state will be exported. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of handle requested. |
| |
| The properties of the file descriptor returned depend on the value of |
| pname:handleType. |
| See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the |
| properties of the defined external semaphore handle types. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01132]] |
| pname:handleType must: have been included in |
| slink:VkExportSemaphoreCreateInfo::pname:handleTypes when |
| pname:semaphore's current payload was created |
| * [[VUID-VkSemaphoreGetFdInfoKHR-semaphore-01133]] |
| pname:semaphore must: not currently have its payload replaced by an |
| imported payload as described below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>> |
| unless that imported payload's handle type was included in |
| slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes |
| for pname:handleType |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01134]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, as defined below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, |
| there must: be no queue waiting on pname:semaphore |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01135]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:semaphore must: be signaled, or have an |
| associated <<synchronization-semaphores-signaling,semaphore signal |
| operation>> pending execution |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-01136]] |
| pname:handleType must: be defined as a POSIX file descriptor handle |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-03253]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:semaphore must: have been created with a |
| elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY |
| * [[VUID-VkSemaphoreGetFdInfoKHR-handleType-03254]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:semaphore must: have an associated |
| semaphore signal operation that has been submitted for execution and any |
| semaphore signal operations on which it depends (if any) must: have also |
| been submitted for execution |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreGetFdInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_semaphore_fd[] |
| |
| ifdef::VK_FUCHSIA_external_semaphore[] |
| [open,refpage='vkGetSemaphoreZirconHandleFUCHSIA',desc='Get a Zircon event handle for a semaphore',type='protos'] |
| -- |
| To export a Zircon event handle representing the payload of a semaphore, |
| call: |
| |
| include::{generated}/api/protos/vkGetSemaphoreZirconHandleFUCHSIA.adoc[] |
| |
| * pname:device is the logical device that created the semaphore being |
| exported. |
| * pname:pGetZirconHandleInfo is a pointer to a |
| slink:VkSemaphoreGetZirconHandleInfoFUCHSIA structure containing |
| parameters of the export operation. |
| * pname:pZirconHandle will return the Zircon event handle representing the |
| semaphore payload. |
| |
| Each call to fname:vkGetSemaphoreZirconHandleFUCHSIA must: create a Zircon |
| event handle and transfer ownership of it to the application. |
| To avoid leaking resources, the application must: release ownership of the |
| Zircon event handle when it is no longer needed. |
| |
| [NOTE] |
| .Note |
| ==== |
| Ownership can be released in many ways. |
| For example, the application can call zx_handle_close() on the file |
| descriptor, or transfer ownership back to Vulkan by using the file |
| descriptor to import a semaphore payload. |
| ==== |
| |
| Exporting a Zircon event handle from a semaphore may: have side effects |
| depending on the transference of the specified handle type, as described in |
| <<synchronization-semaphores-importing,Importing Semaphore State>>. |
| |
| include::{generated}/validity/protos/vkGetSemaphoreZirconHandleFUCHSIA.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreGetZirconHandleInfoFUCHSIA',desc='Structure describing a Zircon event handle semaphore export operation',type='structs'] |
| -- |
| The sname:VkSemaphoreGetZirconHandleInfoFUCHSIA structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreGetZirconHandleInfoFUCHSIA.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore from which state will be exported. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of handle requested. |
| |
| The properties of the Zircon event handle returned depend on the value of |
| pname:handleType. |
| See elink:VkExternalSemaphoreHandleTypeFlagBits for a description of the |
| properties of the defined external semaphore handle types. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04758]] |
| pname:handleType must: have been included in |
| slink:VkExportSemaphoreCreateInfo::pname:handleTypes when |
| pname:semaphore's current payload was created |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-semaphore-04759]] |
| pname:semaphore must: not currently have its payload replaced by an |
| imported payload as described below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>> |
| unless that imported payload's handle type was included in |
| slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes |
| for pname:handleType |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04760]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, as defined below in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, |
| there must: be no queue waiting on pname:semaphore |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04761]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:semaphore must: be signaled, or have an |
| associated <<synchronization-semaphores-signaling,semaphore signal |
| operation>> pending execution |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-04762]] |
| pname:handleType must: be defined as a Zircon event handle |
| * [[VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-semaphore-04763]] |
| pname:semaphore must: have been created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_BINARY |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreGetZirconHandleInfoFUCHSIA.adoc[] |
| -- |
| endif::VK_FUCHSIA_external_semaphore[] |
| |
| ifdef::VK_NV_external_sci_sync[] |
| [open,refpage='VkExportSemaphoreSciSyncInfoNV',desc='Structure specifying additional attributes of NvSciSync handles exported from a semaphore',type='structs'] |
| -- |
| To specify additional attributes of NvSciSync handles exported from a |
| semaphore, add a sname:VkExportSemaphoreSciSyncInfoNV structure to the |
| pname:pNext chain of the slink:VkSemaphoreCreateInfo structure. |
| The sname:VkExportSemaphoreSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkExportSemaphoreSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:pAttributes is an opaque sname:NvSciSyncAttrList describing the |
| attributes of the NvSciSync object that will be exported. |
| |
| If slink:VkExportSemaphoreCreateInfo is not present in the same pname:pNext |
| chain, this structure is ignored. |
| If the pname:pNext chain of slink:VkSemaphoreCreateInfo includes a |
| slink:VkExportSemaphoreCreateInfo structure with a NvSciSync |
| pname:handleType, but either slink:VkExportSemaphoreSciSyncInfoNV is not |
| included in the pname:pNext chain, or it is included but pname:pAttributes |
| is set to `NULL`, flink:vkCreateSemaphore will return |
| ename:VK_ERROR_INITIALIZATION_FAILED. |
| |
| The pname:pAttributes must: be a reconciled sname:NvSciSyncAttrList. |
| Before exporting a NvSciSync handle, the application must: use the |
| flink:vkGetPhysicalDeviceSciSyncAttributesNV command to obtain the |
| unreconciled sname:NvSciSyncAttrList and then use the NvSciSync API to |
| reconcile it. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExportSemaphoreSciSyncInfoNV-pAttributes-05121]] |
| pname:pAttributes must: be a reconciled stext:NvSciSyncAttrList |
| **** |
| |
| include::{generated}/validity/structs/VkExportSemaphoreSciSyncInfoNV.adoc[] |
| -- |
| |
| [open,refpage='vkGetSemaphoreSciSyncObjNV',desc='Get a stext:NvSciSyncObj handle for a semaphore',type='protos'] |
| -- |
| |
| To export a stext:NvSciSyncObj handle representing the payload of a |
| semaphore, call: |
| |
| include::{generated}/api/protos/vkGetSemaphoreSciSyncObjNV.adoc[] |
| |
| * pname:device is the logical device that created the semaphore being |
| exported. |
| * pname:pGetSciSyncInfo is a pointer to a |
| slink:VkSemaphoreGetSciSyncInfoNV structure containing parameters of the |
| export operation. |
| * pname:pHandle will return the stext:NvSciSyncObj representing the |
| semaphore payload. |
| |
| Each call to fname:vkGetSemaphoreSciSyncObjNV will duplicate the underlying |
| stext:NvSciSyncObj and transfer the ownership of the stext:NvSciSyncObj |
| handle to the application. |
| To avoid leaking resources, the application must: release ownership of the |
| stext:NvSciSyncObj when it is no longer needed. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetSemaphoreSciSyncObjNV-sciSyncSemaphore-05147]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore |
| must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkGetSemaphoreSciSyncObjNV.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreGetSciSyncInfoNV',desc='Structure describing a slink:VkSemaphore export operation to NvSciSync',type='structs'] |
| -- |
| |
| The sname:VkSemaphoreGetSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreGetSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore from which state will be exported. |
| * pname:handleType is the type of NvSciSync handle (stext:NvSciSyncObj) |
| representing the semaphore that will be exported. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreGetSciSyncInfoNV-handleType-05122]] |
| pname:handleType must: be |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV |
| * [[VUID-VkSemaphoreGetSciSyncInfoNV-semaphore-05123]] |
| pname:semaphore must: have been created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| * [[VUID-VkSemaphoreGetSciSyncInfoNV-semaphore-05129]] |
| pname:semaphore must: have been created with |
| slink:VkExportSemaphoreSciSyncInfoNV included pname:pNext chain of |
| slink:VkSemaphoreCreateInfo, or previously imported by |
| flink:vkImportSemaphoreSciSyncObjNV |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreGetSciSyncInfoNV.adoc[] |
| -- |
| endif::VK_NV_external_sci_sync[] |
| |
| ifdef::VK_NV_external_sci_sync2[] |
| [open,refpage='VkSemaphoreSciSyncCreateInfoNV',desc='Structure to create a semaphore from a semaphore SciSync pool',type='structs'] |
| -- |
| The sname:VkSemaphoreSciSyncCreateInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreSciSyncCreateInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphorePool is a slink:VkSemaphoreSciSyncPoolNV handle. |
| * pname:pFence is a pointer to a stext:NvSciSyncFence. |
| |
| When slink:VkSemaphoreSciSyncCreateInfoNV is included in |
| slink:VkSemaphoreCreateInfo::pname:pNext chain, the semaphore is created |
| from the slink:VkSemaphoreSciSyncPoolNV handle that represents a |
| stext:NvSciSyncObj with one or more primitives. |
| The slink:VkSemaphoreSciSyncCreateInfoNV::pname:pFence parameter provides |
| the information to select the corresponding primitive represented by this |
| semaphore. |
| When a stext:NvSciSyncObj with signaler permissions is imported to |
| slink:VkSemaphoreSciSyncPoolNV, it only supports one primitive and |
| slink:VkSemaphoreSciSyncCreateInfoNV::pname:pFence must: be in the cleared |
| state. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreSciSyncCreateInfoNV-sciSyncSemaphore2-05148]] |
| The <<features-sciSyncSemaphore2, |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> |
| feature must: be enabled |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreSciSyncCreateInfoNV.adoc[] |
| -- |
| endif::VK_NV_external_sci_sync2[] |
| |
| |
| [open,refpage='vkDestroySemaphore',desc='Destroy a semaphore object',type='protos'] |
| -- |
| To destroy a semaphore, call: |
| |
| include::{generated}/api/protos/vkDestroySemaphore.adoc[] |
| |
| * pname:device is the logical device that destroys the semaphore. |
| * pname:semaphore is the handle of the semaphore to destroy. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| |
| ifdef::VK_NV_external_sci_sync2[] |
| If pname:semaphore was created with slink:VkSemaphoreSciSyncCreateInfoNV |
| present in the slink:VkSemaphoreCreateInfo::pname:pNext chain, |
| pname:semaphore can: be destroyed immediately after all batches that refer |
| to it are submitted. |
| Otherwise, all submitted batches that refer to pname:semaphore must: have |
| completed execution before it can be destroyed. |
| endif::VK_NV_external_sci_sync2[] |
| |
| .Valid Usage |
| **** |
| ifndef::VK_NV_external_sci_sync2[] |
| * [[VUID-vkDestroySemaphore-semaphore-01137]] |
| All submitted batches that refer to pname:semaphore must: have completed |
| execution |
| endif::VK_NV_external_sci_sync2[] |
| ifdef::VK_NV_external_sci_sync2[] |
| * [[VUID-vkDestroySemaphore-semaphore-05149]] |
| If pname:semaphore was not created with |
| slink:VkSemaphoreSciSyncCreateInfoNV present in the |
| slink:VkSemaphoreCreateInfo::pname:pNext chain when it was created, all |
| submitted batches that refer to pname:semaphore must: have completed |
| execution |
| endif::VK_NV_external_sci_sync2[] |
| ifndef::VKSC_VERSION_1_0[] |
| * [[VUID-vkDestroySemaphore-semaphore-01138]] |
| If sname:VkAllocationCallbacks were provided when pname:semaphore was |
| created, a compatible set of callbacks must: be provided here |
| * [[VUID-vkDestroySemaphore-semaphore-01139]] |
| If no sname:VkAllocationCallbacks were provided when pname:semaphore was |
| created, pname:pAllocator must: be `NULL` |
| endif::VKSC_VERSION_1_0[] |
| **** |
| |
| include::{generated}/validity/protos/vkDestroySemaphore.adoc[] |
| -- |
| |
| ifdef::VK_NV_external_sci_sync2[] |
| === Semaphore SciSync Pools |
| |
| A semaphore SciSync pool is used to represent a stext:NvSciSyncObj with one |
| or more primitives. |
| |
| [open,refpage='VkSemaphoreSciSyncPoolNV',desc='Opaque handle to a semaphore SciSync pool',type='handles'] |
| -- |
| Semaphore SciSync pools are represented by sname:VkSemaphoreSciSyncPoolNV |
| handles: |
| |
| include::{generated}/api/handles/VkSemaphoreSciSyncPoolNV.adoc[] |
| -- |
| |
| To import a stext:NvSciSyncObj with multiple primitives, use |
| flink:vkCreateSemaphoreSciSyncPoolNV to reserve a semaphore pool to map the |
| multiple semaphores allocated by stext:NvSciSyncObj. |
| Then create a slink:VkSemaphore from the semaphore pool using the index |
| provided by the stext:NvSciSyncFence when chaining the |
| slink:VkSemaphoreSciSyncCreateInfoNV structure to |
| slink:VkSemaphoreCreateInfo. |
| |
| [open,refpage='vkCreateSemaphoreSciSyncPoolNV',desc='Create a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] |
| -- |
| :refpage: vkCreateSemaphoreSciSyncPoolNV |
| |
| To create a sname:VkSemaphoreSciSyncPoolNV, call: |
| |
| include::{generated}/api/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] |
| |
| * pname:device is the logical device that creates the semaphore pool. |
| * pname:pCreateInfo is a pointer to a |
| slink:VkSemaphoreSciSyncPoolCreateInfoNV structure containing |
| information about the semaphore SciSync pool being created. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| * pname:pSemaphorePool is a pointer to a handle in which the resulting |
| semaphore pool object is returned. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| .Valid Usage |
| **** |
| ifdef::VKSC_VERSION_1_0[] |
| * [[VUID-vkCreateSemaphoreSciSyncPoolNV-device-05150]] |
| The number of semaphore pools currently allocated from pname:device plus |
| 1 must: be less than or equal to the total number of semaphore pools |
| requested via |
| slink:VkDeviceSemaphoreSciSyncPoolReservationCreateInfoNV::pname:semaphoreSciSyncPoolRequestCount |
| specified when pname:device was created |
| endif::VKSC_VERSION_1_0[] |
| * [[VUID-vkCreateSemaphoreSciSyncPoolNV-sciSyncSemaphore2-05151]] |
| The <<features-sciSyncSemaphore2, |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> |
| feature must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreSciSyncPoolCreateInfoNV',desc='Structure describing the creation parameters for a SciSync pool',type='structs'] |
| -- |
| The sname:VkSemaphoreSciSyncPoolCreateInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:handle is an external stext:NvSciSyncObj to import. |
| |
| During flink:vkCreateSemaphoreSciSyncPoolNV, the external stext:NvSciSyncObj |
| is imported to sname:VkSemaphoreSciSyncPoolNV. |
| The import does not transfer the ownership of the stext:NvSciSyncObj to the |
| implementation, but will increment the reference count of that object. |
| ifndef::VKSC_VERSION_1_0[] |
| flink:vkDestroySemaphoreSciSyncPoolNV will decrement the reference count of |
| that object. |
| endif::VKSC_VERSION_1_0[] |
| The application must: delete other references of the original |
| stext:NvSciSyncObj using <<NvSciSync2-extension-page, NvSciSync APIs>> when |
| it is no longer needed. |
| |
| Applications must: not import the same stext:NvSciSyncObj with signaler |
| access permissions to multiple instances of sname:VkSemaphoreSciSyncPoolNV. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreSciSyncPoolCreateInfoNV-handle-05152]] |
| pname:handle must: be a valid stext:NvSciSyncObj |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreSciSyncPoolCreateInfoNV.adoc[] |
| -- |
| |
| ifdef::VKSC_VERSION_1_0[] |
| ifdef::hidden[] |
| // tag::scremoved[] |
| ifdef::VK_NV_external_sci_sync2[] |
| * fname:vkDestroySemaphoreSciSyncPoolNV <<SCID-4>> |
| endif::VK_NV_external_sci_sync2[] |
| // end::scremoved[] |
| endif::hidden[] |
| |
| Semaphore SciSync pools cannot: be freed <<SCID-4>>. |
| If |
| slink:VkPhysicalDeviceVulkanSC10Properties::<<limits-deviceDestroyFreesMemory,pname:deviceDestroyFreesMemory>> |
| is ename:VK_TRUE, the memory is returned to the system and the reference to |
| the stext:NvSciSyncObj that was imported is releasd when the device is |
| destroyed. |
| endif::VKSC_VERSION_1_0[] |
| |
| ifndef::VKSC_VERSION_1_0[] |
| [open,refpage='vkDestroySemaphoreSciSyncPoolNV',desc='Destroy a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] |
| -- |
| To destroy a slink:VkSemaphoreSciSyncPoolNV, call: |
| |
| include::{generated}/api/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] |
| |
| * pname:device is the logical device that destroys the semaphore SciSync |
| pool. |
| * pname:semaphorePool is the handle of the semaphore SciSync pool to |
| destroy. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkDestroySemaphoreSciSyncPoolNV-semaphorePool-05153]] |
| All submitted batches that refer to a semaphore created from |
| pname:semaphorePool must: have completed execution |
| * [[VUID-vkDestroySemaphoreSciSyncPoolNV-sciSyncSemaphore2-05154]] |
| The <<features-sciSyncSemaphore2, |
| slink:VkPhysicalDeviceExternalSciSync2FeaturesNV::pname:sciSyncSemaphore2>> |
| feature must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkDestroySemaphoreSciSyncPoolNV.adoc[] |
| -- |
| endif::VKSC_VERSION_1_0[] |
| endif::VK_NV_external_sci_sync2[] |
| |
| |
| [[synchronization-semaphores-signaling]] |
| === Semaphore Signaling |
| |
| When a batch is submitted to a queue via a <<devsandqueues-submission, queue |
| submission>>, and it includes semaphores to be signaled, it defines a memory |
| dependency on the batch, and defines _semaphore signal operations_ which set |
| the semaphores to the signaled state. |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| In case of semaphores created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE the semaphore is considered signaled with |
| respect to the counter value set to be signaled as specified in |
| slink:VkTimelineSemaphoreSubmitInfo or slink:VkSemaphoreSignalInfo. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes every command submitted in the same batch. |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| In the case of flink:vkQueueSubmit2, the first synchronization scope is |
| limited to the pipeline stage specified by |
| slink:VkSemaphoreSubmitInfo::pname:stageMask. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| Semaphore signal operations that are defined by flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or flink:vkQueueSubmit2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| additionally include all commands that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| Semaphore signal operations that are defined by flink:vkQueueSubmit |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[or flink:vkQueueSubmit2] |
| ifndef::VKSC_VERSION_1_0[or flink:vkQueueBindSparse] |
| additionally include in the first synchronization scope any semaphore and |
| fence signal operations that occur earlier in |
| <<synchronization-signal-operation-order,signal operation order>>. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the semaphore signal operation. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> |
| includes all memory access performed by the device. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| empty. |
| |
| |
| [[synchronization-semaphores-waiting]] |
| === Semaphore Waiting |
| |
| When a batch is submitted to a queue via a <<devsandqueues-submission, queue |
| submission>>, and it includes semaphores to be waited on, it defines a |
| memory dependency between prior semaphore signal operations and the batch, |
| and defines _semaphore wait operations_. |
| |
| Such semaphore wait operations set the semaphores |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| created with a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| to the unsignaled state. |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| In case of semaphores created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE a prior semaphore signal operation defines |
| a memory dependency with a semaphore wait operation if the value the |
| semaphore is signaled with is greater than or equal to the value the |
| semaphore is waited with, thus the semaphore will continue to be considered |
| signaled with respect to the counter value waited on as specified in |
| slink:VkTimelineSemaphoreSubmitInfo. |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| The first synchronization scope includes all semaphore signal operations |
| that operate on semaphores waited on in the same batch, and that |
| happen-before the wait completes. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes every command submitted in the same batch. |
| In the case of flink:vkQueueSubmit, the second synchronization scope is |
| limited to operations on the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, destination stage mask>> specified |
| by the corresponding element of pname:pWaitDstStageMask. |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| In the case of flink:vkQueueSubmit2, the second synchronization scope is |
| limited to the pipeline stage specified by |
| slink:VkSemaphoreSubmitInfo::pname:stageMask. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| Also, in the case of |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| either flink:vkQueueSubmit2 or |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| flink:vkQueueSubmit, the second synchronization scope additionally includes |
| all commands that occur later in |
| <<synchronization-submission-order,submission order>>. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| empty. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> |
| includes all memory access performed by the device. |
| |
| The semaphore wait operation happens-after the first set of operations in |
| the execution dependency, and happens-before the second set of operations in |
| the execution dependency. |
| |
| [NOTE] |
| .Note |
| ==== |
| Unlike |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| timeline semaphores, |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| fences or events, the act of waiting for a binary semaphore also unsignals |
| that semaphore. |
| Applications must: ensure that between two such wait operations, the |
| semaphore is signaled again, with execution dependencies used to ensure |
| these occur in order. |
| Binary semaphore waits and signals should thus occur in discrete 1:1 pairs. |
| ==== |
| |
| ifdef::VK_KHR_swapchain[] |
| [NOTE] |
| .Note |
| ==== |
| A common scenario for using pname:pWaitDstStageMask with values other than |
| ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT is when synchronizing a window |
| system presentation operation against subsequent command buffers which |
| render the next frame. |
| In this case, a presentation image must: not be overwritten until the |
| presentation operation completes, but other pipeline stages can: execute |
| without waiting. |
| A mask of ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT prevents |
| subsequent color attachment writes from executing until the semaphore |
| signals. |
| Some implementations may: be able to execute transfer operations and/or |
| pre-rasterization work before the semaphore is signaled. |
| |
| If an image layout transition needs to be performed on a presentable image |
| before it is used in a framebuffer, that can: be performed as the first |
| operation submitted to the queue after acquiring the image, and should: not |
| prevent other work from overlapping with the presentation operation. |
| For example, a sname:VkImageMemoryBarrier could use: |
| |
| * pname:srcStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
| * pname:srcAccessMask = 0 |
| * pname:dstStageMask = ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
| * pname:dstAccessMask = ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | |
| ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. |
| * pname:oldLayout = ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR |
| * pname:newLayout = ename:VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| |
| Alternatively, pname:oldLayout can: be ename:VK_IMAGE_LAYOUT_UNDEFINED, if |
| the image's contents need not be preserved. |
| |
| This barrier accomplishes a dependency chain between previous presentation |
| operations and subsequent color attachment output operations, with the |
| layout transition performed in between, and does not introduce a dependency |
| between previous work and any |
| <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader |
| stage>>s. |
| More precisely, the semaphore signals after the presentation operation |
| completes, the semaphore wait stalls the |
| ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage, and there is a |
| dependency from that same stage to itself with the layout transition |
| performed in between. |
| ==== |
| endif::VK_KHR_swapchain[] |
| |
| |
| [[synchronization-semaphores-waiting-state]] |
| === Semaphore State Requirements for Wait Operations |
| |
| Before waiting on a semaphore, the application must: ensure the semaphore is |
| in a valid state for a wait operation. |
| Specifically, when a <<synchronization-semaphores-waiting,semaphore wait |
| operation>> is submitted to a queue: |
| |
| * A binary semaphore must: be signaled, or have an associated |
| <<synchronization-semaphores-signaling,semaphore signal operation>> that |
| is pending execution. |
| * Any <<synchronization-semaphores-signaling,semaphore signal operations>> |
| on which the pending binary semaphore signal operation depends must: |
| also be completed or pending execution. |
| * There must: be no other queue waiting on the same binary semaphore when |
| the operation executes. |
| |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| [[synchronization-semaphores-hostops]] |
| === Host Operations on Semaphores |
| |
| In addition to <<synchronization-semaphores-signaling,semaphore signal |
| operations>> and <<synchronization-semaphores-waiting,semaphore wait |
| operations>> submitted to device queues, timeline semaphores support the |
| following host operations: |
| |
| * Query the current counter value of the semaphore using the |
| flink:vkGetSemaphoreCounterValue command. |
| * Wait for a set of semaphores to reach particular counter values using |
| the flink:vkWaitSemaphores command. |
| * Signal the semaphore with a particular counter value from the host using |
| the flink:vkSignalSemaphore command. |
| |
| [open,refpage='vkGetSemaphoreCounterValue',desc='Query the current state of a timeline semaphore',type='protos',alias='vkGetSemaphoreCounterValueKHR'] |
| -- |
| :refpage: vkGetSemaphoreCounterValue |
| |
| To query the current counter value of a semaphore created with a |
| elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE from the host, |
| call: |
| |
| ifdef::VK_VERSION_1_2[] |
| include::{generated}/api/protos/vkGetSemaphoreCounterValue.adoc[] |
| endif::VK_VERSION_1_2[] |
| |
| ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| include::{generated}/api/protos/vkGetSemaphoreCounterValueKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:device is the logical device that owns the semaphore. |
| * pname:semaphore is the handle of the semaphore to query. |
| * pname:pValue is a pointer to a 64-bit integer value in which the current |
| counter value of the semaphore is returned. |
| |
| [NOTE] |
| .Note |
| ==== |
| If a <<devsandqueues-submission, queue submission>> command is pending |
| execution, then the value returned by this command may: immediately be out |
| of date. |
| ==== |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetSemaphoreCounterValue-semaphore-03255]] |
| pname:semaphore must: have been created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| **** |
| |
| include::{generated}/validity/protos/vkGetSemaphoreCounterValue.adoc[] |
| -- |
| |
| [open,refpage='vkWaitSemaphores',desc='Wait for timeline semaphores on the host',type='protos',alias='vkWaitSemaphoresKHR'] |
| -- |
| :refpage: vkWaitSemaphores |
| |
| To wait for a set of semaphores created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE to reach particular counter values on the |
| host, call: |
| |
| ifdef::VK_VERSION_1_2[] |
| include::{generated}/api/protos/vkWaitSemaphores.adoc[] |
| endif::VK_VERSION_1_2[] |
| |
| ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| include::{generated}/api/protos/vkWaitSemaphoresKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:device is the logical device that owns the semaphores. |
| * pname:pWaitInfo is a pointer to a slink:VkSemaphoreWaitInfo structure |
| containing information about the wait condition. |
| * pname:timeout is the timeout period in units of nanoseconds. |
| pname:timeout is adjusted to the closest value allowed by the |
| implementation-dependent timeout accuracy, which may: be substantially |
| longer than one nanosecond, and may: be longer than the requested |
| period. |
| |
| If the condition is satisfied when fname:vkWaitSemaphores is called, then |
| fname:vkWaitSemaphores returns immediately. |
| If the condition is not satisfied at the time fname:vkWaitSemaphores is |
| called, then fname:vkWaitSemaphores will block and wait until the condition |
| is satisfied or the pname:timeout has expired, whichever is sooner. |
| |
| If pname:timeout is zero, then fname:vkWaitSemaphores does not wait, but |
| simply returns information about the current state of the semaphores. |
| ename:VK_TIMEOUT will be returned in this case if the condition is not |
| satisfied, even though no actual wait was performed. |
| |
| If the condition is satisfied before the pname:timeout has expired, |
| fname:vkWaitSemaphores returns ename:VK_SUCCESS. |
| Otherwise, fname:vkWaitSemaphores returns ename:VK_TIMEOUT after the |
| pname:timeout has expired. |
| |
| If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before |
| the timeout has expired, fname:vkWaitSemaphores must: return in finite time |
| with either ename:VK_SUCCESS or ename:VK_ERROR_DEVICE_LOST. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkWaitSemaphores.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreWaitInfo',desc='Structure containing information about the semaphore wait condition',type='structs',alias='VkSemaphoreWaitInfoKHR'] |
| -- |
| The sname:VkSemaphoreWaitInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreWaitInfo.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkSemaphoreWaitInfoKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:flags is a bitmask of elink:VkSemaphoreWaitFlagBits specifying |
| additional parameters for the semaphore wait operation. |
| * pname:semaphoreCount is the number of semaphores to wait on. |
| * pname:pSemaphores is a pointer to an array of pname:semaphoreCount |
| semaphore handles to wait on. |
| * pname:pValues is a pointer to an array of pname:semaphoreCount timeline |
| semaphore values. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreWaitInfo-pSemaphores-03256]] |
| All of the elements of pname:pSemaphores must: reference a semaphore |
| that was created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| * [[VUID-VkSemaphoreWaitInfo-pSemaphores-05124]] |
| If any of the semaphores in pname:pSemaphores have stext:NvSciSyncObj as |
| payload, application must: calculate the corresponding timeline |
| semaphore values in pname:pValues by calling |
| <<NvSciSync2-extension-page, NvSciSync APIs>>. |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreWaitInfo.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreWaitFlagBits',desc='Bitmask specifying additional parameters of a semaphore wait operation',type='enums',alias='VkSemaphoreWaitFlagBitsKHR'] |
| -- |
| Bits which can: be set in slink:VkSemaphoreWaitInfo::pname:flags, specifying |
| additional parameters of a semaphore wait operation, are: |
| |
| include::{generated}/api/enums/VkSemaphoreWaitFlagBits.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkSemaphoreWaitFlagBitsKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * ename:VK_SEMAPHORE_WAIT_ANY_BIT specifies that the semaphore wait |
| condition is that at least one of the semaphores in |
| sname:VkSemaphoreWaitInfo::pname:pSemaphores has reached the value |
| specified by the corresponding element of |
| sname:VkSemaphoreWaitInfo::pname:pValues. |
| If ename:VK_SEMAPHORE_WAIT_ANY_BIT is not set, the semaphore wait |
| condition is that all of the semaphores in |
| sname:VkSemaphoreWaitInfo::pname:pSemaphores have reached the value |
| specified by the corresponding element of |
| sname:VkSemaphoreWaitInfo::pname:pValues. |
| -- |
| |
| [open,refpage='VkSemaphoreWaitFlags',desc='Bitmask of VkSemaphoreWaitFlagBits',type='flags',alias='VkSemaphoreWaitFlagsKHR'] |
| -- |
| include::{generated}/api/flags/VkSemaphoreWaitFlags.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/flags/VkSemaphoreWaitFlagsKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| tname:VkSemaphoreWaitFlags is a bitmask type for setting a mask of zero or |
| more elink:VkSemaphoreWaitFlagBits. |
| -- |
| |
| [open,refpage='vkSignalSemaphore',desc='Signal a timeline semaphore on the host',type='protos',alias='vkSignalSemaphoreKHR'] |
| -- |
| :refpage: vkSignalSemaphore |
| |
| To signal a semaphore created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE with a particular counter value, on the |
| host, call: |
| |
| ifdef::VK_VERSION_1_2[] |
| include::{generated}/api/protos/vkSignalSemaphore.adoc[] |
| endif::VK_VERSION_1_2[] |
| |
| ifdef::VK_VERSION_1_2+VK_KHR_timeline_semaphore[or the equivalent command] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| include::{generated}/api/protos/vkSignalSemaphoreKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:device is the logical device that owns the semaphore. |
| * pname:pSignalInfo is a pointer to a slink:VkSemaphoreSignalInfo |
| structure containing information about the signal operation. |
| |
| When fname:vkSignalSemaphore is executed on the host, it defines and |
| immediately executes a <<synchronization-semaphores-signaling,_semaphore |
| signal operation_>> which sets the timeline semaphore to the given value. |
| |
| The first synchronization scope is defined by the host execution model, but |
| includes execution of fname:vkSignalSemaphore on the host and anything that |
| happened-before it. |
| |
| The second synchronization scope is empty. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkSignalSemaphore.adoc[] |
| -- |
| |
| [open,refpage='VkSemaphoreSignalInfo',desc='Structure containing information about a semaphore signal operation',type='structs',alias='VkSemaphoreSignalInfoKHR'] |
| -- |
| The sname:VkSemaphoreSignalInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkSemaphoreSignalInfo.adoc[] |
| |
| ifdef::VK_KHR_timeline_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkSemaphoreSignalInfoKHR.adoc[] |
| endif::VK_KHR_timeline_semaphore[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the handle of the semaphore to signal. |
| * pname:value is the value to signal. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkSemaphoreSignalInfo-semaphore-03257]] |
| pname:semaphore must: have been created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| * [[VUID-VkSemaphoreSignalInfo-value-03258]] |
| pname:value must: have a value greater than the current value of the |
| semaphore |
| * [[VUID-VkSemaphoreSignalInfo-value-03259]] |
| pname:value must: be less than the value of any pending semaphore signal |
| operations |
| * [[VUID-VkSemaphoreSignalInfo-value-03260]] |
| pname:value must: have a value which does not differ from the current |
| value of the semaphore or the value of any outstanding semaphore wait or |
| signal operation on pname:semaphore by more than |
| <<limits-maxTimelineSemaphoreValueDifference, |
| pname:maxTimelineSemaphoreValueDifference>> |
| ifdef::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| * [[VUID-VkSemaphoreSignalInfo-semaphores-05125]] |
| If pname:semaphores has stext:NvSciSyncObj as payload, application must: |
| calculate the corresponding timeline semaphore value in pname:value by |
| calling <<NvSciSync2-extension-page, NvSciSync APIs>>. |
| endif::VK_NV_external_sci_sync,VK_NV_external_sci_sync2[] |
| **** |
| |
| include::{generated}/validity/structs/VkSemaphoreSignalInfo.adoc[] |
| -- |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| [[synchronization-semaphores-importing]] |
| === Importing Semaphore Payloads |
| |
| Applications can: import a semaphore payload into an existing semaphore |
| using an external semaphore handle. |
| The effects of the import operation will be either temporary or permanent, |
| as specified by the application. |
| If the import is temporary, the implementation must: restore the semaphore |
| to its prior permanent state after submitting the next semaphore wait |
| operation. |
| Performing a subsequent temporary import on a semaphore before performing a |
| semaphore wait has no effect on this requirement; the next wait submitted on |
| the semaphore must: still restore its last permanent state. |
| A permanent payload import behaves as if the target semaphore was destroyed, |
| and a new semaphore was created with the same handle but the imported |
| payload. |
| Because importing a semaphore payload temporarily or permanently detaches |
| the existing payload from a semaphore, similar usage restrictions to those |
| applied to fname:vkDestroySemaphore are applied to any command that imports |
| a semaphore payload. |
| Which of these import types is used is referred to as the import operation's |
| _permanence_. |
| Each handle type supports either one or both types of permanence. |
| |
| The implementation must: perform the import operation by either referencing |
| or copying the payload referred to by the specified external semaphore |
| handle, depending on the handle's type. |
| The import method used is referred to as the handle type's _transference_. |
| When using handle types with reference transference, importing a payload to |
| a semaphore adds the semaphore to the set of all semaphores sharing that |
| payload. |
| This set includes the semaphore from which the payload was exported. |
| Semaphore signaling and waiting operations performed on any semaphore in the |
| set must: behave as if the set were a single semaphore. |
| Importing a payload using handle types with copy transference creates a |
| duplicate copy of the payload at the time of import, but makes no further |
| reference to it. |
| Semaphore signaling and waiting operations performed on the target of copy |
| imports must: not affect any other semaphore or payload. |
| |
| Export operations have the same transference as the specified handle type's |
| import operations. |
| Additionally, exporting a semaphore payload to a handle with copy |
| transference has the same side effects on the source semaphore's payload as |
| executing a semaphore wait operation. |
| If the semaphore was using a temporarily imported payload, the semaphore's |
| prior permanent payload will be restored. |
| |
| ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] |
| [NOTE] |
| .Note |
| ==== |
| The permanence and transference of handle types can be found in: |
| |
| ifdef::VK_KHR_external_semaphore_win32[] |
| * <<synchronization-semaphore-handletypes-win32,Handle Types Supported by |
| sname:VkImportSemaphoreWin32HandleInfoKHR>> |
| endif::VK_KHR_external_semaphore_win32[] |
| ifdef::VK_KHR_external_semaphore_fd[] |
| * <<synchronization-semaphore-handletypes-fd,Handle Types Supported by |
| sname:VkImportSemaphoreFdInfoKHR>> |
| endif::VK_KHR_external_semaphore_fd[] |
| ifdef::VK_FUCHSIA_external_semaphore[] |
| * <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported |
| by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> |
| endif::VK_FUCHSIA_external_semaphore[] |
| ==== |
| endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] |
| |
| <<fundamentals-threadingbehavior,External synchronization>> allows |
| implementations to modify an object's internal state, i.e. payload, without |
| internal synchronization. |
| However, for semaphores sharing a payload across processes, satisfying the |
| external synchronization requirements of sname:VkSemaphore parameters as if |
| all semaphores in the set were the same object is sometimes infeasible. |
| Satisfying the <<synchronization-semaphores-waiting-state,wait operation |
| state requirements>> would similarly require impractical coordination or |
| levels of trust between processes. |
| Therefore, these constraints only apply to a specific semaphore handle, not |
| to its payload. |
| For distinct semaphore objects which share a payload, if the semaphores are |
| passed to separate queue submission commands concurrently, behavior will be |
| as if the commands were called in an arbitrary sequential order. |
| If the <<synchronization-semaphores-waiting-state,wait operation state |
| requirements>> are violated for the shared payload by a queue submission |
| command, or if a signal operation is queued for a shared payload that is |
| already signaled or has a pending signal operation, effects must: be limited |
| to one or more of the following: |
| |
| * Returning ename:VK_ERROR_INITIALIZATION_FAILED from the command which |
| resulted in the violation. |
| * Losing the logical device on which the violation occurred immediately or |
| at a future time, resulting in a ename:VK_ERROR_DEVICE_LOST error from |
| subsequent commands, including the one causing the violation. |
| * Continuing execution of the violating command or operation as if the |
| semaphore wait completed successfully after an implementation-dependent |
| timeout. |
| In this case, the state of the payload becomes undefined:, and future |
| operations on semaphores sharing the payload will be subject to these |
| same rules. |
| The semaphore must: be destroyed or have its payload replaced by an |
| import operation to again have a well-defined state. |
| |
| [NOTE] |
| .Note |
| ==== |
| These rules allow processes to synchronize access to shared memory without |
| trusting each other. |
| However, such processes must still be cautious not to use the shared |
| semaphore for more than synchronizing access to the shared memory. |
| For example, a process should not use a shared semaphore as part of an |
| execution dependency chain that, when complete, leads to objects being |
| destroyed, if it does not trust other processes sharing the semaphore |
| payload. |
| ==== |
| |
| When a semaphore is using an imported payload, its |
| slink:VkExportSemaphoreCreateInfo::pname:handleTypes value is specified when |
| creating the semaphore from which the payload was exported, rather than |
| specified when creating the semaphore. |
| Additionally, |
| slink:VkExternalSemaphoreProperties::pname:exportFromImportedHandleTypes |
| restricts which handle types can: be exported from such a semaphore based on |
| the specific handle type used to import the current payload. |
| ifdef::VK_KHR_swapchain[] |
| Passing a semaphore to flink:vkAcquireNextImageKHR is equivalent to |
| temporarily importing a semaphore payload to that semaphore. |
| |
| [NOTE] |
| .Note |
| ==== |
| Because the exportable handle types of an imported semaphore correspond to |
| its current imported payload, and flink:vkAcquireNextImageKHR behaves the |
| same as a temporary import operation for which the source semaphore is |
| opaque to the application, applications have no way of determining whether |
| any external handle types can: be exported from a semaphore in this state. |
| Therefore, applications must: not attempt to export external handles from |
| semaphores using a temporarily imported payload from |
| flink:vkAcquireNextImageKHR. |
| ==== |
| endif::VK_KHR_swapchain[] |
| |
| When importing a semaphore payload, it is the responsibility of the |
| application to ensure the external handles meet all valid usage |
| requirements. |
| However, implementations must: perform sufficient validation of external |
| handles to ensure that the operation results in a valid semaphore which will |
| not cause program termination, device loss, queue stalls, or corruption of |
| other resources when used as allowed according to its import parameters, and |
| excepting those side effects allowed for violations of the |
| <<synchronization-semaphores-waiting-state,valid semaphore state for wait |
| operations>> rules. |
| If the external handle provided does not meet these requirements, the |
| implementation must: fail the semaphore payload import operation with the |
| error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. |
| |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| In addition, when importing a semaphore payload that is not compatible with |
| the payload type corresponding to the elink:VkSemaphoreType the semaphore |
| was created with, the implementation may: fail the semaphore payload import |
| operation with the error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE. |
| |
| [NOTE] |
| .Note |
| ==== |
| As the introduction of the external semaphore handle type |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT predates that of |
| timeline semaphores, support for importing semaphore payloads from external |
| handles of that type into semaphores created (implicitly or explicitly) with |
| a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_BINARY is preserved for |
| backwards compatibility. |
| However, applications should: prefer importing such handle types into |
| semaphores created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE. |
| ==== |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| |
| ifdef::VK_KHR_external_semaphore_win32[] |
| [open,refpage='vkImportSemaphoreWin32HandleKHR',desc='Import a semaphore from a Windows HANDLE',type='protos'] |
| -- |
| To import a semaphore payload from a Windows handle, call: |
| |
| include::{generated}/api/protos/vkImportSemaphoreWin32HandleKHR.adoc[] |
| |
| * pname:device is the logical device that created the semaphore. |
| * pname:pImportSemaphoreWin32HandleInfo is a pointer to a |
| slink:VkImportSemaphoreWin32HandleInfoKHR structure specifying the |
| semaphore and import parameters. |
| |
| Importing a semaphore payload from Windows handles does not transfer |
| ownership of the handle to the Vulkan implementation. |
| For handle types defined as NT handles, the application must: release |
| ownership using the code:CloseHandle system call when the handle is no |
| longer needed. |
| |
| Applications can: import the same semaphore payload into multiple instances |
| of Vulkan, into the same instance from which it was exported, and multiple |
| times into a given Vulkan instance. |
| |
| include::{generated}/validity/protos/vkImportSemaphoreWin32HandleKHR.adoc[] |
| -- |
| |
| [open,refpage='VkImportSemaphoreWin32HandleInfoKHR',desc='Structure specifying Windows handle to import to a semaphore',type='structs'] |
| -- |
| The sname:VkImportSemaphoreWin32HandleInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore into which the payload will be |
| imported. |
| * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying |
| additional parameters for the semaphore payload import operation. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of pname:handle. |
| * pname:handle is `NULL` or the external handle to import. |
| * pname:name is `NULL` or a null-terminated UTF-16 string naming the |
| underlying synchronization primitive to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-semaphore-handletypes-win32]] |
| .Handle Types Supported by sname:VkImportSemaphoreWin32HandleInfoKHR |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | Reference | Temporary,Permanent |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | Reference | Temporary,Permanent |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT | Reference | Temporary,Permanent |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140]] |
| pname:handleType must: be a value included in the |
| <<synchronization-semaphore-handletypes-win32,Handle Types Supported by |
| sname:VkImportSemaphoreWin32HandleInfoKHR>> table |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01466]] |
| If pname:handleType is not |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, pname:name |
| must: be `NULL` |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01467]] |
| If pname:handle is `NULL`, pname:name must: name a valid synchronization |
| primitive of the type specified by pname:handleType |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01468]] |
| If pname:name is `NULL`, pname:handle must: be a valid handle of the |
| type specified by pname:handleType |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01469]] |
| If pname:handle is not `NULL`, pname:name must: be `NULL` |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01542]] |
| If pname:handle is not `NULL`, it must: obey any requirements listed for |
| pname:handleType in |
| <<external-semaphore-handle-types-compatibility,external semaphore |
| handle types compatibility>> |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-name-01543]] |
| If pname:name is not `NULL`, it must: obey any requirements listed for |
| pname:handleType in |
| <<external-semaphore-handle-types-compatibility,external semaphore |
| handle types compatibility>> |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03261]] |
| If pname:handleType is |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the |
| slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the |
| semaphore from which pname:handle or pname:name was exported |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-03262]] |
| If pname:handleType is |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT or |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, the |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match |
| that of the semaphore from which pname:handle or pname:name was exported |
| * [[VUID-VkImportSemaphoreWin32HandleInfoKHR-flags-03322]] |
| If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the |
| semaphore from which pname:handle or pname:name was exported must: not |
| be ename:VK_SEMAPHORE_TYPE_TIMELINE |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| **** |
| |
| include::{generated}/validity/structs/VkImportSemaphoreWin32HandleInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_semaphore_win32[] |
| |
| ifdef::VK_KHR_external_semaphore_fd[] |
| [open,refpage='vkImportSemaphoreFdKHR',desc='Import a semaphore from a POSIX file descriptor',type='protos'] |
| -- |
| :refpage: vkImportSemaphoreFdKHR |
| |
| To import a semaphore payload from a POSIX file descriptor, call: |
| |
| include::{generated}/api/protos/vkImportSemaphoreFdKHR.adoc[] |
| |
| * pname:device is the logical device that created the semaphore. |
| * pname:pImportSemaphoreFdInfo is a pointer to a |
| slink:VkImportSemaphoreFdInfoKHR structure specifying the semaphore and |
| import parameters. |
| |
| Importing a semaphore payload from a file descriptor transfers ownership of |
| the file descriptor from the application to the Vulkan implementation. |
| The application must: not perform any operations on the file descriptor |
| after a successful import. |
| |
| Applications can: import the same semaphore payload into multiple instances |
| of Vulkan, into the same instance from which it was exported, and multiple |
| times into a given Vulkan instance. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportSemaphoreFdKHR-semaphore-01142]] |
| pname:semaphore must: not be associated with any queue command that has |
| not yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/protos/vkImportSemaphoreFdKHR.adoc[] |
| -- |
| |
| [open,refpage='VkImportSemaphoreFdInfoKHR',desc='Structure specifying POSIX file descriptor to import to a semaphore',type='structs'] |
| -- |
| The sname:VkImportSemaphoreFdInfoKHR structure is defined as: |
| |
| include::{generated}/api/structs/VkImportSemaphoreFdInfoKHR.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore into which the payload will be |
| imported. |
| * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying |
| additional parameters for the semaphore payload import operation. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of pname:fd. |
| * pname:fd is the external handle to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-semaphore-handletypes-fd]] |
| .Handle Types Supported by sname:VkImportSemaphoreFdInfoKHR |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | Reference | Temporary,Permanent |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT | Copy | Temporary |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-01143]] |
| pname:handleType must: be a value included in the |
| <<synchronization-semaphore-handletypes-fd,Handle Types Supported by |
| sname:VkImportSemaphoreFdInfoKHR>> table |
| * [[VUID-VkImportSemaphoreFdInfoKHR-fd-01544]] |
| pname:fd must: obey any requirements listed for pname:handleType in |
| <<external-semaphore-handle-types-compatibility,external semaphore |
| handle types compatibility>> |
| * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03263]] |
| If pname:handleType is |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the |
| slink:VkSemaphoreCreateInfo::pname:flags field must: match that of the |
| semaphore from which pname:fd was exported |
| * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-07307]] |
| If pname:handleType refers to a handle type with copy payload |
| transference semantics, pname:flags must: contain |
| ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| * [[VUID-VkImportSemaphoreFdInfoKHR-handleType-03264]] |
| If pname:handleType is |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, the |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: match |
| that of the semaphore from which pname:fd was exported |
| * [[VUID-VkImportSemaphoreFdInfoKHR-flags-03323]] |
| If pname:flags contains ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the |
| slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field of the |
| semaphore from which pname:fd was exported must: not be |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| **** |
| |
| If pname:handleType is ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, |
| the special value `-1` for pname:fd is treated like a valid sync file |
| descriptor referring to an object that has already signaled. |
| The import operation will succeed and the sname:VkSemaphore will have a |
| temporarily imported payload as if a valid file descriptor had been |
| provided. |
| |
| [NOTE] |
| .Note |
| ==== |
| This special behavior for importing an invalid sync file descriptor allows |
| easier interoperability with other system APIs which use the convention that |
| an invalid sync file descriptor represents work that has already completed |
| and does not need to be waited for. |
| It is consistent with the option for implementations to return a `-1` file |
| descriptor when exporting a |
| ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT from a sname:VkSemaphore |
| which is signaled. |
| ==== |
| |
| include::{generated}/validity/structs/VkImportSemaphoreFdInfoKHR.adoc[] |
| -- |
| endif::VK_KHR_external_semaphore_fd[] |
| |
| ifdef::VK_FUCHSIA_external_semaphore[] |
| [open,refpage='vkImportSemaphoreZirconHandleFUCHSIA',desc='Import a semaphore from a Zircon event handle',type='protos'] |
| -- |
| To import a semaphore payload from a Zircon event handle, call: |
| |
| include::{generated}/api/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] |
| |
| * pname:device is the logical device that created the semaphore. |
| * pname:pImportSemaphoreZirconHandleInfo is a pointer to a |
| slink:VkImportSemaphoreZirconHandleInfoFUCHSIA structure specifying the |
| semaphore and import parameters. |
| |
| Importing a semaphore payload from a Zircon event handle transfers ownership |
| of the handle from the application to the Vulkan implementation. |
| The application must: not perform any operations on the handle after a |
| successful import. |
| |
| Applications can: import the same semaphore payload into multiple instances |
| of Vulkan, into the same instance from which it was exported, and multiple |
| times into a given Vulkan instance. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportSemaphoreZirconHandleFUCHSIA-semaphore-04764]] |
| pname:semaphore must: not be associated with any queue command that has |
| not yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/protos/vkImportSemaphoreZirconHandleFUCHSIA.adoc[] |
| -- |
| |
| [open,refpage='VkImportSemaphoreZirconHandleInfoFUCHSIA',desc='Structure specifying Zircon event handle to import to a semaphore',type='structs'] |
| -- |
| The sname:VkImportSemaphoreZirconHandleInfoFUCHSIA structure is defined as: |
| |
| include::{generated}/api/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore into which the payload will be |
| imported. |
| * pname:flags is a bitmask of elink:VkSemaphoreImportFlagBits specifying |
| additional parameters for the semaphore payload import operation. |
| * pname:handleType is a elink:VkExternalSemaphoreHandleTypeFlagBits value |
| specifying the type of pname:zirconHandle. |
| * pname:zirconHandle is the external handle to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-semaphore-handletypes-fuchsia]] |
| .Handle Types Supported by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA | Reference | Temporary,Permanent |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-handleType-04765]] |
| pname:handleType must: be a value included in the |
| <<synchronization-semaphore-handletypes-fuchsia,Handle Types Supported |
| by sname:VkImportSemaphoreZirconHandleInfoFUCHSIA>> table |
| * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04766]] |
| pname:zirconHandle must: obey any requirements listed for |
| pname:handleType in |
| <<external-semaphore-handle-types-compatibility,external semaphore |
| handle types compatibility>> |
| * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-zirconHandle-04767]] |
| pname:zirconHandle must: have code:ZX_RIGHTS_BASIC and |
| code:ZX_RIGHTS_SIGNAL rights |
| ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| * [[VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-semaphoreType-04768]] |
| The slink:VkSemaphoreTypeCreateInfo::pname:semaphoreType field must: not |
| be ename:VK_SEMAPHORE_TYPE_TIMELINE |
| endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] |
| **** |
| |
| include::{generated}/validity/structs/VkImportSemaphoreZirconHandleInfoFUCHSIA.adoc[] |
| -- |
| endif::VK_FUCHSIA_external_semaphore[] |
| |
| ifdef::VK_NV_external_sci_sync[] |
| [open,refpage='vkImportSemaphoreSciSyncObjNV',desc='Import a semaphore from a SciSync handle',type='protos'] |
| -- |
| To import a semaphore payload from a stext:NvSciSyncObj, call: |
| |
| include::{generated}/api/protos/vkImportSemaphoreSciSyncObjNV.adoc[] |
| |
| * pname:device is the logical device that created the semaphore. |
| * pname:pImportSemaphoreSciSyncInfo is a pointer to a |
| slink:VkImportSemaphoreSciSyncInfoNV structure containing parameters of |
| the import operation |
| |
| Importing a semaphore payload from stext:NvSciSyncObj does not transfer |
| ownership of the handle to the Vulkan implementation. |
| When importing stext:NvSciSyncObj, Vulkan will make a new reference to that |
| object, the application must: release its ownership using |
| <<NvSciSync-extension-page, NvSciSync APIs>> when that ownership is no |
| longer needed. |
| |
| Application must: not import the same stext:NvSciSyncObj with signaler |
| access permissions into multiple instances of VkSemaphore, and must: not |
| import into the same instance from which it was exported. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkImportSemaphoreSciSyncObjNV-sciSyncImport-05155]] |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncImport and |
| slink:VkPhysicalDeviceExternalSciSyncFeaturesNV::pname:sciSyncSemaphore |
| must: be enabled |
| **** |
| |
| include::{generated}/validity/protos/vkImportSemaphoreSciSyncObjNV.adoc[] |
| -- |
| |
| [open,refpage='VkImportSemaphoreSciSyncInfoNV',desc='Structure specifying SciSync handle to import to a semaphore',type='structs'] |
| -- |
| The sname:VkImportSemaphoreSciSyncInfoNV structure is defined as: |
| |
| include::{generated}/api/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:semaphore is the semaphore into which the payload will be |
| imported. |
| * pname:handleType specifies the type of stext:handle. |
| * pname:handle is the external handle to import. |
| |
| The handle types supported by pname:handleType are: |
| |
| [[synchronization-semaphore-handletypes-sci-sync]] |
| .Handle Types Supported by sname:VkImportSemaphoreSciSyncInfoNV |
| [width="80%",options="header"] |
| |==== |
| | Handle Type | Transference | Permanence Supported |
| | ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SCI_SYNC_OBJ_BIT_NV | Reference | Permanent |
| |==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkImportSemaphoreSciSyncInfoNV-handleType-05126]] |
| pname:handleType must: be a value included in the |
| <<synchronization-semaphore-handletypes-sci-sync, Handle Types Supported |
| by sname:VkImportSemaphoreSciSyncInfoNV>> table |
| * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05127]] |
| pname:semaphore must: have been created with a elink:VkSemaphoreType of |
| ename:VK_SEMAPHORE_TYPE_TIMELINE |
| * [[VUID-VkImportSemaphoreSciSyncInfoNV-semaphore-05128]] |
| pname:semaphore must: not be associated with any queue command that has |
| not yet completed execution on that queue |
| **** |
| |
| include::{generated}/validity/structs/VkImportSemaphoreSciSyncInfoNV.adoc[] |
| -- |
| endif::VK_NV_external_sci_sync[] |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| ifdef::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] |
| [open,refpage='VkSemaphoreImportFlagBits',desc='Bitmask specifying additional parameters of semaphore payload import',type='enums'] |
| -- |
| Bits which can: be set in |
| |
| ifdef::VK_KHR_external_semaphore_win32[] |
| * slink:VkImportSemaphoreWin32HandleInfoKHR::pname:flags |
| endif::VK_KHR_external_semaphore_win32[] |
| ifdef::VK_KHR_external_semaphore_fd[] |
| * slink:VkImportSemaphoreFdInfoKHR::pname:flags |
| endif::VK_KHR_external_semaphore_fd[] |
| ifdef::VK_FUCHSIA_external_semaphore[] |
| * slink:VkImportSemaphoreZirconHandleInfoFUCHSIA::pname:flags |
| endif::VK_FUCHSIA_external_semaphore[] |
| |
| specifying additional parameters of a semaphore import operation are: |
| |
| include::{generated}/api/enums/VkSemaphoreImportFlagBits.adoc[] |
| |
| ifdef::VK_KHR_external_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VkSemaphoreImportFlagBitsKHR.adoc[] |
| endif::VK_KHR_external_semaphore[] |
| |
| These bits have the following meanings: |
| |
| * ename:VK_SEMAPHORE_IMPORT_TEMPORARY_BIT specifies that the semaphore |
| payload will be imported only temporarily, as described in |
| <<synchronization-semaphores-importing,Importing Semaphore Payloads>>, |
| regardless of the permanence of pname:handleType. |
| -- |
| |
| [open,refpage='VkSemaphoreImportFlags',desc='Bitmask of VkSemaphoreImportFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkSemaphoreImportFlags.adoc[] |
| |
| ifdef::VK_KHR_external_semaphore[] |
| or the equivalent |
| |
| include::{generated}/api/flags/VkSemaphoreImportFlagsKHR.adoc[] |
| endif::VK_KHR_external_semaphore[] |
| |
| tname:VkSemaphoreImportFlags is a bitmask type for setting a mask of zero or |
| more elink:VkSemaphoreImportFlagBits. |
| -- |
| endif::VK_KHR_external_semaphore_win32,VK_KHR_external_semaphore_fd,VK_FUCHSIA_external_semaphore[] |
| endif::VK_VERSION_1_1,VK_KHR_external_semaphore[] |
| |
| |
| [[synchronization-events]] |
| == Events |
| |
| [open,refpage='VkEvent',desc='Opaque handle to an event object',type='handles'] |
| -- |
| Events are a synchronization primitive that can: be used to insert a |
| fine-grained dependency between commands submitted to the same queue, or |
| between the host and a queue. |
| Events must: not be used to insert a dependency between commands submitted |
| to different queues. |
| Events have two states - signaled and unsignaled. |
| An application can: signal or unsignal an event either on the host or on the |
| device. |
| A device can: be made to wait for an event to become signaled before |
| executing further operations. |
| No command exists to wait for an event to become signaled on the host, but |
| the current state of an event can: be queried. |
| |
| Events are represented by sname:VkEvent handles: |
| |
| include::{generated}/api/handles/VkEvent.adoc[] |
| -- |
| |
| [open,refpage='vkCreateEvent',desc='Create a new event object',type='protos'] |
| -- |
| :refpage: vkCreateEvent |
| :objectnameplural: events |
| :objectnamecamelcase: event |
| :objectcount: 1 |
| |
| To create an event, call: |
| |
| include::{generated}/api/protos/vkCreateEvent.adoc[] |
| |
| * pname:device is the logical device that creates the event. |
| * pname:pCreateInfo is a pointer to a slink:VkEventCreateInfo structure |
| containing information about how the event is to be created. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| * pname:pEvent is a pointer to a handle in which the resulting event |
| object is returned. |
| |
| When created, the event object is in the unsignaled state. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| .Valid Usage |
| **** |
| ifdef::VK_KHR_portability_subset[] |
| * [[VUID-vkCreateEvent-events-04468]] |
| If the `apiext:VK_KHR_portability_subset` extension is enabled, and |
| slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:events is |
| ename:VK_FALSE, then the implementation does not support |
| <<synchronization-events, events>>, and flink:vkCreateEvent must: not be |
| used |
| endif::VK_KHR_portability_subset[] |
| include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] |
| **** |
| |
| include::{generated}/validity/protos/vkCreateEvent.adoc[] |
| -- |
| |
| [open,refpage='VkEventCreateInfo',desc='Structure specifying parameters of a newly created event',type='structs'] |
| -- |
| The sname:VkEventCreateInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkEventCreateInfo.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:flags is a bitmask of elink:VkEventCreateFlagBits defining |
| additional creation parameters. |
| |
| ifdef::VK_EXT_metal_objects[] |
| .Valid Usage |
| **** |
| * [[VUID-VkEventCreateInfo-pNext-06790]] |
| If the pname:pNext chain includes a |
| slink:VkExportMetalObjectCreateInfoEXT structure, its |
| pname:exportObjectType member must: be |
| ename:VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT |
| **** |
| endif::VK_EXT_metal_objects[] |
| |
| include::{generated}/validity/structs/VkEventCreateInfo.adoc[] |
| -- |
| |
| [open,refpage='VkEventCreateFlagBits',desc='Event creation flag bits',type='enums'] |
| -- |
| include::{generated}/api/enums/VkEventCreateFlagBits.adoc[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT specifies that host event commands |
| will not be used with this event. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [NOTE] |
| .Note |
| ==== |
| All bits for this type are defined by extensions, and none of those |
| extensions are enabled in this build of the specification. |
| ==== |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| -- |
| |
| [open,refpage='VkEventCreateFlags',desc='Bitmask of event creation flag bits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkEventCreateFlags.adoc[] |
| |
| tname:VkEventCreateFlags is a bitmask type for setting a mask of |
| elink:VkEventCreateFlagBits. |
| -- |
| |
| [open,refpage='vkDestroyEvent',desc='Destroy an event object',type='protos'] |
| -- |
| To destroy an event, call: |
| |
| include::{generated}/api/protos/vkDestroyEvent.adoc[] |
| |
| * pname:device is the logical device that destroys the event. |
| * pname:event is the handle of the event to destroy. |
| * pname:pAllocator controls host memory allocation as described in the |
| <<memory-allocation, Memory Allocation>> chapter. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkDestroyEvent-event-01145]] |
| All submitted commands that refer to pname:event must: have completed |
| execution |
| ifndef::VKSC_VERSION_1_0[] |
| * [[VUID-vkDestroyEvent-event-01146]] |
| If sname:VkAllocationCallbacks were provided when pname:event was |
| created, a compatible set of callbacks must: be provided here |
| * [[VUID-vkDestroyEvent-event-01147]] |
| If no sname:VkAllocationCallbacks were provided when pname:event was |
| created, pname:pAllocator must: be `NULL` |
| endif::VKSC_VERSION_1_0[] |
| **** |
| |
| include::{generated}/validity/protos/vkDestroyEvent.adoc[] |
| -- |
| |
| [open,refpage='vkGetEventStatus',desc='Retrieve the status of an event object',type='protos'] |
| -- |
| :refpage: vkGetEventStatus |
| |
| To query the state of an event from the host, call: |
| |
| include::{generated}/api/protos/vkGetEventStatus.adoc[] |
| |
| * pname:device is the logical device that owns the event. |
| * pname:event is the handle of the event to query. |
| |
| Upon success, fname:vkGetEventStatus returns the state of the event object |
| with the following return codes: |
| |
| .Event Object Status Codes |
| [width="80%",options="header"] |
| |==== |
| | Status | Meaning |
| | ename:VK_EVENT_SET | The event specified by pname:event is signaled. |
| | ename:VK_EVENT_RESET | The event specified by pname:event is unsignaled. |
| |==== |
| |
| If a fname:vkCmdSetEvent or fname:vkCmdResetEvent command is in a command |
| buffer that is in the <<commandbuffers-lifecycle, pending state>>, then the |
| value returned by this command may: immediately be out of date. |
| |
| The state of an event can: be updated by the host. |
| The state of the event is immediately changed, and subsequent calls to |
| fname:vkGetEventStatus will return the new state. |
| If an event is already in the requested state, then updating it to the same |
| state has no effect. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| .Valid Usage |
| **** |
| * [[VUID-vkGetEventStatus-event-03940]] |
| pname:event must: not have been created with |
| ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT |
| **** |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| include::{generated}/validity/protos/vkGetEventStatus.adoc[] |
| -- |
| |
| [[synchronization-events-signaling-host]] |
| [open,refpage='vkSetEvent',desc='Set an event to signaled state',type='protos'] |
| -- |
| :refpage: vkSetEvent |
| |
| To set the state of an event to signaled from the host, call: |
| |
| include::{generated}/api/protos/vkSetEvent.adoc[] |
| |
| * pname:device is the logical device that owns the event. |
| * pname:event is the event to set. |
| |
| When flink:vkSetEvent is executed on the host, it defines an _event signal |
| operation_ which sets the event to the signaled state. |
| |
| If pname:event is already in the signaled state when flink:vkSetEvent is |
| executed, then flink:vkSetEvent has no effect, and no event signal operation |
| occurs. |
| |
| [NOTE] |
| .Note |
| ==== |
| If a command buffer is waiting for an event to be signaled from the host, |
| the application must signal the event before submitting the command buffer, |
| as described in the <<commandbuffers-submission-progress, queue forward |
| progress>> section. |
| ==== |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| .Valid Usage |
| **** |
| * [[VUID-vkSetEvent-event-03941]] |
| pname:event must: not have been created with |
| ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT |
| **** |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| include::{generated}/validity/protos/vkSetEvent.adoc[] |
| -- |
| |
| [[synchronization-events-unsignaling-host]] |
| [open,refpage='vkResetEvent',desc='Reset an event to non-signaled state',type='protos'] |
| -- |
| To set the state of an event to unsignaled from the host, call: |
| |
| include::{generated}/api/protos/vkResetEvent.adoc[] |
| |
| * pname:device is the logical device that owns the event. |
| * pname:event is the event to reset. |
| |
| When flink:vkResetEvent is executed on the host, it defines an _event |
| unsignal operation_ which resets the event to the unsignaled state. |
| |
| If pname:event is already in the unsignaled state when flink:vkResetEvent is |
| executed, then flink:vkResetEvent has no effect, and no event unsignal |
| operation occurs. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkResetEvent-event-03821]] |
| There must: be an execution dependency between fname:vkResetEvent and |
| the execution of any flink:vkCmdWaitEvents that includes pname:event in |
| its pname:pEvents parameter |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * [[VUID-vkResetEvent-event-03822]] |
| There must: be an execution dependency between fname:vkResetEvent and |
| the execution of any flink:vkCmdWaitEvents2 that includes pname:event in |
| its pname:pEvents parameter |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * [[VUID-vkResetEvent-event-03823]] |
| pname:event must: not have been created with |
| ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| **** |
| |
| include::{generated}/validity/protos/vkResetEvent.adoc[] |
| -- |
| |
| The state of an event can: also be updated on the device by commands |
| inserted in command buffers. |
| |
| [[synchronization-events-signaling-device]] |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='vkCmdSetEvent2',desc='Set an event object to signaled state',type='protos',alias='vkCmdSetEvent2KHR'] |
| -- |
| To signal an event from a device, call: |
| |
| ifdef::VK_VERSION_1_3[] |
| include::{generated}/api/protos/vkCmdSetEvent2.adoc[] |
| endif::VK_VERSION_1_3[] |
| |
| ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] |
| |
| ifdef::VK_KHR_synchronization2[] |
| include::{generated}/api/protos/vkCmdSetEvent2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:event is the event that will be signaled. |
| * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure |
| defining the first scopes of this operation. |
| |
| When flink:vkCmdSetEvent2 is submitted to a queue, it defines the first half |
| of memory dependencies defined by pname:pDependencyInfo, as well as an event |
| signal operation which sets the event to the signaled state. |
| A memory dependency is defined between the event signal operation and |
| commands that occur earlier in submission order. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> are defined by |
| the union of all the memory dependencies defined by pname:pDependencyInfo, |
| and are applied to all operations that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| <<synchronization-queue-transfers, Queue family ownership transfers>> and |
| <<synchronization-image-layout-transitions, image layout transitions>> |
| defined by pname:pDependencyInfo are also included in the first scopes. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the event signal operation, and any |
| <<synchronization-queue-transfers, queue family ownership transfers>> and |
| <<synchronization-image-layout-transitions, image layout transitions>> |
| defined by pname:pDependencyInfo. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> |
| includes only <<synchronization-queue-transfers, queue family ownership |
| transfers>> and <<synchronization-image-layout-transitions, image layout |
| transitions>>. |
| |
| Future flink:vkCmdWaitEvents2 commands rely on all values of each element in |
| pname:pDependencyInfo matching exactly with those used to signal the |
| corresponding event. |
| flink:vkCmdWaitEvents must: not be used to wait on the result of a signal |
| operation defined by fname:vkCmdSetEvent2. |
| |
| [NOTE] |
| .Note |
| ==== |
| The extra information provided by flink:vkCmdSetEvent2 compared to |
| flink:vkCmdSetEvent allows implementations to more efficiently schedule the |
| operations required to satisfy the requested dependencies. |
| With flink:vkCmdSetEvent, the full dependency information is not known until |
| flink:vkCmdWaitEvents is recorded, forcing implementations to insert the |
| required operations at that point and not before. |
| ==== |
| |
| If pname:event is already in the signaled state when flink:vkCmdSetEvent2 is |
| executed on the device, then flink:vkCmdSetEvent2 has no effect, no event |
| signal operation occurs, and no dependency is generated. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkCmdSetEvent2-synchronization2-03824]] |
| The <<features-synchronization2, pname:synchronization2>> feature must: |
| be enabled |
| * [[VUID-vkCmdSetEvent2-dependencyFlags-03825]] |
| The pname:dependencyFlags member of pname:pDependencyInfo must: be `0` |
| * [[VUID-vkCmdSetEvent2-srcStageMask-09391]] |
| The pname:srcStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not |
| include ename:VK_PIPELINE_STAGE_2_HOST_BIT |
| * [[VUID-vkCmdSetEvent2-dstStageMask-09392]] |
| The pname:dstStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: not |
| include ename:VK_PIPELINE_STAGE_2_HOST_BIT |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdSetEvent2-commandBuffer-03826]] |
| The current device mask of pname:commandBuffer must: include exactly one |
| physical device |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdSetEvent2-srcStageMask-03827]] |
| The pname:srcStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only |
| include pipeline stages valid for the queue family that was used to |
| create the command pool that pname:commandBuffer was allocated from |
| * [[VUID-vkCmdSetEvent2-dstStageMask-03828]] |
| The pname:dstStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only |
| include pipeline stages valid for the queue family that was used to |
| create the command pool that pname:commandBuffer was allocated from |
| **** |
| |
| include::{generated}/validity/protos/vkCmdSetEvent2.adoc[] |
| -- |
| |
| [open,refpage='VkDependencyInfo',desc='Structure specifying dependency information for a synchronization command',type='structs',alias='VkDependencyInfoKHR'] |
| -- |
| The sname:VkDependencyInfo structure is defined as: |
| |
| include::{generated}/api/structs/VkDependencyInfo.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkDependencyInfoKHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits |
| specifying how execution and memory dependencies are formed. |
| * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers |
| array. |
| * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier2 |
| structures defining memory dependencies between any memory accesses. |
| * pname:bufferMemoryBarrierCount is the length of the |
| pname:pBufferMemoryBarriers array. |
| * pname:pBufferMemoryBarriers is a pointer to an array of |
| slink:VkBufferMemoryBarrier2 structures defining memory dependencies |
| between buffer ranges. |
| * pname:imageMemoryBarrierCount is the length of the |
| pname:pImageMemoryBarriers array. |
| * pname:pImageMemoryBarriers is a pointer to an array of |
| slink:VkImageMemoryBarrier2 structures defining memory dependencies |
| between image subresources. |
| |
| This structure defines a set of <<synchronization-dependencies-memory, |
| memory dependencies>>, as well as <<synchronization-queue-transfers, queue |
| family transfer operations>> and <<synchronization-image-layout-transitions, |
| image layout transitions>>. |
| |
| Each member of pname:pMemoryBarriers, pname:pBufferMemoryBarriers, and |
| pname:pImageMemoryBarriers defines a separate |
| <<synchronization-dependencies-memory, memory dependency>>. |
| |
| include::{generated}/validity/structs/VkDependencyInfo.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='vkCmdSetEvent',desc='Set an event object to signaled state',type='protos'] |
| -- |
| :refpage: vkCmdSetEvent |
| |
| To set the state of an event to signaled from a device, call: |
| |
| include::{generated}/api/protos/vkCmdSetEvent.adoc[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:event is the event that will be signaled. |
| * pname:stageMask specifies the <<synchronization-pipeline-stages,source |
| stage mask>> used to determine the first |
| <<synchronization-dependencies-scopes, synchronization scope>>. |
| |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| fname:vkCmdSetEvent behaves identically to flink:vkCmdSetEvent2, except that |
| it does not define an access scope, and must: only be used with |
| flink:vkCmdWaitEvents, not flink:vkCmdWaitEvents2. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| When flink:vkCmdSetEvent is submitted to a queue, it defines an execution |
| dependency on commands that were submitted before it, and defines an event |
| signal operation which sets the event to the signaled state. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| The synchronization scope is limited to operations on the pipeline stages |
| determined by the <<synchronization-pipeline-stages-masks, source stage |
| mask>> specified by pname:stageMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the event signal operation. |
| |
| If pname:event is already in the signaled state when flink:vkCmdSetEvent is |
| executed on the device, then flink:vkCmdSetEvent has no effect, no event |
| signal operation occurs, and no execution dependency is generated. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| .Valid Usage |
| **** |
| :stageMaskName: stageMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| * [[VUID-vkCmdSetEvent-stageMask-06457]] |
| Any pipeline stage included in pname:stageMask must: be supported by the |
| capabilities of the queue family specified by the pname:queueFamilyIndex |
| member of the slink:VkCommandPoolCreateInfo structure that was used to |
| create the sname:VkCommandPool that pname:commandBuffer was allocated |
| from, as specified in the <<synchronization-pipeline-stages-supported, |
| table of supported pipeline stages>> |
| * [[VUID-vkCmdSetEvent-stageMask-01149]] |
| pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdSetEvent-commandBuffer-01152]] |
| The current device mask of pname:commandBuffer must: include exactly one |
| physical device |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| **** |
| |
| include::{generated}/validity/protos/vkCmdSetEvent.adoc[] |
| -- |
| |
| [[synchronization-events-unsignaling-device]] |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='vkCmdResetEvent2',desc='Reset an event object to non-signaled state',type='protos',alias='vkCmdResetEvent2KHR'] |
| -- |
| :refpage: vkCmdResetEvent2 |
| |
| To unsignal the event from a device, call: |
| |
| ifdef::VK_VERSION_1_3[] |
| include::{generated}/api/protos/vkCmdResetEvent2.adoc[] |
| endif::VK_VERSION_1_3[] |
| |
| ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] |
| |
| ifdef::VK_KHR_synchronization2[] |
| include::{generated}/api/protos/vkCmdResetEvent2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:event is the event that will be unsignaled. |
| * pname:stageMask is a tlink:VkPipelineStageFlags2 mask of pipeline stages |
| used to determine the first <<synchronization-dependencies-scopes, |
| synchronization scope>>. |
| |
| When flink:vkCmdResetEvent2 is submitted to a queue, it defines an execution |
| dependency on commands that were submitted before it, and defines an event |
| unsignal operation which resets the event to the unsignaled state. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| The synchronization scope is limited to operations by pname:stageMask or |
| stages that are <<synchronization-pipeline-stages-order,logically earlier>> |
| than pname:stageMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the event unsignal operation. |
| |
| If pname:event is already in the unsignaled state when |
| flink:vkCmdResetEvent2 is executed on the device, then this command has no |
| effect, no event unsignal operation occurs, and no execution dependency is |
| generated. |
| |
| .Valid Usage |
| **** |
| :stageMaskName: stageMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| * [[VUID-vkCmdResetEvent2-synchronization2-03829]] |
| The <<features-synchronization2, pname:synchronization2>> feature must: |
| be enabled |
| * [[VUID-vkCmdResetEvent2-stageMask-03830]] |
| pname:stageMask must: not include ename:VK_PIPELINE_STAGE_2_HOST_BIT |
| * [[VUID-vkCmdResetEvent2-event-03831]] |
| There must: be an execution dependency between fname:vkCmdResetEvent2 |
| and the execution of any flink:vkCmdWaitEvents that includes pname:event |
| in its pname:pEvents parameter |
| * [[VUID-vkCmdResetEvent2-event-03832]] |
| There must: be an execution dependency between fname:vkCmdResetEvent2 |
| and the execution of any flink:vkCmdWaitEvents2 that includes |
| pname:event in its pname:pEvents parameter |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdResetEvent2-commandBuffer-03833]] |
| pname:commandBuffer's current device mask must: include exactly one |
| physical device |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| **** |
| |
| include::{generated}/validity/protos/vkCmdResetEvent2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='vkCmdResetEvent',desc='Reset an event object to non-signaled state',type='protos'] |
| -- |
| :refpage: vkCmdResetEvent |
| |
| To set the state of an event to unsignaled from a device, call: |
| |
| include::{generated}/api/protos/vkCmdResetEvent.adoc[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:event is the event that will be unsignaled. |
| * pname:stageMask is a bitmask of elink:VkPipelineStageFlagBits specifying |
| the <<synchronization-pipeline-stages, source stage mask>> used to |
| determine when the pname:event is unsignaled. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| fname:vkCmdResetEvent behaves identically to flink:vkCmdResetEvent2. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| When flink:vkCmdResetEvent is submitted to a queue, it defines an execution |
| dependency on commands that were submitted before it, and defines an event |
| unsignal operation which resets the event to the unsignaled state. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| The synchronization scope is limited to operations on the pipeline stages |
| determined by the <<synchronization-pipeline-stages-masks, source stage |
| mask>> specified by pname:stageMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes only the event unsignal operation. |
| |
| If pname:event is already in the unsignaled state when flink:vkCmdResetEvent |
| is executed on the device, then flink:vkCmdResetEvent has no effect, no |
| event unsignal operation occurs, and no execution dependency is generated. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| .Valid Usage |
| **** |
| :stageMaskName: stageMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| * [[VUID-vkCmdResetEvent-stageMask-06458]] |
| Any pipeline stage included in pname:stageMask must: be supported by the |
| capabilities of the queue family specified by the pname:queueFamilyIndex |
| member of the slink:VkCommandPoolCreateInfo structure that was used to |
| create the sname:VkCommandPool that pname:commandBuffer was allocated |
| from, as specified in the <<synchronization-pipeline-stages-supported, |
| table of supported pipeline stages>> |
| * [[VUID-vkCmdResetEvent-stageMask-01153]] |
| pname:stageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT |
| * [[VUID-vkCmdResetEvent-event-03834]] |
| There must: be an execution dependency between fname:vkCmdResetEvent and |
| the execution of any flink:vkCmdWaitEvents that includes pname:event in |
| its pname:pEvents parameter |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * [[VUID-vkCmdResetEvent-event-03835]] |
| There must: be an execution dependency between fname:vkCmdResetEvent and |
| the execution of any flink:vkCmdWaitEvents2 that includes pname:event in |
| its pname:pEvents parameter |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdResetEvent-commandBuffer-01157]] |
| pname:commandBuffer's current device mask must: include exactly one |
| physical device |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| **** |
| |
| include::{generated}/validity/protos/vkCmdResetEvent.adoc[] |
| -- |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='vkCmdWaitEvents2',desc='Wait for one or more events',type='protos',alias='vkCmdWaitEvents2KHR'] |
| -- |
| To wait for one or more events to enter the signaled state on a device, |
| call: |
| |
| [[synchronization-events-waiting-device]] |
| ifdef::VK_VERSION_1_3[] |
| include::{generated}/api/protos/vkCmdWaitEvents2.adoc[] |
| endif::VK_VERSION_1_3[] |
| |
| ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] |
| |
| ifdef::VK_KHR_synchronization2[] |
| include::{generated}/api/protos/vkCmdWaitEvents2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:eventCount is the length of the pname:pEvents array. |
| * pname:pEvents is a pointer to an array of pname:eventCount events to |
| wait on. |
| * pname:pDependencyInfos is a pointer to an array of pname:eventCount |
| slink:VkDependencyInfo structures, defining the second |
| <<synchronization-dependencies-scopes, synchronization scope>>. |
| |
| When fname:vkCmdWaitEvents2 is submitted to a queue, it inserts memory |
| dependencies according to the elements of pname:pDependencyInfos and each |
| corresponding element of pname:pEvents. |
| fname:vkCmdWaitEvents2 must: not be used to wait on event signal operations |
| occurring on other queues, or signal operations executed by |
| flink:vkCmdSetEvent. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> of each memory |
| dependency defined by any element [eq]#i# of pname:pDependencyInfos are |
| applied to operations that occurred earlier in |
| <<synchronization-submission-order,submission order>> than the last event |
| signal operation on element [eq]#i# of pname:pEvents. |
| |
| Signal operations for an event at index [eq]#i# are only included if: |
| |
| * The event was signaled by a flink:vkCmdSetEvent2 command that occurred |
| earlier in <<synchronization-submission-order,submission order>> with a |
| pname:dependencyInfo parameter exactly equal to the element of |
| pname:pDependencyInfos at index [eq]#i# ; or |
| * The event was created without ename:VK_EVENT_CREATE_DEVICE_ONLY_BIT, and |
| the first <<synchronization-dependencies-scopes, synchronization scope>> |
| defined by the element of pname:pDependencyInfos at index [eq]#i# only |
| includes host operations (ename:VK_PIPELINE_STAGE_2_HOST_BIT). |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| and <<synchronization-dependencies-access-scopes, access scope>> of each |
| memory dependency defined by any element [eq]#i# of pname:pDependencyInfos |
| are applied to operations that occurred later in |
| <<synchronization-submission-order,submission order>> than |
| fname:vkCmdWaitEvents2. |
| |
| [NOTE] |
| .Note |
| ==== |
| flink:vkCmdWaitEvents2 is used with flink:vkCmdSetEvent2 to define a memory |
| dependency between two sets of action commands, roughly in the same way as |
| pipeline barriers, but split into two commands such that work between the |
| two may: execute unhindered. |
| ==== |
| |
| [NOTE] |
| .Note |
| ==== |
| Applications should be careful to avoid race conditions when using events. |
| There is no direct ordering guarantee between fname:vkCmdSetEvent2 and |
| flink:vkCmdResetEvent2, flink:vkCmdResetEvent, or flink:vkCmdSetEvent. |
| Another execution dependency (e.g. a pipeline barrier or semaphore with |
| ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT) is needed to prevent such a race |
| condition. |
| ==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkCmdWaitEvents2-synchronization2-03836]] |
| The <<features-synchronization2, pname:synchronization2>> feature must: |
| be enabled |
| * [[VUID-vkCmdWaitEvents2-pEvents-03837]] |
| Members of pname:pEvents must: not have been signaled by |
| flink:vkCmdSetEvent |
| * [[VUID-vkCmdWaitEvents2-pEvents-03838]] |
| For any element [eq]#i# of pname:pEvents, if that event is signaled by |
| flink:vkCmdSetEvent2, that command's pname:dependencyInfo parameter |
| must: be exactly equal to the [eq]##i##th element of |
| pname:pDependencyInfos |
| * [[VUID-vkCmdWaitEvents2-pEvents-03839]] |
| For any element [eq]#i# of pname:pEvents, if that event is signaled by |
| flink:vkSetEvent, barriers in the [eq]##i##th element of |
| pname:pDependencyInfos must: include only host operations in their first |
| <<synchronization-dependencies-scopes, synchronization scope>> |
| * [[VUID-vkCmdWaitEvents2-pEvents-03840]] |
| For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th |
| element of pname:pDependencyInfos include only host operations, the |
| [eq]##i##th element of pname:pEvents must: be signaled before |
| flink:vkCmdWaitEvents2 is executed |
| * [[VUID-vkCmdWaitEvents2-pEvents-03841]] |
| For any element [eq]#i# of pname:pEvents, if barriers in the [eq]##i##th |
| element of pname:pDependencyInfos do not include host operations, the |
| [eq]##i##th element of pname:pEvents must: be signaled by a |
| corresponding flink:vkCmdSetEvent2 that occurred earlier in |
| <<synchronization-submission-order,submission order>> |
| * [[VUID-vkCmdWaitEvents2-srcStageMask-03842]] |
| The pname:srcStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfos must: |
| either include only pipeline stages valid for the queue family that was |
| used to create the command pool that pname:commandBuffer was allocated |
| from, or include only ename:VK_PIPELINE_STAGE_2_HOST_BIT |
| * [[VUID-vkCmdWaitEvents2-dstStageMask-03843]] |
| The pname:dstStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfos must: only |
| include pipeline stages valid for the queue family that was used to |
| create the command pool that pname:commandBuffer was allocated from |
| * [[VUID-vkCmdWaitEvents2-dependencyFlags-03844]] |
| If fname:vkCmdWaitEvents2 is being called inside a render pass instance, |
| the pname:srcStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfos must: not |
| include ename:VK_PIPELINE_STAGE_2_HOST_BIT |
| * [[VUID-vkCmdWaitEvents2-commandBuffer-03846]] |
| pname:commandBuffer's current device mask must: include exactly one |
| physical device |
| **** |
| |
| include::{generated}/validity/protos/vkCmdWaitEvents2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='vkCmdWaitEvents',desc='Wait for one or more events and insert a set of memory',type='protos'] |
| -- |
| :refpage: vkCmdWaitEvents |
| |
| To wait for one or more events to enter the signaled state on a device, |
| call: |
| |
| [[synchronization-events-waiting-device]] |
| include::{generated}/api/protos/vkCmdWaitEvents.adoc[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:eventCount is the length of the pname:pEvents array. |
| * pname:pEvents is a pointer to an array of event object handles to wait |
| on. |
| * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits |
| specifying the <<synchronization-pipeline-stages, source stage mask>>. |
| * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits |
| specifying the <<synchronization-pipeline-stages, destination stage |
| mask>>. |
| * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers |
| array. |
| * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier |
| structures. |
| * pname:bufferMemoryBarrierCount is the length of the |
| pname:pBufferMemoryBarriers array. |
| * pname:pBufferMemoryBarriers is a pointer to an array of |
| slink:VkBufferMemoryBarrier structures. |
| * pname:imageMemoryBarrierCount is the length of the |
| pname:pImageMemoryBarriers array. |
| * pname:pImageMemoryBarriers is a pointer to an array of |
| slink:VkImageMemoryBarrier structures. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| fname:vkCmdWaitEvents is largely similar to flink:vkCmdWaitEvents2, but can: |
| only wait on signal operations defined by flink:vkCmdSetEvent. |
| As flink:vkCmdSetEvent does not define any access scopes, |
| fname:vkCmdWaitEvents defines the first access scope for each event signal |
| operation in addition to its own access scopes. |
| |
| [NOTE] |
| .Note |
| ==== |
| Since flink:vkCmdSetEvent does not have any dependency information beyond a |
| stage mask, implementations do not have the same opportunity to perform |
| <<synchronization-dependencies-available-and-visible, availability and |
| visibility operations>> or <<synchronization-image-layout-transitions, image |
| layout transitions>> in advance as they do with flink:vkCmdSetEvent2 and |
| flink:vkCmdWaitEvents2. |
| ==== |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| When fname:vkCmdWaitEvents is submitted to a queue, it defines a memory |
| dependency between prior event signal operations on the same queue or the |
| host, and subsequent commands. |
| fname:vkCmdWaitEvents must: not be used to wait on event signal operations |
| occurring on other queues. |
| |
| The first synchronization scope only includes event signal operations that |
| operate on members of pname:pEvents, and the operations that happened-before |
| the event signal operations. |
| Event signal operations performed by flink:vkCmdSetEvent that occur earlier |
| in <<synchronization-submission-order,submission order>> are included in the |
| first synchronization scope, if the <<synchronization-pipeline-stages-order, |
| logically latest>> pipeline stage in their pname:stageMask parameter is |
| <<synchronization-pipeline-stages-order, logically earlier>> than or equal |
| to the <<synchronization-pipeline-stages-order, logically latest>> pipeline |
| stage in pname:srcStageMask. |
| Event signal operations performed by flink:vkSetEvent are only included in |
| the first synchronization scope if ename:VK_PIPELINE_STAGE_HOST_BIT is |
| included in pname:srcStageMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur later in |
| <<synchronization-submission-order,submission order>>. |
| The second synchronization scope is limited to operations on the pipeline |
| stages determined by the <<synchronization-pipeline-stages-masks, |
| destination stage mask>> specified by pname:dstStageMask. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to accesses in the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, source stage mask>> specified by |
| pname:srcStageMask. |
| Within that, the first access scope only includes the first access scopes |
| defined by elements of the pname:pMemoryBarriers, |
| pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which |
| each define a set of <<synchronization-memory-barriers, memory barriers>>. |
| If no memory barriers are specified, then the first access scope includes no |
| accesses. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to accesses in the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, destination stage mask>> specified |
| by pname:dstStageMask. |
| Within that, the second access scope only includes the second access scopes |
| defined by elements of the pname:pMemoryBarriers, |
| pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which |
| each define a set of <<synchronization-memory-barriers, memory barriers>>. |
| If no memory barriers are specified, then the second access scope includes |
| no accesses. |
| |
| ifndef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [NOTE] |
| .Note |
| ==== |
| flink:vkCmdWaitEvents is used with flink:vkCmdSetEvent to define a memory |
| dependency between two sets of action commands, roughly in the same way as |
| pipeline barriers, but split into two commands such that work between the |
| two may: execute unhindered. |
| |
| Unlike flink:vkCmdPipelineBarrier, a <<synchronization-queue-transfers, |
| queue family ownership transfer>> cannot: be performed using |
| flink:vkCmdWaitEvents. |
| ==== |
| |
| [NOTE] |
| .Note |
| ==== |
| Applications should be careful to avoid race conditions when using events. |
| There is no direct ordering guarantee between flink:vkCmdWaitEvents and |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[flink:vkCmdResetEvent2,] |
| flink:vkCmdResetEvent, or flink:vkCmdSetEvent. |
| Another execution dependency (e.g. a pipeline barrier or semaphore with |
| ename:VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) is needed to prevent such a race |
| condition. |
| ==== |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| .Valid Usage |
| **** |
| :stageMaskName: srcStageMask |
| :accessMaskName: srcAccessMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_common.adoc[] |
| |
| :stageMaskName: dstStageMask |
| :accessMaskName: dstAccessMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_common.adoc[] |
| include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] |
| * [[VUID-vkCmdWaitEvents-srcStageMask-06459]] |
| Any pipeline stage included in pname:srcStageMask must: be supported by |
| the capabilities of the queue family specified by the |
| pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo |
| structure that was used to create the sname:VkCommandPool that |
| pname:commandBuffer was allocated from, as specified in the |
| <<synchronization-pipeline-stages-supported, table of supported pipeline |
| stages>> |
| * [[VUID-vkCmdWaitEvents-dstStageMask-06460]] |
| Any pipeline stage included in pname:dstStageMask must: be supported by |
| the capabilities of the queue family specified by the |
| pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo |
| structure that was used to create the sname:VkCommandPool that |
| pname:commandBuffer was allocated from, as specified in the |
| <<synchronization-pipeline-stages-supported, table of supported pipeline |
| stages>> |
| * [[VUID-vkCmdWaitEvents-srcStageMask-01158]] |
| pname:srcStageMask must: be the bitwise OR of the pname:stageMask |
| parameter used in previous calls to fname:vkCmdSetEvent with any of the |
| elements of pname:pEvents and ename:VK_PIPELINE_STAGE_HOST_BIT if any of |
| the elements of pname:pEvents was set using fname:vkSetEvent |
| * [[VUID-vkCmdWaitEvents-srcStageMask-07308]] |
| If fname:vkCmdWaitEvents is being called inside a render pass instance, |
| pname:srcStageMask must: not include ename:VK_PIPELINE_STAGE_HOST_BIT |
| * [[VUID-vkCmdWaitEvents-srcQueueFamilyIndex-02803]] |
| The pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex members of |
| any element of pname:pBufferMemoryBarriers or pname:pImageMemoryBarriers |
| must: be equal |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * [[VUID-vkCmdWaitEvents-commandBuffer-01167]] |
| pname:commandBuffer's current device mask must: include exactly one |
| physical device |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| * [[VUID-vkCmdWaitEvents-pEvents-03847]] |
| Elements of pname:pEvents must: not have been signaled by |
| flink:vkCmdSetEvent2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| **** |
| |
| include::{generated}/validity/protos/vkCmdWaitEvents.adoc[] |
| -- |
| |
| |
| [[synchronization-pipeline-barriers]] |
| == Pipeline Barriers |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='vkCmdPipelineBarrier2',desc='Insert a memory dependency',type='protos',alias='vkCmdPipelineBarrier2KHR'] |
| -- |
| :refpage: vkCmdPipelineBarrier2 |
| |
| To record a pipeline barrier, call: |
| |
| ifdef::VK_VERSION_1_3[] |
| include::{generated}/api/protos/vkCmdPipelineBarrier2.adoc[] |
| endif::VK_VERSION_1_3[] |
| |
| ifdef::VK_VERSION_1_3+VK_KHR_synchronization2[or the equivalent command] |
| |
| ifdef::VK_KHR_synchronization2[] |
| include::{generated}/api/protos/vkCmdPipelineBarrier2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:pDependencyInfo is a pointer to a slink:VkDependencyInfo structure |
| defining the scopes of this operation. |
| |
| When flink:vkCmdPipelineBarrier2 is submitted to a queue, it defines memory |
| dependencies between commands that were submitted to the same queue before |
| it, and those submitted to the same queue after it. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> of each memory |
| dependency defined by pname:pDependencyInfo are applied to operations that |
| occurred earlier in <<synchronization-submission-order,submission order>>. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| and <<synchronization-dependencies-access-scopes, access scope>> of each |
| memory dependency defined by pname:pDependencyInfo are applied to operations |
| that occurred later in <<synchronization-submission-order,submission |
| order>>. |
| |
| If fname:vkCmdPipelineBarrier2 is recorded within a render pass instance, |
| the synchronization scopes are limited to operations within the same subpass |
| ifdef::VK_EXT_shader_tile_image[] |
| , or must: follow the restrictions for |
| <<synchronization-pipeline-barriers-explicit-renderpass-tileimage, Tile |
| Image Access Synchronization>> if the render pass instance was started with |
| flink:vkCmdBeginRendering |
| endif::VK_EXT_shader_tile_image[] |
| . |
| |
| .Valid Usage |
| **** |
| include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] |
| * [[VUID-vkCmdPipelineBarrier2-synchronization2-03848]] |
| The <<features-synchronization2, pname:synchronization2>> feature must: |
| be enabled |
| * [[VUID-vkCmdPipelineBarrier2-srcStageMask-03849]] |
| The pname:srcStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only |
| include pipeline stages valid for the queue family that was used to |
| create the command pool that pname:commandBuffer was allocated from |
| * [[VUID-vkCmdPipelineBarrier2-dstStageMask-03850]] |
| The pname:dstStageMask member of any element of the |
| pname:pMemoryBarriers, pname:pBufferMemoryBarriers, or |
| pname:pImageMemoryBarriers members of pname:pDependencyInfo must: only |
| include pipeline stages valid for the queue family that was used to |
| create the command pool that pname:commandBuffer was allocated from |
| **** |
| |
| include::{generated}/validity/protos/vkCmdPipelineBarrier2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='vkCmdPipelineBarrier',desc='Insert a memory dependency',type='protos'] |
| -- |
| :refpage: vkCmdPipelineBarrier |
| |
| To record a pipeline barrier, call: |
| |
| include::{generated}/api/protos/vkCmdPipelineBarrier.adoc[] |
| |
| * pname:commandBuffer is the command buffer into which the command is |
| recorded. |
| * pname:srcStageMask is a bitmask of elink:VkPipelineStageFlagBits |
| specifying the <<synchronization-pipeline-stages-masks,source stages>>. |
| * pname:dstStageMask is a bitmask of elink:VkPipelineStageFlagBits |
| specifying the <<synchronization-pipeline-stages-masks,destination |
| stages>>. |
| * pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits |
| specifying how execution and memory dependencies are formed. |
| * pname:memoryBarrierCount is the length of the pname:pMemoryBarriers |
| array. |
| * pname:pMemoryBarriers is a pointer to an array of slink:VkMemoryBarrier |
| structures. |
| * pname:bufferMemoryBarrierCount is the length of the |
| pname:pBufferMemoryBarriers array. |
| * pname:pBufferMemoryBarriers is a pointer to an array of |
| slink:VkBufferMemoryBarrier structures. |
| * pname:imageMemoryBarrierCount is the length of the |
| pname:pImageMemoryBarriers array. |
| * pname:pImageMemoryBarriers is a pointer to an array of |
| slink:VkImageMemoryBarrier structures. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| fname:vkCmdPipelineBarrier operates almost identically to |
| flink:vkCmdPipelineBarrier2, except that the scopes and barriers are defined |
| as direct parameters rather than being defined by an slink:VkDependencyInfo. |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| When flink:vkCmdPipelineBarrier is submitted to a queue, it defines a memory |
| dependency between commands that were submitted to the same queue before it, |
| and those submitted to the same queue after it. |
| |
| If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, |
| the first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur earlier in |
| <<synchronization-submission-order,submission order>>. |
| If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, |
| the first synchronization scope includes only commands that occur earlier in |
| <<synchronization-submission-order,submission order>> within the same |
| subpass. |
| In either case, the first synchronization scope is limited to operations on |
| the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, source stage mask>> specified by |
| pname:srcStageMask. |
| |
| If flink:vkCmdPipelineBarrier was recorded outside a render pass instance, |
| the second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands that occur later in |
| <<synchronization-submission-order,submission order>>. |
| If flink:vkCmdPipelineBarrier was recorded inside a render pass instance, |
| the second synchronization scope includes only commands that occur later in |
| <<synchronization-submission-order,submission order>> within the same |
| subpass. |
| In either case, the second synchronization scope is limited to operations on |
| the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, destination stage mask>> specified |
| by pname:dstStageMask. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to accesses in the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, source stage mask>> specified by |
| pname:srcStageMask. |
| Within that, the first access scope only includes the first access scopes |
| defined by elements of the pname:pMemoryBarriers, |
| pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which |
| each define a set of <<synchronization-memory-barriers, memory barriers>>. |
| If no memory barriers are specified, then the first access scope includes no |
| accesses. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to accesses in the pipeline stages determined by the |
| <<synchronization-pipeline-stages-masks, destination stage mask>> specified |
| by pname:dstStageMask. |
| Within that, the second access scope only includes the second access scopes |
| defined by elements of the pname:pMemoryBarriers, |
| pname:pBufferMemoryBarriers and pname:pImageMemoryBarriers arrays, which |
| each define a set of <<synchronization-memory-barriers, memory barriers>>. |
| If no memory barriers are specified, then the second access scope includes |
| no accesses. |
| |
| If pname:dependencyFlags includes ename:VK_DEPENDENCY_BY_REGION_BIT, then |
| any dependency between <<synchronization-framebuffer-regions, |
| framebuffer-space>> pipeline stages is |
| <<synchronization-framebuffer-regions, framebuffer-local>> - otherwise it is |
| <<synchronization-framebuffer-regions, framebuffer-global>>. |
| |
| .Valid Usage |
| **** |
| :stageMaskName: srcStageMask |
| :accessMaskName: srcAccessMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_common.adoc[] |
| |
| :stageMaskName: dstStageMask |
| :accessMaskName: dstAccessMask |
| include::{chapters}/commonvalidity/stage_mask_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_common.adoc[] |
| include::{chapters}/commonvalidity/fine_sync_commands_common.adoc[] |
| include::{chapters}/commonvalidity/pipeline_barrier_common.adoc[] |
| * [[VUID-vkCmdPipelineBarrier-srcStageMask-06461]] |
| Any pipeline stage included in pname:srcStageMask must: be supported by |
| the capabilities of the queue family specified by the |
| pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo |
| structure that was used to create the sname:VkCommandPool that |
| pname:commandBuffer was allocated from, as specified in the |
| <<synchronization-pipeline-stages-supported, table of supported pipeline |
| stages>> |
| * [[VUID-vkCmdPipelineBarrier-dstStageMask-06462]] |
| Any pipeline stage included in pname:dstStageMask must: be supported by |
| the capabilities of the queue family specified by the |
| pname:queueFamilyIndex member of the slink:VkCommandPoolCreateInfo |
| structure that was used to create the sname:VkCommandPool that |
| pname:commandBuffer was allocated from, as specified in the |
| <<synchronization-pipeline-stages-supported, table of supported pipeline |
| stages>> |
| **** |
| |
| include::{generated}/validity/protos/vkCmdPipelineBarrier.adoc[] |
| -- |
| |
| [open,refpage='VkDependencyFlagBits',desc='Bitmask specifying how execution and memory dependencies are formed',type='enums'] |
| -- |
| Bits which can: be set in fname:vkCmdPipelineBarrier::pname:dependencyFlags, |
| specifying how execution and memory dependencies are formed, are: |
| |
| include::{generated}/api/enums/VkDependencyFlagBits.adoc[] |
| |
| * ename:VK_DEPENDENCY_BY_REGION_BIT specifies that dependencies will be |
| <<synchronization-framebuffer-regions, framebuffer-local>>. |
| ifdef::VK_VERSION_1_1,VK_KHR_multiview[] |
| * ename:VK_DEPENDENCY_VIEW_LOCAL_BIT specifies that dependencies will be |
| <<synchronization-view-local-dependencies, view-local>>. |
| endif::VK_VERSION_1_1,VK_KHR_multiview[] |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| * ename:VK_DEPENDENCY_DEVICE_GROUP_BIT specifies that dependencies are |
| <<synchronization-device-local-dependencies, non-device-local>>. |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| ifdef::VK_EXT_attachment_feedback_loop_layout[] |
| * ename:VK_DEPENDENCY_FEEDBACK_LOOP_BIT_EXT specifies that the render pass |
| will write to and read from the same image using the |
| ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout. |
| endif::VK_EXT_attachment_feedback_loop_layout[] |
| -- |
| |
| [open,refpage='VkDependencyFlags',desc='Bitmask of VkDependencyFlagBits',type='flags'] |
| -- |
| include::{generated}/api/flags/VkDependencyFlags.adoc[] |
| |
| tname:VkDependencyFlags is a bitmask type for setting a mask of zero or more |
| elink:VkDependencyFlagBits. |
| -- |
| |
| |
| ifdef::VK_EXT_shader_tile_image[] |
| [[synchronization-pipeline-barriers-explicit-renderpass-tileimage]] |
| === Explicit Render Pass Tile Image Access Synchronization |
| |
| A fragment shader can: declare code:NonCoherentColorAttachmentReadEXT, |
| code:NonCoherentDepthAttachmentReadEXT, or |
| code:NonCoherentStencilAttachmentReadEXT execution modes to enable |
| non-coherent tile image reads for color, depth, or stencil, respectively. |
| When non-coherent tile image reads are enabled, writes via color, depth and |
| stencil attachments are not automatically made visible to the corresponding |
| attachment reads via tile images. |
| For the writes to be made visible, an explicit memory dependency must: be |
| inserted between when the attachment is written to and when it is read from |
| by later fragments. |
| Such memory dependencies must: be inserted every time a fragment will read |
| values at a particular sample (x, y, layer, sample) coordinate, if those |
| values have been written since the most recent pipeline barrier; or since |
| the start of the render pass instance, if there have been no pipeline |
| barriers since the start of the render pass instance. |
| When such memory dependencies are used the values at all sample locations |
| inside the fragment area are made visible, regardless of coverage. |
| |
| To insert a memory dependency for explicit render pass tile image |
| synchronization, call flink:vkCmdPipelineBarrier2 inside a render pass |
| instance started with flink:vkCmdBeginRendering. |
| The following restrictions apply for such pipeline barriers: |
| |
| * pname:dependencyFlags must: include ename:VK_DEPENDENCY_BY_REGION_BIT. |
| * The pipeline barriers can: only include memory barriers. |
| That is, buffer memory barriers and image memory barriers must: not be |
| used. |
| * The stages in slink:VkMemoryBarrier2::pname:srcStageMask and |
| slink:VkMemoryBarrier2::pname:dstStageMask are restricted to framebuffer |
| space stages. |
| * The access types in slink:VkMemoryBarrier2::pname:srcAccessMask and |
| slink:VkMemoryBarrier2::pname:dstAccessMask are restricted to the |
| following types: ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, |
| ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, |
| ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT, and |
| ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT. |
| endif::VK_EXT_shader_tile_image[] |
| |
| [[synchronization-memory-barriers]] |
| == Memory Barriers |
| |
| _Memory barriers_ are used to explicitly control access to buffer and image |
| subresource ranges. |
| Memory barriers are used to <<synchronization-queue-transfers, transfer |
| ownership between queue families>>, |
| <<synchronization-image-layout-transitions, change image layouts>>, and |
| define <<synchronization-dependencies-available-and-visible, availability |
| and visibility operations>>. |
| They explicitly define the <<synchronization-access-types, access types>> |
| and buffer and image subresource ranges that are included in the |
| <<synchronization-dependencies-access-scopes, access scopes>> of a memory |
| dependency that is created by a synchronization command that includes them. |
| |
| |
| [[synchronization-global-memory-barriers]] |
| === Global Memory Barriers |
| |
| Global memory barriers apply to memory accesses involving all memory objects |
| that exist at the time of its execution. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='VkMemoryBarrier2',desc='Structure specifying a global memory barrier',type='structs',alias='VkMemoryBarrier2KHR'] |
| -- |
| :refpage: VkMemoryBarrier2 |
| |
| The sname:VkMemoryBarrier2 structure is defined as: |
| |
| include::{generated}/api/structs/VkMemoryBarrier2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkMemoryBarrier2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| first synchronization scope>>. |
| * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, first |
| access scope>>. |
| * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| second synchronization scope>>. |
| * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, second |
| access scope>>. |
| |
| This structure defines a <<synchronization-dependencies-memory, memory |
| dependency>> affecting all device memory. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> described by |
| this structure include only operations and memory accesses specified by |
| pname:srcStageMask and pname:srcAccessMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| and <<synchronization-dependencies-access-scopes, access scope>> described |
| by this structure include only operations and memory accesses specified by |
| pname:dstStageMask and pname:dstAccessMask. |
| |
| .Valid Usage |
| **** |
| :stageMaskName: srcStageMask |
| :accessMaskName: srcAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| |
| :stageMaskName: dstStageMask |
| :accessMaskName: dstAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| **** |
| |
| include::{generated}/validity/structs/VkMemoryBarrier2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='VkMemoryBarrier',desc='Structure specifying a global memory barrier',type='structs'] |
| -- |
| The sname:VkMemoryBarrier structure is defined as: |
| |
| include::{generated}/api/structs/VkMemoryBarrier.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, source access mask>>. |
| * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, destination access mask>>. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access types in the <<synchronization-access-masks, source access |
| mask>> specified by pname:srcAccessMask. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access types in the <<synchronization-access-masks, destination |
| access mask>> specified by pname:dstAccessMask. |
| |
| include::{generated}/validity/structs/VkMemoryBarrier.adoc[] |
| -- |
| |
| |
| [[synchronization-buffer-memory-barriers]] |
| === Buffer Memory Barriers |
| |
| Buffer memory barriers only apply to memory accesses involving a specific |
| buffer range. |
| That is, a memory dependency formed from a buffer memory barrier is |
| <<synchronization-dependencies-access-scopes, scoped>> to access via the |
| specified buffer range. |
| Buffer memory barriers can: also be used to define a |
| <<synchronization-queue-transfers, queue family ownership transfer>> for the |
| specified buffer range. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='VkBufferMemoryBarrier2',desc='Structure specifying a buffer memory barrier',type='structs',alias='VkBufferMemoryBarrier2KHR'] |
| -- |
| :refpage: VkBufferMemoryBarrier2 |
| |
| The sname:VkBufferMemoryBarrier2 structure is defined as: |
| |
| include::{generated}/api/structs/VkBufferMemoryBarrier2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkBufferMemoryBarrier2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| first synchronization scope>>. |
| * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, first |
| access scope>>. |
| * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| second synchronization scope>>. |
| * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, second |
| access scope>>. |
| * pname:srcQueueFamilyIndex is the source queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:dstQueueFamilyIndex is the destination queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:buffer is a handle to the buffer whose backing memory is affected |
| by the barrier. |
| * pname:offset is an offset in bytes into the backing memory for |
| pname:buffer; this is relative to the base offset as bound to the buffer |
| (see flink:vkBindBufferMemory). |
| * pname:size is a size in bytes of the affected area of backing memory for |
| pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset |
| to the end of the buffer. |
| |
| This structure defines a <<synchronization-dependencies-memory, memory |
| dependency>> limited to a range of a buffer, and can: define a |
| <<synchronization-queue-transfers, queue family transfer operation>> for |
| that range. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> described by |
| this structure include only operations and memory accesses specified by |
| pname:srcStageMask and pname:srcAccessMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| and <<synchronization-dependencies-access-scopes, access scope>> described |
| by this structure include only operations and memory accesses specified by |
| pname:dstStageMask and pname:dstAccessMask. |
| |
| Both <<synchronization-dependencies-access-scopes, access scopes>> are |
| limited to only memory accesses to pname:buffer in the range defined by |
| pname:offset and pname:size. |
| |
| If pname:buffer was created with ename:VK_SHARING_MODE_EXCLUSIVE, and |
| pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this |
| memory barrier defines a <<synchronization-queue-transfers, queue family |
| transfer operation>>. |
| When executed on a queue in the family identified by |
| pname:srcQueueFamilyIndex, this barrier defines a |
| <<synchronization-queue-transfers-release, queue family release operation>> |
| for the specified buffer range, and the second synchronization and access |
| scopes do not synchronize operations on that queue. |
| When executed on a queue in the family identified by |
| pname:dstQueueFamilyIndex, this barrier defines a |
| <<synchronization-queue-transfers-acquire, queue family acquire operation>> |
| for the specified buffer range, and the first synchronization and access |
| scopes do not synchronize operations on that queue. |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| A <<synchronization-queue-transfers, queue family transfer operation>> is |
| also defined if the values are not equal, and either is one of the special |
| queue family values reserved for external memory ownership transfers, as |
| described in <<synchronization-queue-transfers>>. |
| A <<synchronization-queue-transfers-release, queue family release |
| operation>> is defined when pname:dstQueueFamilyIndex is one of those |
| values, and a <<synchronization-queue-transfers-acquire, queue family |
| acquire operation>> is defined when pname:srcQueueFamilyIndex is one of |
| those values. |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| |
| |
| .Valid Usage |
| **** |
| |
| :stageMaskName: srcStageMask |
| :accessMaskName: srcAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| |
| :stageMaskName: dstStageMask |
| :accessMaskName: dstAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] |
| * [[VUID-VkBufferMemoryBarrier2-srcStageMask-03851]] |
| If either pname:srcStageMask or pname:dstStageMask includes |
| ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and |
| pname:dstQueueFamilyIndex must: be equal |
| **** |
| |
| include::{generated}/validity/structs/VkBufferMemoryBarrier2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='VkBufferMemoryBarrier',desc='Structure specifying a buffer memory barrier',type='structs'] |
| -- |
| :refpage: VkBufferMemoryBarrier |
| |
| The sname:VkBufferMemoryBarrier structure is defined as: |
| |
| include::{generated}/api/structs/VkBufferMemoryBarrier.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, source access mask>>. |
| * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, destination access mask>>. |
| * pname:srcQueueFamilyIndex is the source queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:dstQueueFamilyIndex is the destination queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:buffer is a handle to the buffer whose backing memory is affected |
| by the barrier. |
| * pname:offset is an offset in bytes into the backing memory for |
| pname:buffer; this is relative to the base offset as bound to the buffer |
| (see flink:vkBindBufferMemory). |
| * pname:size is a size in bytes of the affected area of backing memory for |
| pname:buffer, or ename:VK_WHOLE_SIZE to use the range from pname:offset |
| to the end of the buffer. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access to memory through the specified buffer range, via access |
| types in the <<synchronization-access-masks, source access mask>> specified |
| by pname:srcAccessMask. |
| If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, a |
| <<synchronization-dependencies-available-and-visible, memory domain |
| operation>> is performed where available memory in the host domain is also |
| made available to the device domain. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access to memory through the specified buffer range, via access |
| types in the <<synchronization-access-masks, destination access mask>> |
| specified by pname:dstAccessMask. |
| If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or |
| ename:VK_ACCESS_HOST_READ_BIT, a |
| <<synchronization-dependencies-available-and-visible, memory domain |
| operation>> is performed where available memory in the device domain is also |
| made available to the host domain. |
| |
| [NOTE] |
| .Note |
| ==== |
| When ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT is used, available memory in |
| host domain is automatically made visible to host domain, and any host write |
| is automatically made available to host domain. |
| ==== |
| |
| If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and |
| pname:srcQueueFamilyIndex is equal to the current queue family, then the |
| memory barrier defines a <<synchronization-queue-transfers-release, queue |
| family release operation>> for the specified buffer range, and the second |
| access scope includes no access, as if pname:dstAccessMask was `0`. |
| |
| If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and |
| pname:dstQueueFamilyIndex is equal to the current queue family, then the |
| memory barrier defines a <<synchronization-queue-transfers-acquire, queue |
| family acquire operation>> for the specified buffer range, and the first |
| access scope includes no access, as if pname:srcAccessMask was `0`. |
| |
| .Valid Usage |
| **** |
| include::{chapters}/commonvalidity/buffer_memory_barrier_common.adoc[] |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkBufferMemoryBarrier-None-09049]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:buffer was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, at least one of |
| pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkBufferMemoryBarrier-None-09050]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:buffer was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| or ename:VK_QUEUE_FAMILY_EXTERNAL |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkBufferMemoryBarrier-None-09051]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:buffer was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| or ename:VK_QUEUE_FAMILY_EXTERNAL |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| **** |
| |
| include::{generated}/validity/structs/VkBufferMemoryBarrier.adoc[] |
| -- |
| |
| [open,refpage='VK_WHOLE_SIZE',desc='Sentinel value to use entire remaining array length',type='consts'] |
| -- |
| ename:VK_WHOLE_SIZE is a special value indicating that the entire remaining |
| length of a buffer following a given pname:offset should be used. |
| It can: be specified for slink:VkBufferMemoryBarrier::pname:size and other |
| structures. |
| |
| include::{generated}/api/enums/VK_WHOLE_SIZE.adoc[] |
| -- |
| |
| |
| [[synchronization-image-memory-barriers]] |
| === Image Memory Barriers |
| |
| Image memory barriers only apply to memory accesses involving a specific |
| image subresource range. |
| That is, a memory dependency formed from an image memory barrier is |
| <<synchronization-dependencies-access-scopes, scoped>> to access via the |
| specified image subresource range. |
| Image memory barriers can: also be used to define |
| <<synchronization-image-layout-transitions, image layout transitions>> or a |
| <<synchronization-queue-transfers, queue family ownership transfer>> for the |
| specified image subresource range. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [open,refpage='VkImageMemoryBarrier2',desc='Structure specifying an image memory barrier',type='structs',alias='VkImageMemoryBarrier2KHR'] |
| -- |
| :refpage: VkImageMemoryBarrier2 |
| |
| The sname:VkImageMemoryBarrier2 structure is defined as: |
| |
| include::{generated}/api/structs/VkImageMemoryBarrier2.adoc[] |
| |
| ifdef::VK_KHR_synchronization2[] |
| or the equivalent |
| |
| include::{generated}/api/structs/VkImageMemoryBarrier2KHR.adoc[] |
| endif::VK_KHR_synchronization2[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| first synchronization scope>>. |
| * pname:srcAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, first |
| access scope>>. |
| * pname:dstStageMask is a tlink:VkPipelineStageFlags2 mask of pipeline |
| stages to be included in the <<synchronization-dependencies-scopes, |
| second synchronization scope>>. |
| * pname:dstAccessMask is a tlink:VkAccessFlags2 mask of access flags to be |
| included in the <<synchronization-dependencies-access-scopes, second |
| access scope>>. |
| * pname:oldLayout is the old layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:newLayout is the new layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:srcQueueFamilyIndex is the source queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:dstQueueFamilyIndex is the destination queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:image is a handle to the image affected by this barrier. |
| * pname:subresourceRange describes the <<resources-image-views, image |
| subresource range>> within pname:image that is affected by this barrier. |
| |
| This structure defines a <<synchronization-dependencies-memory, memory |
| dependency>> limited to an image subresource range, and can: define a |
| <<synchronization-queue-transfers, queue family transfer operation>> and |
| <<synchronization-image-layout-transitions, image layout transition>> for |
| that subresource range. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> and |
| <<synchronization-dependencies-access-scopes, access scope>> described by |
| this structure include only operations and memory accesses specified by |
| pname:srcStageMask and pname:srcAccessMask. |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| and <<synchronization-dependencies-access-scopes, access scope>> described |
| by this structure include only operations and memory accesses specified by |
| pname:dstStageMask and pname:dstAccessMask. |
| |
| Both <<synchronization-dependencies-access-scopes, access scopes>> are |
| limited to only memory accesses to pname:image in the subresource range |
| defined by pname:subresourceRange. |
| |
| If pname:image was created with ename:VK_SHARING_MODE_EXCLUSIVE, and |
| pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, this |
| memory barrier defines a <<synchronization-queue-transfers, queue family |
| transfer operation>>. |
| When executed on a queue in the family identified by |
| pname:srcQueueFamilyIndex, this barrier defines a |
| <<synchronization-queue-transfers-release, queue family release operation>> |
| for the specified image subresource range, and the second synchronization |
| and access scopes do not synchronize operations on that queue. |
| When executed on a queue in the family identified by |
| pname:dstQueueFamilyIndex, this barrier defines a |
| <<synchronization-queue-transfers-acquire, queue family acquire operation>> |
| for the specified image subresource range, and the first synchronization and |
| access scopes do not synchronize operations on that queue. |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| A <<synchronization-queue-transfers, queue family transfer operation>> is |
| also defined if the values are not equal, and either is one of the special |
| queue family values reserved for external memory ownership transfers, as |
| described in <<synchronization-queue-transfers>>. |
| A <<synchronization-queue-transfers-release, queue family release |
| operation>> is defined when pname:dstQueueFamilyIndex is one of those |
| values, and a <<synchronization-queue-transfers-acquire, queue family |
| acquire operation>> is defined when pname:srcQueueFamilyIndex is one of |
| those values. |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| |
| If pname:oldLayout is not equal to pname:newLayout, then the memory barrier |
| defines an <<synchronization-image-layout-transitions, image layout |
| transition>> for the specified image subresource range. |
| If this memory barrier defines a <<synchronization-queue-transfers, queue |
| family transfer operation>>, the layout transition is only executed once |
| between the queues. |
| |
| [NOTE] |
| .Note |
| ==== |
| When the old and new layout are equal, the layout values are ignored - data |
| is preserved no matter what values are specified, or what layout the image |
| is currently in. |
| ==== |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] |
| |
| If pname:image has a multi-planar format and the image is _disjoint_, then |
| including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of |
| pname:subresourceRange is equivalent to including |
| ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and |
| (for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. |
| |
| endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] |
| |
| .Valid Usage |
| **** |
| |
| :stageMaskName: srcStageMask |
| :accessMaskName: srcAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| |
| :stageMaskName: dstStageMask |
| :accessMaskName: dstAccessMask |
| include::{chapters}/commonvalidity/stage_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/access_mask_2_common.adoc[] |
| include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] |
| include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] |
| * [[VUID-VkImageMemoryBarrier2-srcStageMask-03854]] |
| If either pname:srcStageMask or pname:dstStageMask includes |
| ename:VK_PIPELINE_STAGE_2_HOST_BIT, pname:srcQueueFamilyIndex and |
| pname:dstQueueFamilyIndex must: be equal |
| * [[VUID-VkImageMemoryBarrier2-srcStageMask-03855]] |
| If pname:srcStageMask includes ename:VK_PIPELINE_STAGE_2_HOST_BIT, and |
| pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex define a |
| <<synchronization-queue-transfers, queue family ownership transfer>> or |
| pname:oldLayout and pname:newLayout define an |
| <<synchronization-image-layout-transitions, image layout transition>>, |
| pname:oldLayout must: be one of ename:VK_IMAGE_LAYOUT_PREINITIALIZED, |
| ename:VK_IMAGE_LAYOUT_UNDEFINED, or ename:VK_IMAGE_LAYOUT_GENERAL |
| **** |
| |
| include::{generated}/validity/structs/VkImageMemoryBarrier2.adoc[] |
| -- |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| [open,refpage='VkImageMemoryBarrier',desc='Structure specifying the parameters of an image memory barrier',type='structs'] |
| -- |
| :refpage: VkImageMemoryBarrier |
| |
| The sname:VkImageMemoryBarrier structure is defined as: |
| |
| include::{generated}/api/structs/VkImageMemoryBarrier.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:srcAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, source access mask>>. |
| * pname:dstAccessMask is a bitmask of elink:VkAccessFlagBits specifying a |
| <<synchronization-access-masks, destination access mask>>. |
| * pname:oldLayout is the old layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:newLayout is the new layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:srcQueueFamilyIndex is the source queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:dstQueueFamilyIndex is the destination queue family for a |
| <<synchronization-queue-transfers, queue family ownership transfer>>. |
| * pname:image is a handle to the image affected by this barrier. |
| * pname:subresourceRange describes the <<resources-image-views, image |
| subresource range>> within pname:image that is affected by this barrier. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access to memory through the specified image subresource range, |
| via access types in the <<synchronization-access-masks, source access mask>> |
| specified by pname:srcAccessMask. |
| If pname:srcAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT, memory |
| writes performed by that access type are also made visible, as that access |
| type is not performed through a resource. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> is |
| limited to access to memory through the specified image subresource range, |
| via access types in the <<synchronization-access-masks, destination access |
| mask>> specified by pname:dstAccessMask. |
| If pname:dstAccessMask includes ename:VK_ACCESS_HOST_WRITE_BIT or |
| ename:VK_ACCESS_HOST_READ_BIT, available memory writes are also made visible |
| to accesses of those types, as those access types are not performed through |
| a resource. |
| |
| If pname:srcQueueFamilyIndex is not equal to pname:dstQueueFamilyIndex, and |
| pname:srcQueueFamilyIndex is equal to the current queue family, then the |
| memory barrier defines a <<synchronization-queue-transfers-release, queue |
| family release operation>> for the specified image subresource range, and |
| the second access scope includes no access, as if pname:dstAccessMask was |
| `0`. |
| |
| If pname:dstQueueFamilyIndex is not equal to pname:srcQueueFamilyIndex, and |
| pname:dstQueueFamilyIndex is equal to the current queue family, then the |
| memory barrier defines a <<synchronization-queue-transfers-acquire, queue |
| family acquire operation>> for the specified image subresource range, and |
| the first access scope includes no access, as if pname:srcAccessMask was |
| `0`. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| If the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled or pname:oldLayout is not equal to pname:newLayout, |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| pname:oldLayout and pname:newLayout define an |
| <<synchronization-image-layout-transitions, image layout transition>> for |
| the specified image subresource range. |
| |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| [NOTE] |
| .Note |
| ==== |
| If the <<features-synchronization2, pname:synchronization2>> feature is |
| enabled, when the old and new layout are equal, the layout values are |
| ignored - data is preserved no matter what values are specified, or what |
| layout the image is currently in. |
| ==== |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] |
| |
| If pname:image has a multi-planar format and the image is _disjoint_, then |
| including ename:VK_IMAGE_ASPECT_COLOR_BIT in the pname:aspectMask member of |
| pname:subresourceRange is equivalent to including |
| ename:VK_IMAGE_ASPECT_PLANE_0_BIT, ename:VK_IMAGE_ASPECT_PLANE_1_BIT, and |
| (for three-plane formats only) ename:VK_IMAGE_ASPECT_PLANE_2_BIT. |
| |
| endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] |
| |
| .Valid Usage |
| **** |
| include::{chapters}/commonvalidity/image_memory_barrier_common.adoc[] |
| include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkImageMemoryBarrier-None-09052]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:image was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, at least one of |
| pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkImageMemoryBarrier-None-09053]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:image was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, pname:srcQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| or ename:VK_QUEUE_FAMILY_EXTERNAL |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| * [[VUID-VkImageMemoryBarrier-None-09054]] |
| If |
| ifdef::VK_KHR_synchronization2[] |
| the <<features-synchronization2, pname:synchronization2>> feature is not |
| enabled, and |
| endif::VK_KHR_synchronization2[] |
| pname:image was created with a sharing mode of |
| ename:VK_SHARING_MODE_CONCURRENT, pname:dstQueueFamilyIndex must: be |
| ename:VK_QUEUE_FAMILY_IGNORED |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| or ename:VK_QUEUE_FAMILY_EXTERNAL |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| **** |
| |
| include::{generated}/validity/structs/VkImageMemoryBarrier.adoc[] |
| -- |
| |
| ifdef::VK_EXT_host_image_copy[] |
| To facilitate usage of images whose memory is initialized on the host, |
| Vulkan allows image layout transitions to be performed by the host as well, |
| albeit supporting limited layouts. |
| |
| [open,refpage='vkTransitionImageLayoutEXT',desc='Perform an image layout transition on the host',type='protos'] |
| -- |
| To perform an image layout transition on the host, call: |
| |
| include::{generated}/api/protos/vkTransitionImageLayoutEXT.adoc[] |
| |
| * pname:device is the device which owns pname:pTransitions[i].pname:image. |
| * pname:transitionCount is the number of image layout transitions to |
| perform. |
| * pname:pTransitions is a pointer to an array of |
| slink:VkHostImageLayoutTransitionInfoEXT structures specifying the image |
| and <<resources-image-views, subresource ranges>> within them to |
| transition. |
| |
| include::{generated}/validity/protos/vkTransitionImageLayoutEXT.adoc[] |
| -- |
| |
| [open,refpage='VkHostImageLayoutTransitionInfoEXT',desc='Structure specifying the parameters of a host-side image layout transition',type='structs'] |
| -- |
| :refpage: VkHostImageLayoutTransitionInfoEXT |
| |
| The sname:VkHostImageLayoutTransitionInfoEXT structure is defined as: |
| |
| include::{generated}/api/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:image is a handle to the image affected by this layout transition. |
| * pname:oldLayout is the old layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:newLayout is the new layout in an |
| <<synchronization-image-layout-transitions, image layout transition>>. |
| * pname:subresourceRange describes the <<resources-image-views, image |
| subresource range>> within pname:image that is affected by this layout |
| transition. |
| |
| fname:vkTransitionImageLayoutEXT does not check whether the device memory |
| associated with an image is currently in use before performing the layout |
| transition. |
| The application must: guarantee that any previously submitted command that |
| reads from or writes to this subresource has completed before the host |
| performs the layout transition. |
| |
| [NOTE] |
| .Note |
| ==== |
| Image layout transitions performed on the host do not require queue family |
| ownership transfers as the physical layout of the image will not vary |
| between queue families for the layouts supported by this function. |
| ==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkHostImageLayoutTransitionInfoEXT-image-09055]] |
| pname:image must: have been created with |
| ename:VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT |
| include::{chapters}/commonvalidity/image_layout_transition_common.adoc[] |
| * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09229]] |
| pname:oldLayout must: be either ename:VK_IMAGE_LAYOUT_UNDEFINED or the |
| current layout of the image subresources as specified in |
| pname:subresourceRange |
| * [[VUID-VkHostImageLayoutTransitionInfoEXT-oldLayout-09230]] |
| If pname:oldLayout is not ename:VK_IMAGE_LAYOUT_UNDEFINED or |
| ename:VK_IMAGE_LAYOUT_PREINITIALIZED, it must: be one of the layouts in |
| slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopySrcLayouts |
| * [[VUID-VkHostImageLayoutTransitionInfoEXT-newLayout-09057]] |
| pname:newLayout must: be one of the layouts in |
| slink:VkPhysicalDeviceHostImageCopyPropertiesEXT::pname:pCopyDstLayouts |
| **** |
| |
| include::{generated}/validity/structs/VkHostImageLayoutTransitionInfoEXT.adoc[] |
| -- |
| endif::VK_EXT_host_image_copy[] |
| |
| [[synchronization-queue-transfers]] |
| === Queue Family Ownership Transfer |
| |
| Resources created with a elink:VkSharingMode of |
| ename:VK_SHARING_MODE_EXCLUSIVE must: have their ownership explicitly |
| transferred from one queue family to another in order to access their |
| content in a well-defined manner on a queue in a different queue family. |
| |
| [open,refpage='VK_QUEUE_FAMILY_IGNORED',desc='Ignored queue family index sentinel',type='consts'] |
| -- |
| The special queue family index ename:VK_QUEUE_FAMILY_IGNORED indicates that |
| a queue family parameter or member is ignored. |
| |
| include::{generated}/api/enums/VK_QUEUE_FAMILY_IGNORED.adoc[] |
| -- |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_external_memory[] |
| Resources shared with external APIs or instances using external memory must: |
| also explicitly manage ownership transfers between local and external queues |
| (or equivalent constructs in external APIs) regardless of the |
| elink:VkSharingMode specified when creating them. |
| |
| [open,refpage='VK_QUEUE_FAMILY_EXTERNAL',desc='External queue family index sentinel',type='consts',alias='VK_QUEUE_FAMILY_EXTERNAL_KHR'] |
| -- |
| The special queue family index ename:VK_QUEUE_FAMILY_EXTERNAL represents any |
| queue external to the resource's current Vulkan instance, as long as the |
| queue uses the same underlying |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] |
| physical device, and the same driver version as the resource's |
| slink:VkDevice, as indicated by |
| slink:VkPhysicalDeviceIDProperties::pname:deviceUUID and |
| slink:VkPhysicalDeviceIDProperties::pname:driverUUID. |
| |
| include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL.adoc[] |
| |
| ifdef::VK_KHR_external_memory[] |
| or the equivalent |
| |
| include::{generated}/api/enums/VK_QUEUE_FAMILY_EXTERNAL_KHR.adoc[] |
| endif::VK_KHR_external_memory[] |
| -- |
| |
| ifdef::VK_EXT_queue_family_foreign[] |
| [open,refpage='VK_QUEUE_FAMILY_FOREIGN_EXT',desc='Foreign queue family index sentinel',type='consts'] |
| -- |
| The special queue family index ename:VK_QUEUE_FAMILY_FOREIGN_EXT represents |
| any queue external to the resource's current Vulkan instance, regardless of |
| the queue's underlying physical device or driver version. |
| This includes, for example, queues for fixed-function image processing |
| devices, media codec devices, and display devices, as well as all queues |
| that use the same underlying |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[device group or] |
| physical device, and the same driver version as the resource's |
| slink:VkDevice. |
| |
| include::{generated}/api/enums/VK_QUEUE_FAMILY_FOREIGN_EXT.adoc[] |
| -- |
| endif::VK_EXT_queue_family_foreign[] |
| endif::VK_VERSION_1_1,VK_KHR_external_memory[] |
| |
| If memory dependencies are correctly expressed between uses of such a |
| resource between two queues in different families, but no ownership transfer |
| is defined, the contents of that resource are undefined: for any read |
| accesses performed by the second queue family. |
| |
| [NOTE] |
| .Note |
| ==== |
| If an application does not need the contents of a resource to remain valid |
| when transferring from one queue family to another, then the ownership |
| transfer should: be skipped. |
| ==== |
| |
| ifdef::VK_EXT_queue_family_foreign[] |
| [NOTE] |
| .Note |
| ==== |
| Applications should expect transfers to/from |
| ename:VK_QUEUE_FAMILY_FOREIGN_EXT to be more expensive than transfers |
| to/from ename:VK_QUEUE_FAMILY_EXTERNAL_KHR. |
| ==== |
| endif::VK_EXT_queue_family_foreign[] |
| |
| A queue family ownership transfer consists of two distinct parts: |
| |
| . Release exclusive ownership from the source queue family |
| . Acquire exclusive ownership for the destination queue family |
| |
| An application must: ensure that these operations occur in the correct order |
| by defining an execution dependency between them, e.g. using a semaphore. |
| |
| [[synchronization-queue-transfers-release]] A _release operation_ is used to |
| release exclusive ownership of a range of a buffer or image subresource |
| range. |
| A release operation is defined by executing a |
| <<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a |
| buffer range) or an <<synchronization-image-memory-barriers, image memory |
| barrier>> (for an image subresource range) using a pipeline barrier command, |
| on a queue from the source queue family. |
| The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the |
| source queue family index, and the pname:dstQueueFamilyIndex parameter to |
| the destination queue family index. |
| pname:dstAccessMask is ignored for such a barrier, such that no visibility |
| operation is executed - the value of this mask does not affect the validity |
| of the barrier. |
| The release operation happens-after the availability operation, and |
| happens-before operations specified in the second synchronization scope of |
| the calling command. |
| |
| [[synchronization-queue-transfers-acquire]] An _acquire operation_ is used |
| to acquire exclusive ownership of a range of a buffer or image subresource |
| range. |
| An acquire operation is defined by executing a |
| <<synchronization-buffer-memory-barriers, buffer memory barrier>> (for a |
| buffer range) or an <<synchronization-image-memory-barriers, image memory |
| barrier>> (for an image subresource range) using a pipeline barrier command, |
| on a queue from the destination queue family. |
| The buffer range or image subresource range specified in an acquire |
| operation must: match exactly that of a previous release operation. |
| The pname:srcQueueFamilyIndex parameter of the barrier must: be set to the |
| source queue family index, and the pname:dstQueueFamilyIndex parameter to |
| the destination queue family index. |
| pname:srcAccessMask is ignored for such a barrier, such that no availability |
| operation is executed - the value of this mask does not affect the validity |
| of the barrier. |
| The acquire operation happens-after operations in the first synchronization |
| scope of the calling command, and happens-before the visibility operation. |
| |
| [NOTE] |
| .Note |
| ==== |
| Whilst it is not invalid to provide destination or source access masks for |
| memory barriers used for release or acquire operations, respectively, they |
| have no practical effect. |
| Access after a release operation has undefined: results, and so visibility |
| for those accesses has no practical effect. |
| Similarly, write access before an acquire operation will produce undefined: |
| results for future access, so availability of those writes has no practical |
| use. |
| In an earlier version of the specification, these were required to match on |
| both sides - but this was subsequently relaxed. |
| These masks should: be set to 0. |
| ==== |
| |
| If the transfer is via an image memory barrier, and an |
| <<synchronization-image-layout-transitions, image layout transition>> is |
| desired, then the values of pname:oldLayout and pname:newLayout in the |
| _release operation_'s memory barrier must: be equal to values of |
| pname:oldLayout and pname:newLayout in the _acquire operation_'s memory |
| barrier. |
| Although the image layout transition is submitted twice, it will only be |
| executed once. |
| A layout transition specified in this way happens-after the _release |
| operation_ and happens-before the _acquire operation_. |
| |
| If the values of pname:srcQueueFamilyIndex and pname:dstQueueFamilyIndex are |
| equal, no ownership transfer is performed, and the barrier operates as if |
| they were both set to ename:VK_QUEUE_FAMILY_IGNORED. |
| |
| Queue family ownership transfers may: perform read and write accesses on all |
| memory bound to the image subresource or buffer range, so applications must: |
| ensure that all memory writes have been made |
| <<synchronization-dependencies-available-and-visible, available>> before a |
| queue family ownership transfer is executed. |
| Available memory is automatically made visible to queue family release and |
| acquire operations, and writes performed by those operations are |
| automatically made available. |
| |
| Once a queue family has acquired ownership of a buffer range or image |
| subresource range of a ename:VK_SHARING_MODE_EXCLUSIVE resource, its |
| contents are undefined: to other queue families unless ownership is |
| transferred. |
| The contents of any portion of another resource which aliases memory that is |
| bound to the transferred buffer or image subresource range are undefined: |
| after a release or acquire operation. |
| |
| [NOTE] |
| .Note |
| ==== |
| Because <<synchronization-events, events>> cannot: be used directly for |
| inter-queue synchronization, and because flink:vkCmdSetEvent does not have |
| the queue family index or memory barrier parameters needed by a _release |
| operation_, the release and acquire operations of a queue family ownership |
| transfer can: only be performed using flink:vkCmdPipelineBarrier. |
| ==== |
| |
| ifdef::VK_EXT_external_memory_acquire_unmodified[] |
| [open,refpage='VkExternalMemoryAcquireUnmodifiedEXT',desc='Structure specifying that external memory has remained unmodified since releasing ownership',type='structs'] |
| -- |
| An _acquire operation_ may: have a performance penalty when acquiring |
| ownership of a subresource range from one of the special queue families |
| reserved for external memory ownership transfers described above. |
| The application can: reduce the performance penalty in some cases by adding |
| a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the pname:pNext |
| chain of the _acquire operation_'s memory barrier structure. |
| |
| The sname:VkExternalMemoryAcquireUnmodifiedEXT structure is defined as: |
| |
| include::{generated}/api/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:acquireUnmodifiedMemory specifies, if ename:VK_TRUE, that no range |
| of slink:VkDeviceMemory bound to the resource of the memory barrier's |
| subresource range was modified at any time since the resource's most |
| recent release of ownership to the queue family specified by the memory |
| barrier's pname:srcQueueFamilyIndex. |
| If ename:VK_FALSE, it specifies nothing. |
| |
| If the application releases ownership of the subresource range to one of the |
| special queue families reserved for external memory ownership transfers with |
| a memory barrier structure, and later re-acquires ownership from the same |
| queue family with a memory barrier structure, and if no range of |
| slink:VkDeviceMemory bound to the resource was modified at any time between |
| the _release operation_ and the _acquire operation_, then the application |
| should: add a slink:VkExternalMemoryAcquireUnmodifiedEXT structure to the |
| pname:pNext chain of the _acquire operation_'s memory barrier structure |
| because this may: reduce the performance penalty. |
| |
| This struct is ignored if pname:acquireUnmodifiedMemory is ename:VK_FALSE. |
| In particular, ename:VK_FALSE does _not_ specify that memory was modified. |
| |
| This struct is ignored if the memory barrier's pname:srcQueueFamilyIndex is |
| not a special queue family reserved for external memory ownership transfers. |
| |
| [NOTE] |
| .Note |
| ==== |
| The method by which the application determines whether memory was modified |
| between the _release operation_ and _acquire operation_ is outside the scope |
| of Vulkan. |
| |
| For any Vulkan operation that accesses a resource, the application must: not |
| assume the implementation accesses the resource's memory as read-only, even |
| for _apparently_ read-only operations such as transfer commands and shader |
| reads. |
| |
| The validity of |
| slink:VkExternalMemoryAcquireUnmodifiedEXT::pname:acquireUnmodifiedMemory is |
| independent of memory ranges outside the ranges of slink:VkDeviceMemory |
| bound to the resource. |
| In particular, it is independent of any implementation-private memory |
| associated with the resource. |
| ==== |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkExternalMemoryAcquireUnmodifiedEXT-acquireUnmodifiedMemory-08922]] |
| If pname:acquireUnmodifiedMemory is ename:VK_TRUE, and the memory |
| barrier's pname:srcQueueFamilyIndex is a special queue family reserved |
| for external memory ownership transfers (as described in |
| <<synchronization-queue-transfers>>), then each range of |
| slink:VkDeviceMemory bound to the resource must: have remained |
| unmodified during all time since the resource's most recent release of |
| ownership to the queue family. |
| **** |
| |
| include::{generated}/validity/structs/VkExternalMemoryAcquireUnmodifiedEXT.adoc[] |
| -- |
| endif::VK_EXT_external_memory_acquire_unmodified[] |
| |
| [[synchronization-wait-idle]] |
| == Wait Idle Operations |
| |
| [open,refpage='vkQueueWaitIdle',desc='Wait for a queue to become idle',type='protos'] |
| -- |
| :refpage: vkQueueWaitIdle |
| |
| To wait on the host for the completion of outstanding queue operations for a |
| given queue, call: |
| |
| include::{generated}/api/protos/vkQueueWaitIdle.adoc[] |
| |
| * pname:queue is the queue on which to wait. |
| |
| fname:vkQueueWaitIdle is equivalent to having submitted a valid fence to |
| every previously executed <<devsandqueues-submission,queue submission |
| command>> that accepts a fence, then waiting for all of those fences to |
| signal using flink:vkWaitForFences with an infinite timeout and |
| pname:waitAll set to ename:VK_TRUE. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkQueueWaitIdle.adoc[] |
| -- |
| |
| [open,refpage='vkDeviceWaitIdle',desc='Wait for a device to become idle',type='protos'] |
| -- |
| :refpage: vkDeviceWaitIdle |
| |
| To wait on the host for the completion of outstanding queue operations for |
| all queues on a given logical device, call: |
| |
| include::{generated}/api/protos/vkDeviceWaitIdle.adoc[] |
| |
| * pname:device is the logical device to idle. |
| |
| fname:vkDeviceWaitIdle is equivalent to calling fname:vkQueueWaitIdle for |
| all queues owned by pname:device. |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkDeviceWaitIdle.adoc[] |
| -- |
| |
| |
| [[synchronization-submission-host-writes]] |
| == Host Write Ordering Guarantees |
| |
| When batches of command buffers are submitted to a queue via a |
| <<devsandqueues-submission, queue submission command>>, it defines a memory |
| dependency with prior host operations, and execution of command buffers |
| submitted to the queue. |
| |
| The first <<synchronization-dependencies-scopes, synchronization scope>> |
| includes execution of flink:vkQueueSubmit on the host and anything that |
| happened-before it, as defined by the host memory model. |
| |
| [NOTE] |
| .Note |
| ==== |
| Some systems allow writes that do not directly integrate with the host |
| memory model; these have to be synchronized by the application manually. |
| One example of this is non-temporal store instructions on x86; to ensure |
| these happen-before submission, applications should call `_mm_sfence()`. |
| ==== |
| |
| The second <<synchronization-dependencies-scopes, synchronization scope>> |
| includes all commands submitted in the same <<devsandqueues-submission, |
| queue submission>>, and all commands that occur later in |
| <<synchronization-submission-order,submission order>>. |
| |
| The first <<synchronization-dependencies-access-scopes, access scope>> |
| includes all host writes to mappable device memory that are available to the |
| host memory domain. |
| |
| The second <<synchronization-dependencies-access-scopes, access scope>> |
| includes all memory access performed by the device. |
| |
| ifdef::VK_VERSION_1_1,VK_KHR_device_group[] |
| [[synchronization-device-group]] |
| == Synchronization and Multiple Physical Devices |
| |
| If a logical device includes more than one physical device, then fences, |
| semaphores, and events all still have a single instance of the signaled |
| state. |
| |
| A fence becomes signaled when all physical devices complete the necessary |
| queue operations. |
| |
| Semaphore wait and signal operations all include a device index that is the |
| sole physical device that performs the operation. |
| These indices are provided in the slink:VkDeviceGroupSubmitInfo |
| ifndef::VKSC_VERSION_1_0[and slink:VkDeviceGroupBindSparseInfo] |
| structures. |
| Semaphores are not exclusively owned by any physical device. |
| For example, a semaphore can be signaled by one physical device and then |
| waited on by a different physical device. |
| |
| An event can: only be waited on by the same physical device that signaled it |
| (or the host). |
| endif::VK_VERSION_1_1,VK_KHR_device_group[] |
| |
| |
| ifdef::VK_EXT_calibrated_timestamps[] |
| [[calibrated-timestamps]] |
| == Calibrated Timestamps |
| |
| [open,refpage='vkGetCalibratedTimestampsEXT',desc='Query calibrated timestamps',type='protos'] |
| -- |
| :refpage: vkGetCalibratedTimestampsEXT |
| |
| In order to be able to correlate the time a particular operation took place |
| at on timelines of different time domains (e.g. a device operation vs. a |
| host operation), Vulkan allows querying calibrated timestamps from multiple |
| time domains. |
| |
| To query calibrated timestamps from a set of time domains, call: |
| |
| include::{generated}/api/protos/vkGetCalibratedTimestampsEXT.adoc[] |
| |
| * pname:device is the logical device used to perform the query. |
| * pname:timestampCount is the number of timestamps to query. |
| * pname:pTimestampInfos is a pointer to an array of pname:timestampCount |
| slink:VkCalibratedTimestampInfoEXT structures, describing the time |
| domains the calibrated timestamps should be captured from. |
| * pname:pTimestamps is a pointer to an array of pname:timestampCount |
| 64-bit unsigned integer values in which the requested calibrated |
| timestamp values are returned. |
| * pname:pMaxDeviation is a pointer to a 64-bit unsigned integer value in |
| which the strictly positive maximum deviation, in nanoseconds, of the |
| calibrated timestamp values is returned. |
| |
| [NOTE] |
| .Note |
| ==== |
| The maximum deviation may: vary between calls to |
| fname:vkGetCalibratedTimestampsEXT even for the same set of time domains due |
| to implementation and platform specific reasons. |
| It is the application's responsibility to assess whether the returned |
| maximum deviation makes the timestamp values suitable for any particular |
| purpose and can: choose to re-issue the timestamp calibration call pursuing |
| a lower deviation value. |
| ==== |
| |
| Calibrated timestamp values can: be extrapolated to estimate future |
| coinciding timestamp values, however, depending on the nature of the time |
| domains and other properties of the platform extrapolating values over a |
| sufficiently long period of time may: no longer be accurate enough to fit |
| any particular purpose, so applications are expected to re-calibrate the |
| timestamps on a regular basis. |
| |
| .Valid Usage |
| **** |
| * [[VUID-vkGetCalibratedTimestampsEXT-timeDomain-09246]] |
| The pname:timeDomain value of each slink:VkCalibratedTimestampInfoEXT in |
| pname:pTimestampInfos must: be unique |
| **** |
| |
| include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] |
| |
| include::{generated}/validity/protos/vkGetCalibratedTimestampsEXT.adoc[] |
| -- |
| |
| [open,refpage='VkCalibratedTimestampInfoEXT',desc='Structure specifying the input parameters of a calibrated timestamp query',type='structs'] |
| -- |
| The sname:VkCalibratedTimestampInfoEXT structure is defined as: |
| |
| include::{generated}/api/structs/VkCalibratedTimestampInfoEXT.adoc[] |
| |
| * pname:sType is a elink:VkStructureType value identifying this structure. |
| * pname:pNext is `NULL` or a pointer to a structure extending this |
| structure. |
| * pname:timeDomain is a elink:VkTimeDomainEXT value specifying the time |
| domain from which the calibrated timestamp value should be returned. |
| |
| .Valid Usage |
| **** |
| * [[VUID-VkCalibratedTimestampInfoEXT-timeDomain-02354]] |
| pname:timeDomain must: be one of the elink:VkTimeDomainEXT values |
| returned by flink:vkGetPhysicalDeviceCalibrateableTimeDomainsEXT |
| **** |
| include::{generated}/validity/structs/VkCalibratedTimestampInfoEXT.adoc[] |
| -- |
| |
| [open,refpage='VkTimeDomainEXT',desc='Supported time domains',type='enums'] |
| -- |
| The set of supported time domains consists of: |
| |
| include::{generated}/api/enums/VkTimeDomainEXT.adoc[] |
| |
| * ename:VK_TIME_DOMAIN_DEVICE_EXT specifies the device time domain. |
| Timestamp values in this time domain use the same units and are |
| comparable with device timestamp values captured using |
| flink:vkCmdWriteTimestamp |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or flink:vkCmdWriteTimestamp2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| and are defined to be incrementing according to the |
| <<limits-timestampPeriod, pname:timestampPeriod>> of the device. |
| |
| * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT specifies the CLOCK_MONOTONIC |
| time domain available on POSIX platforms. |
| Timestamp values in this time domain are in units of nanoseconds and are |
| comparable with platform timestamp values captured using the POSIX |
| clock_gettime API as computed by this example: |
| |
| [NOTE] |
| .Note |
| ==== |
| An implementation supporting `apiext:VK_EXT_calibrated_timestamps` will use |
| the same time domain for all its slink:VkQueue so that timestamp values |
| reported for ename:VK_TIME_DOMAIN_DEVICE_EXT can be matched to any timestamp |
| captured through flink:vkCmdWriteTimestamp |
| ifdef::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| or flink:vkCmdWriteTimestamp2 |
| endif::VK_VERSION_1_3,VK_KHR_synchronization2[] |
| . |
| ==== |
| |
| [source,c] |
| ---- |
| struct timespec tv; |
| clock_gettime(CLOCK_MONOTONIC, &tv); |
| return tv.tv_nsec + tv.tv_sec*1000000000ull; |
| ---- |
| |
| * ename:VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT specifies the |
| CLOCK_MONOTONIC_RAW time domain available on POSIX platforms. |
| Timestamp values in this time domain are in units of nanoseconds and are |
| comparable with platform timestamp values captured using the POSIX |
| clock_gettime API as computed by this example: |
| |
| [source,c] |
| ---- |
| struct timespec tv; |
| clock_gettime(CLOCK_MONOTONIC_RAW, &tv); |
| return tv.tv_nsec + tv.tv_sec*1000000000ull; |
| ---- |
| |
| * ename:VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT specifies the |
| performance counter (QPC) time domain available on Windows. |
| Timestamp values in this time domain are in the same units as those |
| provided by the Windows QueryPerformanceCounter API and are comparable |
| with platform timestamp values captured using that API as computed by |
| this example: |
| |
| [source,c] |
| ---- |
| LARGE_INTEGER counter; |
| QueryPerformanceCounter(&counter); |
| return counter.QuadPart; |
| ---- |
| -- |
| endif::VK_EXT_calibrated_timestamps[] |