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