• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015-2021 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[extensions]]
6= API Versions, Extensions, and Layers
7
8This chapter describes required and recommended processes for writing
9specification language for different core API versions, extensions, and API
10layers.
11It is concerned with processes and registration, while fine-grained naming
12conventions are included in the <<naming,API Naming Conventions chapter>>.
13
14[NOTE]
15.Note
16====
17The mechanism and process of specifying extensions is subject to change, as
18we receive feedback from authors and further requirements of documentation
19tooling.
20This document will be updated as changes are made.
21====
22
23
24== Introduction
25
26The Khronos extension registries and extension naming conventions serve
27several purposes:
28
29  * Avoiding naming collisions between extensions developed by mutually
30    unaware parties, both in the extension names themselves, as well as
31    their token, command, and type names.
32  * Allocating enumerant values for tokens added by extensions
33  * Creating a defined order between extensions.
34    Extensions with higher numbers may have dependencies upon extensions
35    with lower numbers, and must define any relevant interactions with
36    lower-numbered extensions.
37  * Provides a central repository for documentation and header changes
38    associated with extensions
39
40
41== Proposing New Extensions
42
43The first step in the process should be to fill out a proposal document, and
44iterate on that before committing to writing specification language.
45
46The main reasons to do this are to ensure that everyone understands the
47nature of the problem being addressed, to be clear why a particular solution
48was chosen in lieu of others, and to allow for design changes before
49committing to specification text.
50If a potential implementor has concerns with any of the design choices, it
51is much easier to change details in a proposal document than it is to
52rewrite specification text.
53
54In the top level `proposals` folder there is a template (`template.adoc`)
55for writing design proposals, including guidance on how it should be used.
56
57For some simpler extensions it may not be necessary to write a proposal
58document if both the problem is well understood and the solution well
59bounded, so this is not a required piece of documentation.
60However it may still be useful to write this in a proposal document.
61
62Once a proposal is written, the Vulkan Working Group and other interested
63parties should be asked to review and provide feedback before specification
64work begins.
65
66
67[[extensions-rules]]
68== General Rules/Guidelines
69
70Some general rules to simplify the specific rules below:
71
72  * API versions, extensions and layers must each have a globally unique
73    name.
74  * All commands and tokens must have a globally unique name.
75  * API versions and extensions can expose new commands, types, and/or
76    tokens, but layers must not.
77  ** However, layers can expose their own extensions, which in turn are
78     allowed to expose new commands and tokens.
79  * All extensions must be registered with Khronos.
80  * Extensions in general are strictly additive and backwards-compatible
81    with each other and with the core API.
82    However, as described in more detail the Fundamentals chapter of the
83    <<vulkan-spec,Vulkan API Specification>>, explicit incompatibilities may
84    exist, and must be documented.
85
86
87[[extensions-naming-conventions]]
88== Version, Extension, and Layer Naming Conventions
89
90Versions, extensions and layers have formal _names_.
91These names are used in a variety of places:
92
93  * When specifying extensions and layers to enable in the API.
94  * As a preprocessor symbol in the `vulkan_*.h` header files indicating
95    that an extension interface is defined at compile time.
96  * To control building the Vulkan Specification from asciidoctor source
97    containing multiple versions and extensions, by explicitly enabling
98    their inclusion.
99
100[NOTE]
101.Note
102====
103Published extensions are documented as part of the default branch (`main`)
104of the <<vulkan-docs,KhronosGroup/Vulkan-Docs>> project.
105They can optionally be included or excluded when generating specifications.
106====
107
108There is a rigid syntax for these names:
109
110  * Versions are named with the syntax `VK_VERSION_<major>_<minor>`.
111  * Extensions are named with the syntax `VK_<author>_<name>`.
112  * Layers are named with the syntax `VK_LAYER_<author>_<name>` or
113    `VK_LAYER_<fqdn>_<name>`.
114
115All these names include a `VK_` prefix, as described in the
116<<naming-preprocessor,Preprocessor Defines>> section above.
117In addition, layers add a `LAYER_` prefix.
118
119All these names must be valid C language identifiers.
120
121
122[[extensions-naming-conventions-name-strings]]
123=== Version, Extension and Layer Name Strings
124
125The `<name>` portion of version, extension and layer names is a concise name
126describing its purpose or functionality.
127The underscore (`_`) character is used as a delimiter between words.
128Every alphabetic character of the name must be in lower case.
129
130
131[[extensions-naming-author-IDs]]
132=== Author IDs for Extensions and Layers
133
134Extension and layer names also contain an _author ID_, indicated by
135`<author>` above, identifying the author of the extension/layer.
136This ID is a short, capitalized string identifying an author, such as a
137Khronos member developing Vulkan implementations for their devices, or a
138non-Khronos developer creating Vulkan layers.
139Author IDs must be registered with Khronos.
140
141Some authors have platform communities they wish to distinguish between, and
142can register additional author IDs for that purpose.
143For example, Google has separate Android and Chrome communities.
144
145Details on how to register an author ID are provided below.
146Layer authors not wishing to register an author ID with Khronos can instead
147use a fully-qualified domain name (FQDN, indicated by `<fqdn>` above) as the
148ID.
149The FQDN should be a domain name owned by the author.
150FQDNs cannot be used for extensions, only for layers.
151
152  * The following are examples of extension and layer names, demonstrating
153    the above syntax:
154  ** Extension names all use the base prefix `VK_`.
155  ** Khronos-ratified extensions add the reserved author ID `KHR` and use
156     the prefix `VK_KHR_`.
157  ** The following author IDs are reserved and must not be used:
158  *** `VK` - To avoid confusion with the top-level `VK_` prefix.
159  *** `VULKAN` - To avoid confusion with the name of the Vulkan API.
160  *** `LAYER` - To avoid confusion with the higher-level "`LAYER`" prefix.
161  *** `KHRONOS` - To avoid confusion with the Khronos organization.
162  ** Multi-author extensions that have not been ratified by Khronos (those
163     developed via cooperation between, and intended to be supported by two
164     or more registered authors) add the special author ID `EXT` to the base
165     prefix, and will use the prefix `VK_EXT_`.
166  ** Traditional author-specific extensions developed by one author (or one
167     author in cooperation with non-authors) add the author ID to the base
168     prefix.
169     For example, NVIDIA will use the prefix `VK_NV_`, and Valve will use
170     the prefix `VK_VALVE_`.
171     Some authors can have additional registered author IDs for special
172     purposes.
173     For example, an Android extension developed by Google - but part of an
174     Android open-source community project, and so not a proprietary Google
175     extension - will use the author ID `ANDROID`.
176  ** Layer names follow the same conventions as extensions, but use the base
177     prefix `VK_LAYER_`.
178  ** Because layers need not be registered with Khronos, an alternative
179     mechanism is needed to allow creating unique layer names without
180     registering an author ID.
181     Layer authors that prefer not to register an author ID can instead use
182     a fully-qualified domain name (FQDN) in reverse-order as an author ID,
183     replacing `.` (period) with `_` (underscore) characters.
184     The restriction that layer names must be valid C identifiers means that
185     some FQDNs cannot be used as part of layer names.
186
187[NOTE]
188.Note
189====
190The `KHX` author ID was used for _experimental_ extensions, as described in
191the "`Layers & Extensions`" appendix of the <<vulkan-spec,Vulkan API
192Specification>>.
193As of the initial Vulkan 1.1 public release, all `KHX` extensions have been
194promoted to `KHR` status, and this mechanism is no longer used.
195====
196
197[source, c]
198.Example
199----
200// Core API version name for Vulkan 1.1
201VK_VERSION_1_1
202
203// Khronos extension name
204VK_KHR_mirror_clamp_to_edge
205
206// Multivendor extension name
207VK_EXT_debug_marker
208
209// Vendor extension name using author ID NV
210VK_NV_glsl_shader
211
212// Vendor layer name using author ID LUNARG
213VK_LAYER_LUNARG_vktrace
214
215// Layer name using the FQDN www.3dxcl.invalid instead of an author ID
216VK_LAYER_invalid_3dxcl_www
217----
218
219[NOTE]
220.Note
221====
222To avoid linking to a nonexistent domain, the reserved TLD `.invalid` is
223used in the example above.
224====
225
226
227[[extensions-naming]]
228== Extension Command, Type, and Token Naming Conventions
229
230Extensions may add new commands, types, and tokens, or collectively
231"`objects`", to the Vulkan API.
232These objects are given globally unique names by appending the author ID
233defined above for the extension name as described in the
234<<naming-extension-identifiers, Extension Identifier Naming Conventions>>
235section above.
236
237
238[[extensions-api-registry]]
239== The Vulkan API Registry
240
241The canonical definition of the Vulkan APIs is kept in an XML file known as
242the *Vulkan API Registry*.
243The registry is kept in `xml/vk.xml` in the default branch (`main`) of the
244<<vulkan-docs,KhronosGroup/Vulkan-Docs>> project, containing the most
245recently released Vulkan API specification.
246The registry contains reserved author IDs, core and extension interface
247definitions, definitions of individual commands and structures, and other
248information which must be agreed on by all implementations.
249The registry is used to maintain a single, consistent global namespace for
250the registered entities, to generate the Khronos-supplied Vulkan header
251files, and to create a variety of related documentation used in generating
252the API specification and reference pages.
253Other uses of the registry outside Khronos include the LunarG Loader and
254Validation Layers, and a variety of language bindings.
255
256
257[[extensions-author-ID]]
258== Registering an Author ID with Khronos
259
260Previous Khronos APIs could only officially be modified by Khronos members.
261In an effort to build a more flexible platform, Vulkan allows non-Khronos
262developers to extend and modify the API via layers and extensions in the
263same manner as Khronos members.
264However, extensions must still be registered with Khronos.
265A mechanism for non-members to register layers and extensions is provided.
266
267Extension authors will be able to create an account on GitHub and register
268an author ID with Khronos through the
269<<vulkan-docs,KhronosGroup/Vulkan-Docs>> project.
270The author ID must be used for any extensions that author registers.
271The same mechanism will be used to request registration of extensions or
272layers with Khronos, as described below.
273
274To reserve an author ID, propose a merge request against
275<<extensions-api-registry,`vk.xml`>> in the default branch.
276The merge must add a `<tag>` XML tag and fill in the `name`, `author` and
277`contact` attributes with the requested author ID, the author's formal name
278(e.g. company or project name), and contact email address, respectively.
279The author ID will only be reserved once this merge request is accepted.
280
281Please do not try to reserve author IDs which clearly belong to another
282existing company or project which may wish to develop Vulkan extensions or
283layers in the future, as a matter of courtesy and respect.
284Khronos may decline to register author IDs that are not requested in good
285faith.
286
287
288[[extensions-vendor-id]]
289== Registering a Vendor ID with Khronos
290
291Vulkan implementors must report a valid vendor ID for their implementation
292when queried by fname:vkGetPhysicalDeviceProperties, as described in the
293"`Devices and Queues`" section of the <<vulkan-spec,Vulkan API
294Specification>>.
295If there is no valid PCI vendor ID defined for the physical device,
296implementations must obtain a Khronos vendor ID.
297
298Khronos vendor IDs are reserved in a similar fashion to
299<<extensions-author-ID,author IDs>>.
300While vendor IDs are not directly related to API extensions, the reservation
301process is similar, and so is described in this section.
302
303To reserve an Khronos vendor ID, you must first have a Khronos author ID.
304Propose a merge request against <<extensions-api-registry,`vk.xml`>> in the
305default branch.
306The merge must define a new enumerant by adding an `<enum>` tag to the
307`VkVendorId` `<enums>` tag, following the existing examples.
308The `value` attribute of the `<enum>` must be the next available unused
309value, and is the reserved vendor ID.
310The `name` attribute must be `VK_VENDOR_ID_<author>`, where `<author>` is
311the author tag.
312The vendor ID will be reserved only once this merge request has been
313accepted.
314
315Please do not try to reserve vendor IDs unless you are making a good faith
316effort to develop an implementation of a Khronos API and require one for
317that purpose.
318
319[NOTE]
320.Note
321====
322Other Khronos APIs such as OpenCL also utilize vendor IDs and share the
323Khronos vendor ID space.
324To obtain a vendor ID for these APIs, first reserve it in Vulkan's `vk.xml`
325and once that is done, utilize it in the other API.
326To avoid collisions, we are currently utilizing `vk.xml` as the central
327Khronos vendor ID registry.
328====
329
330
331== Registering Extensions and Layers
332
333Extensions must be registered with Khronos.
334Layers should be registered, but registration is not required.
335Registration means:
336
337  * Receiving an extension number.
338  * Adding the extension or layer name to the list in `vk.xml` and appearing
339    on the Khronos registry website, which will link to associated
340    documentation hosted on Khronos.
341  * For extensions which add to the Vulkan API, including definitions of
342    those additions to `vk.xml`.
343
344Registration for Khronos members is handled by filing a merge request in the
345internal gitlab repository modifying `vk.xml` in the default branch,
346containing the core specification against which the extension or layer will
347be written.
348Registration is not complete until the registry maintainer has validated and
349accepted the merge.
350
351A similar mechanism is used to register extensions not authored by Khronos
352members.
353Implementors who are not Khronos members and who need to create extensions
354must register with Khronos by creating a GitHub account, and registering
355their author ID and/or FQDNs to that account.
356They can then submit new extension registration requests by proposing merges
357to `vk.xml`.
358On acceptance of the merge, the extension will be registered, though its
359specification need not be checked into the Khronos GitHub repository at that
360point.
361
362The registration process can be split into several steps to accommodate
363extension number assignment prior to extension publication:
364
365  * Acquire an extension number.
366    This is done by proposing a merge request against `vk.xml` similarly to
367    how <<extensions-author-ID,author IDs are reserved>>.
368    The merge should add a new `<extension>` tag at the end of the file with
369    attributes specifying the proposed extension `name`, the next unused
370    sequential extension `number`, the `author` and `contact` information
371    (if different than that already specified for the author ID used in the
372    extension name), and finally, specifying `supported="disabled"`.
373    The extension number will be reserved only once this merge request is
374    accepted into the default branch.
375  * Develop and test the extension using the registered extension number.
376  * Publish the extension to Khronos using the previously registered
377    extension number, by submitting merge requests to the default branch
378    defining the changes specific to the extension.
379    Changes to both the specification source, and to `vk.xml` will be
380    needed.
381  ** Extension changes to the specification source must be protected by
382     asciidoctor conditionals as described in the
383     <<extensions-documenting,Documenting Extensions>> section.
384  ** Changes to `vk.xml` must define the extension interfaces in the
385     `<extension>` block, and must also change the `supported` attribute
386     value of the `<extension>` to `supported="vulkan"`.
387  ** When publishing an extension, mark it as enabled by proposing a merge
388     to the default branch changing the `supported` attribute value of the
389     `<extension>` to `supported="vulkan"`.
390  ** Once the merge request defining an extension has been accepted into the
391     default branch, publication is complete - although it may not be
392     visible on GitHub until the next regular core Specification update is
393     pushed out.
394  ** Publishing on the <<vulkan-docs,Khronos public GitHub repository>> is
395     preferred when possible.
396     Khronos members may instead create branches on Khronos' internal gitlab
397     server, but those branches will eventually be mirrored to GitHub.
398  * It is still possible to publish a separate branch of the repository with
399    appropriate changes relative to the core Vulkan API branch instead, but
400    this approach is deprecated and discouraged.
401    If this is done, all changes to `vk.xml` must still be made in the
402    default branch.
403
404
405[[extensions-documenting]]
406== Documenting API Versions and Extensions
407
408API versions and extensions are documented as modifications to the Vulkan
409specification.
410Changes specific to a version or extension are protected by asciidoctor
411conditionals.
412The changes are only visible in generated documentation when the
413Specification is built with an asciidoctor attribute of that name defined.
414Khronos publishes three forms of the Vulkan Specification: the core API
415(e.g. versions 1.x) only; core API with all registered `KHR` extensions; and
416core API with all registered extensions.
417
418
419[[extensions-documenting-extensions]]
420=== Changes for New Extensions
421
422If an new extension, or a related group of them is of sufficient scope to
423require a new chapter of the specification, localize such changes into a
424small number of asciidoctor include files located under a subdirectory with
425the name of the extension.
426An example can be found in `chapters/VK_KHR_surface/wsi.txt`.
427Most extensions are not entirely self-contained, and also require changes in
428existing parts of the specification to document new interactions.
429Such changes should be inline in existing chapters.
430
431Extensions may also require small additions to `vk.xml`, in addition to
432defining the extension interfaces themselves, for purposes such as
433introducing new return codes or extending structures to existing APIs.
434
435[NOTE]
436.Note
437====
438We do not yet fully document an example of including a new version or
439extension.
440New versions are authored only by Khronos and examples will be available at
441such time that we publish a new version.
442Extension authors should refer to the default branch and search for the
443names of existing extensions, such as `VK_KHR_surface`, for markup examples.
444Some aspects of the changes for this example extension are described below.
445====
446
447Changes for extensions include (but may not be limited to) the following:
448
449  * All extensions must add an appendix to the Vulkan specification.
450    The appendix can be modeled after the `VK_KHR_shader_float_controls`
451    extension in `appendices/VK_KHR_shader_float_controls.txt.txt`.
452    It contains metainformation about the extension as well as code
453    examples, and revision history.
454    Other useful references are the `VK_KHR_shader_draw_parameters`
455    appendix, which includes a variety of external dependencies and
456    interactions, and the `VK_EXT_debug_marker` appendix, which is a
457    simpler, standalone example.
458  ** The extension appendices are also incorporated in separate
459     per-extension reference pages, and must rigidly follow the structure of
460     the model appendices (although individual subsections can be added or
461     removed as required).
462  ** When creating references to the extension appendix from elsewhere in
463     the Specification, use the custom macro `apiext:`, instead of an
464     explicit asciidoctor link.
465     This allows more easily checking for invalid extensions, and changing
466     the link target for generated reference pages and other alternate
467     output forms.
468+
469--
470[source,asciidoc]
471.Example Markup
472----
473A link to the apiext:VK_KHR_shader_float_controls extension.
474
475Do not use this (old) form: `<<VK_KHR_shader_float_controls>>`.
476----
477
478[NOTE]
479.Note
480====
481If you are converting an old branch with extension references in it to use
482the `apiext:` macro, you can use this shell script:
483
484[source,sh,subs=attributes+]
485----
486sed -i -E 's/`?<<(VK_[A-Za-z0-9_]*)>>`?/apiext:\1/g' chapters/{*txt,*/*txt} appendices/*txt
487----
488====
489--
490  * In the preamble to the appendix, start with an asciidoctor `include` of
491    the automatically generated meta information.
492    This information includes the extension name string, type, number,
493    revision, and contact information from `vk.xml`.
494  * Following the `include`, add an *Other Extension Metadata* subsection
495    containing as many of the following items as are meaningful:
496  ** *Status* - *Complete*, *Draft*, or other.
497     When an extension is published in the default branch, it is normally
498     assumed to be complete; the *Status* field should be removed at this
499     time, unless it contains additional information.
500  ** *Last Modified Date* - if wanted, although git log queries can provide
501     equivalent information.
502  ** *IP Status* - Such as *No known IP claims*, or more specific
503     information if there are known IP claims and the extension has, or has
504     not been ratified by the Khronos Board of Promoters.
505  ** *Interactions and External Dependencies* - may include requirements or
506     interactions with optional Vulkan features, SPIR-V (`SPV`) and OpenGL
507     extensions, and interactions (other than strictly requiring) with other
508     Vulkan extensions.
509  ** *Contributors* - Names and corporate affiliations of people who have
510     made significant direct contributions to this extension.
511  * Following these items, add whitespace followed by a *Description*
512    section.
513    The first paragraph of this section should be a compact, standalone
514    description of the extension's functionality and purpose, suitable for
515    use in summaries of new functionality such as press releases or the
516    Vulkan change log.
517    Additional paragraphs expanding on the description may be added at the
518    author's discretion.
519  * If the extension has been deprecated or promoted, add *Deprecation*
520    and/or *Promotion* sections describing these actions.
521    There is standard boilerplate *Promotion* language used when promoting
522    to a Vulkan core version.
523    For example, see `appendices/VK_EXT_descriptor_indexing.txt` for
524    language used when promoting to Vulkan core, with some features made
525    optional in the promoted version.
526  * Next, add an asciidoctor `include` of the automatically generated
527    interface information.
528    This information includes API entities defined by the extension in
529    `vk.xml`, such as new commands, structures, enumerants, and so on.
530  * Following the `include`, add subsections describing interface
531    information for SPIR-V shading capabilities not captured in `vk.xml`,
532    such as:
533  ** *New SPIR-V Capabilities* (include xrefs to the appropriate new section
534     of the List of SPIR-V Capabilities in `appendices/spirvenv.txt`).
535  ** *New or Modified Built-In Variables* (include xrefs to the appropriate
536     new section of the Interfaces chapter).
537  ** *New Variable Decorations* (include xrefs to the appropriate new
538     section of the Interfaces chapter).
539  * Finally, add subsections describing other information about the
540    extension, such as:
541  ** *Issues* (in itemized list style, describing each significant issue
542     raised during development of the extension, and its resolution).
543  ** *Version History* (in itemized list style, describing significant
544     functional changes to the extension during its development).
545  * Each extension's appendix file is automatically included from
546    `appendices/extensions.txt` via code generated from `vk.xml`.
547    It is not necessary to explicitly include the appendices.
548  * Extensions usually make significant additions and changes to the Vulkan
549    specification.
550    They often add an entirely new chapter, or a new section of an existing
551    chapter, defining the new commands, structures, and enumerants.
552    For example, in the case of `VK_EXT_debug_marker`, it adds a new section
553    of the "`Debugging`" chapter in `chapters/debugging.txt`, by including
554    in that file:
555+
556[source,asciidoc]
557.Example Markup
558----
559\ifdef::VK_EXT_debug_marker[]
560\include::{chapters}/VK_EXT_debug_marker/wsi.txt[]
561\endif::VK_EXT_debug_marker[]
562----
563  * In every other place where the extension alters the behavior of the core
564    Specification, make such changes and protect the modifications with the
565    same asciidoctor conditionals.
566    For example, `VK_KHR_surface` adds new error codes to Vulkan.
567    These are added to `chapters/fundamentals.txt` in the "`Return Codes`"
568    section as follows:
569+
570[source,asciidoc]
571.Example Markup
572----
573... list of existing error codes
574\ifdef::VK_KHR_surface[]
575\include::{chapters}/VK_KHR_surface/VkResultErrorDescriptions_surface.txt[]
576\endif::VK_KHR_surface[]
577----
578  * If two extensions interact, the asciidoctor conditionals must be
579    carefully structured so as to properly document the interactions if the
580    specification is built with both extensions.
581    Asciidoc conditionals allow
582    link:{docguide}/directives/ifdef-ifndef/#checking-multiple-attributes[AND
583    and OR constructs].
584+
585[source,asciidoc]
586.Example Markup
587----
588\ifdef::VK_KHR_foo[]
589... discussion of VK_KHR_foo ...
590\ifdef::VK_KHR_fum[]
591... discussion of interactions between VK_KHR_foo and VK_KHR_fum ...
592\endif::VK_KHR_fum[]
593\endif::VK_KHR_foo[]
594
595\ifdef::VK_KHR_fum[]
596... discussion of VK_KHR_fum ...
597\endif::VK_KHR_fum[]
598----
599  * In cases where a new extension (A) modifies both core and an existing
600    extension (B), if the new extension (A) becomes part of the core at a
601    future release (i.e. is no longer an extension), the portion of the new
602    extension that modified the existing extension (B) effectively becomes
603    part of that existing extension.
604    Thus, at the new core release, enabling the pre-existing extension (B)
605    also enables the functionality that was previously enabled by enabling
606    the previously-new extension (A).
607  * For vendor extensions, changes made to existing core Specification
608    source files and to `vk.xml` all fall under the Contributor License
609    Agreement.
610    Vendors may use their own copyright on new files they add to the
611    repository, although that copyright must be compatible with the
612    Specification copyright.
613  * In most cases, there will be at most two new files added to the
614    specification: `extensions/*extension_name*.txt`, and
615    `chapters/*extension_name*.txt`.
616    If you need more than one new file in either the `chapters/` or
617    `extensions/` directories, create a subdirectory named with the
618    extension name and place the new files there.
619    For example, instead of `chapters/VK_KHR_android_surface.txt`, there is
620    `chapters/VK_KHR_android_surface/platformCreateSurface_android.txt` and
621    `chapters/VK_KHR_android_surface/platformQuerySupport_android.txt`, both
622    of which are conditionally included elsewhere in the core specification
623    files.
624  * Valid usage statements referring to interactions between structures in a
625    pname:pNext chain must be described in the parent structure's language,
626    as specified <<extensions-interactions-parent, in more detail below>>.
627  * Valid usage statements must: be kept atomic with regards to extension
628    conditionals.
629    Do not surround part of a single statement with conditionals.
630    Valid usage statements are automatically extracted from the
631    specification for use by ecosystem components like the validation
632    layers, and the extraction scripts need to know which valid usage
633    statements apply to which extensions.
634    The loops required to deal with partial statements are simply not worth
635    the trouble.
636    For example, instead of
637+
638[source,asciidoc]
639.Example Markup
640----
641  * If pname:buffer was created with a sharing mode of
642    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
643    pname:dstQueueFamilyIndex must: either both be
644    ename:VK_QUEUE_FAMILY_IGNORED, or both be a valid queue family (see
645    <<devsandqueues-queueprops>>)
646\ifdef::VK_KHR_external_memory[]
647    unless one of them is ename:VK_QUEUE_FAMILY_EXTERNAL_KHR and the other
648    is ename:VK_QUEUE_FAMILY_IGNORED.
649\endif::VK_KHR_external_memory[]
650----
651+
652Use
653+
654[source,asciidoc]
655.Example Markup
656----
657ifndef::VK_KHR_external_memory[]
658  * If pname:buffer was created with a sharing mode of
659    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
660    pname:dstQueueFamilyIndex must: either both be
661    ename:VK_QUEUE_FAMILY_IGNORED, or both be a valid queue family (see
662    <<devsandqueues-queueprops>>)
663endif::VK_KHR_external_memory[]
664ifdef::VK_KHR_external_memory[]
665  * If pname:buffer was created with a sharing mode of
666    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
667    pname:dstQueueFamilyIndex must: either both be
668    ename:VK_QUEUE_FAMILY_IGNORED, both be a valid queue family (see
669    <<devsandqueues-queueprops>>), or be
670    ename:VK_QUEUE_FAMILY_EXTERNAL_KHR and ename:VK_QUEUE_FAMILY_IGNORED in
671    either order
672endif::VK_KHR_external_memory[]
673----
674
675When writing language dependent on the interaction of multiple extensions,
676asciidoctor conditional syntax is very restricted and only supports a single
677level of logical AND (`+`) or OR (`,`) operators.
678For example, if a section of text only applies when one extensions is
679enabled and another is not, the following markup will not work:
680
681[source,asciidoc]
682.Example Markup (Does Not Work)
683----
684\ifdef::VK_KHR_shader_float16_int8+!VK_KHR_8bit_storage[]
685This should only appear if VK_KHR_shader_float16_int8 is defined and
686VK_KHR_8bit_storage is not defined.
687\endif::VK_KHR_shader_float16_int8+!VK_KHR_8bit_storage[]
688----
689
690Instead, expand the complex conditional into nested simpler ones:
691
692[source,asciidoc]
693.Example Markup (Does Work)
694----
695\ifdef::VK_KHR_shader_float16_int8[]
696\ifndef::VK_KHR_8bit_storage[]
697This should only appear if VK_KHR_shader_float16_int8 is defined and
698VK_KHR_8bit_storage is not defined.
699\endif::VK_KHR_8bit_storage[]
700\endif::VK_KHR_shader_float16_int8
701----
702
703
704[[extensions-documenting-versions]]
705=== Changes for New API Versions
706
707When creating a new version of the core API, such as Vulkan 1.1, changes are
708done similarly to extensions, with the following differences:
709
710[NOTE]
711.Note
712====
713This list is being developed in conjunction with the Vulkan 1.1
714Specification, is probably incomplete, and is subject to change.
715Items marked *TBD* are still being discussed within the Vulkan Working
716Group.
717====
718
719  * New API versions will be more tightly integrated into the specification
720    sources than extensions, although it is still helpful to partition
721    changes into new files when they are sufficiently self-contained.
722  * New API versions must add an appendix to the Vulkan specification.
723    Unlike the extension appendices, this appendix simply summarizes release
724    information (dates of Ratification by the Khronos Board of Promoters,
725    and of public release), the contributor list, and high-level
726    descriptions of new features in this version (including the names of any
727    extensions promoted to core status in this version).
728  ** TBD - we might choose to include a new API summary with links into the
729     specification body for new features, as well.
730  * TBD - how to name and where to include this appendix file.
731  * Changes to the Specification for new versions will range from small
732    changes to existing language, to new commands and structures, to adding
733    entire new chapters.
734    New chapters must be defined in separate files under the `chapters/`
735    directory, and included at an appropriate point in `vkspec.txt` or other
736    specification source files.
737    Other changes and additions are included inline in existing chapters.
738  * All changes that are specific to the new version must be protected by
739    the asciidoctor conditional (e.g. the version name).
740    For example, in the case of Vulkan 1.1:
741+
742[source,asciidoc]
743.Example Markup
744----
745Add a new chapter:
746
747\ifdef::VK_VERSION_1_1[]
748\include::{chapters}/newchapter11.txt[]
749\endif::VK_VERSION_1_1[]
750
751Add a new feature:
752
753\ifdef::VK_VERSION_1_1[]
754... language describing the new command, structure, or enumeration
755\endif::VK_VERSION_1_1[]
756----
757  * The specification must continue to be a valid document when the new
758    version is *not* defined, so that (for example) the Vulkan 1.1 branch
759    specification can continue to be updated.
760  * TBD - how to deprecate extensions which have been promoted to core
761    status in the new version, while continuing to have those extensions
762    appear then older versions of the specification are being built.
763  * The same constraints <<extensions-documenting-extensions, described
764    above>> for Valid Usage statements modified by extensions apply for new
765    versions.
766
767
768== Assigning Extension Token Values
769
770Extensions can define their own enumeration types and assign any values to
771their enumerants that they like.
772Each enumeration has a private namespace, so collisions are not a problem.
773However, when extending existing enumeration objects with new values, care
774must be taken to preserve global uniqueness of values.
775Enumerations which define new bits in a bitmask are treated specially as
776described in <<extensions-reserving-bitmask-values,Reserving Bitmask
777Values>> below.
778
779Each extension is assigned a range of values that can be used to create
780globally-unique enum values.
781Most values will be negative numbers, but positive numbers are also
782reserved.
783The ability to create both positive and negative extension values is
784necessary to enable extending enumerations such as etext:VkResult that
785assign special meaning to negative and positive values.
786Therefore, 1000 positive and 1000 negative values are reserved for each
787extension.
788Extensions must not define enum values outside their reserved range without
789explicit permission from the owner of those values (e.g. from the author of
790another extension whose range is infringed on, or from the Khronos Registrar
791if the values do not belong to any extension's range).
792
793[NOTE]
794.Note
795====
796Typically, extensions use a unique offset for each enumeration constant they
797add, yielding 1000 distinct token values per extension.
798Since each enumeration object has its own namespace, if an extension needs
799to add many enumeration constant values, it can reuse offsets on a per-type
800basis.
801====
802
803The information needed to add new values to the XML are as follows:
804
805  * The **extension name** (e.g. `VK_KHR_swapchain`) that is adding the new
806    enumeration constant.
807  * The existing enumeration **type** being extended (e.g.
808    stext:VkStructureType).
809  * The name of the new enumeration **token** being added (e.g.
810    etext:VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR).
811  * The **offset**, which is an integer between 0 and 999 relative to the
812    base being used for the extension.
813  * The **direction** may be specified to indicate a negative value
814    (`dir="-"`) when needed for negative etext:VkResult values indicating
815    errors, like etext:VK_ERROR_SURFACE_LOST_KHR.
816    The default direction is positive, if not specified.
817
818Implicit is the registered number of an extension, which is used to create a
819range of unused values offset against a global extension base value.
820Individual enumerant values are calculated as offsets in that range.
821Values are calculated as follows:
822
823  * [eq]#_base_value_ = 1000000000#
824  * [eq]#_range_size_ = 1000#
825  * [eq]#enum_offset(_extension_number_, _offset_) = _base_value_ {plus}
826    (_extension_number_ - 1) {times} _range_size_ + _offset_#
827  * Positive values: [eq]#enum_offset(_extension_number_, _offset_})#
828  * Negative values: [eq]#enum_offset(_extension_number_, _offset_})#
829
830The exact syntax for specifying extension enumerant values is defined in the
831`readme.pdf` specifying the format of `vk.xml`, and extension authors can
832also refer to existing extensions for examples.
833
834If an extension becomes part of core, the enumerant values should remain the
835same as they were in the original extension, in order to maintain binary
836compatibility with existing applications.
837
838
839[[extensions-reserving-bitmask-values]]
840=== Reserving Bitmask Values
841
842Enumerants which define bitmask values are a special case, since there are
843only a small number of unused bits available for extensions.
844For core Vulkan API and KHR extension bitmask types, reservations must be
845approved by a vote of the Vulkan Working Group.
846For EXT and vendor extension bitmask types, reservations must be approved by
847the listed contact of the extension.
848Bits are reserved in the same fashion as extension numbers, by creating a
849placeholder reservation for each bit in the disabled XML `<extension>` block
850for that extension in the default branch.
851Once the extension is ready to be merged into the default branch, the
852`<extension>` block is updated with the actual name.
853An example reservation for a disabled extension is:
854
855[source,xml]
856----
857<extension name="VK_AMD_extension_24" number="24" author="AMD" supported="disabled">
858  <require>
859    <enum bitpos="6" extends="VkQueueFlagBits" name="VK_QUEUE_RESERVED_6_BIT_KHR"/>
860----
861
862[NOTE]
863.Note
864====
865Because of the way in which extension bitmask values are assigned inside the
866XML `<extension>` tag, it is not always obvious what the next free bit in a
867bitmask type is, or when a collision occurs.
868The most straightforward way to determine the next free bit for a given
869bitmask type is to look at the declaration of that type in the generated
870header files.
871When generating the headers, the script will raise warnings about "`Two
872enums found with the same value`" that will help identify this problem.
873====
874
875When a 32-bit flags type is close to running out of bits, a corresponding
87664-bit flag type may be created for use with new interfaces, such as the
877tlink:VkAccessFlags and tlink:VkAccessFlags2KHR types.
878These flag types have corresponding 32- and 64-bit bitmask types
879(elink:VkAccessFlagBits and elink:VkAccessFlagBits2KHR).
880When reserving remaining bits at bit positions 0 through 31, a similarly
881named bit should be reserved in both bitmask types
882(ename:VK_ACCESS_MEMORY_READ_BIT and ename:VK_ACCESS_2_MEMORY_READ_BIT_KHR),
883to avoid having the same bit used for different purposes in two otherwise
884very similar interfaces.
885If that usage is not actually supported by one or the other bitmask type,
886the bit should still be reserved, but commented out in the XML.
887
888[NOTE]
889.Note
890====
891The existing reservation mechanism used for in-development extensions does
892not work well for non-disabled extensions.
893So we currently do not have a good way of semantically indicating that a bit
894is reserved, but should not appear in the header file, for a non-disabled
895extension, and an XML comment reserving the bit is a workaround.
896This case will come up very rarely.
897====
898
899
900[[extensions-new-flags-types]]
901== New Flags and Bitmask Types
902
903When an extension introduces a new flags (etext:*Flags) type, it should also
904introduce a corresponding new bitmask (etext:*FlagBits) type.
905The flags type contains zero more more bits from the bitmask, and is used to
906specify sets of bits for commands or structures.
907
908In some cases, a new flags type will be defined with no individual bits yet
909specified.
910This usage occurs when the flags are intended for future expansion.
911In this case, even though the corresponding bitmask type is not yet useful,
912the (empty) bitmask type should be defined in `vk.xml`.
913The empty bitmask type and corresponding flags type should be given
914boilerplate definitions in the specification.
915
916
917== Required Extension Tokens
918
919In addition to any tokens specific to the functionality of an extension, all
920extensions must define two additional tokens.
921
922  * `VK_EXTNAME_SPEC_VERSION` is an integer constant which is the revision
923    of the extension named `VK_extname` (`EXTNAME` is all upper-case, while
924    extname is the capitalization of the actual extension name).
925    This value begins at 1 when an extension specification is first
926    published (pre-release versions may use an internal numbering scheme
927    that is reset at release time), and is incremented when changes are
928    made.
929    Note that the revision of an extension defined in the Vulkan header
930    files and the revision supported by the Vulkan implementation (the
931    pname:specVersion field of the sname:VkExtensionProperties structure
932    corresponding to the extension and returned by one of the
933    link:html/vkspec.html#extendingvulkan-extensions[extension queries]) may
934    differ.
935    The revision value indicates a patch version of the extension
936    specification, and differences in this version number maintain full
937    compatibility, as defined in the
938    link:html/vkspec.html#_compatibility_guarantees_informative[Compatibility
939    Guarantees] section of the <<vulkan-spec,Vulkan API Specification>>.
940
941[NOTE]
942.Note
943====
944Any changes requiring the addition or removal of a type or command should be
945done by creating a new extension.
946The resulting extension should take care to include the appropriate
947dependency information on the original extension.
948====
949
950[NOTE]
951.Note
952====
953When the Debug Report extension (VK_EXT_debug_report) was recently updated
954to include the enum values of VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT
955and VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT, we violated this
956policy.
957That change was done prior to this revision policy clarification.
958We intend to follow this policy in the future, although in exceptional
959circumstances an exception may be made.
960====
961
962  * `VK_EXTNAME_EXTENSION_NAME` is a string constant which is the name of
963    the extension.
964
965For example, for the WSI extension `VK_KHR_surface`, at the time of writing
966the following definitions were in effect:
967
968[source,c]
969----
970#define VK_KHR_SURFACE_SPEC_VERSION 24
971#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
972----
973
974
975== Extension Handles, Objects, Enums, and Typedefs
976
977Expanding on previous discussion, extensions can add values to existing
978enums; and can add their own commands, enums, typedefs, etc.
979This is done by adding to <<extensions-api-registry,`vk.xml`>>.
980All such additions will be included in the Vulkan header files supplied by
981Khronos.
982
983If the extension adds a new handle to Vulkan, a corresponding value must be
984added to ename:VkObjectType (as defined in the "`Debugging`" section of the
985<<vulkan-spec,Vulkan API Specification>>) in order to allow components to
986identify and track objects of the new type.
987
988The new enumeration value must conform to the naming defined in the
989<<naming-extension-enumerant-names,Extension Enumerant Names>> section.
990In this case, the type's etext:Vk prefix is replaced with the enum prefix
991etext:VK_OBJECT_TYPE_, and the rest of the handle name is converted as
992described in that section.
993
994.Conversion of Handle to sname:VkObjectType Examples:
995[width="70%",options="header",cols="50%,50%"]
996|====
997| Handle                        | sname:VkObjectType token
998| VkSurfaceKHR                  | VK_OBJECT_TYPE_SURFACE_KHR
999| VkDescriptorUpdateTemplateKHR | VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR
1000|====
1001
1002
1003[[extension-function_prototypes]]
1004== Extension Function Prototypes
1005
1006Function pointer declarations and function prototypes for all core Vulkan
1007API commands are included in the Vulkan header files.
1008These come from the official XML specification of the Vulkan API hosted by
1009Khronos.
1010
1011Function pointer declarations are also included in the Vulkan header for all
1012commands defined by registered extensions.
1013Function prototypes for extensions may be included in the headers.
1014Extension commands that are part of the Vulkan ABI must be flagged in the
1015XML.
1016Function prototypes will be included in the headers for all extension
1017commands that are part of the Vulkan ABI.
1018
1019An extension can be considered platform specific, in which case its
1020interfaces in the header files are protected by #ifdefs.
1021This is orthogonal to whether an extension command is considered to be part
1022of the Vulkan ABI.
1023
1024The initial set of WSI extension commands (i.e. for `VK_KHR_surface`,
1025`VK_KHR_swapchain`, and `VK_KHR_*_surface`) are considered to be part of the
1026Vulkan ABI.
1027Function prototypes for these WSI commands are included in platform-specific
1028files such as `vulkan_android.h`.
1029See the "`Window System-Specific Header Control (Informative)`" section of
1030the Vulkan Specification for more details.
1031
1032[NOTE]
1033.Note
1034====
1035Based on feedback from implementors, Khronos expects the Android, Linux, and
1036Windows Vulkan SDKs to include our header files, and export the supported
1037WSI functions for those platforms from their loader libraries.
1038Other implementations can make different choices for their headers and
1039loader libraries, but are encouraged to be consistent with these
1040implementations.
1041====
1042
1043
1044== Accessing Extension Functions from Programs
1045
1046fname:vkGetInstanceProcAddr and fname:vkGetDeviceProcAddr can be used in
1047order to obtain function pointer addresses for core and extension commands
1048(per the description in the "`Command Function Pointers`" section of the
1049<<vulkan-spec,Vulkan API Specification>>).
1050Different Vulkan API loaders can choose to statically export functions for
1051some or all of the core Vulkan API commands, and can statically export
1052functions for some or all extension commands.
1053If a loader statically exports a function, an application can link against
1054that function without needing to call one of the ftext:vkGet*ProcAddr
1055commands.
1056
1057[NOTE]
1058.Note
1059====
1060The Vulkan API loader for Android, Linux, and Windows exports functions for
1061all core Vulkan API commands, and for a set of WSI extension commands that
1062are applicable to those operating systems (see Vulkan loader documentation
1063for the relevant platform/OS for details).
1064The WSI functions are considered special, because they are required for many
1065applications.
1066====
1067
1068
1069[[extensions-interactions]]
1070== Extending Structures
1071
1072Extending structures modify the behavior of existing commands or structures
1073by providing additional parameters, using the pname:pNext field of an
1074existing structure to point to a chain of additional structures.
1075This mechanism is described in more detail in the "`Valid Usage for
1076Structure Pointer Chains`" section of the <<vulkan-spec,Vulkan API
1077Specification>>.
1078
1079Multiple extending structures affecting the same structure, defined by
1080multiple core versions or extensions, can be chained together in this
1081fashion.
1082Any structure which can be chained in this fashion must begin with the
1083following two members:
1084
1085["source","c++",title=""]
1086----
1087VkStructureType        sType;
1088const void*            pNext;
1089----
1090
1091It is in principle possible for extensions to provide additional parameters
1092through alternate means, such as passing a handle parameter to a structure
1093with a pname:sType value defined by the extension.
1094This approach is strongly discouraged.
1095
1096When chaining multiple extending structures together, the implementation
1097will process the chain starting with the base structure and proceeding
1098through each successive extending structure in turn.
1099Extending structures should behave in the same fashion no matter the order
1100of chaining, and must define their interactions with other extensions such
1101that the results are deterministic.
1102
1103If an extending structure must be present in a pname:pNext chain in specific
1104ordering relative to other structures in the chain in order to provide
1105deterministic results, it must define that ordering and expected behavior as
1106part of its specification and valid usage statements.
1107
1108[NOTE]
1109.Note
1110====
1111Specific ordering requirements in a pname:pNext chain are strongly
1112discouraged.
1113====
1114
1115Validation of structure types in pname:pNext chains is automatically
1116generated from the registry, based on the description of attr:structextends
1117in link:registry.html[the registry document].
1118
1119
1120[[extensions-interactions-parent]]
1121== Valid Usage and pname:pNext Chains
1122
1123When there is a Valid Usage interaction between a parent structure and an
1124extending structure appearing in the pname:pNext chain of the parent, that
1125interaction must: be described in the explicit Valid Usage section of the
1126parent structure, rather than the extending structure, and must: be
1127protected by appropriate extension-specific `ifdef` constructs.
1128
1129For example, a constraint added to the sname:VkImageCreateInfo structure by
1130the presence of structures defined by two extensions which cannot interact
1131is described as:
1132
1133[source,asciidoc]
1134.Example Markup
1135----
1136// CORRECT: define interaction with children in parent VkImageCreateInfo
1137// structure
1138\ifdef::VK_NV_external_memory+VK_KHR_external_memory[]
1139  * If the pname:pNext chain includes a
1140    slink:VkExternalMemoryImageCreateInfoNV structure, it must: not include
1141    a slink:VkExternalMemoryImageCreateInfoKHR structure.
1142\endif::VK_NV_external_memory+VK_KHR_external_memory[]
1143----
1144
1145However, a constraint added to sname:VkBufferCreateInfo by an extending
1146structure in the `VK_NV_dedicated_allocation` extension must not be
1147described as part of the extending structure's valid usage:
1148
1149[source,asciidoc]
1150.Example Markup
1151----
1152// WRONG! Do not define interaction with parent in child
1153// VkDedicatedAllocationBufferCreateInfoNV structure
1154  * If pname:dedicatedAllocation is ename:VK_TRUE,
1155    sname:VkBufferCreateInfo::pname:flags must: not include
1156    ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT,
1157    ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT, or
1158    ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT
1159----
1160
1161Instead, define the constraint as part of the parent
1162sname:VkBufferCreateInfo structure's valid usage:
1163
1164[source,asciidoc]
1165.Example Markup
1166----
1167// REWRITTEN CORRECTLY: Define interaction with child in
1168// parent VkBufferCreateInfo structure
1169\ifdef::VK_NV_dedicated_allocation[]
1170  * If the pname:pNext chain includes a
1171    slink:VkDedicatedAllocationBufferCreateInfoNV structure, and the
1172    pname:dedicatedAllocation member of the chained structure is
1173    ename:VK_TRUE, then pname:flags must: not include
1174    ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT,
1175    ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT, or
1176    ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT
1177\endif::VK_NV_dedicated_allocation[]
1178----
1179
1180[[extensions-feature-structures]]
1181== Feature Structures
1182
1183A feature structure is a structure that extends
1184sname:VkPhysicalDeviceFeatures2 and sname:VkDeviceCreateInfo, and which
1185provides basetype:VkBool32 members to indicate implementation support for
1186individual features.
1187
1188["source","c++",title=""]
1189----
1190typedef struct VkPhysicalDeviceImageRobustnessFeaturesEXT {
1191    VkStructureType    sType;
1192    void*              pNext;
1193    VkBool32           robustImageAccess;
1194} VkPhysicalDeviceImageRobustnessFeaturesEXT;
1195----
1196
1197Every device or physical-device extension that adds or modifies device-level
1198commands, or adds new structures or enum values used in device-level
1199commands, must define a feature structure.
1200
1201If an extension requires a feature structure, then any mandatory features
1202must be described in the Feature Requirements section.
1203New extensions must mandate that implementions support at least one feature
1204of an extension.
1205
1206[source,asciidoc]
1207.Example Markup
1208----
1209ifdef::VK_EXT_image_robustness[]
1210  * <<features-robustImageAccess, pname:robustImageAccess>>, if the
1211    apiext:VK_EXT_image_robustness extension is supported.
1212endif::VK_EXT_image_robustness[]
1213----
1214