1e5c31af7Sopenharmony_ci// Copyright 2020-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ciinclude::{generated}/meta/{refprefix}VK_KHR_synchronization2.adoc[]
6e5c31af7Sopenharmony_ci
7e5c31af7Sopenharmony_ci=== Other Extension Metadata
8e5c31af7Sopenharmony_ci
9e5c31af7Sopenharmony_ci*Last Modified Date*::
10e5c31af7Sopenharmony_ci    2020-12-03
11e5c31af7Sopenharmony_ci*Interactions and External Dependencies*::
12e5c31af7Sopenharmony_ci  - Interacts with `apiext:VK_KHR_create_renderpass2`
13e5c31af7Sopenharmony_ci*Contributors*::
14e5c31af7Sopenharmony_ci  - Tobias Hector
15e5c31af7Sopenharmony_ci
16e5c31af7Sopenharmony_ci=== Description
17e5c31af7Sopenharmony_ci
18e5c31af7Sopenharmony_ciThis extension modifies the original core synchronization APIs to simplify
19e5c31af7Sopenharmony_cithe interface and improve usability of these APIs.
20e5c31af7Sopenharmony_ciIt also adds new pipeline stage and access flag types that extend into the
21e5c31af7Sopenharmony_ci64-bit range, as we have run out within the 32-bit range.
22e5c31af7Sopenharmony_ciThe new flags are identical to the old values within the 32-bit range, with
23e5c31af7Sopenharmony_cinew stages and bits beyond that.
24e5c31af7Sopenharmony_ci
25e5c31af7Sopenharmony_ciPipeline stages and access flags are now specified together in memory
26e5c31af7Sopenharmony_cibarrier structures, making the connection between the two more obvious.
27e5c31af7Sopenharmony_ciAdditionally, scoping the pipeline stages into the barrier structs allows
28e5c31af7Sopenharmony_cithe use of the etext:MEMORY_READ and etext:MEMORY_WRITE flags without
29e5c31af7Sopenharmony_cisacrificing precision.
30e5c31af7Sopenharmony_ciThe per-stage access flags should be used to disambiguate specific accesses
31e5c31af7Sopenharmony_ciin a given stage or set of stages - for instance, between uniform reads and
32e5c31af7Sopenharmony_cisampling operations.
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_ciLayout transitions have been simplified as well; rather than requiring a
35e5c31af7Sopenharmony_cidifferent set of layouts for depth/stencil/color attachments, there are
36e5c31af7Sopenharmony_cigeneric ename:VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR and
37e5c31af7Sopenharmony_ciename:VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL_KHR layouts which are contextually
38e5c31af7Sopenharmony_ciapplied based on the image format.
39e5c31af7Sopenharmony_ciFor example, for a depth format image,
40e5c31af7Sopenharmony_ciename:VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL_KHR is equivalent to
41e5c31af7Sopenharmony_ciename:VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL_KHR.
42e5c31af7Sopenharmony_ciename:VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL_KHR also functionally replaces
43e5c31af7Sopenharmony_ciename:VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ciEvents are now more efficient, because they include memory dependency
46e5c31af7Sopenharmony_ciinformation when you set them on the device.
47e5c31af7Sopenharmony_ciPreviously, this information was only known when waiting on an event, so the
48e5c31af7Sopenharmony_cidependencies could not be satisfied until the wait occurred.
49e5c31af7Sopenharmony_ciThat sometimes meant stalling the pipeline when the wait occurred.
50e5c31af7Sopenharmony_ciThe new API provides enough information for implementations to satisfy these
51e5c31af7Sopenharmony_cidependencies in parallel with other tasks.
52e5c31af7Sopenharmony_ci
53e5c31af7Sopenharmony_ciQueue submission has been changed to wrap command buffers and semaphores in
54e5c31af7Sopenharmony_ciextensible structures, which incorporate changes from Vulkan 1.1,
55e5c31af7Sopenharmony_ci`apiext:VK_KHR_device_group`, and `apiext:VK_KHR_timeline_semaphore`.
56e5c31af7Sopenharmony_ciThis also adds a pipeline stage to the semaphore signal operation, mirroring
57e5c31af7Sopenharmony_cithe existing pipeline stage specification for wait operations.
58e5c31af7Sopenharmony_ci
59e5c31af7Sopenharmony_ciOther miscellaneous changes include:
60e5c31af7Sopenharmony_ci
61e5c31af7Sopenharmony_ci  * Events can now be specified as interacting only with the device,
62e5c31af7Sopenharmony_ci    allowing more efficient access to the underlying object.
63e5c31af7Sopenharmony_ci  * Image memory barriers that do not perform an image layout transition can
64e5c31af7Sopenharmony_ci    be specified by setting pname:oldLayout equal to pname:newLayout.
65e5c31af7Sopenharmony_ci  ** E.g. the old and new layout can both be set to
66e5c31af7Sopenharmony_ci     ename:VK_IMAGE_LAYOUT_UNDEFINED, without discarding data in the image.
67e5c31af7Sopenharmony_ci  * Queue family ownership transfer parameters are simplified in some cases.
68e5c31af7Sopenharmony_ci  * Where two synchronization commands need to be matched up (queue transfer
69e5c31af7Sopenharmony_ci    operations, events), the dependency information specified in each place
70e5c31af7Sopenharmony_ci    must now match completely for consistency.
71e5c31af7Sopenharmony_ci  * Extensions with commands or functions with a tlink:VkPipelineStageFlags
72e5c31af7Sopenharmony_ci    or elink:VkPipelineStageFlagBits parameter have had those APIs replaced
73e5c31af7Sopenharmony_ci    with equivalents using tlink:VkPipelineStageFlags2KHR.
74e5c31af7Sopenharmony_ci  * The new event and barrier interfaces are now more extensible for future
75e5c31af7Sopenharmony_ci    changes.
76e5c31af7Sopenharmony_ci  * Relevant pipeline stage masks can now be specified as empty with the new
77e5c31af7Sopenharmony_ci    ename:VK_PIPELINE_STAGE_NONE_KHR and ename:VK_PIPELINE_STAGE_2_NONE_KHR
78e5c31af7Sopenharmony_ci    values.
79e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_create_renderpass2[]
80e5c31af7Sopenharmony_ci  * slink:VkMemoryBarrier2KHR can be chained to slink:VkSubpassDependency2,
81e5c31af7Sopenharmony_ci    overriding the original 32-bit stage and access masks.
82e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_create_renderpass2[]
83e5c31af7Sopenharmony_ci
84e5c31af7Sopenharmony_ciinclude::{generated}/interfaces/VK_KHR_synchronization2.adoc[]
85e5c31af7Sopenharmony_ci
86e5c31af7Sopenharmony_ci=== Promotion to Vulkan 1.3
87e5c31af7Sopenharmony_ci
88e5c31af7Sopenharmony_ciFunctionality in this extension is included in core Vulkan 1.3, with the KHR
89e5c31af7Sopenharmony_cisuffix omitted.
90e5c31af7Sopenharmony_ciThe original type, enum and command names are still available as aliases of
91e5c31af7Sopenharmony_cithe core functionality.
92e5c31af7Sopenharmony_ci
93e5c31af7Sopenharmony_ci=== Examples
94e5c31af7Sopenharmony_ci
95e5c31af7Sopenharmony_ciSee
96e5c31af7Sopenharmony_cihttps://github.com/KhronosGroup/Vulkan-Docs/wiki/Synchronization-Examples
97e5c31af7Sopenharmony_ci
98e5c31af7Sopenharmony_ci
99e5c31af7Sopenharmony_ci=== Version History
100e5c31af7Sopenharmony_ci
101e5c31af7Sopenharmony_ci  * Revision 1, 2020-12-03 (Tobias Hector)
102e5c31af7Sopenharmony_ci  ** Internal revisions
103